当前位置: 首页>>代码示例>>C#>>正文


C# SortedList.IndexOfKey方法代码示例

本文整理汇总了C#中System.Collections.SortedList.IndexOfKey方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.IndexOfKey方法的具体用法?C# SortedList.IndexOfKey怎么用?C# SortedList.IndexOfKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.SortedList的用法示例。


在下文中一共展示了SortedList.IndexOfKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadMoudelTree

        public void LoadMoudelTree(string roleCode)
        {
            DataTable tempTable = roleBll.GetUserModuleListByRoleCode(roleCode);
            this.UltraWebTreeModule.Nodes.Clear();
            SortedList allTreeNodes = new SortedList();
            foreach (DataRow row in tempTable.Rows)
            {
                Node newNode = base.CreateNode(Convert.ToString(row["modulecode"]), FunctionText.ResourceManager.GetString(row["LANGUAGE_KEY"].ToString()) + this.CreateFunctionList(Convert.ToString(row["FunctionList"]), Convert.ToString(row["FunctionListed"]), Convert.ToString(row["Authorized"])), Convert.ToString(row["authorized"]).Equals("Y"), Convert.ToDecimal(tempTable.Compute("count(modulecode)", "parentmodulecode='" + row["modulecode"] + "'")) == 0M);
                allTreeNodes.Add(Convert.ToString(row["modulecode"]), newNode);
                if (row["parentmodulecode"].ToString().Trim().Length > 0)
                {
                    if (allTreeNodes.IndexOfKey(row["parentmodulecode"]) >= 0)
                    {
                        ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentmodulecode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["modulecode"])));
                    }
                }
                else
                {
                    this.UltraWebTreeModule.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["modulecode"]))));
                }
                foreach (Node node in this.UltraWebTreeModule.Nodes)
                {
                    node.Expand(true);

                }
            }
        }
开发者ID:chanhan,项目名称:Project,代码行数:27,代码来源:AuthorityForm.aspx.cs

示例2: CalcCachedInterpolationInfo

        public double[,] CalcCachedInterpolationInfo(double a_dTime, SortedList a_sorted)
        {
            double[,] aReturn = new double[,]{{1}};

            int nIndex = 0;
            //			if (a_sorted.ContainsKey(a_dTime))
            nIndex = a_sorted.IndexOfKey(a_dTime);
            if (nIndex >= 0)
            {
                return new double[,]{{(double)a_sorted.GetByIndex(nIndex)}};
            }
            else
            {
                a_sorted.Add(a_dTime, -4711);
                nIndex = a_sorted.IndexOfKey(a_dTime);
                a_sorted.RemoveAt(nIndex);
            }

            //nIndex is meant to represent the next index after a_dTime.
            //If a_dTime is the same as a key, nIndex should be that key's index - 1

            if (nIndex <= 0)
                return new double[,]{{(double)a_sorted.GetByIndex(0)}};

            if (nIndex >= a_sorted.Count)
                return new double[,]{{(double)a_sorted.GetByIndex(a_sorted.Count-1)}};

            double dTimeAtIndexBefore = (double)a_sorted.GetKey(nIndex-1);
            double dTimeAtIndexAfter = (double)a_sorted.GetKey(nIndex);

            if (a_dTime == dTimeAtIndexAfter)
            {
                /*    if (nPos < nCnt) then nPos = nPos+1
            fTimePosBefore = a_paList.getPropAt(nPos-1)
            fTimePosAfter = a_paList.getPropAt(nPos)*/
            }

            double dVal1 = 0;
            double dVal2 = (double)a_sorted.GetValueList()[nIndex-1];
            double dVal3 = (double)a_sorted.GetValueList()[nIndex];
            double dVal4 = 0;
            //TODO: support commands in the list!
            //if (ilk(mvVal2) = #List) then mvVal2 = mvVal3
            //if (ilk(mvVal3) = #List) then mvVal3 = mvVal2

            if (nIndex == 1)
                dVal1 = dVal2;
            else
                dVal1 = (double)a_sorted.GetValueList()[nIndex-2];
            //if (ilk(mvVal1) = #List) then mvVal1 = mvVal2

            if (nIndex == a_sorted.Count-1)
                dVal4 = dVal3;
            else
                dVal4 = (double)a_sorted.GetValueList()[nIndex+1];
            //TODO if (ilk(mvVal4) = #List) then mvVal4 = mvVal3

            aReturn = new double[,] {{dVal1, 0}, {dVal2, dTimeAtIndexBefore}, {dVal3, dTimeAtIndexAfter}, {dVal4,0}};
            return aReturn;
        }
