protected void btnAdd_Click(object sender, EventArgs e) { lblEMsg.Visible = false; string[] Supp; try { string sql = "SELECT COUNT(*) FROM SUPPLIER WHERE SUPPLIER_NAME = '" + txtSName.Text + "' And Status = 'A'"; SqlDataReader sdr; Profile pro = new Profile(); sdr = pro.ReturnMDetails(sql); sdr.Read(); int RegNo = (int)sdr[0]; if (RegNo > 0) { lblEMsg.Text = "Supplier Name already exists."; lblEMsg.Visible = true; sdr.Close(); return; } else { Supp = new string[15]; Supp[0] = txtSupplier.Text; Supp[1] = txtSName.Text; Supp[2] = txtAdd.Text; Supp[3] = txtPhone.Text; Supp[4] = txtFax.Text; Supp[5] = txtemail.Text; if (chkStatus.Checked == true) { Supp[6] = "A"; } else { Supp[7] = "I"; } bool status; status = pro.AddSupplier(Supp); if (status == false) { lblEMsg.Visible = true; lblEMsg.Text = "Supplier creation Failed"; } lblEMsg.Visible = true; lblEMsg.Text = "Supplier added."; ReadSupplier(); txtSName.Text = ""; txtAdd.Text = ""; txtPhone.Text = ""; txtFax.Text = ""; txtemail.Text = ""; } } catch (Exception ex) { throw ex; } }