예제 #1
0
        public override void saveButton_Click(object sender, EventArgs e)
        {
            if (categoryTextBox.Text == "")
            {
                categoryNameErrorLabel.Visible = true;
            }
            else
            {
                categoryNameErrorLabel.Visible = false;
            }


            if (isActiveComboBox.SelectedIndex == -1)
            {
                isActiveErrorLabel.Visible = true;
            }
            else
            {
                isActiveErrorLabel.Visible = false;
            }

            if (isActiveErrorLabel.Visible || categoryNameErrorLabel.Visible)
            {
                MainClass.ShowMsg("Fields with * are mandatory", "Stop", "Error");//Error is the type of msg
            }
            else
            {
                if (isActiveComboBox.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (isActiveComboBox.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();


                    i.insertCat(categoryTextBox.Text, stat);
                    r.showCategories(displayDataGridView, catIDGV, NameGV, statusGV);
                    MainClass.disableReset(leftPanel);
                }
                else if (edit == 1) //Code for UPDATE operation
                {
                    DialogResult dr = MessageBox.Show("Are you sure, you want to update record?", "Question..",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (isActiveComboBox.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (isActiveComboBox.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateCat(catId, categoryTextBox.Text, stat);
                        r.showCategories(displayDataGridView, catIDGV, NameGV, statusGV);

                        MainClass.disableReset(leftPanel);
                    }
                }
            }
        }
예제 #2
0
 public override void addButton_Click(object sender, EventArgs e)
 {
     MainClass.enableReset(leftPanel);
     edit = 0;
 }
예제 #3
0
 public override void editButton_Click(object sender, EventArgs e)
 {
     edit = 1;
     MainClass.enable(leftPanel);
 }
예제 #4
0
 private void Categories_Load(object sender, EventArgs e)
 {
     MainClass.disable(leftPanel);
 }