开发者ID:timdetering,项目名称:Endogine,代码行数:60,代码来源:Interpolator.cs

示例3: Test01

        public void Test01()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            SortedList sl2 = null;
            Hashtable ht = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            //
            // Construct a hashtable with 3 elements in an unsorted order
            //
            ht = new Hashtable();
            var k0 = new SortedListCtorTestClass("cde");
            var k1 = new SortedListCtorTestClass("abc");
            var k2 = new SortedListCtorTestClass("bcd");

            ht.Add(k0, null);
            ht.Add(k1, null);
            ht.Add(k2, null);

            //
            // Constructor: Create a SortedList using the hashtable (dictionary) created
            //
            sl2 = new SortedList(ht);

            // Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            // Verify that the SortedList Count is right.
            Assert.Equal(3, sl2.Count);

            // Verify that the SortedList actually sorted the hashtable.
            Assert.Equal(2, sl2.IndexOfKey(k0));

            Assert.Equal(0, sl2.IndexOfKey(k1));

            Assert.Equal(1, sl2.IndexOfKey(k2));

            // Verify that the SortedList contains the right keys.
            Assert.True(((SortedListCtorTestClass)sl2.GetKey(0)).ToString().Equals("abc"));

            Assert.True(((SortedListCtorTestClass)sl2.GetKey(1)).ToString().Equals("bcd"));

            Assert.True(((SortedListCtorTestClass)sl2.GetKey(2)).ToString().Equals("cde"));

            ht = new Hashtable();
            sl2 = new SortedList(ht);
            Assert.Equal(0, sl2.Count);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:52,代码来源:CtorDictionaryTests.cs

