private void btnDelete_Click(object sender, EventArgs e) { try { int MaKH = int.Parse(txtMaKH.Text); string status = ""; DialogResult result = MessageBox.Show("Có chắc chắn muốn xóa?", "STATUS", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { status = Customer.Delete(MaKH); if (status != "Successful") { throw new Exception(status); } MessageBox.Show("Xóa thành công", "STATUS", MessageBoxButtons.OK, MessageBoxIcon.Information); Reset(); } } catch (FormatException exception) { MessageBox.Show("Mã không hợp lệ!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected void gvCustomer_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteRecord" && e.CommandArgument != null) { CustomerBAL balCustomer = new CustomerBAL(); if (balCustomer.Delete(Convert.ToInt32(e.CommandArgument))) { FillCustomerGridView(Convert.ToInt32(Session["UserID"])); } else { lblMessage.Text = balCustomer.Message; } } }
protected void gvCustomer_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "DeleteRecord" && e.CommandArgument != null) { CustomerBAL balCustomer = new CustomerBAL(); if (balCustomer.Delete(Convert.ToInt32(e.CommandArgument))) { FillCustomerGridView(); } else { lblMessage.Text = balCustomer.Message; } } } catch (Exception ex) { lblMessage.Text = ex.Message.ToString(); } }