diff --git a/Acumuladores/RepIndicadorDiario.aspx b/Acumuladores/RepIndicadorDiario.aspx new file mode 100644 index 000000000..d8060715c --- /dev/null +++ b/Acumuladores/RepIndicadorDiario.aspx @@ -0,0 +1,396 @@ +<%@ Page Title="Reporte de Compras Clasificación" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="RepIndicadorDiario.aspx.vb" Inherits="ACumuladores_RepIndicadorDiario" %> + +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %> + + +
  • + Generar PDF +
  • +
  • + + Exportar Excel + +
  • + + +
    + + Reporte Indicador Diario + + + + + + + + + + +
    +
    +
    + + +
    +
    +
    + + + + + +
    + Fecha Inicio: +
    +
    +
    + + + + +
    + + + + + + +
    +
    + Fecha Fin: +
    +
    +
    + + + + +
    + + + + + + +
    + + SubProyecto: +
    + <%-- + + --%> + +
    + + +
    +
    +
    + + + +
    +
    +
    +
    + + + + + + + Concepto + + + + + + + + Acumulado + + + + + + + + Importe Acumulado + + + + + + + + Venta Diaria + + + + + + + + Importe Al Día + + + + + + + + + Cantidad Total + + + + + + + + + Total + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + diff --git a/Acumuladores/RepIndicadorDiario.aspx.vb b/Acumuladores/RepIndicadorDiario.aspx.vb new file mode 100644 index 000000000..b890c1481 --- /dev/null +++ b/Acumuladores/RepIndicadorDiario.aspx.vb @@ -0,0 +1,371 @@ +Option Explicit On +Option Strict On + +Imports Extensiones +Imports Microsoft.Reporting.WebForms +Imports System.Data + +Partial Class ACumuladores_RepIndicadorDiario + Inherits ClsPaginas + +#Region " PROPIEDADES " + Private Property DtDatos As DataTable + Get + DtDatos = DirectCast(ViewState("DtDatos"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtDatos") = value + End Set + End Property + + Private Property NumeroRemesa As String + Get + NumeroRemesa = ViewState("NumeroRemesa").ToString + End Get + Set(value As String) + ViewState("NumeroRemesa") = value + End Set + End Property + + Private Property TCEspecifico As Double + Get + If ViewState("TCEspecifico") Is Nothing Then + Return -1 + Else + Return DirectCast(ViewState("TCEspecifico"), Double) + End If + End Get + Set(value As Double) + ViewState("TCEspecifico") = value + End Set + End Property + Private Property DtColor As DataTable + Get + Return DirectCast(ViewState("DtColor"), DataTable) + End Get + Set(value As DataTable) + ViewState("DtColor") = value + End Set + End Property + Private Property Agrupador As String + Get + Return ViewState("Agrupador").ToString + End Get + + Set(value As String) + ViewState("Agrupador") = value + End Set + End Property + Private Property CveMoneda As Integer + Get + CveMoneda = ViewState("CveMoneda").ToString.ToEntero + End Get + Set(value As Integer) + ViewState("CveMoneda") = value + End Set + End Property + +#End Region + + Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load + If Not IsPostBack Then + + txtFechaI.Text = Now.AddMonths(-1).ToString("dd/MM/yyyy") + txtFechaF.Text = Now.ToString("dd/MM/yyyy") + + CargaCombos() + + CargaDatos() + End If + End Sub + +#Region "CARGAS" + + + + + Private Sub CargaCombos() + + DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa) + DdlSubProyecto.DataBind() + DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1")) + DdlSubProyecto.SelectedValuesIfExist("-1") + + End Sub + + + + Private Sub CargaDatos() + + Dim ObjAcum As New ClsAcumuladores() + + Dim FechaI, FechaF As Date + FechaI = txtFechaI.Text.ToDate + FechaF = txtFechaF.Text.ToDate + + If RblTipoCambio.SelectedValue.ToEntero = 3 And TxtEspecifico.Text <> "" Then + TCEspecifico = TxtEspecifico.Text.ToDouble + Else + TCEspecifico = -1 + End If + + If ObjAcum.GetRepInicadorDiario(FechaI, FechaF, DdlSubProyecto.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then + GvDatos.DataSource = ObjAcum.DtResultados + DtDatos = ObjAcum.DtResultados + Else + GvDatos.DataSource = Nothing + End If + + ObjAcum.Dispose() + GvDatos.DataBind() + + + + + + End Sub + +#End Region + +#Region "SELECTED INDEX CHANGE" + + + + Private Sub RblTipoCambio_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RblTipoCambio.SelectedIndexChanged + If RblTipoCambio.SelectedValue.ToEntero = 3 Then + Dim TipoCambio As Double + LiEspecifico.Visible = True + TipoCambio = GlobalTipoCambio(Now) + TxtEspecifico.Text = TipoCambio.ToString + Else + LiEspecifico.Visible = False + End If + UpBodyTipoCambio.Update() + End Sub + +#End Region + +#Region "CONSULTAR" + + Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click + CargaDatos() + UPDatos.Update() + End Sub + +#End Region + +#Region "GRIDVIEW" + + Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound + + If e.Row.RowType = DataControlRowType.DataRow Then + + If e.Row.DataKey("Ordernador2").ToEntero = 100 Or e.Row.DataKey("Seccion").ToEntero = 3 And (e.Row.DataKey("TipoCategoria").ToEntero = 6 Or e.Row.DataKey("TipoCategoria").ToEntero = 7) Then + e.Row.Font.Bold = True + + End If + + + End If + End Sub + +#End Region + +#Region " IMPRIMIR " + + Protected Sub LnkExportar_Click(sender As Object, e As EventArgs) Handles LnkExportar.Click + 'GvDatos.ExportToExcel("ReporteComprasClasificacion" & Now.ToShortDateString) + GenerarPDF("EXCEL") + End Sub + + Protected Sub LnkPdf_Click(sender As Object, e As EventArgs) + GenerarPDF("PDF") + End Sub + Private Sub GenerarPDF(Opcion As String) + Dim FechaI = If(txtFechaI.Text = "" Or txtFechaI.Text = "__/__/____", "-1", txtFechaI.Text) + Dim FechaF = If(txtFechaF.Text = "" Or txtFechaF.Text = "__/__/____", "-1", txtFechaF.Text) + + + + Dim FechaIn As String = $" Fecha Inicio: {txtFechaI.Text}" + Dim FechaFn As String = $" Fecha Fin: {txtFechaF.Text}" + If txtFechaI.Text = "" Then FechaIn = "" + If txtFechaF.Text = "" Then FechaFn = "" + + + Dim SubProyecto = If(DdlSubProyecto.GetSelectedText = "", "", $" SubProyecto: {DdlSubProyecto.GetSelectedText}") + + + Dim FechaIF, FechaFF As String + FechaIF = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1") + FechaFF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1") + + + + If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 Then + For Each Dr As DataRow In DtDatos.Rows + Dr("Fecha") = Dr("Fecha").ToString.ToDate.ToShortDateString + Next + 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) + Dim params As New List(Of ReportParameter) + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("FechaInicio", FechaI)) + params.Add(New ReportParameter("FechaFin", FechaF)) + params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa)) + params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre)) + params.Add(New ReportParameter("FechaImpresion", Now.ToString)) + params.Add(New ReportParameter("AgrupadoPor", $"Filtros Por: {FechaIn} {FechaFn} {SubProyecto} ")) + If Imagen.Exists Then + params.Add(New ReportParameter("LogoPath", logouri)) + Else + params.Add(New ReportParameter("LogoPath", "")) + End If + ImprimirPDF("Empresas/Grales/Formatos/RepIndicadorDiario.rdlc", DtDatos, params, $"RepIndicadorDiario_{Now.ToString("yyyyMMddhhmmss")}", Opcion) + Else + Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia) + End If + + End Sub +#End Region + +#Region "GRAFICA" + + Protected Sub LnkVerGrafica_Click(sender As Object, e As EventArgs) + If Not DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 Then + Alert("No hay datos disponibles", TipoMensaje.MsgAdvertencia) + Exit Sub + End If + + LblTituloGrafica.Text = $"Agrupado por: {Agrupador}" + RegistraScript("$('#DivModalGrafica').modal('show')") + CambioGrafica() + End Sub + Private Sub CreaDataTableColor() + DtColor = New DataTable + DtColor.Columns.Add("Color") + Dim RowColor As DataRow = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#FF0F00" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#FF6600" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#FF9E01" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#FCD202" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#F8FF01" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#B0DE09" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#04D215" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#0D8ECF" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#0D52D1" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#2A0CD0" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#8A0CCF" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#CD0D74" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#754DEB" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#DDDDDD" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#999999" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#333333" + DtColor.Rows.Add(RowColor) + RowColor = Nothing + RowColor = DtColor.NewRow() + RowColor("Color") = "#000000" + DtColor.Rows.Add(RowColor) + End Sub + + Private Sub CambioGrafica() + Dim Dt As New DataTable() + Dt.Columns.Add("Texto") + Dt.Columns.Add("Valor") + Dt.Columns.Add("Color") + Dt.Columns.Add("Moneda") + Dim RowColorIndex As Integer = 0 + For Each Dr As DataRow In DtDatos.Rows + If Not Dr("CveCompra").ToString.ToEntero > 0 Then + Dim Row As DataRow = Nothing + Row = Dt.NewRow() + Row("Texto") = $"{Dr("GPO").ToString} {GlobalDTMonedas().FiltraParametros($"CveMoneda = {CveMoneda}").Rows(0)("Abreviatura").ToString}" + Select Case DdlVer.SelectedValue.ToEntero + Case 1 + Row("Valor") = Dr("Total").ToString.FormatoNumero + Case 2 + Row("Valor") = Dr("SubTotal").ToString.FormatoNumero + Case 3 + Row("Valor") = Dr("IVA").ToString.FormatoNumero + End Select + Row("Color") = DtColor.Rows(RowColorIndex)("Color").ToString + Row("Moneda") = GlobalDTMonedas().FiltraParametros($"CveMoneda = {CveMoneda}").Rows(0)("Moneda").ToString + Dt.Rows.Add(Row) + RowColorIndex += 1 + If RowColorIndex = 17 Then + RowColorIndex = 0 + End If + End If + Next + + Dim query = From s In Dt.AsEnumerable() Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(query) + Select Case DdlGrafica.SelectedValue.ToEntero + Case 1 + RegistraScript($"CargaGraficaBarras({json})", "22") + Case 2 + RegistraScript($"CargaGraficaPastel({json})", "22") + End Select + UPModalProd.Update() + End Sub + Protected Sub DdlGrafica_SelectedIndexChanged(sender As Object, e As EventArgs) + CambioGrafica() + End Sub + + Protected Sub DdlVer_SelectedIndexChanged(sender As Object, e As EventArgs) + CambioGrafica() + End Sub + +#End Region + + + +End Class + diff --git a/App_Code/ClsAcumuladores.vb b/App_Code/ClsAcumuladores.vb index 1980df4a1..ee525f979 100644 --- a/App_Code/ClsAcumuladores.vb +++ b/App_Code/ClsAcumuladores.vb @@ -898,12 +898,12 @@ Public Class ClsAcumuladores Dim Retorno As Boolean = False - SqlDataAdapter("PA_Acum_RepInicadorDiarioGet") + SqlDataAdapter("PA_Acum_RepIndicadorDiarioGet") With SqlAdapter.SelectCommand.Parameters .Add("@FechaInicio", SqlDbType.Date).Value = FechaInicio .Add("@FechaFin", SqlDbType.Date).Value = FechaFin - .Add("@CveSubProeycto", SqlDbType.Int).Value = CveSubProeycto + .Add("@CveSubProyecto", SqlDbType.Int).Value = CveSubProeycto .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa End With