Пример #1
0
        private void buscarViajesButton_Click(object sender, EventArgs e)
        {
            if (chofer == null || turno == null)
            {
                Utility.ShowInfo("Rendicion", "Debe seleccionar un chofer y un turno para buscar los viajes");
                return;
            }

            DataTable dt = new DataTable();

            dt.Load(RendicionDAO.getViajesNoRendidos(chofer, turno, fechaRendicionDateTimePicker.Value));


            if (dt.Rows.Count == 0)
            {
                Utility.ShowInfo("Rendicion", "No hay viajes sin rendir para los datos ingresados");
                return;
            }

            viajesParaRendirDataGridView.DataSource = dt;

            List <double> valorRendiciones = dt.AsEnumerable().Select(x =>
                                                                      Convert.ToDouble(x[x.Table.Columns["valor_rendicion"].Ordinal])).ToList();

            viajesParaRendirList.AddRange(dt.AsEnumerable().Select(x =>
                                                                   Convert.ToInt32(x[x.Table.Columns["viaje_id"].Ordinal])).ToList());

            importeTotal = valorRendiciones.Sum();

            totalRendicionMontoLabel.Text = "$ " + importeTotal;
        }
Пример #2
0
        private void btnRendirMesSeleccionado_Click(object sender, EventArgs e)
        {
            seleccionada = getEmpresaSelec();
            if (seleccionada == null)
            {
                MessageBox.Show("Seleccione una empresa", "Error en Rendicion de facturas", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            int mes  = 0;
            int anio = 0;

            if (dateTimeMesAnio.Value > Utils.obtenerFecha())
            {
                MessageBox.Show("La fecha Seleccionada es superior a la actual", "Error en Rendicion de facturas", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            mes  = dateTimeMesAnio.Value.Month;
            anio = dateTimeMesAnio.Value.Year;



            if (fueRendidaEsteMes(seleccionada.id))
            {
                MessageBox.Show("La empresa seleccionada ya fue rendida este mes, solo se permite una rendicion mensual por empresa", "Error en Rendicion de facturas", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            else
            {
                lblEspere.Visible = true;
                RendicionDAO.cargarGridFacturasPagadasMesEspecificado(dataGridFacturas, seleccionada, mes, anio);
                setPanelRendicion(mes, anio);
            }
        }
Пример #3
0
        private void generarRendicionButton_Click(object sender, EventArgs e)
        {
            if (chofer == null || turno == null)
            {
                Utility.ShowInfo("Rendicion", "Debe seleccionar un chofer y un turno para buscar los viajes");
                return;
            }

            if (viajesParaRendirList.Count == 0)
            {
                Utility.ShowInfo("Rendicion", "Seleccione Buscar Viajes para encontrar los viajes del chofer");
                return;
            }

            try
            {
                RendicionDAO.generarRendicion(chofer, turno, fechaRendicionDateTimePicker.Value, importeTotal, viajesParaRendirList);
                Utility.ShowInfo("Rendicion", "Rendicion creada con exito");
                cleanFields();
            }
            catch (ApplicationException ex)
            {
                Utility.ShowError("Rendicion", ex.Message);
            }
        }
Пример #4
0
        public void onOperationFinishChofer(ChoferDTO chofer)
        {
            this.chofer                     = chofer;
            this.dniTextBox.Text            = chofer.dni.ToString();
            this.nombreApellidoTextBox.Text = chofer.nombre + " " + chofer.apellido;

            turnosChoferComboBox.DataSource = RendicionDAO.getTurnosViajesByChofer(chofer);
        }
Пример #5
0
 private void btnRendir_Click(object sender, EventArgs e)
 {
     if (dataGridFacturas.Rows.Count == 0)
     {
         exito(0);
     }
     else
     {
         Model.Rendicion rend = new Model.Rendicion(0, Utils.obtenerFecha(), totalRendido, porcentajeComision);
         int             idR  = RendicionDAO.nuevaRendicion(rend);
         if (idR == 0)
         {
             MessageBox.Show("Error al generar la rendicion", "Error en Rendicion de facturas", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             foreach (DataGridViewRow fila in dataGridFacturas.Rows)
             {
                 string idFactura = fila.Cells[0].Value.ToString(); ///Para mostrar en el msgbox
                 try
                 {
                     rend.id = idR;
                     Factura f = new Factura(
                         int.Parse(fila.Cells[0].Value.ToString()),
                         DateTime.Parse(fila.Cells[1].Value.ToString()),
                         double.Parse(fila.Cells[2].Value.ToString()),
                         DateTime.Parse(fila.Cells[3].Value.ToString()),
                         seleccionada,
                         new Cliente(int.Parse(fila.Cells[4].Value.ToString()), "", "", 0, Utils.obtenerFecha(), "", "", "", "", true), //genero cualquier cliente, total solo importa el id en este update
                         rend,
                         true);                                                                                                         //Se supone que ya busca las habilitadas
                     FacturaDAO.modificarFactura(f);
                 }
                 catch (Exception)
                 {
                     MessageBox.Show("Error al actualizar la factura Nº " + idFactura, "Error en Rendicion de facturas", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     return;
                 }
             }
             exito(idR);
         }
     }
 }
Пример #6
0
        private void btnRendirTodo_Click(object sender, EventArgs e)
        {
            seleccionada = getEmpresaSelec();
            if (seleccionada == null)
            {
                MessageBox.Show("Seleccione una empresa", "Error en Rendicion de facturas", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (fueRendidaEsteMes(seleccionada.id))
            {
                MessageBox.Show("La empresa seleccionada ya fue rendida este mes, solo se permite una rendicion mensual por empresa", "Error en Rendicion de facturas", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            else
            {
                lblEspere.Visible = true;
                RendicionDAO.cargarGridFacturasPagadasTotal(dataGridFacturas, seleccionada);
                setPanelRendicion();
            }
        }
Пример #7
0
 private bool fueRendidaMesEspecifico(int idEmpresa, int mes, int anio)
 {
     return(RendicionDAO.fn_empresa_rendida_mes_especifico(idEmpresa, mes, anio));
 }
Пример #8
0
 private bool fueRendidaEsteMes(int idEmpresa)
 {
     return(RendicionDAO.fn_empresa_rendida_este_mes(idEmpresa));
 }