252 lines
10 KiB
VB.net
252 lines
10 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class Contabilidad2_RepBalanzaComprobacion
|
|
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 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 ModoImpresion As Boolean
|
|
Get
|
|
ModoImpresion = CType(ViewState("ModoImpresion"), Boolean)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("ModoImpresion") = 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(Now), Month(Now), 1).ToShortDateString
|
|
TxtFechaAl.Text = Date.Now.ToShortDateString
|
|
|
|
|
|
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
|
|
'End If
|
|
End If
|
|
'DdlSubproyecto.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, -1)
|
|
'DdlSubproyecto.DataBind()
|
|
|
|
If Not ErrorParametros Then
|
|
CargaDatos()
|
|
End If
|
|
Else
|
|
|
|
DdlSubproyecto.DataSource = GlobalDTSubProyectos(-1, -1, UsuarioActual.CveEmpresa, -1)
|
|
DdlSubproyecto.DataBind()
|
|
End If
|
|
End Sub
|
|
|
|
#Region "CARGA DATOS Y GRID"
|
|
Private Sub CargaDatos()
|
|
' Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
|
|
Dim ObjConta As New ClsContabilidad
|
|
Dim CveSubProyecto As String = DdlSubproyecto.SelectedValue.ToString
|
|
|
|
Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero
|
|
|
|
If ObjConta.GetBalanzaComprobacion(FechaInicio, FechaFin, DdlTipoCuentas.SelectedValue.ToEntero, TipoReporte, CveSubProyecto, UsuarioActual.CveEmpresa, 0) Then
|
|
DtDatos = ObjConta.DtResultados
|
|
|
|
|
|
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
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs)
|
|
|
|
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", Date.Now, TxtFechaDel.Text.ToDate)
|
|
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", Date.Now, TxtFechaAl.Text.ToDate)
|
|
|
|
CargaDatos()
|
|
|
|
RegistraScript("Enable();")
|
|
End Sub
|
|
|
|
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
|
|
' e.Row.ControlStyle.Font.Bold = True
|
|
' 'e.Row.ControlStyle.Font.Size = 9
|
|
' 'e.Row.ControlStyle.Height = 30
|
|
'Else
|
|
' e.Row.ControlStyle.Font.Bold = False
|
|
'End If
|
|
|
|
If e.Row.DBCampo("CtaMayor") = "1" Or e.Row.DBCampo("CtaMayor") = "1" Then
|
|
e.Row.ControlStyle.Font.Bold = True
|
|
End If
|
|
|
|
'Acomoda Deudor y Acreedor
|
|
If e.Row.DBCampo("CveTipo") = "1" Then
|
|
e.Row.FCLabel("LbSaldoInicial").Text = String.Format("{0} ", e.Row.DBCampo("SaldoInicial").FormatoNumero)
|
|
e.Row.FCLabel("LbSaldoActual").Text = " "
|
|
End If
|
|
|
|
'Colorea NEGATIVOS
|
|
If e.Row.DBCampo("SaldoInicial").ToString.ToDouble < 0 Then
|
|
e.Row.FCLabel("LbSaldoInicial").ForeColor = Drawing.Color.Red
|
|
End If
|
|
If e.Row.DBCampo("Cargos").ToString.ToDouble < 0 Then
|
|
e.Row.FCLabel("LbCargos").ForeColor = Drawing.Color.Red
|
|
End If
|
|
If e.Row.DBCampo("Abonos").ToString.ToDouble < 0 Then
|
|
e.Row.FCLabel("LbAbonos").ForeColor = Drawing.Color.Red
|
|
End If
|
|
If e.Row.DBCampo("SaldoActual").ToString.ToDouble < 0 Then
|
|
e.Row.FCHyperLink("HLSaldoActual").ForeColor = Drawing.Color.Red
|
|
End If
|
|
|
|
'Total general
|
|
If e.Row.DBCampo("Id") = "" Then
|
|
'e.Row.Cells(2).HorizontalAlign = HorizontalAlign.NotSet
|
|
'Dim TotSaldoID, TotSaldoIA As Double
|
|
e.Row.ControlStyle.Font.Bold = True
|
|
e.Row.ControlStyle.Font.Size = 9
|
|
e.Row.ControlStyle.Height = 30
|
|
e.Row.FCLabel("LbNombre").Text = "Sumas Iguales"
|
|
e.Row.FCLabel("LbSaldoInicial").Text = String.Format("{0} <br/>{1}", e.Row.DBCampo("SaldoID").FormatoNumero, e.Row.DBCampo("SaldoIA").FormatoNumero)
|
|
e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("TotalCargos").FormatoNumero
|
|
e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("TotalAbonos").FormatoNumero
|
|
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("/Contabilidad2/RepMovimientosAuxiliaresCatalogo.aspx?CveCuenta={0}&FI={1}&FF={2}", e.Row.DBCampo("ID"), FechaInicio.ToShortDateString, FechaFin.ToShortDateString)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
|
|
ModoImpresion = True
|
|
|
|
CargaDatos()
|
|
|
|
ImprimirReporte()
|
|
|
|
'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
|
|
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
|
|
' Verifies that the control is rendered
|
|
End Sub
|
|
|
|
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
'GvDatos.ExportToExcel("BalanzaComprobacion")
|
|
ImprimirReporte("Excel")
|
|
End Sub
|
|
|
|
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))
|
|
params.Add(New ReportParameter("pImg", New Uri(Server.MapPath(String.Format("~/Empresas/{0}/Logo.png", UsuarioActual.CveEmpresa))).AbsoluteUri))
|
|
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
|
|
|
|
End Class
|