Пример #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            if (dgvClientes.SelectedRows == null || dgvClientes.SelectedRows.Count == 0)
            {
                return;
            }
            var row     = dgvClientes.SelectedRows[0];
            var cliente = row.DataBoundItem as Cliente;

            if (MessageBox.Show(string.Format("Confirma que desea eliminar al cliente {0} {1}?", cliente.Nombre.Trim(), cliente.Apellido.Trim())
                                , "Eliminar cliente", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                try
                {
                    _clienteManager.Delete(cliente);
                    var dataSource = dgvClientes.DataSource as BindingList <Cliente>;
                    dataSource.Remove(cliente);
                    dgvClientes.Refresh();
                    MessageBox.Show(string.Format("Cliente {0} {1} eliminado", cliente.Nombre.Trim(), cliente.Apellido.Trim()));
                }
                catch
                {
                    MessageBox.Show("Error al eliminar el cliente");
                }
            }
        }
Пример #2
0
 // GET: Cliente/Delete/5
 public ActionResult Delete(String id)
 {
     try
     {
         cc.Delete(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        // DELETE
        public IHttpActionResult Delete(Cliente cliente)
        {
            try
            {
                var mng = new ClienteManager();
                mng.Delete(cliente);

                apiResp         = new ApiResponse();
                apiResp.Message = "Action was executed.";

                return(Ok(apiResp));
            }
            catch (BusinessException bex)
            {
                return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message)));
            }
        }
Пример #4
0
        private void BorrarBtn_Click(object sender, EventArgs e)
        {
            status = RecordAction.Delete;
            if (currentcliente != null)
            {
                if (currentcliente.Idcliente != -1)
                {
                    var resp = MessageBox.Show("Desea Borrar el registro?", "Confirmación", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                    if (resp == DialogResult.OK && Currentindex > 0)
                    {
                        cli.Delete(Currentindex);
                    }
                    currentcliente.Idcliente = -1;
                    Utilities.Controles(this.panel1, "Reset");

                    Utilities.Mensaje(errorBar1, "El Registro ha sido eliminado con exito", errorType.Alert);
                }
            }
            else
            {
                Utilities.Mensaje(errorBar1, "Debe seleccionar un usuario", errorType.Info);
            }
        }