示例4: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            string strDepName;
            try
            {
                if (!this.Page.IsPostBack)
                {
                    this.ModuleCode.Value = "KQMSYS306";
                    this.UltraWebTreeData.Nodes.Clear();
                    SortedList allTreeNodes = new SortedList();

                    RelationSelectorBll bll = new RelationSelectorBll();
                    DataTable tempTable = bll.GetTypeDataList(CurrentUserInfo.Personcode, "Foxconn", this.ModuleCode.Value, "N");
                    foreach (DataRow row in tempTable.Rows)
                    {
                        strDepName = row["depname"].ToString() + "[" + row["depcode"].ToString() + "]";
                        if (row["costcode"].ToString().Trim().Length > 0)
                        {
                            strDepName = strDepName + "-" + row["costcode"].ToString();
                        }
                        Node node = base.CreateNode(row["depcode"].ToString(), strDepName, false, Convert.ToDecimal(tempTable.Compute("count(depcode)", "parentdepcode='" + row["depcode"].ToString() + "'")) == 0M);
                        if (row["deleted"].ToString().Equals("Y"))
                        {
                            node.Style.BorderColor = Color.DarkGray;
                        }
                        allTreeNodes.Add(row["depcode"].ToString(), node);
                        if (row["parentdepcode"].ToString().Trim().Length > 0)
                        {
                            if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
                            {
                                ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
                            }
                            else
                            {
                                this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
                            }
                        }
                        else
                        {
                            this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //base.WriteMessage(2, (ex.InnerException == null) ? ex.Message : ex.InnerException.Message);
            }
        }
开发者ID:chanhan,项目名称:Project,代码行数:49,代码来源:KQMOrgShiftForm.aspx.cs

示例5: Page_Load

        /// <summary>
        /// 頁面加載--組織樹
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            string strDepName;

            if (!this.Page.IsPostBack)
            {
                this.ModuleCode.Value = Request.QueryString["ModuleCode"].ToString();
                string personCode = CurrentUserInfo.Personcode;
                string companyId = CurrentUserInfo.CompanyId;
                this.UltraWebTreeData.Nodes.Clear();
                SortedList allTreeNodes = new SortedList();
                RelationSelectorBll bll = new RelationSelectorBll();
                DataTable tempTable = bll.GetTypeDataList(personCode, companyId, this.ModuleCode.Value, "N");
                foreach (DataRow row in tempTable.Rows)
                {

                    strDepName = row["depname"].ToString() + "[" + row["depcode"].ToString() + "]";
                    if (row["costcode"].ToString().Trim().Length > 0)
                    {
                        strDepName = strDepName + "-" + row["costcode"].ToString();
                    }
                    Node node = base.CreateNode(row["depcode"].ToString(), strDepName, false, Convert.ToDecimal(tempTable.Compute("count(depcode)", "parentdepcode='" + row["depcode"].ToString() + "'")) == 0M);
                    if (row["deleted"].ToString().Equals("Y"))
                    {
                        node.Style.ForeColor = Color.DarkGray;
                    }
                    allTreeNodes.Add(row["depcode"].ToString(), node);
                    if (row["parentdepcode"].ToString().Trim().Length > 0)
                    {
                        if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
                        {
                            ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
                        }
                        else
                        {
                            this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
                        }
                    }
                    else
                    {
                        this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"].ToString())));
                    }
                }
            }
        }
开发者ID:chanhan,项目名称:Project,代码行数:50,代码来源:KqmParameterForm.aspx.cs

示例6: DoCreateSection

 /// <summary>
 /// Retourne le dictionnaire de la section nommée dans line, crée la section si nécessaire
 /// </summary>
 /// <param name="sections">Dictionnaire des sections</param>
 /// <param name="line">Ligne contenant un délimiteur de section</param>
 /// <returns>Le dictionnaire associé à la section</returns>
 protected SortedList DoCreateSection( SortedList sections, string line ) {
   string name = line.Substring( 1, line.Length - 2 ) ;
   int index = sections.IndexOfKey( name ) ;
   if (index == -1) {
     SortedList result = new SortedList() ;
     sections.Add( name, result ) ;
     return result ;
   } else return (SortedList) sections.GetByIndex( index ) ;
 }
开发者ID:NicolasR,项目名称:Composants,代码行数:15,代码来源:Archiver.cs

示例7: CheckBoxAbate_CheckedChanged

        protected void CheckBoxAbate_CheckedChanged(object sender, EventArgs e)
        {
            moudelCode = Request.QueryString["modulecode"].ToString();
            this.UltraWebTreeData.Nodes.Clear();
            SortedList allTreeNodes = new SortedList();

            hrmEmpOtherMoveBll.GetDepCodeTable(CurrentUserInfo.Personcode, moudelCode, CurrentUserInfo.CompanyId, "", chkAbate.Checked ? "Y" : "N",logmodel);
              dt = hrmEmpOtherMoveBll.GetAuthorizedTreeDept(CurrentUserInfo.Personcode, CurrentUserInfo.CompanyId, moudelCode);
            string strDepName = "";
            foreach (DataRow row in dt.Rows)
            {
                strDepName = Convert.ToString(row["depname"]) + "[" + Convert.ToString(row["depcode"]) + "]";
                if (Convert.ToString(row["costcode"]).Trim().Length > 0)
                {
                    strDepName = strDepName + "-" + Convert.ToString(row["costcode"]);
                }
                Node node = base.CreateNode(Convert.ToString(row["depcode"]), strDepName, false, Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0M);
                if (Convert.ToString(row["deleted"]).Equals("Y"))
                {
                    node.Style.ForeColor = Color.Red;
                }
                allTreeNodes.Add(Convert.ToString(row["depcode"]), node);
                if (row["parentdepcode"].ToString().Trim().Length > 0)
                {
                    if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
                    {
                        ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
                    }
                    else
                    {
                        this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
                    }
                }
                else
                {
                    this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
                }
            }
            foreach (Node node in this.UltraWebTreeData.Nodes)
            {
                node.Expand(false);
            }
        }
开发者ID:chanhan,项目名称:Project,代码行数:43,代码来源:TreeDataPickForm.aspx.cs

示例8: chkAbate_CheckedChanged

 //綁定所有的組織代碼 (包含已失效的)
 protected void chkAbate_CheckedChanged(object sender, EventArgs e)
 {
     string strDepName;
     string personCode = CurrentUserInfo.Personcode;
     string companyId = CurrentUserInfo.CompanyId;
     this.UltraWebTreeData.Nodes.Clear();
     SortedList allTreeNodes = new SortedList();
     DataTable dt = bll.GetTypeDataList(personCode, companyId, moduleCode);
     foreach (DataRow row in dt.Rows)
     {
         strDepName = Convert.ToString(row["depname"]) + "[" + Convert.ToString(row["depcode"]) + "]";
         if (Convert.ToString(row["costcode"]).Trim().Length > 0)
         {
             strDepName = strDepName + "-" + Convert.ToString(row["costcode"]);
         }
         Node node = base.CreateNode(Convert.ToString(row["depcode"]), strDepName, false, Convert.ToDecimal(dt.Compute("count(depcode)", "parentdepcode='" + row["depcode"] + "'")) == 0M);
         if (Convert.ToString(row["deleted"]).Equals("Y") || Convert.ToString(row["deleted"]).Equals(""))
         {
             node.Style.ForeColor = Color.Red;
         }
         allTreeNodes.Add(Convert.ToString(row["depcode"]), node);
         if (row["parentdepcode"].ToString().Trim().Length > 0)
         {
             if (allTreeNodes.IndexOfKey(row["parentdepcode"]) >= 0)
             {
                 ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentdepcode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["depcode"])));
             }
             else
             {
                 this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
             }
         }
         else
         {
             this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["depcode"]))));
         }
     }
     foreach (Node node in this.UltraWebTreeData.Nodes)
     {
         node.Expand(false);
     }
 }
