437 lines
17 KiB
VB.net
437 lines
17 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class AC_RepMovimientosAuxiliaresCatalogo
|
|
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 DtTotales As DataTable
|
|
Get
|
|
DtTotales = DirectCast(ViewState("DtTotales"), DataTable)
|
|
End Get
|
|
|
|
Set(ByVal value As DataTable)
|
|
ViewState("DtTotales") = value
|
|
End Set
|
|
End Property
|
|
Private Property FechaInicio As Date
|
|
Get
|
|
FechaInicio = ViewState("FechaInicio").ToString.ToDate
|
|
End Get
|
|
Set(value As Date)
|
|
ViewState("FechaInicio") = value
|
|
End Set
|
|
End Property
|
|
Private Property FechaFin As Date
|
|
Get
|
|
FechaFin = ViewState("FechaFin").ToString.ToDate
|
|
End Get
|
|
Set(value As Date)
|
|
ViewState("FechaFin") = value
|
|
End Set
|
|
End Property
|
|
Private Property IdCuenta As Integer
|
|
Get
|
|
IdCuenta = ViewState("IdCuenta").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IdCuenta") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property IdSegNeg As Integer
|
|
Get
|
|
If ViewState("IdSegNeg") Is Nothing Then
|
|
ViewState("IdSegNeg") = -1
|
|
End If
|
|
|
|
Return ViewState("IdSegNeg").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IdSegNeg") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Private Property TotalPadre As Boolean
|
|
Get
|
|
TotalPadre = CBool(ViewState("TotalPadre"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("TotalPadre") = value
|
|
End Set
|
|
End Property
|
|
Private Property DTCuentas As DataTable
|
|
Get
|
|
Return CType(ViewState("DTCuentas"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTCuentas") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then
|
|
|
|
BtnConsultar.Enabled = True
|
|
Dim ErrorParametros As Boolean = True
|
|
|
|
CargaTipoCuentas()
|
|
CargaMoneda()
|
|
CargaSegmentosNegocio()
|
|
|
|
TxtCuenta.Enabled = False
|
|
|
|
If Request("ID") IsNot Nothing AndAlso IsNumeric(Request("ID")) AndAlso Request("ID").ToEntero > 0 Then
|
|
If Request("FF") IsNot Nothing AndAlso Request("FF").ToString.Length = 10 AndAlso Request("FF").ToDate > "01/01/1000".ToDate Then
|
|
|
|
|
|
IdCuenta = Request("ID").ToEntero
|
|
|
|
IdSegNeg = If(Request("IdSegNeg") IsNot Nothing AndAlso Request("IdSegNeg").ToString.ToEntero > 0, Request("IdSegNeg").ToString.ToEntero, -1)
|
|
|
|
HdnCveCuenta.Value = IdCuenta.ToString
|
|
|
|
FechaFin = Request("FF").ToDate
|
|
TxtFechaAl.Text = FechaFin.ToShortDateString
|
|
|
|
If Request("FI") IsNot Nothing AndAlso Request("FI").ToString.Length = 10 AndAlso Request("FI").ToDate > "01/01/1000".ToDate Then
|
|
FechaInicio = Request("FI").ToDate
|
|
TxtFechaDel.Text = FechaInicio.ToShortDateString
|
|
Else
|
|
FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1)
|
|
TxtFechaDel.Text = FechaInicio.ToShortDateString
|
|
End If
|
|
|
|
ErrorParametros = False
|
|
|
|
|
|
If DdlTipoCuentas.Items.FindByValue(IdCuenta.ToString) IsNot Nothing Then
|
|
DdlTipoCuentas.SelectedValue = IdCuenta.ToString
|
|
Else
|
|
DdlTipoCuentas.SelectedValue = "-2"
|
|
TxtCuenta.Enabled = True
|
|
|
|
If DTCuentas.FiltraParametros(String.Format("Id = {0}", IdCuenta)).Rows.Count > 0 Then
|
|
TxtCuenta.Text = DTCuentas.FiltraParametros(String.Format("Id = {0}", IdCuenta)).Rows(0)("CtaCodigo").ToString
|
|
End If
|
|
End If
|
|
|
|
DdlSegmentoNegocio.SelectedValueExist(IdSegNeg)
|
|
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorParametros Then
|
|
TotalPadre = True
|
|
CargaDatos()
|
|
End If
|
|
|
|
Else
|
|
Alert("La empresa no usa Contabilidad ni Armonización Contable", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaSegmentosNegocio()
|
|
Dim ObjContpaq As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim strGlobal As String = ""
|
|
|
|
If ObjContpaq.GetSegmentosNegocio(-1, "-1") Then
|
|
DdlSegmentoNegocio.DataSource = ObjContpaq.DtResultados
|
|
DdlSegmentoNegocio.DataBind()
|
|
End If
|
|
ObjContpaq.Dispose()
|
|
DdlSegmentoNegocio.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
DdlSegmentoNegocio.SelectedValue = "-1"
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaMoneda()
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
|
|
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
|
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
|
IdCuenta = If(DdlTipoCuentas.SelectedValue.ToEntero <> -2, DdlTipoCuentas.SelectedValue.ToEntero, HdnCveCuenta.Value.ToEntero)
|
|
|
|
CargaDatos()
|
|
|
|
' Imprimir_click(sender, e)
|
|
RegistraScript("Enable();")
|
|
End Sub
|
|
|
|
#Region "C A R G A - D A T O S"
|
|
Public Function WSCuentas() As String
|
|
Dim Str As New StringBuilder
|
|
Dim i As Integer = 0
|
|
Dim dt As DataTable = DTCuentas
|
|
|
|
|
|
If dt IsNot Nothing Then
|
|
For Each dr As DataRow In dt.Rows
|
|
i += 1
|
|
Str.AppendFormat("{{value:""{0}"",label:""{1}""}}{2}", dr("Id"), dr("CtaCodigo").ToString.Replace("""", ""), If(i < dt.Rows.Count, ",", ""))
|
|
Next
|
|
End If
|
|
|
|
Return Str.ToString
|
|
End Function
|
|
Private Sub CargaTipoCuentas()
|
|
Dim ObjTipoCuenta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim strGlobal As String = ""
|
|
|
|
If ObjTipoCuenta.GetCuentas(-1, "-1", -1) Then
|
|
Dim dr As DataRow = ObjTipoCuenta.DtResultados.FiltroPrimero("Codigo IN ('_GLOBAL')")
|
|
If dr IsNot Nothing Then strGlobal = dr.Item(0).ToString
|
|
DTCuentas = ObjTipoCuenta.DtResultados
|
|
DdlTipoCuentas.DataSource = ObjTipoCuenta.DtResultados.FiltraParametros("Codigo IN ('_ACTIVO', '_BPASIVO', '_CAPITAL', '_CUADRE', '_ESTADISTICAS', '_ORDEN', '_RACREEDOR', '_RDEUDOR', '_UTILIDAD')")
|
|
End If
|
|
ObjTipoCuenta.Dispose()
|
|
DdlTipoCuentas.DataBind()
|
|
'If strGlobal.Length > 0 Then DdlTipoCuentas.Items.Insert(0, New ListItem("Todas", strGlobal))
|
|
DdlTipoCuentas.Items.Insert(0, New ListItem("Todas las Cuentas", "1"))
|
|
DdlTipoCuentas.Items.Add(New ListItem("Algun específico", "-2"))
|
|
DdlTipoCuentas.SelectedIndex = 0
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa, 60)
|
|
|
|
If ObjConta.GetMovimientosAuxiliaresCatalogo(IdCuenta, FechaInicio, FechaFin, DdlMoneda.SelectedValue.ToEntero, DdlSegmentoNegocio.SelectedValue.ToEntero) Then
|
|
'DtTotales = DtDatos.Clone
|
|
DtDatos = ObjConta.DtResultados
|
|
CargaGrid()
|
|
|
|
|
|
'InsertaTotales()
|
|
Else
|
|
DtDatos = Nothing
|
|
End If
|
|
|
|
ObjConta.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
Private Sub InsertaTotales()
|
|
Dim i = 0
|
|
Dim Aumento = 0
|
|
Dim Row As DataRow
|
|
Dim Row2 As DataRow
|
|
|
|
'Llena DtTotales
|
|
For Each dr As DataRow In DtDatos.Rows
|
|
If dr("Fecha").ToString = "" Then
|
|
|
|
Row = DtTotales.NewRow
|
|
|
|
Row("ID") = -1
|
|
Row("CargosMovto") = If(DdlMoneda.SelectedValue = "1", dr("Cargos"), dr("CargosME"))
|
|
Row("AbonosMovto") = If(DdlMoneda.SelectedValue = "1", dr("Abonos"), dr("AbonosME"))
|
|
Row("Saldo") = dr("SaldoActual")
|
|
Row("CtaMayor") = dr("CtaMayor")
|
|
Row("Concepto") = String.Format("Total {0}:", dr("Nombre"))
|
|
Row("Nombre") = dr("Nombre")
|
|
DtTotales.Rows.Add(Row)
|
|
Row("Clasificacion") = i
|
|
End If
|
|
|
|
i += 1
|
|
Next
|
|
|
|
'Inserta Totales en DtDatos
|
|
For Each dr As DataRow In DtTotales.Rows
|
|
i = 0
|
|
|
|
If dr("CtaMayor").ToString = "1" Then
|
|
DtDatos.ImportRow(dr)
|
|
End If
|
|
|
|
If dr("CtaMayor").ToString = "2" Then
|
|
For index = dr("Clasificacion").ToString.ToEntero + Aumento To DtDatos.Rows.Count
|
|
If DtDatos.Rows(index)("Nombre").ToString <> dr("Nombre").ToString Then
|
|
i = index
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Row2 = DtDatos.NewRow
|
|
Row2.ItemArray = dr.ItemArray
|
|
|
|
DtDatos.Rows.InsertAt(Row2, i + Aumento)
|
|
Aumento += 1
|
|
End If
|
|
|
|
Next
|
|
|
|
End Sub
|
|
|
|
|
|
#Region "G R I D - GV DATOS"
|
|
Private Sub CargaGrid()
|
|
GvDatos.DataSource = DtDatos
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
|
|
End Sub
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DBCampo("Fecha") = "" Then
|
|
e.Row.ControlStyle.Font.Bold = True
|
|
e.Row.ControlStyle.Height = 35
|
|
|
|
'Cuando es Titulo
|
|
If e.Row.DBCampo("SaldoActual") = "" Then
|
|
CType(e.Row.FindControl("tr2"), HtmlTableRow).Visible = False
|
|
|
|
|
|
'Cuando Es Total
|
|
Else
|
|
CType(e.Row.FindControl("tr1"), HtmlTableRow).Visible = False
|
|
|
|
'Anterior para TotalPadre
|
|
'If e.Row.DBCampo("CtaMayor").ToString = "2" And (e.Row.DBCampo("Nivel3").ToString <> "" Xor e.Row.DBCampo("Orden").ToString.Length = 18) Then
|
|
' e.Row.FCLabel("LbReferencia").Text = "Total:"
|
|
'Else
|
|
' e.Row.FCLabel("LbConcepto").Text = String.Format("Total {0}:", e.Row.DBCampo("Nombre").ToString)
|
|
'End If
|
|
|
|
If TotalPadre Then
|
|
CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells.Remove(CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3))
|
|
CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3).Align = "Right"
|
|
CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3).Width = "400px"
|
|
If e.Row.RowIndex + 1 = DtDatos.Rows.Count Then
|
|
CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(4).Attributes.Add("style", "border-top: 1px solid black;")
|
|
CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(5).Attributes.Add("style", "border-top: 1px solid black;")
|
|
CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(6).Attributes.Add("style", "border-top: 1px solid black;")
|
|
End If
|
|
e.Row.FCLabel("LbReferencia").Text = String.Format("Total {0}:", e.Row.DBCampo("Nombre").ToString)
|
|
|
|
|
|
Else
|
|
TotalPadre = True
|
|
e.Row.FCLabel("LbReferencia").Font.Bold = False
|
|
e.Row.FCLabel("LbReferencia").Text = "Total:"
|
|
CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(4).Align = "Right"
|
|
End If
|
|
|
|
'e.Row.FCLabel("LbReferencia").Text = String.Format("Total {0}:", If(e.Row.DBCampo("CtaMayor").ToString = "2", "", e.Row.DBCampo("Nombre").ToString))
|
|
e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("Cargos").ToString.FormatoNumero(If(DdlMoneda.SelectedValue = "1", 2, 4))
|
|
e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("Abonos").ToString.FormatoNumero(If(DdlMoneda.SelectedValue = "1", 2, 4))
|
|
e.Row.FCLabel("LbSaldo").Text = e.Row.DBCampo("SaldoActual").ToString.FormatoNumero(If(DdlMoneda.SelectedValue = "1", 2, 4))
|
|
End If
|
|
|
|
Else
|
|
TotalPadre = False
|
|
e.Row.Width = 200
|
|
e.Row.ControlStyle.Font.Bold = False
|
|
CType(e.Row.FindControl("tr1"), HtmlTableRow).Visible = False
|
|
e.Row.FCHyperLink("HLPoliza").NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", e.Row.DBCampo("IdPoliza"))
|
|
|
|
If e.Row.DBCampo("CargosMovto").ToDouble <> 0 Then e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("CargosMovto").ToString.FormatoNumero(If(DdlMoneda.SelectedValue = "1", 2, 4))
|
|
If e.Row.DBCampo("AbonosMovto").ToDouble <> 0 Then e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("AbonosMovto").ToString.FormatoNumero(If(DdlMoneda.SelectedValue = "1", 2, 4))
|
|
If e.Row.DBCampo("Saldo").ToDouble <> 0 Then e.Row.FCLabel("LbSaldo").Text = e.Row.DBCampo("Saldo").ToString.FormatoNumero(If(DdlMoneda.SelectedValue = "1", 2, 4))
|
|
|
|
End If
|
|
|
|
|
|
'COLOREA NEGATIVOS
|
|
If e.Row.FCLabel("LbCargos").Text.ToDouble < 0 Then
|
|
e.Row.FCLabel("LbCargos").ForeColor = Drawing.Color.Red
|
|
Else
|
|
e.Row.FCLabel("LbCargos").ForeColor = Drawing.Color.Black
|
|
End If
|
|
|
|
If e.Row.FCLabel("LbAbonos").Text.ToDouble < 0 Then
|
|
e.Row.FCLabel("LbAbonos").ForeColor = Drawing.Color.Red
|
|
Else
|
|
e.Row.FCLabel("LbAbonos").ForeColor = Drawing.Color.Black
|
|
End If
|
|
|
|
If e.Row.FCLabel("LbSaldo").Text.ToDouble < 0 Then
|
|
e.Row.FCLabel("LbSaldo").ForeColor = Drawing.Color.Red
|
|
Else
|
|
e.Row.FCLabel("LbSaldo").ForeColor = Drawing.Color.Black
|
|
End If
|
|
|
|
If e.Row.FCLabel("LbSaldoInicial").Text.ToDouble < 0 Then
|
|
e.Row.FCLabel("LbSaldoInicial").ForeColor = Drawing.Color.Red
|
|
Else
|
|
e.Row.FCLabel("LbSaldoInicial").ForeColor = Drawing.Color.Black
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Protected Sub Imprimir_click(sender As Object, e As EventArgs) Handles Imprimir.Click
|
|
If DdlTipoCuentas.SelectedValue.ToEntero = -2 AndAlso TxtCuenta.Text.Trim = "" Then
|
|
Alert("El campo Cuenta es obligatorio.", TipoMensaje.MsgError)
|
|
Else
|
|
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
|
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
|
IdCuenta = If(DdlTipoCuentas.SelectedValue.ToEntero <> -1, DdlTipoCuentas.SelectedValue.ToEntero, HdnCveCuenta.Value.ToEntero)
|
|
|
|
'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
|
|
'If ObjConta.GetAnexoCatalogo(IdCuenta, FechaInicio, FechaFin) Then
|
|
'DtDatos = ObjConta.DtResultados
|
|
DtDatos = DtDatos
|
|
If Not IsNothing(DtDatos) Then
|
|
ImprimirReporte()
|
|
Else
|
|
Alert("No se encontró información para el reporte", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12) Then
|
|
GvDatos.ExportToExcel("MovimientosAuxiliares")
|
|
Else
|
|
If Not IsNothing(DtDatos) Then
|
|
ImprimirReporte("Excel")
|
|
Else
|
|
Alert("No se encontró información para el reporte", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
|
|
|
|
Dim params As New List(Of ReportParameter)
|
|
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
|
|
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
|
params.Add(New ReportParameter("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
|
params.Add(New ReportParameter("pFechaFin", FechaFin.ToString("dd/MM/yyyy")))
|
|
params.Add(New ReportParameter("CveMoneda", DdlMoneda.SelectedValue))
|
|
ImprimirPDF("Contabilidad/Reportes/RepMovimientosAuxiliaresCatalogo.rdlc", DtDatos, params, "MovimientosAuxiliares", Formato)
|
|
End Sub
|
|
|
|
End Class
|