VyA addContrato valida unidad

This commit is contained in:
rakcsle
2024-09-02 09:27:38 -07:00
parent a6176df862
commit 59ccd7e281
12 changed files with 3519 additions and 3077 deletions

View File

@@ -23,13 +23,21 @@
</style>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="H" runat="Server">
<asp:UpdatePanel ID="UpAcciones" runat="server" >
<ContentTemplate>
<li>
<asp:LinkButton ID="ImgExcel" runat="server" Visible="true"><i class="fa fa-file-excel-o" ></i> Generar EXCEL</asp:LinkButton>
</li>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="ImgExcel" />
</Triggers>
</asp:UpdatePanel>
<li>
<asp:LinkButton ID="ImgExcel" runat="server" Visible="false"><i class="fa fa-ad-excel" ></i> Generar EXCEL</asp:LinkButton>
</li>
<li>
<%-- <li>
<asp:LinkButton ID="Imprimir" runat="server" Visible="false"><i class="fa fa-print"></i> Imprimir</asp:LinkButton>
</li>
</li>--%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="E" runat="Server">
@@ -143,13 +151,16 @@
</div>
<asp:UpdatePanel ID="UpDatos" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<div style='color:red'></div>
<asp:GridView ID="GvDatos" runat="server"
CssClass="table table-striped table-advance table-hover Widthall ScrollAD mysmallbtn" AutoGenerateColumns="False"
CssClass="table table-striped table-advance table-hover " AutoGenerateColumns="False"
EmptyDataText="No se encontrarios movimientos."
DataKeyNames="" OnRowDataBound="GvDatos_RowDataBound">
<Columns>
<asp:TemplateField ControlStyle-CssClass="Widthall">
<HeaderTemplate>
<table width="100%" style="border: none">
<tr>
<td colspan="3"><font size="2">Cuenta</font></td>
@@ -164,15 +175,19 @@
<td width="300px" align="left">Concepto</td>
<td width="100px" align="center">Referencia</td>
<td width="100px" align="center">Referencia Movto</td>
<td width="100px" align="center">SubProyecto</td>
<td width="100px" align="center">SubProyecto <asp:Label ID="LblSubProyecto" runat="server"></asp:Label> </td>
<td width="100px" align="center">Cargos</td>
<td width="100px" align="center">Abonos</td>
<td width="100px" align="center">Saldo</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table width="100%" style="border: none">
<tr runat="server" id="tr1">
<td colspan="3" align="left" width="180px">
<asp:Label ID="LbCuenta" runat="server" Text='<%# Eval("Codigo")%>'></asp:Label>
@@ -187,6 +202,7 @@
<asp:Label ID="LbSaldoInicial" runat="server" Text='<%# Eval("SaldoInicial", "{0:N2}")%>'></asp:Label>
</td>
</tr>
<tr runat="server" id="tr2">
<td width="60px" style="border: 0px;" align="center">
<asp:Literal ID="LbFecha" runat="server" Text='<%# Eval("Fecha", "{0:d}")%>'></asp:Literal>
@@ -222,6 +238,7 @@
<asp:Label ID="LbSaldo" runat="server"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<ItemStyle />
@@ -229,6 +246,9 @@
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
@@ -239,8 +259,7 @@
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="JS" runat="Server">
<script type="text/javascript">
</script>
</asp:Content>

View File

