private void btnEliminar_Click(object sender, EventArgs e) { controlCliente = new ControlCliente(); try { String cedula = tabla.SelectedCells[0].Value.ToString(); controlCliente.eliminarCliente(cedula); MessageBox.Show("Cliente Eliminado Exitosamente"); this.Close(); } catch { MessageBox.Show("Elija un Cliente"); } }
private void btnEliminar_Click(object sender, EventArgs e) { try { Cliente mCliente = new Cliente(); int ID = (int)dgvClientes.SelectedRows[0].Cells[0].Value; ControlCliente mControl = new ControlCliente(); mControl.eliminarCliente(ID); MessageBox.Show("Cliente eliminado"); } catch (Exception error) { MessageBox.Show("El cliente tiene Pedidos registrados, no es posible eliminarlo."); } }
/// <summary> /// Unicamente tomando el valor de la cedula y validando que sea correcta, se busca al cliente por ella y se confirma el borrado de la base de datos /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEliminar_Click(object sender, EventArgs e) { if (txtCedula.Text != "") { if (controlCliente.BuscarCliente(txtCedula.Text)) { if (controlCliente.eliminarCliente(txtCedula.Text)) { MessageBox.Show("Borrado exitoso", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); btnVaciarCampos_Click(sender, e); } else { MessageBox.Show("No se realizó el borrado", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("El cliente que desea eliminar no existe en la base de datos", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }