public void EliminarCliente() { IBLLCliente _BLLCliente = new BLLCliente(); string idCliente = "2-332-444"; string pCliente = ""; pCliente = _BLLCliente.EliminarCliente(idCliente); System.Diagnostics.Debug.Write(pCliente); }
/// <summary> /// Metodo para eliminar un cliente de la base de datos /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEliminar_Click(object sender, EventArgs e) { IBLLCliente _BLLCliente = new BLLCliente(); IBLLFactura _BLLFactura = new BLLFactura(); erpErrores.Clear(); string IDCliente = ""; try { if (string.IsNullOrEmpty(dgvClientes.SelectedRows[0].Cells[0].Value.ToString())) { erpErrores.SetError(dgvClientes, "Debe seleccionar un cliente de la lista"); } else { IDCliente = dgvClientes.SelectedRows[0].Cells[0].Value.ToString(); if (_BLLFactura.ObtenerFacturaByIDCliente(IDCliente) != null) { MessageBox.Show("No se puede eliminar un cliente con registros en la base de datos"); } else { _BLLCliente.EliminarCliente(IDCliente); MessageBox.Show("Cliente eliminado"); } } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }