public void DocVenta_Top5Producto(int idEmpresa, int codigoUsuario, DateTime fechaInicio, DateTime fechaFinal, ref List <VendedorTop5BE> lstTop5Venta, ref List <VendedorTop5BE> lstTop5Renta) { DocVentaBL objDocVentaBL = new DocVentaBL(); List <gsDocVenta_ReporteVenta_ProductoTotalResult> lstProductos, lstVentActual, lstRentActual; List <VendedorTop5BE> lstVenta = new List <VendedorTop5BE>(); List <VendedorTop5BE> lstRenta = new List <VendedorTop5BE>(); int cont = 0; try { lstProductos = objDocVentaBL.DocVenta_ReporteVenta_ProductoTotal(idEmpresa, codigoUsuario, null, fechaInicio, fechaFinal); if (idEmpresa == 1) { lstProductos.RemoveAll(x => string.IsNullOrEmpty(x.Descripcion) || x.Kardex == 4104 || x.Kardex == 4105 || x.Kardex == 4106 || x.Kardex == 4107); } if (idEmpresa == 2) { lstProductos.RemoveAll(x => string.IsNullOrEmpty(x.Descripcion) || x.Kardex == 1511 || x.Kardex == 1512 || x.Kardex == 1513 || x.Kardex == 1514); } lstVentActual = lstProductos.FindAll(x => x.Mes == fechaFinal.Month).OrderByDescending(x => x.ValorVenta).Take(5).ToList(); lstRentActual = lstProductos.FindAll(x => x.Mes == fechaFinal.Month).OrderByDescending(x => x.Rentabiliad).Take(5).ToList(); foreach (gsDocVenta_ReporteVenta_ProductoTotalResult producto in lstVentActual) { VendedorTop5BE top5 = new VendedorTop5BE(); if (producto.Descripcion.Length >= 30) { top5.Vendedor = producto.Descripcion.Substring(0, 30); } else { top5.Vendedor = producto.Descripcion; } top5.Valorventa = Math.Round((decimal)producto.ValorVenta / 1000, 0); top5.Ranking = cont + 1; int rankAnt = lstProductos.FindAll(x => x.Mes == fechaInicio.Month).FindIndex(x => x.Kardex == producto.Kardex) + 1; if (rankAnt > top5.Ranking) { top5.Updown = 1; } else { if (rankAnt == top5.Ranking) { top5.Updown = 0; } else { top5.Updown = -1; } } cont++; lstVenta.Add(top5); } lstTop5Venta = lstVenta; lstProductos = lstProductos.OrderByDescending(x => (x.Año * 100 + x.Mes) * 1000 + x.Rentabiliad).ToList(); cont = 0; foreach (gsDocVenta_ReporteVenta_ProductoTotalResult producto in lstRentActual) { VendedorTop5BE top5 = new VendedorTop5BE(); if (producto.Descripcion.Length >= 30) { top5.Vendedor = producto.Descripcion.Substring(0, 30); } else { top5.Vendedor = producto.Descripcion; } top5.Rentabilidad = (decimal)producto.Rentabiliad; top5.Ranking = cont + 1; int rankAnt = lstProductos.FindAll(x => x.Mes == fechaInicio.Month).FindIndex(x => x.Kardex == producto.Kardex) + 1; if (rankAnt > top5.Ranking) { top5.Updown = 1; } else { if (rankAnt == top5.Ranking) { top5.Updown = 0; } else { top5.Updown = -1; } } cont++; lstRenta.Add(top5); } lstTop5Renta = lstRenta; } catch (Exception ex) { throw ex; } }
public void DocVenta_Top5Vendedor(int idEmpresa, int codigoUsuario, DateTime fechaInicio, DateTime fechaFinal, ref List <VendedorTop5BE> lstTop5Venta, ref List <VendedorTop5BE> lstTop5Renta) { DocVentaBL objDocVentaBL = new DocVentaBL(); List <gsDocVenta_ReporteVenta_VendedorResult> lstVendedores, lstVendActual, lstRentActual; List <VendedorTop5BE> lstVenta = new List <VendedorTop5BE>(); List <VendedorTop5BE> lstRenta = new List <VendedorTop5BE>(); int cont = 0; try { lstVendedores = objDocVentaBL.DocVenta_ReporteVenta_Vendedor(idEmpresa, codigoUsuario, null, fechaInicio, fechaFinal); lstVendedores.RemoveAll(x => x.ID_Vendedor == "11111111111" || x.ID_Vendedor == "22222222222" || x.ID_Vendedor == "33333333"); lstVendActual = lstVendedores.FindAll(x => x.Mes == fechaFinal.Month).OrderByDescending(x => x.ValorVenta).Take(5).ToList(); lstRentActual = lstVendedores.FindAll(x => x.Mes == fechaFinal.Month).OrderByDescending(x => x.Rentabilidad).Take(5).ToList(); foreach (gsDocVenta_ReporteVenta_VendedorResult vendedor in lstVendActual) { VendedorTop5BE top5 = new VendedorTop5BE(); if (vendedor.Vendedor.Length >= 30) { top5.Vendedor = vendedor.Vendedor.Substring(0, 30); } else { top5.Vendedor = vendedor.Vendedor; } top5.Valorventa = Convert.ToDecimal(Math.Round(Convert.ToDouble(vendedor.ValorVenta) / 1000.0, 0)); top5.Ranking = cont + 1; int rankAnt = lstVendedores.FindAll(x => x.Mes == fechaInicio.Month).FindIndex(x => x.ID_Vendedor == vendedor.ID_Vendedor) + 1; if (rankAnt > top5.Ranking) { top5.Updown = 1; } else { if (rankAnt == top5.Ranking) { top5.Updown = 0; } else { top5.Updown = -1; } } cont++; lstVenta.Add(top5); } lstTop5Venta = lstVenta; lstVendedores = lstVendedores.OrderByDescending(x => (x.Año * 100 + x.Mes) * 1000 + x.Rentabilidad).ToList(); cont = 0; foreach (gsDocVenta_ReporteVenta_VendedorResult vendedor in lstRentActual) { VendedorTop5BE top5 = new VendedorTop5BE(); if (vendedor.Vendedor.Length >= 30) { top5.Vendedor = vendedor.Vendedor.Substring(0, 30); } else { top5.Vendedor = vendedor.Vendedor; } top5.Rentabilidad = (decimal)vendedor.Rentabilidad; top5.Ranking = cont + 1; int rankAnt = lstVendedores.FindAll(x => x.Mes == fechaInicio.Month).FindIndex(x => x.ID_Vendedor == vendedor.ID_Vendedor) + 1; if (rankAnt > top5.Ranking) { top5.Updown = 1; } else { if (rankAnt == top5.Ranking) { top5.Updown = 0; } else { top5.Updown = -1; } } cont++; lstRenta.Add(top5); } lstTop5Renta = lstRenta; } catch (Exception ex) { throw ex; } }
public void DocVenta_Top5Cliente(int idEmpresa, int codigoUsuario, DateTime fechaInicio, DateTime fechaFinal, ref List <VendedorTop5BE> lstTop5Venta, ref List <VendedorTop5BE> lstTop5Renta) { DocVentaBL objDocVentaBL = new DocVentaBL(); List <gsDocVenta_ReporteVenta_ClienteTotalResult> lstClientes, lstVentActual, lstRentActual; List <VendedorTop5BE> lstVenta = new List <VendedorTop5BE>(); List <VendedorTop5BE> lstRenta = new List <VendedorTop5BE>(); int cont = 0; try { lstClientes = objDocVentaBL.DocVenta_ReporteVenta_ClienteTotal(idEmpresa, codigoUsuario, null, fechaInicio, fechaFinal); lstClientes.RemoveAll(x => x.ID_Cliente == "20191503482" || x.ID_Cliente == "20509089923"); lstClientes.RemoveAll(x => string.IsNullOrEmpty(x.Cliente)); lstVentActual = lstClientes.FindAll(x => x.Mes == fechaFinal.Month).OrderByDescending(x => x.ValorVenta).Take(5).ToList(); lstRentActual = lstClientes.FindAll(x => x.Mes == fechaFinal.Month).OrderByDescending(x => x.Rentabilidad).Take(5).ToList(); foreach (gsDocVenta_ReporteVenta_ClienteTotalResult cliente in lstVentActual) { VendedorTop5BE top5 = new VendedorTop5BE(); if (cliente.Cliente.Length >= 30) { top5.Vendedor = cliente.Cliente.Substring(0, 30); } else { top5.Vendedor = cliente.Cliente; } top5.Valorventa = Math.Round((decimal)cliente.ValorVenta / 1000, 0); top5.Ranking = cont + 1; int rankAnt = lstClientes.FindAll(x => x.Mes == fechaInicio.Month).FindIndex(x => x.ID_Cliente == cliente.ID_Cliente) + 1; if (rankAnt > top5.Ranking) { top5.Updown = 1; } else { if (rankAnt == top5.Ranking) { top5.Updown = 0; } else { top5.Updown = -1; } } cont++; lstVenta.Add(top5); } lstTop5Venta = lstVenta; lstClientes = lstClientes.OrderByDescending(x => (x.Año * 100 + x.Mes) * 1000 + x.Rentabilidad).ToList(); cont = 0; foreach (gsDocVenta_ReporteVenta_ClienteTotalResult cliente in lstRentActual) { VendedorTop5BE top5 = new VendedorTop5BE(); if (cliente.Cliente.Length >= 30) { top5.Vendedor = cliente.Cliente.Substring(0, 30); } else { top5.Vendedor = cliente.Cliente; } top5.Rentabilidad = (decimal)cliente.Rentabilidad; top5.Ranking = cont + 1; int rankAnt = lstClientes.FindAll(x => x.Mes == fechaInicio.Month).FindIndex(x => x.ID_Cliente == cliente.ID_Cliente) + 1; if (rankAnt > top5.Ranking) { top5.Updown = 1; } else { if (rankAnt == top5.Ranking) { top5.Updown = 0; } else { top5.Updown = -1; } } cont++; lstRenta.Add(top5); } lstTop5Renta = lstRenta; } catch (Exception ex) { throw ex; } }