private void btnDeleteDealer_Click(object sender, EventArgs e) { if (dgvDealer.Rows.Count > 0) { DealerBranch dealerBranch = new DealerBranch(); dealerBranch.DealerBranchId = Convert.ToInt32(dgvDealer.CurrentRow.Cells[0].Value.ToString()); dealerBranch.CTDI = Convert.ToInt32(dgvDealer.CurrentRow.Cells[1].Value.ToString()); dealerBranch.DealerName = dgvDealer.CurrentRow.Cells[2].Value.ToString(); dealerBranch.BranchName = dgvDealer.CurrentRow.Cells[3].Value.ToString(); dealerBranch.PhoneNumber = dgvDealer.CurrentRow.Cells[4].Value.ToString(); dealerBranch.BaldoPartner = dgvDealer.CurrentRow.Cells[5].Value.ToString(); dealerBranch.CountryId = Convert.ToInt32(dgvDealer.CurrentRow.Cells[6].Value.ToString()); dealerBranch.CountryName = dgvDealer.CurrentRow.Cells[7].Value.ToString(); dealerBranch.DealerId = Convert.ToInt32(dgvDealer.CurrentRow.Cells[8].Value.ToString()); if (MessageBox.Show("Are you sure you want to delete the Dealer Branch: " + dealerBranch.BranchName + "?", "Delete Dealer Branch", MessageBoxButtons.YesNo) == DialogResult.Yes) { DALHelpers.DeleteDealerBranch(dealerBranch.DealerBranchId); ActivityLog.DealerBranchLogger(dealerBranch, "DELETE", "Dealer Branch", Environment.UserName); Validation.LocalDatabaseConfig(true); dealerBranchesList = loadDealerBranches(); } dgvDealer.ClearSelection(); txtSearchDealer.Clear(); btnDeleteDealerBranch.Enabled = false; btnEditDealerBranch.Enabled = false; } }