public override void button3_Click(object sender, EventArgs e) { if (supplierComTxt.Text == "") { nameErrorLbl.Visible = true; } else { nameErrorLbl.Visible = false; } if (personNameTxt.Text == "") { ContPerErrorlbl.Visible = true; } else { ContPerErrorlbl.Visible = false; } if (phone1txt.Text == "") { phone1Errorlbl.Visible = true; } else { phone1Errorlbl.Visible = false; } // if (phone2txt.Text == "") { phone2Errorlbl.Visible = true; } else { phone2Errorlbl.Visible = false; } if (addresstxt.Text == "") { AddressErroorlbl.Visible = true; } else { AddressErroorlbl.Visible = false; } // if (TaxNotxt.Text == "") { TaxNoErrorlbl.Visible = true; } else { TaxNoErrorlbl.Visible = false; } if (statusDD.SelectedIndex == -1) { statusErrorlbl.Visible = true; } else { statusErrorlbl.Visible = false; } if (nameErrorLbl.Visible || ContPerErrorlbl.Visible || phone1Errorlbl.Visible || AddressErroorlbl.Visible || statusErrorlbl.Visible) { MainClass.showMG("Filds With * Are Mandatory", "Stop", "Error"); // Error is the type of Message } else { if (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } if (edit == 0)//code for save operation { insertion i = new insertion(); if (phone2txt.Text == "" && TaxNotxt.Text != "") { i.insertSupplier(supplierComTxt.Text, personNameTxt.Text, phone1txt.Text, addresstxt.Text, stat, null, TaxNotxt.Text); } else if (phone2txt.Text != "" && TaxNotxt.Text == "") { i.insertSupplier(supplierComTxt.Text, personNameTxt.Text, phone1txt.Text, addresstxt.Text, stat, phone2txt.Text, null); } else if (phone2txt.Text == "" && TaxNotxt.Text == "") { i.insertSupplier(supplierComTxt.Text, personNameTxt.Text, phone1txt.Text, addresstxt.Text, stat, null, null); } else { i.insertSupplier(supplierComTxt.Text, personNameTxt.Text, phone1txt.Text, addresstxt.Text, stat, phone2txt.Text); } r.showSupplier(dataGridView1, suppIDGV, companyGV, personGV, phone1GV, phone2GV, addressGV, ntnGV, 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 (statusDD.SelectedIndex == 0) { stat = 1; } else if (statusDD.SelectedIndex == 1) { stat = 0; } if (phone2txt.Text == "" && TaxNotxt.Text != "") { u.updateSupplier(SupplierID, supplierComTxt.Text, personNameTxt.Text, phone1txt.Text, addresstxt.Text, stat, null, TaxNotxt.Text); } else if (phone2txt.Text != "" && TaxNotxt.Text == "") { u.updateSupplier(SupplierID, supplierComTxt.Text, personNameTxt.Text, phone1txt.Text, addresstxt.Text, stat, phone2txt.Text, null); } else if (phone2txt.Text == "" && TaxNotxt.Text == "") { u.updateSupplier(SupplierID, supplierComTxt.Text, personNameTxt.Text, phone1txt.Text, addresstxt.Text, stat, null, null); } else { u.updateSupplier(SupplierID, supplierComTxt.Text, personNameTxt.Text, phone1txt.Text, addresstxt.Text, stat, phone1txt.Text, phone2txt.Text); } r.showSupplier(dataGridView1, suppIDGV, companyGV, personGV, phone1GV, phone2GV, addressGV, ntnGV, statusGV); MainClass.disable_reset(lftPanel); } } } }