private void mtCus_Click(object sender, EventArgs e) { UpdateCustomer c = new UpdateCustomer(); c.Show(); this.Hide(); c.setid(u_id); }
private void mtUpdate_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Do you want to update?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr.ToString() == "Yes") { if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtadd.Text) || String.IsNullOrEmpty(txtnic.Text) || txttele.Text.Length != 10) { MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { String name = txtname.Text; String add = txtadd.Text; String nic = txtnic.Text; DBCustomer di = new DBCustomer(); int tele = Convert.ToInt32(txttele.Text); int no = di.getCusNo(nic); int line = di.updateCustomer(name, add, nic, tele, u_id, no); if (line == 1) { MessageBox.Show("Data entered successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { MessageBox.Show("Error,please try again", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } UpdateCustomer upd = new UpdateCustomer(); this.Hide(); upd.Show(); upd.setid(u_id); }