-- unificación de módulos de Contabilidad a una sola carpeta. como principal ContaSIG
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System
|
||||
Imports System.Data
|
||||
Imports Extensiones
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class Contabilidad_RepBalanzaComprobacion
|
||||
Partial Class Contabilidad2_RepBalanzaComprobacion
|
||||
Inherits ClsPaginas
|
||||
|
||||
|
||||
@@ -53,58 +54,100 @@ Partial Class Contabilidad_RepBalanzaComprobacion
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property CveProyecto As Integer
|
||||
Get
|
||||
CveProyecto = ViewState("CveProyecto").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveProyecto") = value
|
||||
End Set
|
||||
End Property
|
||||
Private Property CveSubProyecto As Integer
|
||||
Get
|
||||
CveSubProyecto = ViewState("CveSubProyecto").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CveSubProyecto") = 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 = 2 Then
|
||||
' Response.Redirect($"/Contabilidad/RepBalanzaComprobacion.aspx")
|
||||
'End If
|
||||
|
||||
Dim ErrorParametros = True
|
||||
ModoImpresion = False
|
||||
TxtFechaDel.Text = DateSerial(Year(NowADS()), Month(NowADS()), 1).ToShortDateString
|
||||
TxtFechaAl.Text = NowADS().ToShortDateString
|
||||
|
||||
If UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad Then
|
||||
BtnConsultar.Enabled = 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
|
||||
FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1)
|
||||
ErrorParametros = False
|
||||
End If
|
||||
'End If
|
||||
End If
|
||||
|
||||
If Not ErrorParametros Then
|
||||
CargaDatos()
|
||||
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
|
||||
FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1)
|
||||
ErrorParametros = False
|
||||
End If
|
||||
|
||||
If IsNothing(DtDatos) Then
|
||||
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
||||
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
||||
CargaDatos()
|
||||
End If
|
||||
Else
|
||||
Alert("La empresa no usa Armonización Contable o Contabilidad.", TipoMensaje.MsgAdvertencia)
|
||||
'End If
|
||||
End If
|
||||
DdlSubproyecto.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, -1)
|
||||
DdlSubproyecto.DataBind()
|
||||
|
||||
If Not ErrorParametros Then
|
||||
CargaDatos()
|
||||
End If
|
||||
CargarCentrosDeCosto(DdlProyecto, DdlSubproyecto, LblProyecto, LblSubProyecto)
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
||||
CargarSubProyecto(DdlSubproyecto, DdlProyecto.SelectedValue, "Todos")
|
||||
End Sub
|
||||
|
||||
#Region "CARGA DATOS Y GRID"
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
' Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
|
||||
If ObjConta.GetBalanzaComprobacion(FechaInicio, FechaFin, DdlTipoCuentas.SelectedValue.ToEntero) Then
|
||||
Dim ObjConta As New ClsContabilidad
|
||||
|
||||
CveSubProyecto = DdlSubproyecto.SelectedValue.ToEntero.ToEntero
|
||||
CveProyecto = DdlProyecto.SelectedValue.ToEntero.ToEntero
|
||||
|
||||
Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero
|
||||
|
||||
If TipoReporte = 1 Then
|
||||
'mostrar cuales son las cuentas que no tienen asignado el agrupador que sean afectables
|
||||
|
||||
If ObjConta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then
|
||||
Dim dtt As DataTable = ObjConta.DtResultados.FiltraParametros("CveAgrupadorSAT is null and not Codigo like '_%'")
|
||||
If dtt IsNot Nothing AndAlso dtt.Rows.Count > 0 Then
|
||||
Dim str As New StringBuilder
|
||||
For Each dr As DataRow In dtt.Rows
|
||||
str.AppendFormat(" - {0} </br>", dr("CtaCodigo"))
|
||||
Next
|
||||
Alert(str.ToString)
|
||||
End If
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
If ObjConta.GetBalanzaComprobacion(FechaInicio, FechaFin, DdlTipoCuentas.SelectedValue.ToEntero, TipoReporte, CveProyecto, CveSubProyecto, UsuarioActual.CveEmpresa, DdlVista.SelectedValue.ToEntero, DdlNivel.SelectedValue.ToEntero) Then
|
||||
DtDatos = ObjConta.DtResultados
|
||||
|
||||
CargaGrid()
|
||||
Else
|
||||
DtDatos = Nothing
|
||||
Alert("Ocurrio un error al cargar los datos del Anexo del Catálogo", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
ObjConta.Dispose()
|
||||
CargaGrid()
|
||||
End Sub
|
||||
Private Sub CargaGrid()
|
||||
GvDatos.DataSource = DtDatos
|
||||
@@ -126,7 +169,7 @@ Partial Class Contabilidad_RepBalanzaComprobacion
|
||||
Protected Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
If e.Row.DBCampo("CtaMayor") = "1" Or e.Row.DBCampo("CtaMayor") = "1" Then
|
||||
If e.Row.DBCampo("CtaMayor") = "1" OrElse e.Row.DBCampo("CtaMayor") = "3" OrElse e.Row.DBCampo("CtaMayor") = "4" Then
|
||||
e.Row.ControlStyle.Font.Bold = True
|
||||
End If
|
||||
|
||||
@@ -152,6 +195,7 @@ Partial Class Contabilidad_RepBalanzaComprobacion
|
||||
|
||||
'Total general
|
||||
If e.Row.DBCampo("Id") = "" Then
|
||||
|
||||
e.Row.ControlStyle.Font.Bold = True
|
||||
e.Row.ControlStyle.Font.Size = 9
|
||||
e.Row.ControlStyle.Height = 30
|
||||
@@ -162,51 +206,19 @@ Partial Class Contabilidad_RepBalanzaComprobacion
|
||||
e.Row.FCLabel("LbSaldoActual").Visible = True
|
||||
e.Row.FCLabel("LbSaldoActual").Text = String.Format("{0} <br/>{1}", e.Row.DBCampo("SaldoAD").FormatoNumero, e.Row.DBCampo("SaldoAA").FormatoNumero)
|
||||
Else
|
||||
If ModoImpresion Then e.Row.Cells(5).Text = e.Row.FCHyperLink("HLSaldoActual").Text Else e.Row.FCHyperLink("HLSaldoActual").NavigateUrl = String.Format("/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx?ID={0}&FF={1}", e.Row.DBCampo("ID"), FechaFin.ToShortDateString)
|
||||
If ModoImpresion Then e.Row.Cells(5).Text = e.Row.FCHyperLink("HLSaldoActual").Text Else e.Row.FCHyperLink("HLSaldoActual").NavigateUrl = String.Format("/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx?CveCuenta={0}&FI={1}&FF={2}&CveProyecto={3}&CveSubProyecto={4}", e.Row.DBCampo("ID"), FechaInicio.ToShortDateString, FechaFin.ToShortDateString, CveProyecto, CveSubProyecto)
|
||||
End If
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
|
||||
ModoImpresion = True
|
||||
CargaGrid()
|
||||
|
||||
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
||||
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
||||
CargaDatos()
|
||||
|
||||
'RegistraScript("Enable();")
|
||||
ImprimirReporte()
|
||||
|
||||
GenerarPDFCrystal()
|
||||
|
||||
'Using sw As New StringWriter()
|
||||
' Using hw As New HtmlTextWriter(sw)
|
||||
|
||||
' Dim style As StringBuilder = New StringBuilder()
|
||||
' style.Append("<style> ")
|
||||
' style.Append(File.ReadAllText(ModExtensiones.DirectorioBaseEmpresas & "Styles\EstilosExcel.css"))
|
||||
' style.Append(" </style> ")
|
||||
' 'To Export all pages
|
||||
' 'Gv.AllowPaging = False
|
||||
' 'Gv.DataBind()
|
||||
' Tbl.RenderControl(hw)
|
||||
' Dim sr As New StringReader(sw.ToString())
|
||||
' Dim pdfDoc As New Document(PageSize.A2, 10.0F, 10.0F, 10.0F, 0.0F)
|
||||
' Dim htmlparser As New HTMLWorker(pdfDoc)
|
||||
' PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
|
||||
' pdfDoc.Open()
|
||||
' htmlparser.Parse(sr)
|
||||
' pdfDoc.Close()
|
||||
|
||||
' Response.ContentType = "application/pdf"
|
||||
' Response.AddHeader("content-disposition", "attachment;filename=BalanzaComprobacion.pdf")
|
||||
' Response.Cache.SetCacheability(HttpCacheability.NoCache)
|
||||
' Response.Write(style.ToString)
|
||||
' Response.Write(pdfDoc)
|
||||
' Response.[End]()
|
||||
' End Using
|
||||
'End Using
|
||||
|
||||
End Sub
|
||||
'No quitar porque no funciona el exporta PDF
|
||||
@@ -216,58 +228,25 @@ Partial Class Contabilidad_RepBalanzaComprobacion
|
||||
|
||||
|
||||
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
||||
'GvDatos.ExportToExcel("BalanzaComprobacion")
|
||||
ModoImpresion = True
|
||||
CargaGrid()
|
||||
|
||||
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
||||
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
||||
|
||||
'RegistraScript("Enable();")
|
||||
|
||||
GenerarPDFCrystal("EXCEL")
|
||||
ImprimirReporte("Excel")
|
||||
End Sub
|
||||
Private Sub GenerarPDFCrystal(Optional Formato As String = "PDF")
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Contabilidad/Reportes/RepBalanzaComprobacion.rpt", Server.MapPath("~")))
|
||||
|
||||
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
|
||||
'ubicacion del rdlc
|
||||
Dim reportpath As String = "Contabilidad/Reportes/RepBalanzaComprobacion.rdlc"
|
||||
'nombre del reporte
|
||||
Dim fileName As String = "BalanzaComprobacion"
|
||||
'parametros a enviar al reporte
|
||||
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")
|
||||
'Dim logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa)
|
||||
|
||||
'If UsuarioActual.CveUsuario = 100 Then
|
||||
' Alert(String.Format("{0}Contabilidad/Reportes/RepBalanzaComprobacion.rpt", Server.MapPath("~")))
|
||||
' End If
|
||||
' Exit Sub
|
||||
|
||||
If Not IsNothing(DtDatos) Then
|
||||
'Dim dr As DataRow = DtCxC.Rows(0)
|
||||
Dim lista = New List(Of CrystalParametro)
|
||||
lista.Add(New CrystalParametro("pEmp", UsuarioActual.Empresa.Empresa))
|
||||
lista.Add(New CrystalParametro("pFechaFin", FechaFin.ToString("dd/MM/yyyy")))
|
||||
lista.Add(New CrystalParametro("pFechaIni", FechaInicio.ToString("dd/MM/yyyy")))
|
||||
lista.Add(New CrystalParametro("pImg", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
|
||||
|
||||
Dim DTTemp As DataTable = DtDatos.Copy
|
||||
|
||||
ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Contabilidad/Reportes/RepBalanzaComprobacion.rpt"), DTTemp, lista, "Balanza de Comprobación", Formato), "Balanza de Comprobación", Formato)
|
||||
|
||||
Else
|
||||
Alert("No se tienen registrados movimientos", TipoMensaje.MsgAdvertencia)
|
||||
End If
|
||||
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("pFechaIni", FechaInicio.ToString("dd/MM/yyyy")))
|
||||
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Usuario))
|
||||
|
||||
ImprimirPDF(reportpath, DtDatos, params, fileName, Formato)
|
||||
End Sub
|
||||
'Private Sub ImprimirReporte(Optional Formato As String = "PDF")
|
||||
' Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
|
||||
' 'ubicacion del rdlc
|
||||
' Dim reportpath As String = "Contabilidad/Reportes/RepBalanzaComprobacion.rdlc"
|
||||
' 'nombre del reporte
|
||||
' Dim fileName As String = "BalanzaComprobacion"
|
||||
' 'parametros a enviar al reporte
|
||||
' Dim params As New List(Of ReportParameter)
|
||||
' params.Add(New ReportParameter("pEmp", UsuarioActual.Empresa.Empresa))
|
||||
' 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("pFechaIni", FechaInicio.ToString("dd/MM/yyyy")))
|
||||
|
||||
' ImprimirPDF(reportpath, DtDatos, params, fileName, Formato)
|
||||
'End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user