Beispiel #1
0
 private void Filtrar(object sender, EventArgs e)
 {
     try
     {
         IList <Entity.ClienteViewModel> listaClientesFiltro;
         using (var service = new Service.ClienteService())
         {
             if (this.tb_filtro.Text == "")
             {
                 listaClientesFiltro = clientes;
             }
             else
             {
                 listaClientesFiltro = service.FiltrarClientes(tb_filtro.Text);
             }
             dg_clientes.CargarGrid(listaClientesFiltro);
             DecorarGrid();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ocurrio un error: " + ex.Message + "Inner Exception: " + ex.InnerException,
                         APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #2
0
 private void btn_modificar_Click(object sender, EventArgs e)
 {
     using (var service = new Service.ClienteService())
     {
         try
         {
             Model.Cliente cliente = new Model.Cliente();
             validaDatos = ValidarValores(validaDatos);
             if (validaDatos.EsValido)
             {
                 cliente            = ObtenerValores();
                 cliente.Id_Cliente = clienteSeleccionado.Id;
                 service.ModificarCliente(cliente);
                 MessageBox.Show("Datos del cliente " + this.tb_nombre.Text + " modificados exitosamente",
                                 APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 MessageBox.Show(string.Join(" \n", validaDatos.MensajesDeError), APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Beispiel #3
0
 private void btn_guardar_Click(object sender, EventArgs e)
 {
     using (var service = new Service.ClienteService())
     {
         try
         {
             Model.Cliente cliente = new Model.Cliente();
             validaDatos = ValidarValores(validaDatos);
             if (validaDatos.EsValido)
             {
                 cliente = ObtenerValores();
                 var IdCliente = service.GuardarCliente(cliente);
                 MessageBox.Show("Cliente " + cliente.Nombre + " agregado exitosmente",
                                 APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 Controles.ActivarBotones(this.ToolStrip1.Items);
                 Controles.LimpiarControles(this.Controls);
                 clientes = service.ObtenerTodos();
                 dg_clientes.CargarGrid(clientes);
                 this.btn_cancelar.Visible = false;
             }
             else
             {
                 MessageBox.Show(string.Join(" \n", validaDatos.MensajesDeError), APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Ocurrió un error, Por favor intente nuevamente", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #4
0
 private void Form1_Load(object sender, EventArgs e)
 {
     using (var service = new Service.ClienteService())
     {
         clientes = service.ObtenerTodos();
         dg_clientes.CargarGrid(clientes);
         DecorarGrid();
     }
 }
Beispiel #5
0
 private void btn_actualizar_Click(object sender, EventArgs e)
 {
     using (var service = new Service.ClienteService())
     {
         try
         {
             Controles.LimpiarControles(this.Controls);
             clientes = service.ObtenerTodos();
             dg_clientes.CargarGrid(clientes);
             this.btn_cancelar.Visible = false;
         }
         catch (Exception)
         {
             MessageBox.Show("Ocurrió un error, Por favor intente nuevamente", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }