Exemple #1
0
        protected override void BtnSearchClick(object sender, EventArgs e)
        {
            Empresa       = ddlEmpresa.Selected;
            Linea         = ddlPlanta.Selected;
            Departamento  = ddlDepartamento.Selected;
            Desde         = dtDesde.SelectedDate.Value;
            Hasta         = dtHasta.SelectedDate.Value;
            Dias          = GetDiasDeSemana(dtDesde.SelectedDate.Value, dtHasta.SelectedDate.Value);
            DiasHistorico = GetDiasDeSemana(DateTime.UtcNow.AddDays(-30), DateTime.UtcNow);

            var ccDataSource = new List <List <string> >();
            var centros      = DAOFactory.CentroDeCostosDAO.GetList(new[] { Empresa },
                                                                    new[] { Linea },
                                                                    new[] { Departamento });

            foreach (var cc in centros)
            {
                var subCentros = DAOFactory.SubCentroDeCostosDAO.GetList(new[] { Empresa },
                                                                         new[] { Linea },
                                                                         new[] { Departamento },
                                                                         new[] { cc.Id });
                var cantSubCentros = subCentros.Count();
                var objetivoTotal  = (from subcc in subCentros
                                      let vehiculos = DAOFactory.CocheDAO.GetList(new[] { Empresa },
                                                                                  new[] { Linea },
                                                                                  new[] { -1 }, // TIPO VEHICULO
                                                                                  new[] { -1 }, // TRANSPORTISTA
                                                                                  new[] { Departamento },
                                                                                  new[] { cc.Id },
                                                                                  new[] { subcc.Id })
                                                      select(subcc.Objetivo * vehiculos.Count() * Dias)).Sum();

                var entregados = DAOFactory.EntregaDistribucionDAO.GetList(new[] { Empresa },
                                                                           new[] { Linea },
                                                                           new[] { -1 }, // TRANSPORTISTAS
                                                                           new[] { Departamento },
                                                                           new[] { cc.Id },
                                                                           new[] { -1 }, // SUBCC
                                                                           new[] { -1 }, // VEHICULOS
                                                                           new[] { -1 }, // VIAJES
                                                                           new[] { (int)EntregaDistribucion.Estados.Completado },
                                                                           Desde.ToDataBaseDateTime(),
                                                                           Hasta.ToDataBaseDateTime()).Count;
                var ccRegister = new List <string>
                {
                    cc.Id.ToString("#0"),
                    cc.Descripcion,
                    cantSubCentros.ToString("#0"),
                    objetivoTotal.ToString("#0"),
                    entregados.ToString("#0"),
                    objetivoTotal > 0 ? ((double)entregados / (double)objetivoTotal * 100.0).ToString("#0.00") : "0,00"
                };
                ccDataSource.Add(ccRegister);
            }

            gridCentrosDeCostos.Columns[0].HeaderText = CultureManager.GetEntity("PARENTI37");
            gridCentrosDeCostos.Columns[1].HeaderText = CultureManager.GetMenu("SUBCENTROS_COSTOS");
            gridCentrosDeCostos.Columns[2].HeaderText = CultureManager.GetLabel("OBJETIVO");
            gridCentrosDeCostos.Columns[3].HeaderText = CultureManager.GetLabel("REALIZADO");
            gridCentrosDeCostos.Columns[4].HeaderText = "%";
            gridCentrosDeCostos.DataSource            = ccDataSource;
            gridCentrosDeCostos.DataBind();
            gridCentrosDeCostos.SelectedIndex = -1;
            pnlCc.Visible        = true;
            pnlSubcc.Visible     = false;
            pnlVehiculos.Visible = false;
        }
Exemple #2
0
        protected void LblSubCentroDeCostoOnClick(object sender, EventArgs e)
        {
            var lbl = sender as LinkButton;

            if (lbl == null)
            {
                return;
            }
            int idScc;

            if (!int.TryParse(lbl.Attributes["IdSCC"], out idScc) || idScc <= 0)
            {
                return;
            }
            var scc = DAOFactory.SubCentroDeCostosDAO.FindById(idScc);

            if (scc == null)
            {
                return;
            }

            var vDataSource = new List <List <string> >();
            var vehiculos   = DAOFactory.CocheDAO.GetList(new[] { Empresa },
                                                          new[] { Linea },
                                                          new[] { -1 }, // TIPO VEHICULO
                                                          new[] { -1 }, // TRANSPORTISTA
                                                          new[] { Departamento },
                                                          new[] { scc.CentroDeCostos.Id },
                                                          new[] { idScc });

            foreach (var veh in vehiculos)
            {
                var objetivoTotal = scc.Objetivo * Dias;
                var entregados    = DAOFactory.EntregaDistribucionDAO.GetList(new[] { Empresa },
                                                                              new[] { Linea },
                                                                              new[] { -1 }, // TRANSPORTISTAS
                                                                              new[] { Departamento },
                                                                              new[] { scc.CentroDeCostos.Id },
                                                                              new[] { scc.Id },
                                                                              new[] { veh.Id },
                                                                              new[] { -1 }, // VIAJES
                                                                              new[] { (int)EntregaDistribucion.Estados.Completado },
                                                                              Desde.ToDataBaseDateTime(),
                                                                              Hasta.ToDataBaseDateTime()).Count;
                var diasHistorico       = GetDiasDeSemana(DateTime.UtcNow.AddDays(-30), DateTime.UtcNow);
                var objetivoHistorico   = scc.Objetivo * diasHistorico;
                var entregadosHistorico = DAOFactory.EntregaDistribucionDAO.GetList(new[] { Empresa },
                                                                                    new[] { Linea },
                                                                                    new[] { -1 }, // TRANSPORTISTAS
                                                                                    new[] { Departamento },
                                                                                    new[] { scc.CentroDeCostos.Id },
                                                                                    new[] { scc.Id },
                                                                                    new[] { veh.Id },
                                                                                    new[] { -1 }, // VIAJES
                                                                                    new[] { (int)EntregaDistribucion.Estados.Completado },
                                                                                    DateTime.UtcNow.AddDays(-30).ToDataBaseDateTime(),
                                                                                    DateTime.UtcNow.ToDataBaseDateTime()).Count;

                var vRegister = new List <string>
                {
                    veh.Interno,
                    objetivoTotal.ToString("#0"),
                    entregados.ToString("#0"),
                    objetivoTotal > 0 ? ((double)entregados / (double)objetivoTotal * 100.0).ToString("#0.00") : "0,00",
                    objetivoHistorico > 0 ? ((double)entregadosHistorico / (double)objetivoHistorico * 100.0).ToString("#0.00") : "0,00"
                };
                vDataSource.Add(vRegister);
            }

            gridVehiculos.Columns[0].HeaderText = CultureManager.GetEntity("PARENTI03");
            gridVehiculos.Columns[1].HeaderText = CultureManager.GetLabel("OBJETIVO");
            gridVehiculos.Columns[2].HeaderText = CultureManager.GetLabel("REALIZADO");
            gridVehiculos.Columns[3].HeaderText = "%";
            gridVehiculos.Columns[4].HeaderText = "% " + CultureManager.GetLabel("HISTORICO");
            gridVehiculos.DataSource            = vDataSource;
            gridVehiculos.DataBind();
            gridVehiculos.SelectedIndex = -1;
            pnlVehiculos.Visible        = true;
        }