@@ -2,8 +2,12 @@
Option Strict On
Imports System.Data
Imports ADServerControl.DragableList
Imports System.IO
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Imports ClosedXML.Excel
Imports System.Drawing
Partial Class Conta_LibroMayor2
Inherits ClsPaginas
@@ -12,7 +16,11 @@ Partial Class Conta_LibroMayor2
#Region "PROPIEDADES"
Private Property DtDatos As DataTable
Get
DtDatos = DirectCast(ViewState("DtDatos"), DataTable)
If ViewState("DtDatos") Is Nothing Then
ViewState("DtDatos") = New DataTable
End If
Return DirectCast(ViewState("DtDatos"), DataTable)
End Get
Set(ByVal value As DataTable)
@@ -82,14 +90,12 @@ Partial Class Conta_LibroMayor2
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.CveEmpresa <> 119 Then
' Response.Redirect($"/Contabilidad/RepMovimientosAuxiliaresCatalogo.aspx")
'End If
Dim ErrorParametros As Boolean = True
CargaTipoCuentas()
'TxtCuenta.Enabled = False
txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString
txtFechaF.Text = NowADS().LastDayOfMonth.ToShortDateString
@@ -109,7 +115,7 @@ Partial Class Conta_LibroMayor2
txtFechaI.Text = FechaInicio.ToShortDateString
Else
FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1)
TxtFechaF.Text = FechaInicio.ToShortDateString
txtFechaF.Text = FechaInicio.ToShortDateString
End If
If Request("CveProyecto") IsNot Nothing AndAlso IsNumeric(Request("CveProyecto")) Then
@@ -126,20 +132,9 @@ Partial Class Conta_LibroMayor2
If Request("TP") IsNot Nothing AndAlso IsNumeric(Request("TP")) AndAlso Request("TP").ToEntero > 0 Then
TipoReporte = Request("TP").ToString
' DdlTipoReporte.SelectedValue = TipoReporte.ToString
End If
''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("Cvecuenta = {0}", IdCuenta)).Rows.Count > 0 Then
'' TxtCuenta.Text = DTCuentas.FiltraParametros(String.Format("CveCuenta = {0}", IdCuenta)).Rows(0)("Codigo").ToString
'' End If
''End If
End If
End If
@@ -163,23 +158,11 @@ Partial Class Conta_LibroMayor2
CargaDatos()
End If
' 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
For Each dr As DataRow In dt.Rows
i += 1
Str.AppendFormat("{{value:""{0}"",label:""{1}""}}{2}", dr("CveCuenta"), dr("Codigo").ToString.Replace("""", ""), If(i < dt.Rows.Count, ",", ""))
Next
Return Str.ToString
End Function
Private Sub CargaTipoCuentas()
Dim ObjTipoCuenta As New ClsContabilidad
@@ -200,15 +183,11 @@ Partial Class Conta_LibroMayor2
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged
CargarSubProyecto(DdlSubproyecto, DdlProyecto.SelectedValue, "Todos")
End Sub
Private Sub CargaDatos()
Private Sub CargaDatos(Optional RenderGv As Boolean = True)
Dim CveProyecto As Integer = DdlProyecto.SelectedValue.ToEntero
Dim CveSubProyecto As Integer = DdlSubproyecto.SelectedValue.ToEntero
TipoReporte = DdlTipoReporte.SelectedValue.ToString
'If TipoReporte = "1" And DdlCuentas.SelectedValue.ToEntero < 0 Then
' Alert("No ha seleccionado cuenta, Favor de especificar una", TipoMensaje.MsgAdvertencia)
' Exit Sub
'End If
Cuenta = DdlCuentas.SelectedItem.ToString
Dim ObjConta As New ClsContabilidad
@@ -216,7 +195,10 @@ Partial Class Conta_LibroMayor2
DtDatos = ObjConta.DtResultados
DtTotales = DtDatos.Clone
CargaGrid()
If RenderGv Then
CargaGrid()
End If
Else
DtDatos = Nothing
End If
@@ -287,6 +269,11 @@ Partial Class Conta_LibroMayor2
UpDatos.Update()
End Sub
Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.Header Then
e.Row.FCLabel("LblSubProyecto").Text = LblSubProyecto.Text
End If
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DBCampo("Concepto") = "" Then
@@ -378,7 +365,7 @@ Partial Class Conta_LibroMayor2
#End Region
Protected Sub Imprimir_click(sender As Object, e As EventArgs) Handles Imprimir.Click
Protected Sub Imprimir_click(sender As Object, e As EventArgs)
If DdlCuentas.SelectedValue.ToEntero = -1 Then
Alert("El campo Cuenta es obligatorio.", TipoMensaje.MsgError)
Else
@@ -392,62 +379,365 @@ Partial Class Conta_LibroMayor2
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
ImprimirReporte("Excel")
'Dim htmlTabe As New HtmlTable
'Dim RutaLogo As String = $"{UsuarioActual.Empresa.Ruta}Logo.png"
'Dim strinLiteral As String = ""
'Dim EncabezadoLiteral As New LiteralControl
'If System.IO.File.Exists(RutaLogo) Then
' RutaLogo = $"http://{Request.Url.Host }/Empresas/{UsuarioActual.CveEmpresa}/Logo.png"
' strinLiteral = $"<table style='width:{ GvDatos.Width }px'><tr>
' <td colspan='3' style='width:15%;height:150px; text-align:center; vertical-align:middle;font-weight: bold;'><img width='200px' height='150px' style='max-height:150px!important;max-width:200px!important' src='{RutaLogo}' /> </td>
' <td colspan='3' style='width:70%;height:150px; text-align:center; vertical-align:middle;font-weight: bold; display: block;'><p><span>{UsuarioActual.Empresa.Empresa} </span><br><span> Movimientos Auxiliares del Catálogo<p></td>
' <td colspan='3' style='width:15%;height:150px; text-align:center; vertical-align:middle;font-weight: bold;'> Fecha:{NowADS().ToString("dd/MM/yyyy")}</td>
' </tr>
' <tr>
' <td style='text-align:left;' colspan='6'>
' <b>Filtros Cuenta:</b> {DdlCuentas.SelectedItem.Text} <b>Fecha inicio: </b>{ TxtFechaDel.Text} <b>Fecha Fin:</b> {TxtFechaAl.Text}
' <td>
' </tr>
' </table>"
'Else
' strinLiteral = $"<table style='width:{ GvDatos.Width }px'><tr>
' <td colspan='3' style='width:15%;height:150px; text-align:center; vertical-align:middle;font-weight: bold;'> </td>
' <td colspan='3' style='width:70%;height:150px; text-align:center; vertical-align:middle;font-weight: bold; display: block;'><p><span>{UsuarioActual.Empresa.Empresa} </span><br><span> Movimientos Auxiliares del Catálogo<p></td>
' <td colspan='3' style='width:15%;height:150px; text-align:center; vertical-align:middle;font-weight: bold;'> Fecha:{NowADS().ToString("dd/MM/yyyy")}</td>
' </tr>
' <tr>
' <td style='text-align:left;' colspan='9'>
' <b>Filtros Cuenta:</b> {DdlCuentas.SelectedItem.Text} <b>Fecha inicio: </b>{ TxtFechaDel.Text} <b>Fecha Fin:</b> {TxtFechaAl.Text}
' <td>
' <tr>
' </table>"
'End If
'EncabezadoLiteral.Text = strinLiteral
'GvDatos.ExportToExcel($"MovimientosAuxiliares_{NowADS().ToString("yyyyMMddmmss")}", Encabezado2:=EncabezadoLiteral)
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("pFechaInicio", FechaInicio.ToString("dd/MM/yyyy")))
params.Add(New ReportParameter("CveMoneda", "1"))
params.Add(New ReportParameter("Cuenta", Cuenta))
ImprimirPDF("Empresas/Grales/Formatos/RepMovimientosAuxiliaresCatalogo.rdlc", DtDatos, params, "MovimientosAuxiliares", Formato)
Dim WBLibroMayor = New ClosedXML.Excel.XLWorkbook
Dim TipoReporte = DdlTipoReporte.SelectedValue.ToEntero
FechaInicio = If(txtFechaI.Text = "" Or txtFechaI.Text = "__/__/____", NowADS(), txtFechaI.Text.ToDate)
FechaFin = If(txtFechaF.Text = "" Or txtFechaF.Text = "__/__/____", NowADS(), txtFechaF.Text.ToDate)
DtDatos.Rows.Clear()
CargaDatos(False)
If DtDatos.Rows.Count > 0 Then
Dim sp As String = If(DdlSubproyecto.SelectedValue.ToEntero > 0, DdlSubproyecto.SelectedItem.Text, "")
WBLibroMayor.AddWorksheet(WSDocumento(sp, DtDatos))
WBLibroMayor.Worksheet(1).Name = $"LibroMayor"
End If
Dim msB = New MemoryStream()
WBLibroMayor.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.End()
End Sub
Function WSDocumento(SubProyecto As String, DtDatos As DataTable) As IXLWorksheet
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:J1").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
WSReporte.Range("A2:J2").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
WSReporte.Range("A3:J3").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
WSReporte.Range("A4:J4").Merge().Style.Font.SetBold().Font.FontSize = Tamaniofuente
WSReporte.Range("A5:J5").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 = 15
WSReporte.Column(3).Width = 14
WSReporte.Column(4).Width = 70
WSReporte.Column(5).Width = 35
WSReporte.Column(6).Width = 20
WSReporte.Column(7).Width = 14
WSReporte.Column(8).Width = 14
WSReporte.Column(9).Width = 14
WSReporte.Column(10).Width = 14
WSReporte.Cell(1, 1).Value = UsuarioActual.Empresa.Empresa
WSReporte.Cell(2, 1).Value = $"Libro Mayor del {txtFechaI.Text} al {txtFechaF.Text}"
If SubProyecto.Length > 0 Then
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
End If
WSReporte.Cell(6, 1).Value = "Fecha"
WSReporte.Cell(6, 2).Value = $"Cuenta{vbCrLf}Tipo"
WSReporte.Cell(6, 1).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center
WSReporte.Cell(6, 2).Style.Alignment.Vertical = XLAlignmentVerticalValues.Center
WSReporte.Cell(6, 3).Value = $"Número"
WSReporte.Cell(6, 4).Value = $"Concepto"
WSReporte.Cell(6, 5).Value = $"Referencia"
WSReporte.Cell(6, 6).Value = $"Referencia Movto"
WSReporte.Cell(6, 7).Value = $"{LblSubProyecto.Text}"
WSReporte.Cell(6, 8).Value = $"Cargos"
WSReporte.Cell(6, 9).Value = $"Abonos"
WSReporte.Cell(6, 10).Value = $"Saldo"
WSReporte.Range("A6:J6").Style.Font.Bold = True
WSReporte.Range("A6:J6").Style.Font.FontSize = 10
WSReporte.Range("A6:J6").Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Center)
WSReporte.Range("A6:J6").Style.Border.TopBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
WSReporte.Range("A6:J6").Style.Border.BottomBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
WSReporte.Range("A6:J6").Style.Border.RightBorder = ClosedXML.Excel.XLBorderStyleValues.Medium
Dim CuerrentRow As Integer = 7
CuerrentRow = CuerrentRow + 1
For Each Drow As DataRow In DtDatos.Rows
If Drow("Concepto").ToString = "" Then
WSReporte.Range($"A{CuerrentRow }:J{CuerrentRow }").Style.Font.Bold = True
WSReporte.Range($"A{CuerrentRow }:J{CuerrentRow }").Style.Font.FontSize = FontSize.XXLarge '35
If Drow("SaldoActual").ToString = "" Then
'CType(e.Row.FindControl("tr2"), HtmlTableRow).Visible = False
'Cuando Es Total
WSReporte.Cell(CuerrentRow, 1).Value = Drow("Codigo").ToString
WSReporte.Cell(CuerrentRow, 4).Value = Drow("Nombre").ToString
WSReporte.Cell(CuerrentRow, 9).Value = "Saldo Inicial:"
WSReporte.Cell(CuerrentRow, 10).Value = Drow("SaldoInicial").ToString
WSReporte.Cell(CuerrentRow, 10).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
WSReporte.Cell(CuerrentRow, 10).Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
If Drow("SaldoInicial").ToString.ToDecimal < 0 Then
WSReporte.Cell(CuerrentRow, 10).Style.Font.FontColor = XLColor.Red
End If
Else
'CType(e.Row.FindControl("tr1"), HtmlTableRow).Visible = False
WSReporte.Cell(CuerrentRow, 1).Value = Drow("Fecha").ToString
WSReporte.Cell(CuerrentRow, 2).Value = Drow("TipoPoliza").ToString
WSReporte.Cell(CuerrentRow, 3).Value = Drow("Folio").ToString
WSReporte.Cell(CuerrentRow, 4).Value = Drow("Concepto").ToString
WSReporte.Cell(CuerrentRow, 5).Value = Drow("Referencia").ToString
WSReporte.Cell(CuerrentRow, 6).Value = Drow("ReferenciaAdmin").ToString
WSReporte.Cell(CuerrentRow, 7).Value = Drow("SubProyecto").ToString
If TotalPadre Then
WSReporte.Cell(CuerrentRow, 5).Value = String.Format("Total {0}:", Drow("Nombre").ToString)
WSReporte.Cell(CuerrentRow, 5).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
Else
TotalPadre = True
WSReporte.Cell(CuerrentRow, 5).Style.Font.Bold = False
WSReporte.Cell(CuerrentRow, 5).Value = "Total:"
WSReporte.Cell(CuerrentRow, 5).Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
End If
WSReporte.Cell(CuerrentRow, 8).Value = Drow("Cargos").ToString.FormatoNumero(If("1" = "1", 2, 4))
WSReporte.Cell(CuerrentRow, 9).Value = Drow("Abonos").ToString.FormatoNumero(If("1" = "1", 2, 4))
WSReporte.Cell(CuerrentRow, 10).Value = Drow("SaldoActual").ToString.FormatoNumero(If("1" = "1", 2, 4))
WSReporte.Range($"H{CuerrentRow}:J{CuerrentRow}").Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
WSReporte.Range($"H{CuerrentRow}:J{CuerrentRow}").Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
If Drow("Cargos").ToString.ToDecimal < 0 Then
WSReporte.Cell(CuerrentRow, 8).Style.Font.FontColor = XLColor.Red
End If
If Drow("Abonos").ToString.ToDecimal < 0 Then
WSReporte.Cell(CuerrentRow, 9).Style.Font.FontColor = XLColor.Red
End If
If Drow("SaldoActual").ToString.ToDecimal < 0 Then
WSReporte.Cell(CuerrentRow, 10).Style.Font.FontColor = XLColor.Red
End If
End If
Else
WSReporte.Cell(CuerrentRow, 1).Value = Drow("Fecha").ToString
WSReporte.Cell(CuerrentRow, 2).Value = Drow("TipoPoliza").ToString
WSReporte.Cell(CuerrentRow, 3).Value = Drow("Folio").ToString
WSReporte.Cell(CuerrentRow, 4).Value = Drow("Concepto").ToString
WSReporte.Cell(CuerrentRow, 5).Value = Drow("Referencia").ToString
WSReporte.Cell(CuerrentRow, 6).Value = Drow("ReferenciaAdmin").ToString
WSReporte.Cell(CuerrentRow, 7).Value = Drow("SubProyecto").ToString
TotalPadre = False
WSReporte.Range($"A{CuerrentRow }:J{CuerrentRow }").Style.Font.Bold = False
WSReporte.Cell(CuerrentRow, 10).Value = Drow("Folio").ToString
WSReporte.Cell(CuerrentRow, 8).Value = Drow("CargosMovto").ToString.FormatoNumero(If("1" = "1", 2, 4))
WSReporte.Cell(CuerrentRow, 9).Value = Drow("AbonosMovto").ToString.FormatoNumero(If("1" = "1", 2, 4))
WSReporte.Cell(CuerrentRow, 10).Value = Drow("Saldo").ToString.FormatoNumero(If("1" = "1", 2, 4))
WSReporte.Range($"H{CuerrentRow}:J{CuerrentRow}").Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Right)
WSReporte.Range($"H{CuerrentRow}:J{CuerrentRow}").Style.NumberFormat.Format = "#,##0.00; [Black] - #,##0.00 ;""-"""
If Drow("CargosMovto").ToString.ToDecimal < 0 Then
WSReporte.Cell(CuerrentRow, 8).Style.Font.FontColor = XLColor.Red
End If
If Drow("AbonosMovto").ToString.ToDecimal < 0 Then
WSReporte.Cell(CuerrentRow, 9).Style.Font.FontColor = XLColor.Red
End If
If Drow("Saldo").ToString.ToDecimal < 0 Then
WSReporte.Cell(CuerrentRow, 10).Style.Font.FontColor = XLColor.Red
End If
End If
CuerrentRow = CuerrentRow + 1
Next
For xy As Integer = 6 To CuerrentRow
WSReporte.Cell(xy, 10).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.Range($"A{CuerrentRow}:J{CuerrentRow}").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("SaldoID").ToString.ToDecimal
'Dim LastTotalAbonos As Decimal = ultimaFila("TotalAbonos").ToString.ToDecimal
'Dim LastTotalCargos As Decimal = ultimaFila("TotalCargos").ToString.ToDecimal
'Dim LastSaldoAD As Decimal = ultimaFila("SaldoAD").ToString.ToDecimal
'Dim LastSaldoIA As Decimal = ultimaFila("SaldoIA").ToString.ToDecimal
'Dim LastSaldoAA As Decimal = ultimaFila("SaldoAA").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, "LibroMayor")
Return WBReporte.Worksheet(1)
End Function
Public Function CloneGridView(ByVal originalGridView As GridView) As GridView
' Crear un nuevo GridView
Dim clonedGridView As New GridView()
' Copiar propiedades básicas del GridView
clonedGridView.ID = originalGridView.ID & "_Copy"
clonedGridView.AutoGenerateColumns = originalGridView.AutoGenerateColumns
clonedGridView.CssClass = originalGridView.CssClass
clonedGridView.GridLines = originalGridView.GridLines
clonedGridView.HeaderStyle.CopyFrom(originalGridView.HeaderStyle)
clonedGridView.RowStyle.CopyFrom(originalGridView.RowStyle)
clonedGridView.AlternatingRowStyle.CopyFrom(originalGridView.AlternatingRowStyle)
clonedGridView.FooterStyle.CopyFrom(originalGridView.FooterStyle)
clonedGridView.EmptyDataText = originalGridView.EmptyDataText
clonedGridView.ShowHeader = originalGridView.ShowHeader
clonedGridView.ShowFooter = originalGridView.ShowFooter
' Copiar columnas
For Each col As DataControlField In originalGridView.Columns
' Crear una copia de la columna
Dim clonedCol As DataControlField = CType(Activator.CreateInstance(col.GetType()), DataControlField)
clonedCol.HeaderStyle.CopyFrom(col.HeaderStyle)
clonedCol.ItemStyle.CopyFrom(col.ItemStyle)
clonedCol.FooterStyle.CopyFrom(col.FooterStyle)
' Si es un BoundField, copiar propiedades específicas
If TypeOf col Is BoundField Then
Dim originalBoundField As BoundField = CType(col, BoundField)
Dim clonedBoundField As BoundField = CType(clonedCol, BoundField)
clonedBoundField.DataField = originalBoundField.DataField
clonedBoundField.HeaderText = originalBoundField.HeaderText
clonedBoundField.SortExpression = originalBoundField.SortExpression
clonedBoundField.ReadOnly = originalBoundField.ReadOnly
End If
' Añadir la columna clonada al nuevo GridView
clonedGridView.Columns.Add(clonedCol)
Next
' Copiar el DataSource (opcional, dependiendo de si deseas copiar los datos actuales)
clonedGridView.DataSource = originalGridView.DataSource
clonedGridView.DataBind()
Return clonedGridView
End Function
Public Overrides Sub VerifyRenderingInServerForm(control As Control)
End Sub

View File

@@ -3,16 +3,22 @@
<asp:Content ID="Content1" ContentPlaceHolderID="H" runat="Server">
<li>
<asp:LinkButton ID="ImgExcel" runat="server"><i class="fa fa-ad-excel"></i> Exporta Excel</asp:LinkButton>
<asp:LinkButton ID="ImgExcel" runat="server"><i class="fa fa-file-excel-o"></i> Exporta Excel</asp:LinkButton>
<%--<asp:ImageButton ID="ImgExcel" runat="server" ImageUrl="/Imagenes/IconoExcel.gif" Width="20px" Height="20px" />&nbsp; &nbsp;--%>
</li>
<li>
<a id="BtnImprimirPoSubProyecto" runat="server" href="javascript:void(0);" onclick="javascript:BtnImprimirPoSubProyecto_Click(); return false;" >
<i class="fa fa-file-excel-o"></i> Exportar por <asp:Label runat="server" ID="LblAccionesSubProyecto" ></asp:Label>
</a>
<div style="display:none">
<asp:Button runat="server" ID="BtnImprimirPorsubProyecto" OnClick="BtnImprimirPorsubProyecto_Click" ClientIDMode="Static" />
</div>
</li>
<li>
<asp:LinkButton ID="BtnImprimir" runat="server"><i class="fa fa-print"></i> Imprimir</asp:LinkButton>
<%--<asp:ImageButton ID="BtnImprimir" runat="server" alt="Imprimir" src="/Imagenes/btnImprimir.gif" Style="cursor: pointer; height: 20px" Visible="true" /> &nbsp;--%>
</li>
<li>
<asp:LinkButton ID="BtnImprimirPoSubProyecto" runat="server" OnClick="BtnImprimirPoSubProyecto_Click" Visible="false" ><i class="fa fa-print"></i> Imprimir por Sub Proyecto</asp:LinkButton>
</li>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="E" runat="Server">
@@ -218,3 +224,63 @@
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="JS" runat="Server">
<script>
function BtnImprimirPoSubProyecto_Click() {
setTimeout(checkFileStatus, 5000);
$('#BtnImprimirPorsubProyecto').click();
//checkFileStatus();
}
function callMyStaticFunction() {
$.ajax({
type: "POST",
url: "MyPage.aspx/MyStaticFunction",
data: JSON.stringify({ parameter: "TuParametro" }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("Resultado: " + response.d);
},
error: function (xhr, status, error) {
console.error("Error: " + error);
}
});
}
function checkFileStatus() {
//$.ajax({
// url: 'RepBalanzaComprobacion.aspx',
// success: function (response) {
// setTimeout(checkFileStatus, 20000);
// }
//});
$.ajax({
type: "POST",
url: 'RepBalanzaComprobacion.aspx',
data: JSON.stringify({ parameter: "TuParametro" }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
//alert("Resultado: " + response.d);
setTimeout(checkFileStatus, 20000);
},
error: function (xhr, status, error) {
console.error("Error: " + error);
}
});
}
</script>
</asp:Content>

View File

@@ -9,6 +9,7 @@ Imports ClosedXML.Excel
Imports Profact.TimbraCFDI40
Imports System.IO
Imports System.Drawing
Imports System.Web.Services
@@ -111,9 +112,7 @@ Partial Class Contabilidad2_RepBalanzaComprobacion
End If
CargarCentrosDeCosto(DdlProyecto, DdlSubproyecto, LblProyecto, LblSubProyecto)
If UsuarioActual.CveRol = 1 Then
BtnImprimirPoSubProyecto.Visible = True
End If
LblAccionesSubProyecto.Text = LblSubProyecto.Text
End If
End Sub
@@ -265,52 +264,11 @@ Partial Class Contabilidad2_RepBalanzaComprobacion
End Sub
Protected Sub BtnImprimirPoSubProyecto_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
For Each drSP As DataRow In GlobalDTSubProyectos(UsuarioActual.CveEmpresa).Rows
Dim ObjConta As New ClsContabilidad
If ObjConta.GetBalanzaComprobacion(FechaInicio, FechaFin, 2, TipoReporte, -1, drSP("CveSubProyecto").ToString.ToEntero, 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)
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
'Protected Sub BtnImprimirPoSubProyecto_Click(sender As Object, e As EventArgs)
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.End()
End Sub
'End Sub
Function WSDocumento(SubProyecto As String, DtDatos As DataTable) As IXLWorksheet
@@ -498,4 +456,59 @@ Partial Class Contabilidad2_RepBalanzaComprobacion
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