public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (catagoryTxt.Text == "")
            {
                catErrorLabel.Visible = true;
            }
            else
            {
                catErrorLabel.Visible = false;
            }
            if (catCombo.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (catErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.showMessage("Fields with * are mandatory", "Stop", "Error");
            }
            else
            {
                if (catCombo.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (catCombo.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0)//Code for Save Operation
                {
                    Insertion i = new Insertion();
                    i.insertCat(catagoryTxt.Text, stat);

                    r.showCategories(dataGridView1, catGV, 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 recored", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.Yes)
                    {
                        Updation u = new Updation();
                        if (catCombo.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (catCombo.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updateCat(catId, catagoryTxt.Text, stat);

                        r.showCategories(dataGridView1, catGV, nameGV, StatusGV);
                        MainClass.disable_reset(leftPanel);
                    }
                }
            }
        }
예제 #2
0
        public override void BtnSave_Click(object sender, EventArgs e)
        {
            //validation for Users form
            if (categoryNameTxt.Text == string.Empty)
            {
                catNameErrorLabel.Visible = true;
            }
            else
            {
                catNameErrorLabel.Visible = false;
            }
            if (isActiveCB.SelectedIndex == -1)
            {
                IsActiveErrorLabel.Visible = true;
            }
            else
            {
                IsActiveErrorLabel.Visible = false;
            }

            if (catNameErrorLabel.Visible || IsActiveErrorLabel.Visible)
            {
                MainClass.showMSG("Fields with * are mandatory", "Stop", "Error"); //Error is the type of message
            }
            else
            {
                if (isActiveCB.SelectedIndex == 0)
                {
                    stat = 1;
                }
                else if (isActiveCB.SelectedIndex == 1)
                {
                    stat = 0;
                }
                if (edit == 0) // Code for SAVE Operation
                {
                    Insertion i = new Insertion();
                    i.insertCat(categoryNameTxt.Text, stat);
                    r.showCategories(CatDataGridView, catIDGV, NameGV, StatusGV);
                    MainClass.disable_reset(LeftPanel);
                }
                else if (edit == 1) // Code for EDIT 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 (isActiveCB.SelectedIndex == 0)
                        {
                            stat = 1;
                        }
                        else if (isActiveCB.SelectedIndex == 1)
                        {
                            stat = 0;
                        }
                        u.updatetCat(catID, categoryNameTxt.Text, stat);
                        r.showCategories(CatDataGridView, catIDGV, NameGV, StatusGV);
                        MainClass.disable_reset(LeftPanel);
                    }
                }
            }
        }