public static void deletecus(tblcustomerdetail tbl) { db = new db_MiletecDataContext(); db.sp_deleteCustomerdetails(tbl.CustomerID); }
private void btndelete_Click(object sender, EventArgs e) { //delete customer data if (txtcustomername.Text != "Customer Name" && txtaddress.Text != "Address" && txtcontactno1.Text != "Contactno.1" && txtcontactno2.Text != "Contactno.1") { tblcustomerdetail tbl = new tblcustomerdetail(); tbl.CustomerID = dgvcustomerdetails.CurrentRow.Cells[1].Value.ToString(); clsrepository.deletecus(tbl); dgvcustomerdetails.DataSource = clsrepository.customer(); MessageBox.Show("Successfully delete!"); btnsave.Enabled = true; txtcustomername.Text = "Customer Name"; txtaddress.Text = "Address"; txtcontactno1.Text = "Contactno.1"; txtcontactno2.Text = "Contactno.2"; } else { MessageBox.Show("Please choose a customer you want do delete!", "NOTE", MessageBoxButtons.OK, MessageBoxIcon.Error); } }