开发者ID:chanhan,项目名称:Project,代码行数:43,代码来源:RelationSelector.aspx.cs

示例9: WebTreeBind

        /// <summary>
        /// WebTree控件綁定數據
        /// </summary>
        protected void WebTreeBind()
        {
            this.UltraWebTreeData.Nodes.Clear();
            SortedList allTreeNodes = new SortedList();
            DataTable tempTable = moduleBll.GetUserModuleTable();
            foreach (DataRow row in tempTable.Rows)
            {
                allTreeNodes.Add(Convert.ToString(row["ModuleCode"]), base.CreateNode(Convert.ToString(row["ModuleCode"]), Convert.ToString(row["description"]), false, Convert.ToDecimal(tempTable.Compute("count(ModuleCode)", "parentmodulecode='" + row["ModuleCode"] + "'")) == 0M));
                if (row["parentmodulecode"].ToString().Trim().Length > 0)
                {
                    if (allTreeNodes.IndexOfKey(row["parentmodulecode"]) >= 0)
                    {
                        ((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["parentmodulecode"]))).Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(row["ModuleCode"])));
                    }
                }
                else
                {
                    this.UltraWebTreeData.Nodes.Add((Node)allTreeNodes.GetByIndex(allTreeNodes.IndexOfKey(Convert.ToString(row["ModuleCode"]))));
                }

            }
        }
开发者ID:chanhan,项目名称:Project,代码行数:25,代码来源:ModuleSelector.aspx.cs

示例10: DoAddLineToSection

 /// <summary>
 /// Ajoute la ligne line à la section en forme clé=valeur
 /// </summary>
 /// <param name="section">Dictionnaire de la section</param>
 /// <param name="line">Ligne de l'archive en forme "clé=valeur"</param>
 protected void DoAddLineToSection( SortedList section, string line ) {
   if (section == null) return ;
   int pos = line.IndexOf( '=' ) ;
   if (pos == -1) {
     string trimmed = line.Trim() ;
     if (trimmed != "") section.Add( trimmed, null ) ;
   } else {
     string key = line.Substring( 0, pos ) ;
     string val = line.Substring( pos + 1 ) ;
     int index = section.IndexOfKey( key ) ;
     if (index != -1) section.RemoveAt( index ) ;
     section.Add( key, val ) ;
   }
 }
开发者ID:NicolasR,项目名称:Composants,代码行数:19,代码来源:Archiver.cs

示例11: ButtonSave_Click


