Example #1
0
        private void addSearchConditionButton_Click(object sender, EventArgs e)
        {
            SearchConditionClass newsc = getSearchConditionFromGUI();

            if (newsc == null)
            {
                MessageBox.Show("正しく入力してください", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (isEditMode == false)
            {
                var nowsclist = LoadSearchConditions();
                nowsclist.Add(newsc);
                SaveSearchConditions(nowsclist);
                RefreshListBox();
                ResetGUIComponent();
            }
            else
            {
                isEditMode = false;
                var nowsclist = LoadSearchConditions();
                nowsclist[nowedit_index] = newsc;
                SaveSearchConditions(nowsclist);
                RefreshListBox();
                ResetGUIComponent();
                this.addSearchConditionButton.Text = "追加";
            }
        }
Example #2
0
        private void editButton_Click(object sender, EventArgs e)
        {
            SearchConditionClass selectsc = (SearchConditionClass)listBox1.SelectedItem;
            int selectconDBindex          = this.listBox1.SelectedIndex;

            if (isEditMode)
            {
                MessageBox.Show("現在編集中の設定を保存してください", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (listBox1.SelectedIndex < 0 || selectsc == null || selectconDBindex < 0)
            {
                MessageBox.Show("編集する設定を選択してください", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            SetGUIFromSearchCondition(selectsc);
            nowedit_index = selectconDBindex;
            isEditMode    = true;
            this.addSearchConditionButton.Text = "変更を保存";
        }
Example #3
0
        SearchConditionClass getSearchConditionFromGUI()
        {
            SearchConditionClass rst = new SearchConditionClass();

            try {
                rst.condition_name = this.conditionNameTextBox.Text.Trim();
                rst.usecategory    = this.useCategoryCheckBox.Checked;
                rst.usebrand       = this.useBrandCheckBox.Checked;
                if (rst.usecategory)
                {
                    //カテゴリタイプは設定されているもので一番深いカテゴリのカテゴリタイプを取得
                    if (this.categoryComboBox1.SelectedItem != null)
                    {
                        rst.category_level1      = int.Parse(((SecondStreetMaster.Category) this.categoryComboBox1.SelectedItem).id);
                        rst.category_level1_name = ((SecondStreetMaster.Category) this.categoryComboBox1.SelectedItem).name;
                        rst.category_type        = ((SecondStreetMaster.Category) this.categoryComboBox1.SelectedItem).category_type;
                    }
                    if (this.categoryComboBox2.SelectedItem != null)
                    {
                        rst.category_level2      = int.Parse(((SecondStreetMaster.Category) this.categoryComboBox2.SelectedItem).id);
                        rst.category_level2_name = ((SecondStreetMaster.Category) this.categoryComboBox2.SelectedItem).name;
                        rst.category_type        = ((SecondStreetMaster.Category) this.categoryComboBox1.SelectedItem).category_type;
                    }
                    if (this.categoryComboBox3.SelectedItem != null)
                    {
                        rst.category_level3      = int.Parse(((SecondStreetMaster.Category) this.categoryComboBox3.SelectedItem).id);
                        rst.category_level3_name = ((SecondStreetMaster.Category) this.categoryComboBox3.SelectedItem).name;
                        rst.category_type        = ((SecondStreetMaster.Category) this.categoryComboBox1.SelectedItem).category_type;
                    }
                }
                if (rst.usebrand)
                {
                    rst.brand_id   = ((SecondStreetMaster.Brand) this.brandComboBox.SelectedItem).id;
                    rst.brand_name = ((SecondStreetMaster.Brand) this.brandComboBox.SelectedItem).name;
                }
                return(rst);
            } catch (Exception) {
                return(null);
            }
        }
Example #4
0
 private void SetGUIFromSearchCondition(SearchConditionClass con)
 {
     ResetGUIComponent();
     this.conditionNameTextBox.Text   = con.condition_name;
     this.useCategoryCheckBox.Checked = con.usecategory;
     this.useBrandCheckBox.Checked    = con.usebrand;
     if (con.usecategory)
     {
         if (con.category_level1 > 0)
         {
             int category_level1_selected_index = 0;
             foreach (var c in SecondStreetMaster.categoryChildDictionary["1"])
             {
                 if (c.id == con.category_level1.ToString())
                 {
                     selected_category = c;
                     break;
                 }
                 category_level1_selected_index++;
             }
             this.categoryComboBox1.SelectedIndex = category_level1_selected_index;
             this.categoryComboBox1.Visible       = true;
         }
         if (con.category_level2 > 0)
         {
             int category_level2_selected_index = 0;
             foreach (var c in SecondStreetMaster.categoryChildDictionary[con.category_level1.ToString()])
             {
                 if (c.id == con.category_level2.ToString())
                 {
                     selected_category = c;
                     break;
                 }
                 category_level2_selected_index++;
             }
             this.categoryComboBox2.SelectedIndex = category_level2_selected_index;
             this.categoryComboBox2.Visible       = true;
         }
         if (con.category_level3 > 0)
         {
             int category_level3_selected_index = 0;
             foreach (var c in SecondStreetMaster.categoryChildDictionary[con.category_level2.ToString()])
             {
                 if (c.id == con.category_level3.ToString())
                 {
                     selected_category = c;
                     break;
                 }
                 category_level3_selected_index++;
             }
             this.categoryComboBox3.SelectedIndex = category_level3_selected_index;
             this.categoryComboBox3.Visible       = true;
         }
     }
     if (con.usebrand)
     {
         int brandcombo_index = 0;
         foreach (var pair in SecondStreetMaster.brandDictionary)
         {
             if (pair.Value.id == con.brand_id)
             {
                 break;
             }
             brandcombo_index++;
         }
         this.brandComboBox.SelectedIndex = brandcombo_index;
         this.brandComboBox.Visible       = true;
     }
 }