diff --git a/App_Code/ClsVentas.vb b/App_Code/ClsVentas.vb index 93fb38a06..46f49aa46 100644 --- a/App_Code/ClsVentas.vb +++ b/App_Code/ClsVentas.vb @@ -4433,13 +4433,14 @@ Public Class ClsVentas Return retorno End Function - Public Function GetRepTopClientesVentas(CveEmpresa As Integer, Mes As Integer, Año As Integer, Optional CveSubProyecto As Integer = -1) As Boolean + Public Function GetRepTopClientesVentas(CveEmpresa As Integer, Mes As Integer, Año As Integer, Optional Top As Integer = 20, Optional CveSubProyecto As Integer = -1) As Boolean Dim retorno As Boolean = False DataAdapter("PA_Vta_Top20ClientesMasVendidos", CommandType.StoredProcedure) With SqlAdapter.SelectCommand.Parameters .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa .Add("@Mes", SqlDbType.Int).Value = Mes .Add("@Año", SqlDbType.Int).Value = Año + .Add("@Top", SqlDbType.Int).Value = Top .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProyecto End With Try diff --git a/CRM/CatEmpresasCRM.aspx b/CRM/CatEmpresasCRM.aspx index ea133cd46..7095cee60 100644 --- a/CRM/CatEmpresasCRM.aspx +++ b/CRM/CatEmpresasCRM.aspx @@ -5,13 +5,13 @@ - Catálogo de Empresas CRM + Catálogo de Prospectos
  • - Agregar Empresa + Agregar Prospecto
  • @@ -48,7 +48,7 @@ " style="display: inline-block; margin-right: -20px; width: 150px;" /> " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> - diff --git a/CRM/PopUpBuscarAcercamiento.aspx b/CRM/PopUpBuscarAcercamiento.aspx index 548741b9f..ec39a8719 100644 --- a/CRM/PopUpBuscarAcercamiento.aspx +++ b/CRM/PopUpBuscarAcercamiento.aspx @@ -28,7 +28,7 @@ - Empresa CRM: + Prospecto: diff --git a/Ventas/RepTopClientesVentas.aspx b/Ventas/RepTopClientesVentas.aspx index f80a488b7..d6e97de4b 100644 --- a/Ventas/RepTopClientesVentas.aspx +++ b/Ventas/RepTopClientesVentas.aspx @@ -5,6 +5,54 @@ @@ -13,6 +61,13 @@
  • PDF
  • + + +
  • + Ver Grafica +
  • +
    +
    Reporte de Top de Ventas por Cliente @@ -53,11 +108,16 @@ - -
    + +
    + + +
    + +
    @@ -67,17 +127,81 @@ - + - - + + +
    + + + + + + + + + + diff --git a/Ventas/RepTopClientesVentas.aspx.vb b/Ventas/RepTopClientesVentas.aspx.vb index aafccc8f1..69bfc29ed 100644 --- a/Ventas/RepTopClientesVentas.aspx.vb +++ b/Ventas/RepTopClientesVentas.aspx.vb @@ -9,6 +9,15 @@ Imports Microsoft.Reporting.WebForms Partial Class Ventas_RepTopClientesVentas Inherits ClsPaginas + Private Property DtClientes As DataTable + Get + Return DirectCast(ViewState("DtClientes"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtClientes") = value + End Set + End Property + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then CargarFiltros() @@ -47,12 +56,16 @@ Partial Class Ventas_RepTopClientesVentas DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa) DdlSubProyecto.DataBind() DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1")) + + TxtTop.Text = "20" End Sub Private Sub CargaDatos() Dim ObjVentas As New ClsVentas - If ObjVentas.GetRepTopClientesVentas(UsuarioActual.CveEmpresa, DdlMes.SelectedValue.ToEntero, DdlAño.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero) Then + If ObjVentas.GetRepTopClientesVentas(UsuarioActual.CveEmpresa, DdlMes.SelectedValue.ToEntero, DdlAño.SelectedValue.ToEntero, TxtTop.Text.ToEntero, + DdlSubProyecto.SelectedValue.ToEntero) Then GvM.DataSource = ObjVentas.DtResultados + DtClientes = ObjVentas.DtResultados End If ObjVentas.Dispose() GvM.DataBind() @@ -62,4 +75,50 @@ Partial Class Ventas_RepTopClientesVentas CargaDatos() UppGrid.Update() End Sub + + Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click + Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", DateTime.Now.ToString)) + + Dim Imagen As New System.IO.FileInfo(String.Format("{0}/Logo.png", UsuarioActual.Empresa.Ruta)) + Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa) + + If Imagen.Exists Then + params.Add(New ReportParameter("pImg", logouri)) + Else + params.Add(New ReportParameter("pImg", "")) + End If + ImprimirPDF("Empresas/Grales/Formatos/TopClientes.rdlc", DtClientes, params, String.Format("ReporteVentas-{0}", Now.ToDateTime.ToShortDateString), Formato:="PDF") + End Sub + + Protected Sub LnkVerGrafica_Click(sender As Object, e As EventArgs) + If Not DtClientes IsNot Nothing AndAlso DtClientes.Rows.Count > 0 Then + Alert("No hay datos disponibles", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + LblTituloGrafica.Text = $"Agrupado por: Clientes" + RegistraScript("$('#DivModalGrafica').modal('show')") + CambioGrafica() + End Sub + + Private Sub CambioGrafica() + Dim Dt As New DataTable() + Dt.Columns.Add("Cliente") + Dt.Columns.Add("Importe") + For Each Dr As DataRow In DtClientes.Rows + Dim Row As DataRow = Nothing + Row = Dt.NewRow() + Row("Cliente") = Dr("NombreComercial").ToString + Row("Importe") = Dr("ImporteAcumulado").ToString.FormatoNumero + Dt.Rows.Add(Row) + Next + + Dim query = From s In Dt.AsEnumerable() Select New With {.Cliente = s("Cliente").ToString(), .Importe = s("Importe").ToString().ToDouble()} + Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(query) + RegistraScript($"CargaGraficaBarras({json})", "22") + UPModalProd.Update() + End Sub End Class