コード例 #1
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (categoryTxt.Text == "")
            {
                categoryErrorLabel.Visible = true;
            }
            else
            {
                categoryErrorLabel.Visible = false;
            }
            if (activeCB.SelectedIndex == -1)
            {
                activeErrorLabel.Visible = true;
            }
            else
            {
                activeErrorLabel.Visible = false;
            }

            if (categoryErrorLabel.Visible || activeErrorLabel.Visible)
            {
                MainClass.ShowMSG("Feild with * are mandatory", "Stop", "Error");//error is a type of message
            }
            else
            {
                if (activeCB.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (activeCB.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//for save operations
                {
                    insertions i = new insertions();
                    i.insertCat(categoryTxt.Text, stat);
                    r.showCategories(dataGridView1, catIDGV, NameGV, stausGV);
                    MainClass.disable_reset(leftPanel);
                }
                else if (edit == 1)// for update operations
                {
                    DialogResult dr = MessageBox.Show("Are you sure , you want to update record?", "Question..", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (activeCB.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (activeCB.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateCat(categoryID, categoryTxt.Text, stat);
                        r.showCategories(dataGridView1, catIDGV, NameGV, stausGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }