Пример #1
0
        void loadGrid()
        {
            dgvEgresos.Rows.Clear();
            totalEgreso  = 0;
            totalIngreso = 0;
            var list = TransaccionController.listar(-1).Where(x => x.FechaTransaccion.Equals(dtFechaFiltro.Value.Date)).ToList();

            if (list == null)
            {
                throw new Exception("No se pudo cargar");
            }
            for (int i = 0; i < list.Count; i++)
            {
                decimal ingreso = list[i].Egreso.Where(x => x.TipoTransaccion == 1 && x.Activo).Sum(y => y.Cantidad);
                decimal egreso  = list[i].Egreso.Where(x => x.TipoTransaccion == 0 && x.Activo).Sum(y => y.Cantidad);
                string  cajero  = UsuariosController.leer(list[i].Id_usuario).Personas.ToString();
                dgvEgresos.Rows.Add(list[i].IdTransaccion, cajero, list[i].Vehiculo.Placa, list[i].FechaTransaccion.ToShortDateString(), ingreso, egreso);
                if (!list[i].Activo)
                {
                    dgvEgresos.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
                }
                else
                {
                    dgvEgresos.Rows[i].DefaultCellStyle.ForeColor = Color.Black;
                }
                totalIngreso += ingreso;
                totalEgreso  += egreso;
            }
            setTotales();
        }
Пример #2
0
        private void btnFiltrar_Click(object sender, EventArgs e)
        {
            try
            {
                totalEgreso  = 0;
                totalIngreso = 0;
                if (String.IsNullOrWhiteSpace(txtDescripcion.Text) || String.IsNullOrEmpty(txtDescripcion.Text))
                {
                    loadGrid();
                }
                else
                {
                    dgvEgresos.Rows.Clear();
                    var codigoVehiculo = VehiculosController.leer(txtDescripcion.Text);
                    if (codigoVehiculo == null)
                    {
                        throw new Exception("No existe un vehiculo con esa placa");
                    }

                    var list = TransaccionController.listar(codigoVehiculo.Id_Vehiculo).Where(x => x.FechaTransaccion.Equals(dtFechaFiltro.Value.Date)).ToList();

                    if (codigoVehiculo.Transaccion.Count == 0)
                    {
                        throw new Exception("No hay transacciones para ese vehiculo");
                    }
                    for (int i = 0; i < list.Count; i++)
                    {
                        decimal ingreso = list[i].Egreso.Where(y => y.TipoTransaccion == 1 && y.Activo).Sum(x => x.Cantidad);
                        decimal egreso  = list[i].Egreso.Where(y => y.TipoTransaccion == 0 && y.Activo).Sum(x => x.Cantidad);
                        string  cajero  = UsuariosController.leer(list[i].Id_usuario).Personas.ToString();
                        dgvEgresos.Rows.Add(list[i].IdTransaccion, cajero, list[i].Vehiculo.Placa, list[i].FechaTransaccion.ToShortDateString(), ingreso, egreso);
                        if (!list[i].Activo)
                        {
                            dgvEgresos.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
                        }
                        else
                        {
                            dgvEgresos.Rows[i].DefaultCellStyle.ForeColor = Color.Black;
                        }
                        totalIngreso += ingreso;
                        totalEgreso  += egreso;
                    }
                    setTotales();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }