Ejemplo n.º 1
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (catTxt.Text == "")
            {
                catErrorLabel.Visible = true;
            }
            else
            {
                catErrorLabel.Visible = false;
            }
            if (activeDD.SelectedIndex == -1)
            {
                activeErrorLabel.Visible = true;
            }
            else
            {
                activeErrorLabel.Visible = false;
            }

            if (catErrorLabel.Visible || activeErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory", "Stop", "Error"); //Error is the type of msg
            }
            else
            {
                if (activeDD.SelectedIndex == 0)
                {
                    stat = 1; //this is sent to the stored procedure: status = 1 then 'Yes'
                }
                else if (activeDD.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0) //Code for SAVE operation
                {
                    insertion i = new insertion();

                    i.insertCat(catTxt.Text, stat);
                    r.showCategories(dataGridView1, catIDGV, NameGV, StatusGV);
                    MainClass.disable_reset(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.Question);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (activeDD.SelectedIndex == 0)
                        {
                            stat = 1; //this is sent to the stored procedure: status = 1 then 'Yes'
                        }
                        else if (activeDD.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateCat(catID, catTxt.Text, stat);
                        r.showCategories(dataGridView1, catIDGV, NameGV, StatusGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }
        public override void button3_Click(object sender, EventArgs e)
        {
            if (CategoryTxt.Text == "")
            {
                CategoryErrorLbl.Visible = true;
            }
            else
            {
                CategoryErrorLbl.Visible = false;
            }
            if (activeDD.SelectedIndex == -1)
            {
                ActiveErrorlbl.Visible = true;
            }
            else
            {
                ActiveErrorlbl.Visible = false;
            }

            if (ActiveErrorlbl.Visible || CategoryErrorLbl.Visible)
            {
                MainClass.showMG("Filds With * Are Mandatory", "Stop", "Error"); // Error is the type of Message
            }
            else
            {
                if (activeDD.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (activeDD.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//code for save operation
                {
                    insertion i = new insertion();
                    i.insertCat(CategoryTxt.Text, stat);
                    r.ShowCategories(dataGridView1, catIDGV, NameGV, statusGV);
                    MainClass.disable_reset(lftPanel);
                }
                else if (edit == 1)///for Updte Operation
                {
                    DialogResult dr = MessageBox.Show("Are you sure, you want to updata Record", "Question..", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        updation u = new updation();
                        if (activeDD.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (activeDD.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateCat(catID, CategoryTxt.Text, stat);
                        r.ShowCategories(dataGridView1, catIDGV, NameGV, statusGV);
                        MainClass.disable_reset(lftPanel);
                    }
                }
            }
        }