示例#1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            ReadData r = new ReadData();

            if (r.FindString(textBox1.Text))    //checking database if groupname already exits or not
            {
                MessageBox.Show("Name already exists ");
                textBox1.Focus();
                //textBox1.Text = null;
                // textBox2.Text = null;
            }
            else if (textBox1.Text.Length == 0)                  //group_name is null then return error message
            {
                MessageBox.Show("Please enter group name!");
                textBox1.Focus();
            }

            else if (button1.Text == "&Save")                                          //used to save group_name and des in db
            {
                string          Error   = "";
                DBProductMaster saveobj = new DBProductMaster();
                saveobj.savegroup(textBox1.Text, textBox2.Text, ref Error);
                if (Error != "")
                {
                    MessageBox.Show(Error);
                }
                else
                {
                    MessageBox.Show("Saved Sucessfully");
                    fillcombo1();
                    refresh();
                }
            }
            else if (button1.Text == "&Update")
            {
                string          Error     = "";
                DBProductMaster updateobj = new DBProductMaster();
                updateobj.updategroup(textBox1.Text, textBox2.Text, comboBox2.Text, ref Error);
                if (Error != "")
                {
                    MessageBox.Show(Error);
                }
                else
                {
                    MessageBox.Show("Updated Sucessfully");
                    refresh();
                }
                // refresh();
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ReadData r = new ReadData();

            if (r.FindString(txtPercentage.Text))    //checking database if groupname already exits or not
            {
                MessageBox.Show("Name already exists ");
                txtPercentage.Focus();
            }
            else if (txtPercentage.Text.Length == 0)                  //group_name is null then return error message
            {
                MessageBox.Show("Please enter Tax!");
                txtPercentage.Focus();
            }

            else if (btnSave.Text == "&Save")                                          //used to save   and des in db
            {
                string          Error   = "";
                DBProductMaster saveobj = new DBProductMaster();
                saveobj.savetax(txtPercentage.Text, txtDesc.Text, ref Error);
                if (Error != "")
                {
                    MessageBox.Show(Error);
                }
                else
                {
                    MessageBox.Show("Saved Sucessfully");
                    fillcombo1();
                    refresh();
                }
            }
            else if (btnSave.Text == "&Update")
            {
                string          Error     = "";
                DBProductMaster updateobj = new DBProductMaster();
                updateobj.updatetax(txtPercentage.Text, txtDesc.Text, cmbAutono.Text, ref Error);
                if (Error != "")
                {
                    MessageBox.Show(Error);
                }
                else
                {
                    MessageBox.Show("Updated Sucessfully");
                    refresh();
                }
                // refresh();
            }
        }