private void ReporteVenta_Listar()
        {
            ReporteVentaWCFClient objReporteVentaWCF = new ReporteVentaWCFClient();
            List <gsDocVenta_ReporteVenta_VendedorResult> lst;

            try
            {
                DateTime firstDayOfMonth = new DateTime(rmyReporte.SelectedDate.Value.Year, rmyReporte.SelectedDate.Value.Month, 1);
                DateTime lastDayOfMonth  = firstDayOfMonth.AddMonths(1).AddDays(-1);

                lst = objReporteVentaWCF.DocVenta_ReporteVenta_Vendedor(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                        ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, null, firstDayOfMonth, lastDayOfMonth).ToList();


                grdDocVenta.DataSource = lst;
                grdDocVenta.DataBind();



                lblTitulo.Text = "Reporte de ventas (" + rmyReporte.SelectedDate.Value.Year.ToString() + "-" + rmyReporte.SelectedDate.Value.Month.ToString() + ")";

                ViewState["lstDocVenta"] = JsonHelper.JsonSerializer(lst);
                ViewState["fechaInicio"] = firstDayOfMonth.ToString("dd/MM/yyyy");
                ViewState["fechaFinal"]  = lastDayOfMonth.ToString("dd/MM/yyyy");
                ViewState["lstReporte"]  = JsonHelper.JsonSerializer(lst);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        private void Vendedor_Listar()
        {
            ReporteVentaWCFClient objReporteVentaWCF            = new ReporteVentaWCFClient();
            List <gsDocVenta_ReporteVenta_VendedorResult> Lista = new List <gsDocVenta_ReporteVenta_VendedorResult>();

            try {
                DateTime fechaInicio = new DateTime(dpFecInicio.SelectedDate.Value.Year, dpFecInicio.SelectedDate.Value.Month, 1);
                DateTime fechaFinal  = dpFecFinal.SelectedDate.Value.AddMonths(1);
                fechaFinal = (new DateTime(fechaFinal.Year, fechaFinal.Month, 1)).AddDays(-1);
                Lista      = objReporteVentaWCF.DocVenta_ReporteVenta_Vendedor(((Usuario_LoginResult)Session["Usuario"]).idEmpresa, ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, null, fechaInicio, fechaFinal).ToList();

                ViewState["ListaMenus"] = JsonHelper.JsonSerializer(Lista);


                grdVendedor.DataSource = Lista;
                grdVendedor.DataBind();

                lblReporte.Value = "1";
            }
            catch (Exception ex) {
                throw ex;
            }
        }
예제 #3
0
        private void ReporteVenta_Cliente(string ID_Vendedor, DateTime fechaInico, DateTime fechaFinal)
        {
            ReporteVentaWCFClient objReporteVentaWCF = new ReporteVentaWCFClient();

            rhcParticipacion.PlotArea.Series[0].Items.Clear();
            try
            {
                #region Venta de productos
                List <gsDocVenta_ReporteVenta_ProductoResult> lstProductos = objReporteVentaWCF.DocVenta_ReporteVenta_Producto(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                                                                               ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, ID_Vendedor, fechaInico, fechaFinal).ToList();

                grdProducto.DataSource = lstProductos;
                grdProducto.DataBind();

                ViewState["lstProductos"] = JsonHelper.JsonSerializer(lstProductos);
                #endregion

                #region Venta al 80% y 20%
                List <gsDocVenta_ReporteVenta_ClienteResult> lst = objReporteVentaWCF.DocVenta_ReporteVenta_Cliente(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                                                                    ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, ID_Vendedor, fechaInico, fechaFinal, null).ToList().OrderByDescending(x => x.ValorVenta).ToList();

                decimal sum = (decimal)lst.Sum(i => i.ValorVenta);
                //decimal sumPlanif = (decimal)lst.Sum(i => i.ValorPlanificado);
                decimal acumulado = 0;
                bool    paso80    = false;

                foreach (var cliente in lst)
                {
                    SeriesItem item = new SeriesItem();
                    if (sum > 0)
                    {
                        if (((int)((cliente.ValorVenta / sum) * 100)) > 0)
                        {
                            item.YValue = ((int)((cliente.ValorVenta / sum) * 100));
                            item.Name   = string.Format("{0}<br/>Valor Venta:${1}K<br/>Presupuesto:${2}K<br/>Avance:{3}%<br/>Participación:{4}%",
                                                        cliente.ID_Cliente + " - " + cliente.Cliente.Replace("'", string.Empty),
                                                        Math.Round((decimal)cliente.ValorVenta / 1000, 2),
                                                        Math.Round((decimal)cliente.ValorPlanificado / 1000, 2),
                                                        cliente.Avance,
                                                        item.YValue);
                            rhcParticipacion.PlotArea.Series[0].Items.Add(item);
                        }
                    }

                    if (cliente.ValorVenta > 0)
                    {
                        acumulado = acumulado + (decimal)cliente.ValorVenta;
                        if (!paso80)
                        {
                            if (cliente.Cliente.Length > 30)
                            {
                                rhcCliente80.PlotArea.XAxis.Items.Add(cliente.Cliente.Substring(0, 30).Replace("'", string.Empty));
                            }
                            else
                            {
                                rhcCliente80.PlotArea.XAxis.Items.Add(cliente.Cliente.Replace("'", string.Empty));
                            }

                            item        = new SeriesItem();
                            item.Name   = cliente.Cliente.Replace("'", string.Empty);
                            item.YValue = Math.Round((decimal)cliente.ValorVenta / 1000, 2);
                            this.rhcCliente80.PlotArea.Series[0].Items.Add(item);

                            item        = new SeriesItem();
                            item.Name   = cliente.Cliente.Replace("'", string.Empty);
                            item.YValue = Math.Round((decimal)cliente.ValorPlanificado / 1000, 2);
                            this.rhcCliente80.PlotArea.Series[1].Items.Add(item);
                        }
                        else
                        {
                            if (cliente.Cliente.Length > 30)
                            {
                                rhcCliente20.PlotArea.XAxis.Items.Add(cliente.Cliente.Substring(0, 30).Replace("'", string.Empty));
                            }
                            else
                            {
                                rhcCliente20.PlotArea.XAxis.Items.Add(cliente.Cliente.Replace("'", string.Empty));
                            }

                            item        = new SeriesItem();
                            item.Name   = cliente.Cliente.Replace("'", string.Empty);
                            item.YValue = Math.Round((decimal)cliente.ValorVenta / 1000, 2);
                            this.rhcCliente20.PlotArea.Series[0].Items.Add(item);

                            item        = new SeriesItem();
                            item.Name   = cliente.Cliente.Replace("'", string.Empty);
                            item.YValue = Math.Round((decimal)cliente.ValorPlanificado / 1000, 2);
                            this.rhcCliente20.PlotArea.Series[1].Items.Add(item);
                        }

                        if (acumulado / sum * 100 >= 80)
                        {
                            paso80 = true;
                        }
                    }
                }
                #endregion

                #region Datos principales
                //Datos principales de la venta
                gsDocVenta_ReporteVenta_VendedorResult rv = objReporteVentaWCF.DocVenta_ReporteVenta_Vendedor(((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).idEmpresa,
                                                                                                              ((Usuario_LoginResult)HttpContext.Current.Session["Usuario"]).codigoUsuario, ID_Vendedor, fechaInico, fechaFinal).ToList().Single();
                rrgAvance.Pointer.Value = rv.Avance;
                lblPronostico.Text      = string.Format("${0}", Math.Round((decimal)rv.ValorPlanificado, 0).ToString("#,#", CultureInfo.InvariantCulture));
                lblValorVenta.Text      = string.Format("${0}", Math.Round((decimal)rv.ValorVenta, 0).ToString("#,#", CultureInfo.InvariantCulture));
                lblDiferencia.Text      = string.Format("${0}", Math.Round((decimal)rv.Diferencia, 0).ToString("#,#", CultureInfo.InvariantCulture));
                lblAvance.Text          = "Avance: " + Math.Round((decimal)rv.Avance, 0).ToString() + "%";
                lblCantTotal.Text       = lst.Count.ToString();
                lblCantVenta.Text       = lst.FindAll(x => x.ValorVenta > 0).Count.ToString();
                lblCantNoVenta.Text     = lst.FindAll(x => x.ValorVenta <= 0).Count.ToString();
                #endregion

                #region Cliente sin venta
                grdCliente.DataSource = lst.FindAll(x => x.ValorVenta <= 0).OrderByDescending(x => x.ValorPlanificado);
                grdCliente.DataBind();
                #endregion

                #region Venta diaria
                List <gsDocVenta_ReporteVenta_FechaResult> lstFecha = objReporteVentaWCF.DocVenta_ReporteVenta_Fecha(((Usuario_LoginResult)Session["Usuario"]).idEmpresa,
                                                                                                                     ((Usuario_LoginResult)Session["Usuario"]).codigoUsuario, ID_Vendedor, fechaInico, fechaFinal).ToList();

                acumulado = 0;
                for (DateTime day = fechaInico; DateTime.Compare(day, fechaFinal) <= 0; day = day.AddDays(1))
                {
                    AxisItem xitem = new AxisItem();
                    xitem.LabelText = day.ToString("dd/MM/yyyy");
                    rhcDiario.PlotArea.XAxis.Items.Add(xitem);

                    gsDocVenta_ReporteVenta_FechaResult objVFecha = lstFecha.Find(x => x.Fecha == day);
                    SeriesItem serie1 = new SeriesItem();
                    if (objVFecha != null)
                    {
                        acumulado     = acumulado + (decimal)objVFecha.ValorVenta;
                        serie1.YValue = Math.Round((decimal)objVFecha.ValorVenta / 1000, 2);
                    }
                    else
                    {
                        serie1.YValue = 0;
                    }

                    rhcDiario.PlotArea.Series[0].Items.Add(serie1);
                    SeriesItem serie2 = new SeriesItem();
                    serie2.YValue = Math.Round(acumulado / (decimal)rv.ValorPlanificado * 100, 0);
                    rhcDiario.PlotArea.Series[1].Items.Add(serie2);
                }
                //rhcDiario.PlotArea.Series[1].AxisName = "AdditionalAxis";
                #endregion

                lblTitulo.Text = "Reporte " + fechaInico.Year.ToString() + "-" + fechaInico.Month.ToString() + " de " + rv.Vendedor;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }