Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public override void addButton_Click(object sender, EventArgs e)
 {
     MainClass.enableReset(leftPanel);
     edit = 0;
 }
Ejemplo n.º 3
0
 public override void editButton_Click(object sender, EventArgs e)
 {
     edit = 1;
     MainClass.enable(leftPanel);
 }
Ejemplo n.º 4
0
 private void Categories_Load(object sender, EventArgs e)
 {
     MainClass.disable(leftPanel);
 }