Exemple #1
0
 //活用用コンボボックス類設定
 private void setKatsuyoComboBoxes(ComboBox comboBox, List <MKatsuyo> srcList, List <MKatsuyo> destList, int parentId, int level)
 {
     destList.Clear();
     comboBox.Items.Clear();
     comboBox.Items.Add(String.Empty);
     srcList.ForEach(delegate(MKatsuyo mKatsuyoWork)
     {
         if (mKatsuyoWork.ParentId == parentId)
         {
             destList.Add(mKatsuyoWork);
             comboBox.Items.Add(mKatsuyoWork.Name);
         }
     });
     // 該当データがない場合
     if (destList.Count == 0 && comboBox.Items.Count == 1)
     {
         MKatsuyo wrkKatsuyo = new MKatsuyo();
         wrkKatsuyo.ParentId  = parentId;
         wrkKatsuyo.Id        = wrkKatsuyo.ParentId * 100 + destList.Count + 1;
         wrkKatsuyo.Level     = level;
         wrkKatsuyo.Name      = "*";
         wrkKatsuyo.CreatedAt = DateTime.Now;
         wrkKatsuyo.UpdatedAt = DateTime.Now;
         wrkKatsuyo.DeleteFlg = "0";
         destList.Add(wrkKatsuyo);
         srcList.Add(wrkKatsuyo);
         comboBox.Items.Add(wrkKatsuyo.Name);
     }
     comboBox.DropDownStyle = ComboBoxStyle.DropDown;
     comboBox.SelectedIndex = 0;
 }
Exemple #2
0
        // 活用形リストのチェック。なければ追加する
        public static int checkKatsuyoList(List <MKatsuyo> lstSrc, int katsuyoLevel, int parentId, String katsuyoName)
        {
            int indexKatsuyo = lstSrc.FindIndex(x => x.Name.Equals(katsuyoName));

            if (indexKatsuyo < 0)
            {
                MKatsuyo mNewKatsuyo = new MKatsuyo();
                mNewKatsuyo.ParentId = parentId;
                if (katsuyoLevel == 0)
                {
                    mNewKatsuyo.Id = lstSrc.Count + 1;
                }
                else
                {
                    mNewKatsuyo.Id = (mNewKatsuyo.ParentId * 100) + lstSrc.Count + 1;
                }
                mNewKatsuyo.Name      = katsuyoName;
                mNewKatsuyo.Level     = katsuyoLevel;
                mNewKatsuyo.DeleteFlg = "0";

                lstSrc.Add(mNewKatsuyo);
                indexKatsuyo = lstSrc.Count - 1;
            }
            else
            {
                indexKatsuyo = -1;
            }

            return(indexKatsuyo);
        }
Exemple #3
0
        // 活用リストとコンボボックスのチェック。なければ活用リストとコンボボックスに追加する
        private int checkKatsuyoListWithCombo(ComboBox comboBox, List <MKatsuyo> lstSrc, int katsuyoLevel, int parentId, String katsuyoName, List <MKatsuyo> lstDest = null)
        {
            // 以下で "indexKatsuyo = lstDest.Count;"となっているのは、lstDestにはComboBoxにある空白がないため
            int indexKatsuyo = -1;

            if (lstDest != null)
            {
                indexKatsuyo = lstDest.FindIndex(x => x.Name.Equals(katsuyoName));
            }
            else
            {
                indexKatsuyo = lstSrc.FindIndex(x => x.Name.Equals(katsuyoName));
            }

            if (indexKatsuyo > -1)
            {
                comboBox.SelectedIndex = indexKatsuyo + 1;
            }
            else
            {
                MKatsuyo mNewKatsuyo = new MKatsuyo();
                mNewKatsuyo.ParentId = parentId;
                if (katsuyoLevel == 0)
                {
                    mNewKatsuyo.Id = lstSrc.Count;
                }
                else
                {
                    mNewKatsuyo.Id = (mNewKatsuyo.ParentId * 100) + lstDest.Count + 1;
                }
                mNewKatsuyo.Name      = katsuyoName;
                mNewKatsuyo.Level     = katsuyoLevel;
                mNewKatsuyo.CreatedAt = DateTime.Now;
                mNewKatsuyo.UpdatedAt = DateTime.Now;
                mNewKatsuyo.DeleteFlg = "0";

                lstSrc.Add(mNewKatsuyo);
                comboBox.Items.Add(katsuyoName);
                indexKatsuyo = lstSrc.Count;
                if (lstDest != null)
                {
                    lstDest.Add(mNewKatsuyo);
                    indexKatsuyo = lstDest.Count;
                }
                comboBox.SelectedIndex = indexKatsuyo;
            }

            return(indexKatsuyo);
        }