Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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;
            }
        }