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; } } }
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); } } }