Commit inicial Ventas Productivo
This commit is contained in:
245
Contabilidad/RepEdoResultados2.aspx.vb
Normal file
245
Contabilidad/RepEdoResultados2.aspx.vb
Normal file
@@ -0,0 +1,245 @@
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
Imports System.Data
|
||||
Imports System.Collections.Generic
|
||||
Imports System.Linq
|
||||
Imports System.Web
|
||||
Imports System.Web.UI.WebControls
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class Contabilidad_RepEdoResultados2
|
||||
Inherits ClsPaginas
|
||||
|
||||
#Region " PROPIEDADES "
|
||||
Public Property DtIngresos() As DataTable
|
||||
Get
|
||||
Return CType(ViewState("DtIngresos"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtIngresos") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property DtEgresos() As DataTable
|
||||
Get
|
||||
Return CType(ViewState("DtEgresos"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtEgresos") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Public Property DtDiferencias() As DataTable
|
||||
Get
|
||||
Return CType(ViewState("DtDiferencias"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtDiferencias") = value
|
||||
End Set
|
||||
End Property
|
||||
#End Region
|
||||
|
||||
Private Sub Contabilidad_RepEdoResultados2_Load(sender As Object, e As EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
CargaCombos()
|
||||
txtFechaI.Text = $"01/01/{Now.Year}"
|
||||
txtFechaF.Text = $"31/12/{Now.Year}"
|
||||
CargaDatos()
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCombos()
|
||||
DdlClasificacion.DataSource = GlobalDTClasificaciones(CveEmpresa:=UsuarioActual.CveEmpresa)
|
||||
DdlClasificacion.DataBind()
|
||||
DdlClasificacion.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
|
||||
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
||||
DdlSubProyecto.DataBind()
|
||||
DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
|
||||
DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
|
||||
DdlTipoGasto.DataBind()
|
||||
DdlTipoGasto.Items.Insert(0, New ListItem("Todos", "-1"))
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Dim Conta As New ClsContabilidad
|
||||
Dim FechaInicio As Date = txtFechaI.Text.ToDate
|
||||
Dim FechaFin As Date = txtFechaF.Text.ToDate
|
||||
Dim CveClasificacion As Integer = DdlClasificacion.SelectedValue.ToEntero
|
||||
Dim CveTipoGasto As Integer = DdlTipoGasto.SelectedValue.ToEntero
|
||||
Dim CveSubProyecto As Integer = DdlSubProyecto.SelectedValue.ToEntero
|
||||
Dim Agrupador As Integer = DdlAgrupador.SelectedValue.ToEntero
|
||||
|
||||
Dim ds As Data.DataSet = Conta.GetEdoResultadosMes(FechaInicio, FechaFin, CveTipoGasto, CveClasificacion, CveSubProyecto, Agrupador, UsuarioActual.CveEmpresa, DdlMedida.SelectedValue.ToEntero)
|
||||
|
||||
If ds IsNot Nothing AndAlso ds.Tables.Count = 2 Then
|
||||
Dim dting As Data.DataTable = ds.Tables(0)
|
||||
Dim dtgastos As Data.DataTable = ds.Tables(1)
|
||||
DtIngresos = dting
|
||||
DtEgresos = dtgastos
|
||||
|
||||
GvI.DataSource = dting
|
||||
GvG.DataSource = dtgastos
|
||||
End If
|
||||
|
||||
Conta.Dispose()
|
||||
GvG.DataBind()
|
||||
GvI.DataBind()
|
||||
CargaDiferencias()
|
||||
|
||||
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDiferencias()
|
||||
|
||||
If GvG.Rows.Count > 0 And GvI.Rows.Count > 0 Then
|
||||
|
||||
DtDiferencias = New DataTable
|
||||
DtDiferencias.Columns.Add("Agrupador", GetType(String))
|
||||
DtDiferencias.Columns.Add("Enero", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeEnero", GetType(String))
|
||||
DtDiferencias.Columns.Add("Febrero", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeFebrero", GetType(String))
|
||||
DtDiferencias.Columns.Add("Marzo", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeMarzo", GetType(String))
|
||||
DtDiferencias.Columns.Add("Abril", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeAbril", GetType(String))
|
||||
DtDiferencias.Columns.Add("Mayo", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeMayo", GetType(String))
|
||||
DtDiferencias.Columns.Add("Junio", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeJunio", GetType(String))
|
||||
DtDiferencias.Columns.Add("Julio", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeJulio", GetType(String))
|
||||
DtDiferencias.Columns.Add("Agosto", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeAgosto", GetType(String))
|
||||
DtDiferencias.Columns.Add("Septiembre", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeSeptiembre", GetType(String))
|
||||
DtDiferencias.Columns.Add("Octubre", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeOctubre", GetType(String))
|
||||
DtDiferencias.Columns.Add("Noviembre", GetType(String))
|
||||
DtDiferencias.Columns.Add("PorcentajeNoviembre", GetType(String))
|
||||
DtDiferencias.Columns.Add("Diciembre", GetType(Double))
|
||||
DtDiferencias.Columns.Add("PorcentajeDiciembre", GetType(String))
|
||||
DtDiferencias.Columns.Add("Total", GetType(String))
|
||||
|
||||
Dim DR As DataRow = DtDiferencias.NewRow()
|
||||
DR("Agrupador") = ""
|
||||
|
||||
DR("Enero") = (GvI.Rows()(0).DataKey("Enero").ToDouble - GvG.Rows()(0).DataKey("Enero").ToDouble).FormatoNumero
|
||||
DR("PorcentajeEnero") = ((GvI.Rows()(0).DataKey("Enero").ToDouble - GvG.Rows()(0).DataKey("Enero").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Enero").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Enero").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Febrero") = (GvI.Rows()(0).DataKey("Febrero").ToDouble - GvG.Rows()(0).DataKey("Febrero").ToDouble).FormatoNumero
|
||||
DR("PorcentajeFebrero") = ((GvI.Rows()(0).DataKey("Febrero").ToDouble - GvG.Rows()(0).DataKey("Febrero").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Febrero").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Febrero").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Marzo") = (GvI.Rows()(0).DataKey("Marzo").ToDouble - GvG.Rows()(0).DataKey("Marzo").ToDouble).FormatoNumero
|
||||
DR("PorcentajeMarzo") = ((GvI.Rows()(0).DataKey("Marzo").ToDouble - GvG.Rows()(0).DataKey("Marzo").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Marzo").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Marzo").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Abril") = (GvI.Rows()(0).DataKey("Abril").ToDouble - GvG.Rows()(0).DataKey("Abril").ToDouble).FormatoNumero
|
||||
DR("PorcentajeAbril") = ((GvI.Rows()(0).DataKey("Abril").ToDouble - GvG.Rows()(0).DataKey("Abril").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Abril").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Abril").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Mayo") = (GvI.Rows()(0).DataKey("Mayo").ToDouble - GvG.Rows()(0).DataKey("Mayo").ToDouble).FormatoNumero
|
||||
DR("PorcentajeMayo") = ((GvI.Rows()(0).DataKey("Mayo").ToDouble - GvG.Rows()(0).DataKey("Mayo").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Mayo").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Mayo").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Junio") = (GvI.Rows()(0).DataKey("Junio").ToDouble - GvG.Rows()(0).DataKey("Junio").ToDouble).FormatoNumero
|
||||
DR("PorcentajeJunio") = ((GvI.Rows()(0).DataKey("Junio").ToDouble - GvG.Rows()(0).DataKey("Junio").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Junio").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Junio").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Julio") = (GvI.Rows()(0).DataKey("Julio").ToDouble - GvG.Rows()(0).DataKey("Julio").ToDouble).FormatoNumero
|
||||
DR("PorcentajeJulio") = ((GvI.Rows()(0).DataKey("Julio").ToDouble - GvG.Rows()(0).DataKey("Julio").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Julio").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Julio").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Agosto") = (GvI.Rows()(0).DataKey("Agosto").ToDouble - GvG.Rows()(0).DataKey("Agosto").ToDouble).FormatoNumero
|
||||
DR("PorcentajeAgosto") = ((GvI.Rows()(0).DataKey("Agosto").ToDouble - GvG.Rows()(0).DataKey("Agosto").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Agosto").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Agosto").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Septiembre") = (GvI.Rows()(0).DataKey("Septiembre").ToDouble - GvG.Rows()(0).DataKey("Septiembre").ToDouble).FormatoNumero
|
||||
DR("PorcentajeSeptiembre") = ((GvI.Rows()(0).DataKey("Septiembre").ToDouble - GvG.Rows()(0).DataKey("Septiembre").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Septiembre").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Septiembre").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Octubre") = (GvI.Rows()(0).DataKey("Octubre").ToDouble - GvG.Rows()(0).DataKey("Octubre").ToDouble).FormatoNumero
|
||||
DR("PorcentajeOctubre") = ((GvI.Rows()(0).DataKey("Octubre").ToDouble - GvG.Rows()(0).DataKey("Octubre").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Octubre").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Octubre").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Noviembre") = (GvI.Rows()(0).DataKey("Noviembre").ToDouble - GvG.Rows()(0).DataKey("Noviembre").ToDouble).FormatoNumero
|
||||
DR("PorcentajeNoviembre") = ((GvI.Rows()(0).DataKey("Noviembre").ToDouble - GvG.Rows()(0).DataKey("Noviembre").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Noviembre").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Noviembre").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Diciembre") = (GvI.Rows()(0).DataKey("Diciembre").ToDouble - GvG.Rows()(0).DataKey("Diciembre").ToDouble).FormatoNumero
|
||||
DR("PorcentajeDiciembre") = ((GvI.Rows()(0).DataKey("Diciembre").ToDouble - GvG.Rows()(0).DataKey("Diciembre").ToDouble) * 100 / If(GvI.Rows()(0).DataKey("Diciembre").ToDouble = 0, 1, GvI.Rows()(0).DataKey("Diciembre").ToDouble)).FormatoNumero
|
||||
|
||||
DR("Total") = (GvI.Rows()(0).DataKey("Total").ToDouble - GvG.Rows()(0).DataKey("Total").ToDouble).FormatoNumero
|
||||
|
||||
DtDiferencias.Rows.Add(DR)
|
||||
|
||||
GvDiferencias.DataSource = DtDiferencias
|
||||
GvDiferencias.DataBind()
|
||||
|
||||
TableDiferencias.Visible = True
|
||||
Else
|
||||
TableDiferencias.Visible = False
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
Protected Sub GvI_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.RowIndex = 0 Then
|
||||
e.Row.CssClass = "Totales"
|
||||
e.Row.Cells(0).Text = "Total"
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub GvG_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.RowIndex = 0 Then
|
||||
e.Row.CssClass = "Totales"
|
||||
e.Row.Cells(0).Text = "Total"
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub HLImprimir_Click(sender As Object, e As EventArgs) Handles HLImprimir.Click
|
||||
Dim params As New List(Of ReportParameter)
|
||||
Dim lrds As New List(Of ReportDataSource)
|
||||
Dim StrFiltro As New StringBuilder
|
||||
|
||||
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("LogoPath", logouri))
|
||||
Else
|
||||
params.Add(New ReportParameter("LogoPath", ""))
|
||||
End If
|
||||
|
||||
StrFiltro.AppendFormat("<b>Agrupado por</b>: {0}", DdlAgrupador.SelectedItem.Text)
|
||||
|
||||
If DdlClasificacion.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" <b>Clasificación</b>: {0}", DdlClasificacion.SelectedItem.Text)
|
||||
If txtFechaI.Text <> "" Then StrFiltro.AppendFormat(" <b>Fecha Inicio </b>: {0}", txtFechaI.Text.ToDate.ToShortDateString)
|
||||
If txtFechaF.Text <> "" Then StrFiltro.AppendFormat(" <b>Fecha Fin </b>: {0}", txtFechaF.Text.ToDate.ToShortDateString)
|
||||
|
||||
If DdlTipoGasto.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" <b>TipoGasto</b>: {0}", DdlTipoGasto.SelectedItem.Text)
|
||||
If DdlSubProyecto.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" <b>SubProyecto</b>: {0}", DdlSubProyecto.SelectedItem.Text)
|
||||
If DdlMedida.SelectedValue <> "-1" Then StrFiltro.AppendFormat(" <b>Divisor</b>: {0}", DdlMedida.SelectedItem.Text)
|
||||
|
||||
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
|
||||
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
||||
params.Add(New ReportParameter("FechaImpresion", Now.ToLongDateString))
|
||||
params.Add(New ReportParameter("Filtros", StrFiltro.ToString))
|
||||
|
||||
Dim rds1 As New ReportDataSource With {.Name = "DataSet1", .Value = If(DtIngresos IsNot Nothing, DtIngresos, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte
|
||||
lrds.Add(rds1)
|
||||
|
||||
Dim rds2 As New ReportDataSource With {.Name = "DataSet2", .Value = If(DtEgresos IsNot Nothing, DtEgresos, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte
|
||||
lrds.Add(rds2)
|
||||
|
||||
Dim rds3 As New ReportDataSource With {.Name = "DataSet3", .Value = If(DtDiferencias IsNot Nothing, DtDiferencias, New DataTable)} ' sino esta creado el objeto, lo creamos, para que no truene el reporte
|
||||
lrds.Add(rds3)
|
||||
|
||||
|
||||
ImprimirPDF("Empresas/Grales/Formatos/EdoFinanciero.rdlc", lrds, params, "Estado Financiero")
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user