private void dgvAccount_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { string itemN = e.Row.Cells["dgvAccount_LineRef"].Value.ToString(); if (MessageBox.Show("Do you want to delelte current row ? ", "Conformation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { string supid = MyCommon.GetSelectedID(cmbSupplier, true); string respond = ""; int Status = MyBill.GetBillStatus(cmbGRN.Text, int.Parse(supid)); switch (Status) { case 0: respond = MyBill.DeleteBillingDetails(int.Parse(itemN), cmbGRN.Text); if (respond == "True") { Program.InformationMessage("Record deleted successfully"); CalTotalAmount(); e.Cancel = false; } break; case 1: respond = MyBill.DeleteBillingDetails(int.Parse(itemN), cmbGRN.Text); if (respond == "True") { Program.InformationMessage("Record deleted successfully"); CalTotalAmount(); e.Cancel = false; } break; default: Program.VerningMessage("You cannot delete this record ?"); e.Cancel = true; break; } } else { e.Cancel = false; } }