private void btnDeleteCustomer_Click(object sender, System.EventArgs e) { DataGridViewRow r = dgvCustomers.SelectedRows[0]; if (r != null) { if (MetroFramework.MetroMessageBox.Show(this, "Are you sure?", "Delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { customerManagement.DeleteCustomer(r.Cells[0].Value.ToString()); dgvCustomers.Rows.Remove(r); } } }
//Delete Button private void deleteButton_Click(object sender, EventArgs e) { //Set Id as Mandatory if (String.IsNullOrEmpty(idtextBox.Text)) { MessageBox.Show("Id Can not be Empty!!!"); return; } //Delete if (_customerManagement.DeleteCustomer(Convert.ToInt32(idtextBox.Text))) { MessageBox.Show("Deleted"); } else { MessageBox.Show("Not Deleted"); } //show showDataGridView.DataSource = _customerManagement.ShowCustomerInfo(); }
// DELETE api/values/5 public void Delete(int customerId) { CustomerManagement custMgmt = new CustomerManagement(); custMgmt.DeleteCustomer(customerId); }