public override void Add(Action <bool, string> validatorHandler, Func <Task> OnSuccess, Action <Exception> ExceptionHandler) { try { var operacionInValida = textBoxCedula.Text == "" || textBoxComision.Text == "" || textBoxNombre.Text == "" || textBoxTanda.Text == ""; validatorHandler(operacionInValida || !validaCedula(textBoxCedula.Text), !validaCedula(textBoxCedula.Text) ? "La cédula debe ser valida" : "Debes ingresar valores a los campos obligatorios."); if (!operacionInValida && validaCedula(textBoxCedula.Text)) { PersonaDto Persona = _ManejadorPersona.ObtenerPorFiltro(x => x.Cedula == textBoxCedula.Text); if (Persona == null) { Persona = new PersonaDto(); Persona.Cedula = textBoxCedula.Text; Persona.Estado = true; Persona.FechaCreacion = DateTime.Now; Persona.Nombre = textBoxNombre.Text; Persona.TipoPersonaId = 1; Persona = _ManejadorPersona.CrearSync(Persona, true); } else if (Persona.Nombre != textBoxNombre.Text) { Persona.Nombre = textBoxNombre.Text; _ManejadorPersona.Actualizar(Persona); } EmpleadoDto Empleado = _ManejadorEmpleado.ObtenerPorFiltro(x => x.Persona.Cedula == textBoxCedula.Text && x.Estado); if (Empleado == null) { Empleado = new EmpleadoDto(); Empleado.TandaLabor = textBoxTanda.Text; Empleado.PorCientoComision = textBoxComision.Text; Empleado.Estado = true; Empleado.PersonaId = Persona.Id; Empleado.FechaCreacion = DateTime.Now; Empleado.FechaIngreso = DateTime.Now; _ManejadorEmpleado.Crear(Empleado, true); limpiarPantalla(); OnSuccess(); } else { string mensaje = "Ya existe un empleado con esta cédula."; validatorHandler(true, mensaje); } } } catch (Exception ex) { ExceptionHandler(ex); } }
public void Actualizar(int id) { TipoCombustibleDto _TipoCombustible = _Manejador.Obtener(id); _TipoCombustible.Nombre = textBoxNombre.Text; _Manejador.Actualizar(_TipoCombustible); }
public void Actualizar(int id) { TipoVehiculoDto _TipoVehiculo = _Manejador.Obtener(id); _TipoVehiculo.Nombre = textBoxNombre.Text; _Manejador.Actualizar(_TipoVehiculo); }
public void Actualizar(int id) { MarcaDto _Marca = _Manejador.Obtener(id); _Marca.Nombre = textBoxNombre.Text; _Manejador.Actualizar(_Marca); }
public void Actualizar(int id) { ModeloDto _Modelo = _Manejador.Obtener(id); _Modelo.Nombre = textBoxNombre.Text; _Modelo.MarcaId = int.Parse(cbMarca.SelectedValue.ToString()); _Manejador.Actualizar(_Modelo); }
public void Actualizar(int id) { UsuarioDto _Usuario = _Manejador.Obtener(id); _Usuario.Nombre = textBoxNombre.Text; _Usuario.Clave = textBoxClave.Text.generateShaText(); _Usuario.EmpleadoId = int.Parse(cbEmpleado.SelectedValue.ToString()); _Manejador.Actualizar(_Usuario); }
public void Actualizar(int id) { VehículoDto _Vehiculo = _Manejador.Obtener(id); _Vehiculo.MarcaId = int.Parse(cbMarca.SelectedValue.ToString()); _Vehiculo.ModeloId = int.Parse(cbModelo.SelectedValue.ToString()); _Vehiculo.TipoCombustibleId = int.Parse(cbTipoCombustible.SelectedValue.ToString()); _Vehiculo.TipoVehiculoId = int.Parse(cbTipoVehiculo.SelectedValue.ToString()); _Vehiculo.Chasis = textBoxChassis.Text; _Vehiculo.Motor = textBoxMotor.Text; _Vehiculo.Placa = textBoxPlaca.Text; _Manejador.Actualizar(_Vehiculo); }
public void Actualizar(int id) { RentaDevolucionDto _RentaDevolucion = _Manejador.Obtener(id, new[] { "Vehiculo", "Vehiculo.Modelo" }); _RentaDevolucion.ClienteId = int.Parse(cbCliente.SelectedValue.ToString()); _RentaDevolucion.VehiculoId = int.Parse(cbVehículo.SelectedValue.ToString()); _RentaDevolucion.MontoDia = textBoxMontoDia.Text; _RentaDevolucion.Renta = textBoxTotalRenta.Text; _RentaDevolucion.Dias = textBoxDias.Text; _RentaDevolucion.FechaRenta = Convert.ToDateTime(dtpFechaInicio.Text); _RentaDevolucion.FechaDevolucion = Convert.ToDateTime(dtpFechaFinal.Text); _RentaDevolucion.EmpleadoId = Form1.currentUserId; _Manejador.Actualizar(_RentaDevolucion); }
public override void Update(Action <bool, string> validatorHandler, Func <Task> OnSuccess, Action <Exception> ExceptionHandler, int id) { try { var operacionInValida = textBoxCedula.Text == "" || textBoxNombre.Text == "" || textBoxLimite.Text == "" || textBoxTarjeta.Text == ""; validatorHandler(operacionInValida, "Debes ingresar valores a los campos obligatorios."); if (!operacionInValida) { PersonaDto Persona = _ManejadorPersona.ObtenerPorFiltro(x => x.Cedula == textBoxCedula.Text && x.Estado); ClientesDto Cliente = _ManejadorCliente.ObtenerPorFiltro(x => x.TarjetaCredito == textBoxTarjeta.Text && x.Estado); if (Persona == null || !isCedulaEditing) { if (Cliente == null) { Cliente = _ManejadorCliente.Obtener(id); Persona = _ManejadorPersona.Obtener(Cliente.PersonaId); Persona.Cedula = textBoxCedula.Text; Persona.Nombre = textBoxNombre.Text; _ManejadorPersona.Actualizar(Persona); Cliente.TarjetaCredito = textBoxTarjeta.Text; Cliente.LimiteCredito = int.Parse(textBoxLimite.Text); _ManejadorCliente.Actualizar(Cliente); limpiarPantalla(); OnSuccess(); } else { validatorHandler(true, "Ya existe un cliente con este numero de tarjeta de credito."); } } else { validatorHandler(true, "Ya existe un cliente con esta cédula."); } } } catch (Exception ex) { ExceptionHandler(ex); } }
public override void Update(Action <bool, string> validatorHandler, Func <Task> OnSuccess, Action <Exception> ExceptionHandler, int id) { try { var operacionInValida = textBoxCedula.Text == "" || textBoxComision.Text == "" || textBoxNombre.Text == "" || textBoxTanda.Text == ""; validatorHandler(operacionInValida, "Debes ingresar valores a los campos obligatorios."); if (!operacionInValida) { PersonaDto Persona = _ManejadorPersona.ObtenerPorFiltro(x => x.Cedula == textBoxCedula.Text && x.Estado); if (Persona == null || !isCedulaEditing) { EmpleadoDto Empleado = _ManejadorEmpleado.Obtener(id); Persona = _ManejadorPersona.Obtener(Empleado.PersonaId); Persona.Cedula = textBoxCedula.Text; Persona.Nombre = textBoxNombre.Text; _ManejadorPersona.Actualizar(Persona); Empleado.TandaLabor = textBoxTanda.Text; Empleado.PorCientoComision = textBoxComision.Text; _ManejadorEmpleado.Actualizar(Empleado); limpiarPantalla(); OnSuccess(); } else { validatorHandler(true, "Ya existe un cliente con esta cédula."); } } } catch (Exception ex) { ExceptionHandler(ex); } }
public void Crear() { RentaDevolucionDto _RentaDevolucion = new RentaDevolucionDto(); _RentaDevolucion.ClienteId = int.Parse(cbCliente.SelectedValue.ToString()); _RentaDevolucion.VehiculoId = int.Parse(cbVehículo.SelectedValue.ToString()); VehículoDto _Vehiculo = _ManejadorVehículo.Obtener(_RentaDevolucion.VehiculoId); _Vehiculo.Estado = false; _ManejadorVehículo.Actualizar(_Vehiculo); _RentaDevolucion.MontoDia = textBoxMontoDia.Text; _RentaDevolucion.Renta = textBoxTotalRenta.Text; _RentaDevolucion.Dias = textBoxDias.Text; _RentaDevolucion.FechaCreacion = DateTime.Now; _RentaDevolucion.FechaRenta = Convert.ToDateTime(dtpFechaInicio.Text); _RentaDevolucion.FechaDevolucion = Convert.ToDateTime(dtpFechaFinal.Text); _RentaDevolucion.Estado = true; _RentaDevolucion.EmpleadoId = Form1.currentUserId; _Manejador.Crear(_RentaDevolucion, true); }
public void Actualizar(int id) { InspeccionDto _Inspeccion = _Manejador.Obtener(id); _Inspeccion.ClienteId = int.Parse(cbCliente.SelectedValue.ToString()); _Inspeccion.VehiculoId = int.Parse(cbVehiculo.SelectedValue.ToString()); _Inspeccion.CantidadCombustible = textBoxCantidadCombustible.Text; _Inspeccion.FechaInspeccion = Convert.ToDateTime(dtpFechaInspeccion.Text); var items = clbInspeccion.CheckedItems; _Inspeccion.Ralladuras = items.Contains("Ralladuras"); _Inspeccion.GomaRepuesta = items.Contains("Goma Repuesta"); _Inspeccion.Gato = items.Contains("Gato"); _Inspeccion.RoturaCristal = items.Contains("Rotura de cristales"); _Inspeccion.Goma1 = items.Contains("Goma izquierda frente"); _Inspeccion.Goma2 = items.Contains("Goma derecha frente"); _Inspeccion.Goma3 = items.Contains("Goma izquierda atras"); _Inspeccion.Goma4 = items.Contains("Goma derecha atras"); _Inspeccion.EmpleadoId = Form1.currentUserId; _Manejador.Actualizar(_Inspeccion); }
public async Task doLogic(ToolStripMenuItem sender, string texto, bool removeLastChar = false) { operationPanel.Visible = true; panelHeader.Visible = true; panelBienvenido.Visible = false; if (uC != null) { uC.Dispose(); } if (menuItemName == sender.Name) { return; } menuItemName = removeLastChar ? sender.Name.Remove(sender.Name.Length - 1, 1) : sender.Name; if (!loadingCircle1.Visible && menuItemName != "Reporte") { loadingCircle1.Visible = true; loadingCircle1.Active = true; } uC = (BaseUserControl)Activator.CreateInstance(Type.GetType(string.Format("{0}.{1}", "WilmerRentCar.UserControls", menuItemName))); uC.AutoScroll = true; operationPanel.Height = uC.Height + 50; uC.Left = (operationPanel.Width - uC.Width) / 2; uC.Top = 20; operationPanel.Controls.Clear(); operationPanel.Controls.Add(uC); uC.Show(); labelGeneral.Text = texto; if (menuItemName != "Reporte") { btnAdd.Visible = true; if (isFirstClick == true) { btnAdd.Click += (object sender2, EventArgs e2) => uC.Add((bo, t) => OnError(bo, t), () => OnSuccess(), ex => ExcepcionHandler(ex)); btnUpdate.Click += (object sender2, EventArgs e2) => uC.Update((bo, t) => OnError(bo, t), () => OnSuccess(), ex => ExcepcionHandler(ex), currentRowId); } isFirstClick = false; MainPanel.Controls.Remove(tableGeneric1); if (menuItemName != "Consulta") { tableGeneric1 = new TableGeneric(btnUpdate, (DataGridViewRow row) => { var type = row.Cells[2].Value.GetType(); currentRowId = int.Parse(type.Name == "Bitmap" ? row.Cells[3].Value.ToString() : row.Cells[2].Value.ToString()); uC.Edit(row); }, (int id) => { loadingCircle1.Visible = true; loadingCircle1.Active = true; uC.Delete(id, async() => await OnSuccess()); }, (int id) => { loadingCircle1.Visible = true; loadingCircle1.Active = true; Manejador <RentaDevolucion, RentaDevolucionDto> _Manejador = new Manejador <RentaDevolucion, RentaDevolucionDto>(); RentaDevolucionDto renta = _Manejador.ObtenerPorFiltro(x => x.Id == id, new[] { "Vehiculo", "Vehiculo.Modelo", "Vehiculo.Marca" }); renta.Estado = false; _Manejador.Actualizar(renta); Manejador <BOL.Vehículo, VehículoDto> _ManejadorVehiculo = new Manejador <BOL.Vehículo, VehículoDto>(); VehículoDto _Vehiculo = _ManejadorVehiculo.ObtenerPorFiltro(x => x.Id == renta.VehiculoId, new[] { "Marca", "Modelo" }); _Vehiculo.Estado = true; _ManejadorVehiculo.Actualizar(_Vehiculo); OnSuccess(); }, menuItemName); } else { tableGeneric1 = new TableGeneric(menuItemName, loadingHandler, MainPanel.Width, false); uC.SuccessFunction += async() => await SuccessFunction(); } tableGeneric1.BackColor = Color.Transparent; //tableGeneric1.Left = (MainPanel.Width - tableGeneric1.Width) / 2; tableGeneric1.Name = "tableGeneric1"; tableGeneric1.AutoSize = true; MainPanel.Controls.Add(tableGeneric1); if (menuItemName != "Consulta") { await tableGeneric1.FillData(menuItemName, loadingHandler, MainPanel.Width); } tableGeneric1.Top = operationPanel.Height + 105; } else { btnAdd.Visible = false; } }
public override void Add(Action <bool, string> validatorHandler, Func <Task> OnSuccess, Action <Exception> ExceptionHandler) { try { var operacionInValida = textBoxCedula.Text == "" || textBoxNombre.Text == "" || textBoxLimite.Text == "" || textBoxTarjeta.Text == ""; validatorHandler(operacionInValida || !validaCedula(textBoxCedula.Text), !validaCedula(textBoxCedula.Text) ? "La cédula debe ser valida" : "Debes ingresar valores a los campos obligatorios."); if (!operacionInValida) { PersonaDto Persona = _ManejadorPersona.ObtenerPorFiltro(x => x.Cedula == textBoxCedula.Text); if (Persona == null) { Persona = new PersonaDto(); Persona.Cedula = textBoxCedula.Text; Persona.Estado = true; Persona.FechaCreacion = DateTime.Now; Persona.Nombre = textBoxNombre.Text; Persona.TipoPersonaId = 1; Persona = _ManejadorPersona.CrearSync(Persona, true); } else if (Persona.Nombre != textBoxNombre.Text) { Persona.Nombre = textBoxNombre.Text; _ManejadorPersona.Actualizar(Persona); } ClientesDto cliente = _ManejadorCliente.ObtenerPorFiltro(x => x.Persona.Cedula == textBoxCedula.Text && x.Estado); if (cliente == null) { cliente = new ClientesDto(); cliente.TarjetaCredito = textBoxTarjeta.Text; cliente.LimiteCredito = int.Parse(textBoxLimite.Text); cliente.Estado = true; cliente.PersonaId = Persona.Id; cliente.FechaCreacion = DateTime.Now; _ManejadorCliente.Crear(cliente, true); limpiarPantalla(); OnSuccess(); } else { string mensaje = "Ya existe un cliente con esta cédula."; validatorHandler(true, mensaje); } //} else //{ //} } } catch (Exception ex) { ExceptionHandler(ex); } }