536 lines
23 KiB
VB.net
536 lines
23 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
Imports ClosedXML.Excel
|
|
Imports System.IO
|
|
Imports System.Drawing
|
|
Imports System.Web.Services
|
|
|
|
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
|
|
|
|
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 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(UsuarioActual.CveEmpresa)
|
|
DdlSubproyecto.DataBind()
|
|
|
|
If Not ErrorParametros Then
|
|
CargaDatos()
|
|
End If
|
|
CargarCentrosDeCosto(DdlProyecto, DdlSubproyecto, LblProyecto, LblSubProyecto)
|
|
|
|
LblAccionesSubProyecto.Text = LblSubProyecto.Text
|
|
|
|
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 ClsContabilidad
|
|
|
|
CveSubProyecto = DdlSubproyecto.SelectedValue.ToEntero.ToEntero
|
|
CveProyecto = DdlProyecto.SelectedValue.ToEntero.ToEntero
|
|
|
|
Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero
|
|
|
|
If DdlVista.SelectedValue = "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("Cuentas sin clasificador SAT asignado: <br/>" & 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
|
|
Else
|
|
DtDatos = Nothing
|
|
Alert("Ocurrio un error al cargar los datos del Anexo del Catálogo", TipoMensaje.MsgError)
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
If DdlVista.SelectedValue = "1" Then
|
|
GvDatos.Columns(7).Visible = True
|
|
GvDatos.Columns(0).Visible = True
|
|
Else
|
|
GvDatos.Columns(7).Visible = False
|
|
GvDatos.Columns(0).Visible = False
|
|
End If
|
|
|
|
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 = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
|
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
|
|
|
CargaDatos()
|
|
|
|
RegistraScript("Enable();")
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
|
|
If e.Row.RowType = DataControlRowType.DataRow 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
|
|
|
|
'Acomoda Deudor y Acreedor
|
|
If e.Row.DBCampo("CveTipo") = "0" Then
|
|
'e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.FCLabel("LbSaldoInicial").Text = String.Format("{0} ", e.Row.DBCampo("SaldoInicial").FormatoNumero)
|
|
e.Row.FCLabel("LbSaldoInicial").Style.Add("padding-right", "65px")
|
|
e.Row.FCLabel("LbSaldoActual").Text = " "
|
|
e.Row.FCLabel("LbSaldoActual").Style.Add("padding-right", "65px")
|
|
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("CveCuenta") = "" Then
|
|
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").Style.Remove("padding-right")
|
|
e.Row.FCLabel("LbSaldoInicial").Style.Add("white-space", "pre")
|
|
e.Row.FCLabel("LbSaldoInicial").Text = String.Format("{0} <br/>{1}", e.Row.DBCampo("SaldoICargo").FormatoNumero, e.Row.DBCampo("SaldoIAbono").FormatoNumero)
|
|
e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("Cargos").FormatoNumero
|
|
e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("Abonos").FormatoNumero
|
|
e.Row.FCLabel("LbSaldoActual").Visible = True
|
|
e.Row.FCLabel("LbSaldoActual").Text = String.Format("{0} <br/>{1}", e.Row.DBCampo("SaldoFCargo").FormatoNumero, e.Row.DBCampo("SaldoFAbono").FormatoNumero)
|
|
e.Row.FCHyperLink("HLSaldoActual").Visible = False
|
|
Else
|
|
If ModoImpresion Then
|
|
e.Row.Cells(6).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("CveCuenta"), FechaInicio.ToShortDateString, FechaFin.ToShortDateString, CveProyecto, CveSubProyecto)
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
|
|
ModoImpresion = True
|
|
|
|
CargaDatos()
|
|
|
|
ImprimirReporte()
|
|
|
|
|
|
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
|
|
|
|
ImprimirReporte("Excel")
|
|
End Sub
|
|
|
|
Private Sub ImprimirReporte(Optional Formato As String = "PDF")
|
|
|
|
Dim reportpath As String = "Contabilidad/Reportes/RepBalanzaComprobacion.rdlc" 'Contable
|
|
|
|
'ubicacion del rdlc
|
|
If DdlVista.SelectedValue.ToEntero = 1 Then 'SAT
|
|
reportpath = "Contabilidad/Reportes/RepBalanzaComprobacionSAT.rdlc" 'Contable
|
|
End If
|
|
|
|
'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")
|
|
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
|
|
|
|
|
|
'Protected Sub BtnImprimirPoSubProyecto_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
|
|
'End Sub
|
|
|
|
|
|
Function WSDocumento(SubProyecto As String, DtDatos As DataTable) As IXLWorksheet
|
|
|
|
Dim ColumnaAumento As Integer = 0
|
|
|
|
If DdlVista.SelectedValue.ToEntero = 1 Then
|
|
ColumnaAumento = 1
|
|
End If
|
|
|
|
|
|
Dim WBAnexoSalvar = New ClosedXML.Excel.XLWorkbook
|
|
Dim WBReporte = New ClosedXML.Excel.XLWorkbook()
|
|
WBReporte.Worksheets.Add("1")
|
|
|
|
Dim WSReporte = WBReporte.Worksheet(1)
|
|
|
|
Dim RutaLogo As String = String.Format("{0}Logo.png", UsuarioActual.Empresa.Ruta)
|
|
If File.Exists(RutaLogo) Then
|
|
|
|
Dim imagePath As String = RutaLogo
|
|
Dim img As Bitmap = New Bitmap(imagePath)
|
|
Dim picture = WSReporte.AddPicture(img).MoveTo(WSReporte.Cell("A1"))
|
|
picture.Scale(0.5)
|
|
|
|
End If
|
|
|
|
Dim Tamaniofuente As Integer = 13
|
|
Dim Range = WSReporte.Range("A1:D1")
|
|
|
|
WSReporte.Style.Font.FontSize = 10
|
|
WSReporte.Style.Font.FontName = "Arial Narrow"
|
|
|
|
WSReporte.Style.Alignment.WrapText = True
|
|
|
|
Range.Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
|
|
|
|
WSReporte.Range("A1:F1").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
|
|
WSReporte.Range("A2:F2").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
|
|
WSReporte.Range("A3:F3").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
|
|
WSReporte.Range("A4:F4").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
|
|
WSReporte.Range("A5:F5").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
|
|
|
|
WSReporte.Range("A1:A5").Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
|
|
|
|
WSReporte.Column(1).Width = 15
|
|
WSReporte.Column(2).Width = 35
|
|
WSReporte.Column(3).Width = 14
|
|
WSReporte.Column(4).Width = 14
|
|
WSReporte.Column(5).Width = 14
|
|
WSReporte.Column(6).Width = 14
|
|
WSReporte.Column(7).Width = 14
|
|
|
|
WSReporte.Cell(1, 1).Value = UsuarioActual.Empresa.Empresa
|
|
WSReporte.Cell(2, 1).Value = $"Balanza de Comprobación del {TxtFechaDel.Text} al {TxtFechaAl.Text}"
|
|
|
|
WSReporte.Cell(5, 1).Value = $"Sub Proyecto: {SubProyecto}"
|
|
WSReporte.Cell(5, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left
|
|
WSReporte.Cell(5, 1).Style.Font.Bold = True
|
|
|
|
WSReporte.Cell(6, 1).Value = "Cuenta"
|
|
WSReporte.Cell(6, 2).Value = "Nombre"
|
|
WSReporte.Cell(6, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center
|
|
WSReporte.Cell(6, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center
|
|
|
|
WSReporte.Cell(6, 3).Value = $"Saldos Iniciales{vbCrLf}Deudor Acreedor"
|
|
WSReporte.Cell(6, 4).Value = $"Cargos"
|
|
WSReporte.Cell(6, 5).Value = $"Abonos"
|
|
WSReporte.Cell(6, 6).Value = $"Saldo Actuales{vbCrLf} Deudor Acreedo"
|
|
|
|
WSReporte.Range("A6:F6").Style.Font.Bold = True
|
|
WSReporte.Range("A6:F6").Style.Font.FontSize = 10
|
|
WSReporte.Range("A6:F6").Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
|
|
WSReporte.Range("A6:F6").Style.Border.TopBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Range("A6:F6").Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Range("A6:F6").Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
|
|
Dim CuerrentRow As Integer = 7
|
|
|
|
CuerrentRow = CuerrentRow + 1
|
|
|
|
For Each Drow As DataRow In DtDatos.Rows
|
|
|
|
WSReporte.Cell(CuerrentRow, 1).Value = Drow("Codigo").ToString
|
|
WSReporte.Cell(CuerrentRow, 2).Value = Drow("Nombre").ToString
|
|
WSReporte.Cell(CuerrentRow, 3).Value = Drow("SaldoInicial").ToString
|
|
WSReporte.Cell(CuerrentRow, 4).Value = Drow("Cargos").ToString
|
|
WSReporte.Cell(CuerrentRow, 5).Value = Drow("Abonos").ToString
|
|
WSReporte.Cell(CuerrentRow, 6).Value = Drow("SaldoActual").ToString
|
|
|
|
If Drow("CtaMayor").ToString.ToEntero.Contiene(1) Then
|
|
|
|
WSReporte.Cell(CuerrentRow, 1).Style.Font.Bold = True
|
|
WSReporte.Cell(CuerrentRow, 2).Style.Font.Bold = True
|
|
WSReporte.Cell(CuerrentRow, 3).Style.Font.Bold = True
|
|
WSReporte.Cell(CuerrentRow, 4).Style.Font.Bold = True
|
|
WSReporte.Cell(CuerrentRow, 5).Style.Font.Bold = True
|
|
WSReporte.Cell(CuerrentRow, 6).Style.Font.Bold = True
|
|
|
|
If Drow("CtaMayor").ToString.ToEntero.Contiene(1) Then
|
|
WSReporte.Cell(CuerrentRow, 1).Style.Alignment.Indent = 1
|
|
WSReporte.Cell(CuerrentRow, 1).Style.Font.Italic = True
|
|
End If
|
|
|
|
Else
|
|
WSReporte.Cell(CuerrentRow, 1).Style.Alignment.WrapText = True
|
|
WSReporte.Cell(CuerrentRow, 1).Style.Alignment.Indent = 2
|
|
End If
|
|
|
|
WSReporte.Cell(CuerrentRow, 2).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
WSReporte.Cell(CuerrentRow, 3).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
WSReporte.Cell(CuerrentRow, 4).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
WSReporte.Cell(CuerrentRow, 5).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
WSReporte.Cell(CuerrentRow, 6).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
|
|
CuerrentRow = CuerrentRow + 1
|
|
Next
|
|
|
|
|
|
For xy As Integer = 6 To CuerrentRow
|
|
WSReporte.Cell(xy, 6).Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Cell(xy, 1).Style.Border.LeftBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
Next
|
|
|
|
CuerrentRow = CuerrentRow + 1
|
|
|
|
WSReporte.Cell(CuerrentRow, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center
|
|
WSReporte.Cell(CuerrentRow, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center
|
|
|
|
WSReporte.Cell(CuerrentRow, 3).Value = $"Saldos Iniciales{vbCrLf}Deudor Acreedor"
|
|
WSReporte.Cell(CuerrentRow, 4).Value = $"Cargos"
|
|
WSReporte.Cell(CuerrentRow, 5).Value = $"Abonos"
|
|
WSReporte.Cell(CuerrentRow, 6).Value = $"Saldo Actuales{vbCrLf} Deudor Acreedo"
|
|
|
|
WSReporte.Cell(CuerrentRow, 1).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Cell(CuerrentRow, 2).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Cell(CuerrentRow, 3).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Cell(CuerrentRow, 4).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Cell(CuerrentRow, 5).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Cell(CuerrentRow, 6).Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Range($"A{CuerrentRow}:F{CuerrentRow}").Style.Font.Bold = True
|
|
WSReporte.Range($"A{CuerrentRow}:F{CuerrentRow}").Style.Font.FontSize = 10
|
|
WSReporte.Range($"A{CuerrentRow}:F{CuerrentRow}").Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
|
|
WSReporte.Range($"A{CuerrentRow}:F{CuerrentRow}").Style.Border.TopBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Range($"A{CuerrentRow}:F{CuerrentRow}").Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
WSReporte.Range($"A{CuerrentRow}:F{CuerrentRow}").Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
|
|
CuerrentRow = CuerrentRow + 1
|
|
|
|
Dim ultimaFila As DataRow = DtDatos.Rows(DtDatos.Rows.Count - 1)
|
|
|
|
Dim LastSaldoID As Decimal = ultimaFila("SaldoICargo").ToString.ToDecimal
|
|
Dim LastTotalAbonos As Decimal = ultimaFila("Abonos").ToString.ToDecimal
|
|
Dim LastTotalCargos As Decimal = ultimaFila("Cargos").ToString.ToDecimal
|
|
Dim LastSaldoAD As Decimal = ultimaFila("SaldoFCargo").ToString.ToDecimal
|
|
Dim LastSaldoIA As Decimal = ultimaFila("SaldoIAbono").ToString.ToDecimal
|
|
Dim LastSaldoAA As Decimal = ultimaFila("SaldoFAbono").ToString.ToDecimal
|
|
|
|
WSReporte.Cell(CuerrentRow, 2).Value = "Sumas Iguales"
|
|
WSReporte.Cell(CuerrentRow, 3).Value = LastSaldoID
|
|
WSReporte.Cell(CuerrentRow, 4).Value = LastTotalCargos
|
|
WSReporte.Cell(CuerrentRow, 5).Value = LastTotalAbonos
|
|
WSReporte.Cell(CuerrentRow, 6).Value = LastSaldoAD
|
|
|
|
WSReporte.Cell(CuerrentRow, 3).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
WSReporte.Cell(CuerrentRow, 4).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
WSReporte.Cell(CuerrentRow, 5).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
WSReporte.Cell(CuerrentRow, 6).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
|
|
|
|
CuerrentRow = CuerrentRow + 1
|
|
|
|
WSReporte.Cell(CuerrentRow, 3).Value = LastSaldoIA
|
|
WSReporte.Cell(CuerrentRow, 6).Value = LastSaldoAA
|
|
|
|
|
|
WSReporte.Cell(CuerrentRow, 3).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
WSReporte.Cell(CuerrentRow, 6).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
|
|
|
|
WSReporte.Range($"B{CuerrentRow}:F{CuerrentRow}").Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
|
|
|
|
WSReporte.PageSetup.PrintAreas.Add($"A1:G{CuerrentRow + 0 + 1}")
|
|
WSReporte.PageSetup.Margins.Top = 0.3
|
|
WSReporte.PageSetup.Margins.Left = 0.8
|
|
WSReporte.PageSetup.Margins.Right = 0.8
|
|
WSReporte.PageSetup.FitToPages(1, 1)
|
|
|
|
WBReporte.Worksheet(1).CopyTo(WBAnexoSalvar, "SubProyecto")
|
|
|
|
Return WBReporte.Worksheet(1)
|
|
|
|
End Function
|
|
|
|
|
|
Protected Sub BtnImprimirPorsubProyecto_Click(sender As Object, e As EventArgs)
|
|
Dim WBAnexoBalanza = New ClosedXML.Excel.XLWorkbook
|
|
'Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero
|
|
|
|
FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate)
|
|
FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate)
|
|
|
|
Dim SPCounter As Integer = 1
|
|
Dim DtSP As DataTable = GlobalDTSubProyectos(UsuarioActual.CveEmpresa, Estatus:=-1).FiltraParametros("", "SubProyecto")
|
|
For Each drSP As DataRow In DtSP.Rows
|
|
|
|
Dim ObjConta As New ClsContabilidad
|
|
If ObjConta.GetBalanzaComprobacion(FechaInicio, FechaFin, 1, 1, -1, drSP("CveSubProyecto").ToString.ToEntero, UsuarioActual.CveEmpresa, 0, -1) Then
|
|
DtDatos = ObjConta.DtResultados
|
|
Else
|
|
DtDatos = Nothing
|
|
Alert("Ocurrio un error al cargar los datos del Anexo del Catálogo", TipoMensaje.MsgError)
|
|
Exit For
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
If DtDatos.Rows.Count > 0 Then
|
|
WBAnexoBalanza.AddWorksheet(WSDocumento(drSP("SubProyecto").ToString, DtDatos))
|
|
Dim spNombre As String = drSP("SubProyecto").ToString().Replace(":", "_").Replace("/", "_").Replace("\", "_").Replace("?", "_").Replace("*", "_").Replace("[", "_").Replace("]", "_")
|
|
WBAnexoBalanza.Worksheet(SPCounter).Name = $"{SPCounter}_{spNombre}"
|
|
SPCounter = SPCounter + 1
|
|
|
|
End If
|
|
|
|
|
|
Next
|
|
|
|
Dim msB = New MemoryStream()
|
|
WBAnexoBalanza.SaveAs(msB)
|
|
|
|
Dim BB As Byte() = msB.ToArray
|
|
msB.Dispose()
|
|
|
|
Response.Clear()
|
|
Response.Buffer = True
|
|
Response.AddHeader("content-disposition", "attachment; filename=Balanza_" & Now.ToString("yyyyMMddhhmmss") & ".xlsx")
|
|
Response.ContentType = "application/vnd.ms-excel"
|
|
Response.BinaryWrite(BB)
|
|
'Response.Write("Ready")
|
|
|
|
Response.End()
|
|
End Sub
|
|
|
|
<WebMethod>
|
|
Public Shared Function MyStaticFunction(ByVal parameter As String) As String
|
|
' Lógica de tu función aquí
|
|
Return "Resultado: " & parameter
|
|
End Function
|
|
|
|
End Class
|