//.........这里部分代码省略.........
                catch
                {
                    LHZBIsDisplayG2G3 = "N";
                }

                if (LHZBIsDisplayG2G3 == "Y")
                {
                    tmpOTType = tmpOTType.Substring(0, 2);
                }
                #endregion

                double OTHours = 0;
                string strOTHours = "";
                try
                {
                    OTHours = Convert.ToDouble(this.textBoxHours.Text.Trim());
                    strOTHours = GetOTHours(WorkNo, OTDate, StrBtime, StrEtime, tmpOTType);
                }
                catch (System.Exception)
                {
                    this.WriteMessage(1, Message.otm_errorhours);
                    return;
                }

                //抓取班別
                ShiftNo = bll.GetShiftNo(WorkNo, OTDate);
                if (ShiftNo == null || ShiftNo == "")
                {
                    this.WriteMessage(1, Message.otm_exception_errorshiftno_1);
                    return;
                }
                SortedList list = new SortedList();
                list = bll.ReturnOTTTime(WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, ShiftNo);
                dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A")));
                dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B")));

                if (this.ProcessFlag.Value.Equals("Add"))
                {
                    //一天内多笔加班时间不能交叉或重复
                    if (!CheckOverTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo, true))
                    {
                        this.WriteMessage(1, Message.common_message_otm_multi_repeart);
                        return;
                    }
                }
                else
                {
                    //一天内多笔加班时间不能交叉或重复
                    if (!CheckOverTime(this.HiddenID.Value, WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo, true))
                    {
                        this.WriteMessage(1, Message.common_message_otm_multi_repeart);
                        return;
                    }
                }
                //請假中不能申報加班
                if (!CheckLeaveOverTime(WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd"), dtTempBeginTime.ToString("HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd"), dtTempEndTime.ToString("HH:mm")))
                {
                    this.WriteMessage(1, Message.common_message_Leaveovertime_repeart);
                    return;
                }

                //工作時間內不能預報加班
                if (!CheckWorkTime(WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), ShiftNo))
                {
                    this.WriteMessage(1, Message.common_message_otm_worktime_repeart);
                    return;
开发者ID:chanhan,项目名称:Project,代码行数:67,代码来源:OTMAdvanceApplyEditForm.aspx.cs

示例12: TestGetKeyBasic

        public void TestGetKeyBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);

            SortedList sl2 = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            string s1 = null;
            string s2 = null;

            int i = 0;
            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //    Testcase: GetKey - key at index 0 , ArgExc expected
            Assert.Throws<ArgumentOutOfRangeException>(() =>
                {
                    sl2.GetKey(0);
                });

            //   Testcase: GetKey - null val, should pass
            sl2["first key"] = (string)null;
            Assert.Equal(1, sl2.Count);

            //   Testcase: vanila Set
            sl2.Clear();
            //   Testcase: add key-val pairs
            for (i = 0; i < 50; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                sl2.Add(s1, s2);
            }

            //
            //   now get their keys using GetKey
            //
            for (i = 0; i < 50; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();
                Assert.True(((string)sl2.GetKey(sl2.IndexOfKey(s1))).Equals(s1));
            }

            Assert.Equal(50, sl2.Count);
        }
开发者ID:johnhhm,项目名称:corefx,代码行数:67,代码来源:GetKeyTests.cs

示例13: ButtonSave_Click


