-- unificación de módulos de Contabilidad a una sola carpeta. como principal ContaSIG

This commit is contained in:
2024-06-17 08:33:45 -07:00
parent 54ac9b836b
commit 9219751707
88 changed files with 17456 additions and 21235 deletions

View File

@@ -5,9 +5,10 @@ Imports System.Data
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Partial Class AC_RepAnexoCatalogo
Partial Class AC2_RepAnexoCatalogo
Inherits ClsPaginas
#Region "PROPIEDADES"
Private Property DtDatos As DataTable
Get
@@ -26,7 +27,8 @@ Partial Class AC_RepAnexoCatalogo
ViewState("FechaInicio") = value
End Set
End Property
Private Property FechaFin As DateTime
Private Property FechaFin As Date
Get
FechaFin = ViewState("FechaFin").ToString.ToDate
End Get
@@ -36,194 +38,165 @@ Partial Class AC_RepAnexoCatalogo
End Property
Private Property IdCuenta As Integer
Get
IdCuenta = ViewState("IdCuenta").ToString.ToEntero
IdCuenta = ViewState("CveCuenta").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdCuenta") = value
ViewState("CveCuenta") = value
End Set
End Property
Private Property IdSegNeg As Integer
'Private Property DTCuentas As DataTable
' Get
' Return CType(ViewState("DTCuentas"), DataTable)
' End Get
' Set(value As DataTable)
' ViewState("DTCuentas") = value
' End Set
'End Property
Private Property CveProyecto As String
Get
IdSegNeg = ViewState("IdSegNeg").ToString.ToEntero
CveProyecto = ViewState("CveProyecto").ToString
End Get
Set(value As Integer)
ViewState("IdSegNeg") = value
Set(value As String)
ViewState("CveProyecto") = value
End Set
End Property
Private Property DTCuentas As DataTable
Private Property CveSubProyecto As String
Get
Return CType(ViewState("DTCuentas"), DataTable)
CveSubProyecto = ViewState("CveSubProyecto").ToString
End Get
Set(value As DataTable)
ViewState("DTCuentas") = value
Set(value As String)
ViewState("CveSubProyecto") = value
End Set
End Property
Private Property TipoReporte As Integer
Get
TipoReporte = ViewState("TipoReporte").ToString.ToEntero
TipoReporte = ViewState("TP").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("TipoReporte") = value
ViewState("TP") = 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.TipoContabilidad = 1 Then
Response.Redirect($"/Contabilidad2/RepAnexoCatalogo.aspx")
If UsuarioActual.Empresa.TipoContabilidad = 2 Then Response.Redirect($"/Contabilidad/RepAnexoCatalogoCI.aspx")
Dim ErrorParametros = True
DtDatos = Nothing
CargaTipoCuentas()
FechaInicio = NowADS().FirstDayOfMonth
FechaFin = NowADS()
'If UsuarioActual.Empresa.UsaAC Then
' TipoReporte = -1
'Else
' TipoReporte = 1
' tdTipoReporte.Visible = True
' tdTipoReporte2.Visible = True
'End If
If Request("CveCuenta") IsNot Nothing AndAlso IsNumeric(Request("CveCuenta")) AndAlso Request("CveCuenta").ToEntero > 0 Then
'If Request("FI") IsNot Nothing AndAlso Request("FI").ToString.Length = 10 AndAlso Request("FI").ToDate > "01/01/1000".ToDate Then
If Request("FF") IsNot Nothing AndAlso Request("FF").ToString.Length = 10 AndAlso Request("FF").ToDate > "01/01/1000".ToDate Then
IdCuenta = Request("CveCuenta").ToEntero
'FechaInicio = Request("FI").ToDate
FechaFin = Request("FF").ToDate
DdlCuentas.SelectedValueExist(IdCuenta)
If Request("FI") IsNot Nothing AndAlso Request("FI").ToString.Length = 10 AndAlso Request("FI").ToDate > "01/01/1000".ToDate Then
FechaInicio = Request("FI").ToDate
Else
If Request("ER") IsNot Nothing AndAlso Request("ER").ToString = "1" Then
FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1)
Else
FechaInicio = ("1900/01/01").ToDate
End If
End If
If Request("CM") IsNot Nothing AndAlso IsNumeric(Request("CM")) AndAlso Request("CM").ToEntero > 0 Then
DdlCuenta.SelectedValueExist(Request("CM").ToString)
End If
If Request("CveProyecto") IsNot Nothing AndAlso IsNumeric(Request("CveProyecto")) Then
CveProyecto = Request("CveProyecto").ToString
DdlProyecto.SelectedValueExist(CveProyecto)
DdlProyecto_SelectedIndexChanged(Nothing, Nothing)
End If
If Request("CveSubProyecto") IsNot Nothing AndAlso IsNumeric(Request("CveSubProyecto")) Then
CveSubProyecto = Request("CveSubProyecto").ToString
DdlSubproyecto.SelectedValueExist(CveSubProyecto)
End If
ErrorParametros = False
If Request("TP") IsNot Nothing AndAlso IsNumeric(Request("TP")) AndAlso Request("TP").ToEntero > 0 Then
TipoReporte = Request("TP").ToEntero
DdlTipoReporte.SelectedValue = TipoReporte.ToString
End If
End If
'End If
End If
If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then
InicializaValores()
CargaURLParametros()
BtnConsultar.Enabled = True
Else
Alert("La empresa no usa Contabilidad ni Armonización Contable", TipoMensaje.MsgError)
txtFechaI.Text = FechaInicio.ToShortDateString
txtFechaF.Text = FechaFin.ToShortDateString
If Not ErrorParametros Then
CargaDatos()
End If
End If
End Sub
#Region "CARGA DATOS Y GRID"
#Region " INCIALIZA VALORES "
Private Sub InicializaValores()
DtDatos = Nothing
CargaTipoCuentas()
CargaSegmentosNegocio()
FechaInicio = DateSerial(Year(NowADS()), Month(NowADS()), 1)
FechaFin = NowADS()
If UsuarioActual.Empresa.UsaAC Then
TipoReporte = -1
Else
TipoReporte = 1
tdTipoReporte.Visible = True
tdTipoReporte2.Visible = True
End If
End Sub
Public Function WSCuentas() As String
Dim Str As New StringBuilder
Dim i As Integer = 0
Dim dt As DataTable = DTCuentas '.FiltraParametros("Afectable = 1")
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
For Each dr As DataRow In dt.Rows
i += 1
Str.AppendFormat("{{value:""{0}"",label:""{1}{3}""}}{2}", dr("Id"), dr("CtaCodigo").ToString.Replace("""", ""), If(i < dt.Rows.Count, ",", ""), If(dr("Afectable").ToString = "1", " *", ""))
Next
End If
Return Str.ToString
End Function
Private Sub CargaTipoCuentas()
Dim ObjTipoCuenta As New ClsContPAQi(UsuarioActual.Empresa)
'Dim ObjTipoCuenta As New ClsContPAQi(UsuarioActual.Empresa)
Dim ObjTipoCuenta As New ClsContabilidad
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 '.FiltraParametros("Afectable = 1")
DdlTipoCuentas.DataSource = ObjTipoCuenta.DtResultados.FiltraParametros("Codigo IN ('_ACTIVO', '_BPASIVO', '_CAPITAL', '_CUADRE', '_ESTADISTICAS', '_ORDEN', '_RACREEDOR', '_RDEUDOR', '_UTILIDAD')")
If ObjTipoCuenta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then
DdlCuentas.DataSource = ObjTipoCuenta.DtResultados.FiltraParametros("Codigo NOT IN ('_ACTIVO', '_PASIVO', '_CAPITAL', '_CUADRE', '_ESTADISTICAS', '_ORDEN', '_RACREEDOR', '_RDEUDOR', '_UTILIDAD')")
' DdlCuentas.DataSource = ObjTipoCuenta.DtResultados
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
DdlCuentas.DataBind()
CargarCentrosDeCosto(DdlProyecto, DdlSubproyecto, LblProyecto, LblSubProyecto, divProyecto:=divProyecto)
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"
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged
CargarSubProyecto(DdlSubproyecto, DdlProyecto.SelectedValue, "Todos")
End Sub
#End Region
#Region "CARGA DATOS"
Private Sub CargaURLParametros()
Dim ErrorParametros = True
If Request("ID") IsNot Nothing AndAlso IsNumeric(Request("ID")) AndAlso Request("ID").ToEntero > 0 Then
'If Request("FI") IsNot Nothing AndAlso Request("FI").ToString.Length = 10 AndAlso Request("FI").ToDate > "01/01/1000".ToDate 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
'FechaInicio = Request("FI").ToDate
FechaFin = Request("FF").ToDate
If Request("FI") IsNot Nothing AndAlso Request("FI").ToString.Length = 10 AndAlso Request("FI").ToDate > "01/01/1000".ToDate Then
FechaInicio = Request("FI").ToDate
Else
FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1)
End If
DdlTipoCuentas.SelectedValueExist("-2")
HdnCveCuenta.Value = IdCuenta.ToString
TxtCuenta.Text = DTCuentas.FiltroPrimeroValor("CtaCodigo", $"Id={Request("ID")}")
If Request("CM") IsNot Nothing AndAlso IsNumeric(Request("CM")) AndAlso Request("CM").ToEntero > 0 Then
DdlCuenta.SelectedValueExist(Request("CM").ToString)
End If
ErrorParametros = False
If Request("TP") IsNot Nothing AndAlso IsNumeric(Request("TP")) AndAlso Request("TP").ToEntero > 0 Then
TipoReporte = Request("TP").ToEntero
DdlTipoReporte.SelectedValue = TipoReporte.ToString
End If
If Request("IdSegNeg") IsNot Nothing AndAlso IsNumeric(Request("IdSegNeg")) AndAlso Request("IdSegNeg").ToEntero > 0 Then
IdSegNeg = Request("IdSegNeg").ToEntero
DdlSegmentoNegocio.SelectedValue = IdSegNeg.ToString
End If
End If
'End If
End If
UPFiltros.Update()
TxtFechaDel.Text = FechaInicio.ToShortDateString
TxtFechaAl.Text = FechaFin.ToShortDateString
If Not ErrorParametros Then
CargaDatos()
End If
End Sub
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
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 = -2, HdnCveCuenta.Value.ToEntero, DdlTipoCuentas.SelectedValue.ToEntero)
CargaDatos()
RegistraScript("Enable();")
End If
End Sub
Private Sub CargaDatos()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
Dim ObjConta As New ClsContabilidad
TipoReporte = If(TipoReporte = -1, -1, DdlTipoReporte.SelectedValue.ToEntero)
If Request("TipoReporte") IsNot Nothing Then
TipoReporte = If(TipoReporte = -1, -1, DdlTipoReporte.SelectedValue.ToEntero)
Else
TipoReporte = DdlTipoReporte.SelectedValue.ToEntero
End If
'Dim CveSubProyecto As String
If ObjConta.GetAnexoCatalogo(IdCuenta, FechaInicio, FechaFin, DdlCuenta.SelectedValue.ToEntero, TipoReporte, DdlSegmentoNegocio.SelectedValue.ToEntero) Then
CveSubProyecto = DdlSubproyecto.SelectedValue.ToEntero.ToString
CveProyecto = DdlProyecto.SelectedValue.ToEntero.ToString
If Request("ID") IsNot Nothing AndAlso IsNumeric(Request("ID")) AndAlso Request("ID").ToEntero > 0 Then
If ObjConta.GetAnexoCatalogo(IdCuenta, FechaInicio, FechaFin, DdlCuenta.SelectedValue.ToEntero, CveProyecto.ToEntero, CveSubProyecto.ToEntero, UsuarioActual.CveEmpresa, TipoReporte) Then
If Request("CveCuenta") IsNot Nothing AndAlso IsNumeric(Request("CveCuenta")) AndAlso Request("CveCuenta").ToEntero > 0 Then
DtDatos = ObjConta.DtResultados.FiltraParametros(" SaldoInicial <> 0 OR Cargos <> 0 OR Abonos <> 0")
Else
DtDatos = ObjConta.DtResultados
@@ -232,13 +205,14 @@ Partial Class AC_RepAnexoCatalogo
CargaGrid()
Else
DtDatos = Nothing
Alert("Ocurrio un error al cargar los datos del Anexo del Catálogo", TipoMensaje.MsgError)
Alert("Ocurrio un error al cargar los datos del Anexo del Catálogo.", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
End Sub
Private Sub CargaGrid()
GvDatos.DataSource = DtDatos
'GvDatos.Dispose()
GvDatos.DataBind()
UpDatos.Update()
If DtDatos.Rows.Count > 0 Then
@@ -248,12 +222,10 @@ Partial Class AC_RepAnexoCatalogo
End Sub
#End Region
#Region "GV ROW DATA BOUND"
Protected Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("Id").ToEntero = IdCuenta Then
If e.Row.DBCampo("CveCuenta").ToEntero = IdCuenta Then
e.Row.ControlStyle.Font.Bold = True
'e.Row.ControlStyle.Font.Size = 9
'e.Row.ControlStyle.Height = 30
@@ -286,26 +258,21 @@ Partial Class AC_RepAnexoCatalogo
e.Row.FCHyperLink("HLSaldoActual").ForeColor = Drawing.Color.Red
End If
e.Row.FCHyperLink("HLSaldoActual").NavigateUrl = String.Format("/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx?ID={0}&FI={1}&FF={2}&IdSegNeg={3}", e.Row.DBCampo("ID"), FechaInicio.ToShortDateString, FechaFin.ToShortDateString, DdlSegmentoNegocio.SelectedValue.ToEntero)
e.Row.FCHyperLink("HLSaldoActual").NavigateUrl = String.Format("/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx?CveCuenta={0}&FI={1}&FF={2}&CveProyecto={3}&CveSubProyecto={4}&TP={5}", e.Row.DBCampo("CveCuenta"), FechaInicio.ToShortDateString, FechaFin.ToShortDateString, CveProyecto, CveSubProyecto, TipoReporte)
End If
End Sub
#End Region
#Region " IMPRIMIR "
Protected Sub LnkImprimir_Click(sender As Object, e As EventArgs) Handles LnkImprimir.Click
If Not IsNothing(DtDatos) Then
ImprimirReporte()
Else
Alert("Primero debe consultar el Anexo del Catálogo", TipoMensaje.MsgAdvertencia)
End If
End Sub
Protected Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
If Not IsNothing(DtDatos) Then
ImprimirReporte("Excel")
Else
Alert("Primero debe consultar el Anexo del Catálogo", TipoMensaje.MsgAdvertencia)
'GvDatos.ExportToExcelG("AnexoCatalogo" & NowADS().ToShortDateString & ".xlsx")
'GvDatos.ExportToExcelG("ExistenciasHorizontal.xlsx", "Anexo Catalogo", UsuarioActual, "".ToString, 100, 200)
End If
End Sub
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
@@ -317,15 +284,30 @@ Partial Class AC_RepAnexoCatalogo
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("IdCuenta", IdCuenta.ToString))
params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("usuarioImprimio", UsuarioActual.Nombre))
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("pFechaInicio", FechaInicio.ToString("dd/MM/yyyy")))
ImprimirPDF(reportpath, DtDatos, params, fileName, Formato)
End Sub
#End Region
Public Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
If DdlCuentas.SelectedValue.ToEntero = -1 Then
Alert("El campo Cuenta es obligatorio.", TipoMensaje.MsgError)
Else
FechaInicio = If(txtFechaI.Text = "" Or txtFechaI.Text = "__/__/____", NowADS(), txtFechaI.Text.ToDate)
FechaFin = If(txtFechaF.Text = "" Or txtFechaF.Text = "__/__/____", NowADS(), txtFechaF.Text.ToDate)
IdCuenta = DdlCuentas.SelectedValue.ToEntero
CargaDatos()
End If
'RegistraScript("Enable();")
End Sub
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
End Sub
End Class