//.........这里部分代码省略.........
                            OTMSGFlag = "";
                            this.WorkNo = this.GridSelEmployee.Rows[i].Cells.FromKey("WorkNo").Text.ToString().Trim();
                            this.ShiftNo = bll.GetShiftNo(this.WorkNo, OTDate);
                            dtTempBeginTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrBtime);
                            dtTempEndTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " " + StrEtime);
                            dtMidTime = DateTime.Parse(DateTime.Parse(OTDate).ToString("yyyy/MM/dd") + " 12:00");
                            if ((this.ShiftNo == null) || (this.ShiftNo == ""))
                            {
                                msg = msg + "<br>" + this.WorkNo + ": " + Message.otm_exception_errorshiftno_1;
                                failCount++;
                                this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                            }
                            else
                            {
                                tmpOTType = this.FindOTType(OTDate, this.WorkNo);
                                if (tmpOTType.Length == 0)
                                {
                                    msg = msg + "<br>" + this.WorkNo + ": " + Message.OTMType + Message.Required;
                                    failCount++;
                                    this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                }
                                else
                                {
                                    Hour = this.GetOTHours(this.WorkNo, OTDate, StrBtime, StrEtime, tmpOTType);
                                    if (Convert.ToDouble(Hour) < 0.5)
                                    {
                                        msg = msg + "<br>" + this.WorkNo + ": " + Message.otm_othourerror;
                                        failCount++;
                                        this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                    }
                                    else
                                    {
                                        list = bll.ReturnOTTTime(this.WorkNo, OTDate, dtTempBeginTime, dtTempEndTime, this.ShiftNo);
                                        dtTempBeginTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("A")));
                                        dtTempEndTime = Convert.ToDateTime(list.GetByIndex(list.IndexOfKey("B")));
                                        if (!CheckLeaveOverTime(this.WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd"), dtTempBeginTime.ToString("HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd"), dtTempEndTime.ToString("HH:mm")))
                                        {
                                            msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_Leaveovertime_repeart;
                                            failCount++;
                                            this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                        }
                                        else if (!CheckWorkTime(this.WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), this.ShiftNo))
                                        {
                                            msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_worktime_repeart;
                                            failCount++;
                                            this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                        }
                                        else if (!CheckOverTime(this.WorkNo, OTDate, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm"), this.ShiftNo, true))
                                        {
                                            msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_multi_repeart;
                                            failCount++;
                                            this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                        }
                                        else if (!CheckOTOverETM(this.WorkNo, dtTempBeginTime.ToString("yyyy/MM/dd HH:mm"), dtTempEndTime.ToString("yyyy/MM/dd HH:mm")))
                                        {
                                            msg = msg + "<br>" + this.WorkNo + ": " + Message.common_message_otm_etmrepeart;
                                            failCount++;
                                            this.GridSelEmployee.Rows[i].Style.BackColor = Color.Red;
                                        }
                                        else
                                        {
                                            OTMSGFlag = GetOTMSGFlag(this.WorkNo, OTDate, Convert.ToDouble(Hour), tmpOTType, "N", "");
                                            if (OTMSGFlag != "")
                                            {
                                                tmpRemark = OTMSGFlag.Substring(1, OTMSGFlag.Length - 1);
                                                OTMSGFlag = OTMSGFlag.Substring(0, 1);
开发者ID:chanhan,项目名称:Project,代码行数:67,代码来源:OTMBatchOtApply.aspx.cs

示例14: EnterFunction

 /* record call to a function */
 void EnterFunction(SortedList functions, int functionId)
 {
     int index = functions.IndexOfKey(functionId);
     if(index == -1)
     {
         functions.Add(functionId, 1);
     }
     else
     {
         /* if in the list, add 1 to its counter (need to keep keys unique) */
         functions.SetByIndex(index, 1 + (int)functions.GetByIndex(index));
     }
 }
开发者ID:engincancan,项目名称:utilities,代码行数:14,代码来源:CallTreeForm.cs

示例15: TestIndexOfValueBasic

        public void TestIndexOfValueBasic()
        {
            StringBuilder sblMsg = new StringBuilder(99);
            //

            SortedList sl2 = null;

            StringBuilder sbl3 = new StringBuilder(99);
            StringBuilder sbl4 = new StringBuilder(99);
            StringBuilder sblWork1 = new StringBuilder(99);

            string s1 = null;
            string s2 = null;
            string s3 = null;
            string s4 = null;

            int i = 0;
            int j = 0;
            //
            // 	Constructor: Create SortedList using this as IComparer and default settings.
            //
            sl2 = new SortedList(this);

            //  Verify that the SortedList is not null.
            Assert.NotNull(sl2);

            //  Verify that the SortedList is empty.
            Assert.Equal(0, sl2.Count);

            //  with null - should return -1
            // null val
            j = sl2.IndexOfValue((string)null);
            Assert.Equal(-1, j);

            //  invalid val - should return -1
            j = sl2.IndexOfValue("No_Such_Val");
            Assert.Equal(-1, j);

            // null is a valid value
            sl2.Add("Key_0", null);
            j = sl2.IndexOfValue(null);
            Assert.NotEqual(-1, j);

            // first occurrence check
            sl2.Add("Key_1", "Val_Same");
            sl2.Add("Key_2", "Val_Same");

            j = sl2.IndexOfValue("Val_Same");
            Assert.Equal(1, j);

            sl2.Clear();

            //   Testcase: add few key-val pairs
            for (i = 0; i < 100; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_");
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_");
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                sl2.Add(s1, s2);
            }

            //
            //   Testcase: test IndexOfVal 
            //
            for (i = 0; i < sl2.Count; i++)
            {
                sblMsg.Length = 0;
                sblMsg.Append("key_"); //key
                sblMsg.Append(i);
                s1 = sblMsg.ToString();

                sblMsg.Length = 0;
                sblMsg.Append("val_"); //value
                sblMsg.Append(i);
                s2 = sblMsg.ToString();

                //  now use IndexOfKey and IndexOfVal to obtain the same object and check
                s3 = (string)sl2.GetByIndex(sl2.IndexOfKey(s1)); //Get the index of this key and then get object
                s4 = (string)sl2.GetByIndex(sl2.IndexOfValue(s2)); //Get the index of this val and then get object
                Assert.True(s3.Equals(s4));

                // now Get using the index obtained thru IndexOfKey () and compare it with s2
                s3 = (string)sl2.GetByIndex(sl2.IndexOfKey(s1));
                Assert.True(s3.Equals(s2));
            }

            //
            // Remove a key and then check
            //
            sblMsg.Length = 0;
            sblMsg.Append("key_50");
            s1 = sblMsg.ToString();

//.........这里部分代码省略.........
开发者ID:johnhhm,项目名称:corefx,代码行数:101,代码来源:IndexOfValueTests.cs


注:本文中的System.Collections.SortedList.IndexOfKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。