diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index a1016870a..a4082fd46 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -10127,6 +10127,7 @@ Public Class ClsPaginas PaginaDict.Add("/Contabilidad/RepFisImpuestos.aspx".ToUpper(), 432) PaginaDict.Add("/Contabilidad/LibroDiario.aspx".ToUpper(), 620) PaginaDict.Add("/Contabilidad/LibroMayor.aspx".ToUpper(), 619) + PaginaDict.Add("/Contabilidad/LibroMayorCI.aspx".ToUpper(), 619) PaginaDict.Add("/Contabilidad/Reportes/RepCuadreContaAdmon.aspx".ToUpper(), -1) PaginaDict.Add("/Contabilidad/Reportes/RepCuadreContaAdmonDetalle.aspx".ToUpper(), -1) PaginaDict.Add("/Contabilidad/ComparacionesContabilidad.aspx".ToUpper(), 330) @@ -10168,7 +10169,7 @@ Public Class ClsPaginas PaginaDict.Add("/Contabilidad/RepEstadoResultadosHorizontal.aspx".ToUpper(), 420) PaginaDict.Add("/Contabilidad/RepAnexoCatalogoMensualHorizontal.aspx".ToUpper(), -1) PaginaDict.Add("/Contabilidad/CatBloqueoDiario.aspx".ToUpper(), 680) - PaginaDict.Add("/Contabilidad/LibroMayor2.aspx".ToUpper(), 1353) + 'PaginaDict.Add("/Contabilidad/LibroMayor2.aspx".ToUpper(), 1353) #End Region diff --git a/Contabilidad/LibroMayor.aspx b/Contabilidad/LibroMayor.aspx index 167d3038a..933b94341 100644 --- a/Contabilidad/LibroMayor.aspx +++ b/Contabilidad/LibroMayor.aspx @@ -1,4 +1,4 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="LibroMayor.aspx.vb" Inherits="Contabilidad_LibroMayor" %> +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="LibroMayor.aspx.vb" Inherits="Conta_LibroMayor" EnableEventValidation="false" %> - +
  • - Generar EXCEL -
  • -
  • - Imprimir + Generar EXCEL
  • -
    + + + <%--
  • + Imprimir +
  • --%> +
    Libro Mayor - -
    - + + "><%--class="expand"--%> +
    - -
    -
    - - - - - - - - - - -
    -
    - -
    -
    - - - - - - - - - - -
    -
    - <%--
    - + Cuenta: +
    +
    + + -
    --%> + + +
    +
    + Fecha Inicio: +
    +
    +
    + + + + +
    + + + + + + +
    +
    + Fecha Fin: +
    +
    +
    + + + + +
    + + + + + + +
    +
    > +
    +
    + Tipo Movto +
    +
    + + + + + + + +
    +
    + Tipo +
    +
    + + + + + +
    +
    + Proyecto: +
    +
    + + +
    + SubProyecto: +
    + + +
    + +
    +
    -
    -
    - - <%--
    -
    Buscar : - -
    --%> - - - + +
    + " style="display: inline-block; margin-right: -20px; width: 150px;" /> + " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> +
    + - +
    + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +
    CuentaNombreSaldo Inicial
    FechaTipoNúmeroConceptoReferenciaReferencia Movto CargosAbonosSaldo
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + Saldo Inicial: + + +
    + + + + + + +
    + +
    +
    + + + + + + + + + + + +
    +
    + +
    + + +
    + + + +
    - + + + diff --git a/Contabilidad/LibroMayor.aspx.vb b/Contabilidad/LibroMayor.aspx.vb index 10399300b..0f25a5c38 100644 --- a/Contabilidad/LibroMayor.aspx.vb +++ b/Contabilidad/LibroMayor.aspx.vb @@ -2,22 +2,40 @@ 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 Contabilidad_LibroMayor +Partial Class Conta_LibroMayor Inherits ClsPaginas + #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) ViewState("DtDatos") = value End Set End Property + Private Property DtTotales As DataTable + Get + DtTotales = DirectCast(ViewState("DtTotales"), DataTable) + End Get + + Set(ByVal value As DataTable) + ViewState("DtTotales") = value + End Set + End Property Private Property FechaInicio As Date Get FechaInicio = ViewState("FechaInicio").ToString.ToDate @@ -34,147 +52,312 @@ Partial Class Contabilidad_LibroMayor ViewState("FechaFin") = value End Set End Property + + Private Property TotalPadre As Boolean + Get + TotalPadre = CBool(ViewState("TotalPadre")) + End Get + Set(value As Boolean) + ViewState("TotalPadre") = value + End Set + End Property + 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 TipoReporte As String + Get + TipoReporte = ViewState("TP").ToString + End Get + Set(value As String) + ViewState("TP") = value + End Set + End Property + Private Property Cuenta As String + Get + Return ViewState("Cuenta").ToString + End Get + Set(value As String) + ViewState("Cuenta") = 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 - InicializaValores() + If UsuarioActual.Empresa.TipoContabilidad = 2 Then Response.Redirect($"/Contabilidad/LibroMayorCI.aspx") + + Dim ErrorParametros As Boolean = True + + CargaTipoCuentas() + + + txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString + txtFechaF.Text = NowADS().LastDayOfMonth.ToShortDateString + + + If Request("CveCuenta") IsNot Nothing AndAlso IsNumeric(Request("CveCuenta")) AndAlso Request("CveCuenta").ToEntero > 0 Then + If Request("FF") IsNot Nothing AndAlso Request("FF").ToString.Length = 10 AndAlso Request("FF").ToDate > "01/01/1000".ToDate Then + + FechaFin = Request("FF").ToDate + txtFechaF.Text = FechaFin.ToShortDateString + + DdlCuentas.SelectedValueExist(Request("CveCuenta").ToEntero) + + + If Request("FI") IsNot Nothing AndAlso Request("FI").ToString.Length = 10 AndAlso Request("FI").ToDate > "01/01/1000".ToDate Then + FechaInicio = Request("FI").ToDate + txtFechaI.Text = FechaInicio.ToShortDateString + Else + FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1) + txtFechaF.Text = FechaInicio.ToShortDateString + End If + + If Request("CveProyecto") IsNot Nothing AndAlso IsNumeric(Request("CveProyecto")) Then + DdlProyecto.SelectedValueExist(Request("CveProyecto")) + DdlProyecto_SelectedIndexChanged(Nothing, Nothing) + End If + + If Request("CveSubProyecto") IsNot Nothing AndAlso IsNumeric(Request("CveSubProyecto")) Then + DdlSubproyecto.SelectedValueExist(Request("CveSubProyecto")) + End If + + ErrorParametros = False + + If Request("TP") IsNot Nothing AndAlso IsNumeric(Request("TP")) AndAlso Request("TP").ToEntero > 0 Then + TipoReporte = Request("TP").ToString + + End If + - If UsuarioActual.Empresa.UsaAC Then - BtnConsultar.Enabled = True - Else - If UsuarioActual.Empresa.TipoContabilidad = 1 Then - BtnConsultar.Enabled = True - Else - Alert("La empresa no usa Armonización Contable", TipoMensaje.MsgError) End If - End If + If Not ErrorParametros Then + TotalPadre = True + TipoReporte = "1" + CargaDatos() + End If End If End Sub - Private Sub InicializaValores() - - TxtFechaDel.Text = $"01/01/{NowADS().Year}" - TxtFechaAl.Text = NowADS().ToShortDateString - - 'DdlMoneda.DataSource = GlobalDTMonedas - 'DdlMoneda.DataBind() - - End Sub - Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) - CargaDatos() + If DdlCuentas.SelectedValue.ToEntero = -2 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) + + CargaDatos() + End If + End Sub #Region "C A R G A - D A T O S" - Private Sub CargaDatos() - FechaInicio = If(IsDate(TxtFechaDel.Text), TxtFechaDel.Text.ToDate, MinFecha) - FechaFin = If(IsDate(TxtFechaAl.Text), TxtFechaAl.Text.ToDate, MaxFecha) + Private Sub CargaTipoCuentas() + Dim ObjTipoCuenta As New ClsContabilidad + DdlCuentas.Enabled = True + If ObjTipoCuenta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then + DTCuentas = ObjTipoCuenta.DtResultados + DdlCuentas.DataSource = ObjTipoCuenta.DtResultados.FiltraParametros("Codigo NOT IN ('_ACTIVO', '_PASIVO', '_CAPITAL', '_CUADRE', '_ESTADISTICAS', '_ORDEN', '_RACREEDOR', '_RDEUDOR', '_UTILIDAD')") - - If UsuarioActual.Empresa.TipoContabilidad = 1 Then - - - Dim ObjConta As New ClsContabilidad - If ObjConta.GetLibroMayorSIG(-1, FechaInicio, FechaFin, 1, UsuarioActual.CveEmpresa) Then - DtDatos = ObjConta.DtResultados - Else - DtDatos = Nothing - End If - ObjConta.Dispose() - - - Else - Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) - If ObjConta.GetLibroMayor(1, FechaInicio, FechaFin, 1) Then - DtDatos = ObjConta.DtResultados - Else - DtDatos = Nothing - End If - ObjConta.Dispose() End If + ObjTipoCuenta.Dispose() + DdlCuentas.DataBind() - - - If DtDatos IsNot Nothing Then - ImgExcel.Visible = True - Imprimir.Visible = True - CargaGrid() - Else - ImgExcel.Visible = False - Imprimir.Visible = False - End If + CargarCentrosDeCosto(DdlProyecto, DdlSubproyecto, LblProyecto, LblSubProyecto, divProyecto:=divProyecto) End Sub + + Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged + CargarSubProyecto(DdlSubproyecto, DdlProyecto.SelectedValue, "Todos") + End Sub + 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 + + Cuenta = DdlCuentas.SelectedItem.ToString + Dim ObjConta As New ClsContabilidad + If ObjConta.GetLibroMayor2(DdlCuentas.SelectedValue.ToEntero, FechaInicio, FechaFin, -1, CveProyecto, CveSubProyecto, UsuarioActual.CveEmpresa, TipoReporte, DdlOpcionCuentas.SelectedValue.ToEntero) Then + DtDatos = ObjConta.DtResultados + DtTotales = DtDatos.Clone + + If RenderGv Then + CargaGrid() + End If + + Else + DtDatos = Nothing + End If + + ObjConta.Dispose() + End Sub #End Region + Private Sub InsertaTotales() + Dim i As Integer = 0 + Dim Aumento As Integer = 0 + Dim Row As DataRow + Dim Row2 As DataRow + + 'Llena DtTotales + For Each dr As DataRow In DtDatos.Rows + If dr("Concepto").ToString = "" Then + + Row = DtTotales.NewRow + + Row("CveCuenta") = -1 + Row("CargosMovto") = If("1" = "1", dr("Cargos"), dr("CargosME")) + Row("AbonosMovto") = If("1" = "1", dr("Abonos"), dr("AbonosME")) + Row("Saldo") = dr("SaldoActual") + Row("CtaMayor") = dr("CtaMayor") + Row("Concepto") = String.Format("Total {0}:", dr("Nombre")) + Row("Nombre") = dr("Nombre") + DtTotales.Rows.Add(Row) + Row("Clasificacion") = i + End If + + i += 1 + Next + + 'Inserta Totales en DtDatos + For Each dr As DataRow In DtTotales.Rows + i = 0 + + If dr("CtaMayor").ToString = "1" Then + DtDatos.ImportRow(dr) + End If + + If dr("CtaMayor").ToString = "2" Then + For index As Integer = dr("Clasificacion").ToString.ToEntero + Aumento To DtDatos.Rows.Count + If DtDatos.Rows(index)("Nombre").ToString <> dr("Nombre").ToString Then + i = index + Exit For + End If + Next + + Row2 = DtDatos.NewRow + Row2.ItemArray = dr.ItemArray + + DtDatos.Rows.InsertAt(Row2, i + Aumento) + Aumento += 1 + End If + + Next + + End Sub + #Region "G R I D - GV DATOS" Private Sub CargaGrid() GvDatos.DataSource = DtDatos + 'GvDatos.Dispose() GvDatos.DataBind() UpDatos.Update() End Sub - Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound + 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 + e.Row.ControlStyle.Font.Bold = True + e.Row.ControlStyle.Height = 35 - '0 Fecha - '1 TipoPol - '2 Folio - '3 Concepto - '4 Cargos - '5 Abonos - '6 Saldo + 'Cuando es Titulo + If e.Row.DBCampo("SaldoActual") = "" Then + CType(e.Row.FindControl("tr2"), HtmlTableRow).Visible = False - 'CABECERA - If e.Row.DBCampo("TipoRenglon") = "1" Then - e.Row.Font.Bold = True - e.Row.Cells(0).Text = "" - e.Row.Cells(1).Text = "" - e.Row.Cells(2).Text = "" - e.Row.Cells(3).Text = e.Row.DBCampo("Nombre") - e.Row.Cells(4).Text = "" - e.Row.Cells(5).Text = "Saldo inicial:" - e.Row.Cells(6).Text = e.Row.DBCampo("SaldoInicial").FormatoNumero - e.Row.CssClass = "Totales" - End If - 'DETALLE - If e.Row.DBCampo("TipoRenglon") = "2" Then + 'Cuando Es Total + Else + CType(e.Row.FindControl("tr1"), HtmlTableRow).Visible = False + + 'Anterior para TotalPadre + 'If e.Row.DBCampo("CtaMayor").ToString = "2" And (e.Row.DBCampo("Nivel3").ToString <> "" Xor e.Row.DBCampo("Orden").ToString.Length = 18) Then + ' e.Row.FCLabel("LbReferencia").Text = "Total:" + 'Else + ' e.Row.FCLabel("LbConcepto").Text = String.Format("Total {0}:", e.Row.DBCampo("Nombre").ToString) + 'End If + + If TotalPadre Then + CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3).Width = "1px" + 'CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells.Remove(CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3)) + CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3).Align = "Right" + CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3).Width = "400px" + If e.Row.RowIndex + 1 = DtDatos.Rows.Count Then + CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(4).Attributes.Add("style", "border-top: 1px solid black;") + CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(5).Attributes.Add("style", "border-top: 1px solid black;") + CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(6).Attributes.Add("style", "border-top: 1px solid black;") + End If + e.Row.FCLabel("LbReferencia").Text = String.Format("Total {0}:", e.Row.DBCampo("Nombre").ToString) + + + Else + TotalPadre = True + e.Row.FCLabel("LbReferencia").Font.Bold = False + e.Row.FCLabel("LbReferencia").Text = "Total:" + CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(4).Align = "Right" + End If + + 'e.Row.FCLabel("LbReferencia").Text = String.Format("Total {0}:", If(e.Row.DBCampo("CtaMayor").ToString = "2", "", e.Row.DBCampo("Nombre").ToString)) + e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("Cargos").ToString.FormatoNumero(If("1" = "1", 2, 4)) + e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("Abonos").ToString.FormatoNumero(If("1" = "1", 2, 4)) + e.Row.FCLabel("LbSaldo").Text = e.Row.DBCampo("SaldoActual").ToString.FormatoNumero(If("1" = "1", 2, 4)) + End If + + Else + TotalPadre = False + e.Row.ControlStyle.Font.Bold = False + CType(e.Row.FindControl("tr1"), HtmlTableRow).Visible = False + e.Row.FCHyperLink("HLPoliza").NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", e.Row.DBCampo("CvePoliza")) + + If e.Row.DBCampo("CargosMovto").ToDouble <> 0 Then e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("CargosMovto").ToString.FormatoNumero(If("1" = "1", 2, 4)) + If e.Row.DBCampo("AbonosMovto").ToDouble <> 0 Then e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("AbonosMovto").ToString.FormatoNumero(If("1" = "1", 2, 4)) + If e.Row.DBCampo("Saldo").ToDouble <> 0 Then e.Row.FCLabel("LbSaldo").Text = e.Row.DBCampo("Saldo").ToString.FormatoNumero(If("1" = "1", 2, 4)) End If - 'SUBTOTAL - If e.Row.DBCampo("TipoRenglon") = "3" Then - e.Row.Font.Bold = True - e.Row.Cells(1).Text = "" - e.Row.Cells(2).Text = "" - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(3).Text = "SubTotal:" - e.Row.Cells(6).Text = "" - e.Row.CssClass = "SubTotales" + + 'COLOREA NEGATIVOS + If e.Row.FCLabel("LbCargos").Text.ToDouble < 0 Then + e.Row.FCLabel("LbCargos").ForeColor = Drawing.Color.Red + Else + e.Row.FCLabel("LbCargos").ForeColor = Drawing.Color.Black End If - 'TOTAL - If e.Row.DBCampo("TipoRenglon") = "4" Then - e.Row.Font.Bold = True - e.Row.Cells(0).Text = "" - e.Row.Cells(1).Text = "" - e.Row.Cells(2).Text = "" - e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right - e.Row.Cells(3).Text = $"Total ({e.Row.DBCampo("Nombre")}):" - e.Row.Cells(6).Text = "" - e.Row.CssClass = "Totales" + If e.Row.FCLabel("LbAbonos").Text.ToDouble < 0 Then + e.Row.FCLabel("LbAbonos").ForeColor = Drawing.Color.Red + Else + e.Row.FCLabel("LbAbonos").ForeColor = Drawing.Color.Black + End If + + If e.Row.FCLabel("LbSaldo").Text.ToDouble < 0 Then + e.Row.FCLabel("LbSaldo").ForeColor = Drawing.Color.Red + Else + e.Row.FCLabel("LbSaldo").ForeColor = Drawing.Color.Black + End If + + If e.Row.FCLabel("LbSaldoInicial").Text.ToDouble < 0 Then + e.Row.FCLabel("LbSaldoInicial").ForeColor = Drawing.Color.Red + Else + e.Row.FCLabel("LbSaldoInicial").ForeColor = Drawing.Color.Black End If End If @@ -182,37 +365,382 @@ Partial Class Contabilidad_LibroMayor #End Region + 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 + FechaInicio = If(txtFechaI.Text = "" Or txtFechaI.Text = "__/__/____", NowADS(), txtFechaI.Text.ToDate) + FechaFin = If(txtFechaF.Text = "" Or txtFechaF.Text = "__/__/____", NowADS(), txtFechaF.Text.ToDate) -#Region " IMPRIMIR " - -#End Region - - Protected Sub Imprimir_click(sender As Object, e As EventArgs) Handles Imprimir.Click - FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate) - FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate) - DtDatos = DtDatos - ImprimirReporte() + DtDatos = DtDatos + ImprimirReporte() + End If End Sub Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click - FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate) - FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate) - DtDatos = DtDatos - ImprimirReporte("EXCEL") + ImprimirReporte("Excel") End Sub Private Sub ImprimirReporte(Optional Formato As String = "PDF") - 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) - Dim lista = New List(Of CrystalParametro) - lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa)) - lista.Add(New CrystalParametro("FechaInicio", FechaInicio.ToString("dd/MM/yyyy"))) - lista.Add(New CrystalParametro("FechaFin", FechaFin.ToString("dd/MM/yyyy"))) - lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) - lista.Add(New CrystalParametro("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) + 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() - ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/LibroMayor.rpt"), DtDatos, lista, "LibroMayor", Formato), "LibroMayor", Formato) 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 + + End Class diff --git a/Contabilidad/LibroMayor2.aspx b/Contabilidad/LibroMayor2.aspx deleted file mode 100644 index e327102eb..000000000 --- a/Contabilidad/LibroMayor2.aspx +++ /dev/null @@ -1,265 +0,0 @@ -<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="LibroMayor2.aspx.vb" Inherits="Conta_LibroMayor2" EnableEventValidation="false" %> - - - - - - - -
  • - Generar EXCEL -
  • -
    - - - -
    - - - <%--
  • - Imprimir -
  • --%> - -
    - - Libro Mayor - - - - - -
    -
    -
    - - "><%--class="expand"--%> - -
    -
    -
    -
    - Cuenta: -
    -
    - - - - - -
    -
    - Fecha Inicio: -
    -
    -
    - - - - -
    - - - - - - -
    -
    - Fecha Fin: -
    -
    -
    - - - - -
    - - - - - - -
    -
    -
    -
    -
    > -
    -
    - Tipo Movto -
    -
    - - - - - - - -
    -
    - Tipo -
    -
    - - - - - -
    -
    - Proyecto: -
    -
    - - -
    - SubProyecto: -
    - - -
    - -
    -
    -
    -
    -
    -
    - " style="display: inline-block; margin-right: -20px; width: 150px;" /> - " style="margin-top: -3px;" class="btn btn-circle btn-sm label-info"> -
    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    CuentaNombreSaldo Inicial
    FechaTipoNúmeroConceptoReferenciaReferencia Movto CargosAbonosSaldo
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - Saldo Inicial: - - -
    - - - - - - -
    - -
    -
    - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - - -
    -
    - - - - - -
    - - - - - - diff --git a/Contabilidad/LibroMayor2.aspx.vb b/Contabilidad/LibroMayor2.aspx.vb deleted file mode 100644 index 5cc1c9ffe..000000000 --- a/Contabilidad/LibroMayor2.aspx.vb +++ /dev/null @@ -1,746 +0,0 @@ -Option Explicit On -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 - - -#Region "PROPIEDADES" - Private Property DtDatos As DataTable - Get - If ViewState("DtDatos") Is Nothing Then - ViewState("DtDatos") = New DataTable - End If - - Return DirectCast(ViewState("DtDatos"), DataTable) - End Get - - Set(ByVal value As DataTable) - ViewState("DtDatos") = value - End Set - End Property - Private Property DtTotales As DataTable - Get - DtTotales = DirectCast(ViewState("DtTotales"), DataTable) - End Get - - Set(ByVal value As DataTable) - ViewState("DtTotales") = 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 TotalPadre As Boolean - Get - TotalPadre = CBool(ViewState("TotalPadre")) - End Get - Set(value As Boolean) - ViewState("TotalPadre") = value - End Set - End Property - 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 TipoReporte As String - Get - TipoReporte = ViewState("TP").ToString - End Get - Set(value As String) - ViewState("TP") = value - End Set - End Property - Private Property Cuenta As String - Get - Return ViewState("Cuenta").ToString - End Get - Set(value As String) - ViewState("Cuenta") = 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 - - - - Dim ErrorParametros As Boolean = True - - CargaTipoCuentas() - - - txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString - txtFechaF.Text = NowADS().LastDayOfMonth.ToShortDateString - - - If Request("CveCuenta") IsNot Nothing AndAlso IsNumeric(Request("CveCuenta")) AndAlso Request("CveCuenta").ToEntero > 0 Then - If Request("FF") IsNot Nothing AndAlso Request("FF").ToString.Length = 10 AndAlso Request("FF").ToDate > "01/01/1000".ToDate Then - - FechaFin = Request("FF").ToDate - txtFechaF.Text = FechaFin.ToShortDateString - - DdlCuentas.SelectedValueExist(Request("CveCuenta").ToEntero) - - - If Request("FI") IsNot Nothing AndAlso Request("FI").ToString.Length = 10 AndAlso Request("FI").ToDate > "01/01/1000".ToDate Then - FechaInicio = Request("FI").ToDate - txtFechaI.Text = FechaInicio.ToShortDateString - Else - FechaInicio = DateSerial(Year(FechaFin), Month(FechaFin), 1) - txtFechaF.Text = FechaInicio.ToShortDateString - End If - - If Request("CveProyecto") IsNot Nothing AndAlso IsNumeric(Request("CveProyecto")) Then - DdlProyecto.SelectedValueExist(Request("CveProyecto")) - DdlProyecto_SelectedIndexChanged(Nothing, Nothing) - End If - - If Request("CveSubProyecto") IsNot Nothing AndAlso IsNumeric(Request("CveSubProyecto")) Then - DdlSubproyecto.SelectedValueExist(Request("CveSubProyecto")) - End If - - ErrorParametros = False - - If Request("TP") IsNot Nothing AndAlso IsNumeric(Request("TP")) AndAlso Request("TP").ToEntero > 0 Then - TipoReporte = Request("TP").ToString - - End If - - - - End If - End If - - - If Not ErrorParametros Then - TotalPadre = True - TipoReporte = "1" - CargaDatos() - End If - - End If - End Sub - - Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) - If DdlCuentas.SelectedValue.ToEntero = -2 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) - - CargaDatos() - End If - - End Sub - -#Region "C A R G A - D A T O S" - - Private Sub CargaTipoCuentas() - - Dim ObjTipoCuenta As New ClsContabilidad - DdlCuentas.Enabled = True - - If ObjTipoCuenta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then - DTCuentas = ObjTipoCuenta.DtResultados - DdlCuentas.DataSource = ObjTipoCuenta.DtResultados.FiltraParametros("Codigo NOT IN ('_ACTIVO', '_PASIVO', '_CAPITAL', '_CUADRE', '_ESTADISTICAS', '_ORDEN', '_RACREEDOR', '_RDEUDOR', '_UTILIDAD')") - - End If - ObjTipoCuenta.Dispose() - DdlCuentas.DataBind() - - CargarCentrosDeCosto(DdlProyecto, DdlSubproyecto, LblProyecto, LblSubProyecto, divProyecto:=divProyecto) - - End Sub - - Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProyecto.SelectedIndexChanged - CargarSubProyecto(DdlSubproyecto, DdlProyecto.SelectedValue, "Todos") - End Sub - 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 - - Cuenta = DdlCuentas.SelectedItem.ToString - Dim ObjConta As New ClsContabilidad - If ObjConta.GetLibroMayor2(DdlCuentas.SelectedValue.ToEntero, FechaInicio, FechaFin, -1, CveProyecto, CveSubProyecto, UsuarioActual.CveEmpresa, TipoReporte, DdlOpcionCuentas.SelectedValue.ToEntero) Then - DtDatos = ObjConta.DtResultados - DtTotales = DtDatos.Clone - - If RenderGv Then - CargaGrid() - End If - - Else - DtDatos = Nothing - End If - - ObjConta.Dispose() - End Sub -#End Region - - Private Sub InsertaTotales() - Dim i As Integer = 0 - Dim Aumento As Integer = 0 - Dim Row As DataRow - Dim Row2 As DataRow - - 'Llena DtTotales - For Each dr As DataRow In DtDatos.Rows - If dr("Concepto").ToString = "" Then - - Row = DtTotales.NewRow - - Row("CveCuenta") = -1 - Row("CargosMovto") = If("1" = "1", dr("Cargos"), dr("CargosME")) - Row("AbonosMovto") = If("1" = "1", dr("Abonos"), dr("AbonosME")) - Row("Saldo") = dr("SaldoActual") - Row("CtaMayor") = dr("CtaMayor") - Row("Concepto") = String.Format("Total {0}:", dr("Nombre")) - Row("Nombre") = dr("Nombre") - DtTotales.Rows.Add(Row) - Row("Clasificacion") = i - End If - - i += 1 - Next - - 'Inserta Totales en DtDatos - For Each dr As DataRow In DtTotales.Rows - i = 0 - - If dr("CtaMayor").ToString = "1" Then - DtDatos.ImportRow(dr) - End If - - If dr("CtaMayor").ToString = "2" Then - For index As Integer = dr("Clasificacion").ToString.ToEntero + Aumento To DtDatos.Rows.Count - If DtDatos.Rows(index)("Nombre").ToString <> dr("Nombre").ToString Then - i = index - Exit For - End If - Next - - Row2 = DtDatos.NewRow - Row2.ItemArray = dr.ItemArray - - DtDatos.Rows.InsertAt(Row2, i + Aumento) - Aumento += 1 - End If - - Next - - End Sub - - -#Region "G R I D - GV DATOS" - Private Sub CargaGrid() - GvDatos.DataSource = DtDatos - 'GvDatos.Dispose() - GvDatos.DataBind() - 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 - e.Row.ControlStyle.Font.Bold = True - e.Row.ControlStyle.Height = 35 - - 'Cuando es Titulo - If e.Row.DBCampo("SaldoActual") = "" Then - CType(e.Row.FindControl("tr2"), HtmlTableRow).Visible = False - - - 'Cuando Es Total - Else - CType(e.Row.FindControl("tr1"), HtmlTableRow).Visible = False - - 'Anterior para TotalPadre - 'If e.Row.DBCampo("CtaMayor").ToString = "2" And (e.Row.DBCampo("Nivel3").ToString <> "" Xor e.Row.DBCampo("Orden").ToString.Length = 18) Then - ' e.Row.FCLabel("LbReferencia").Text = "Total:" - 'Else - ' e.Row.FCLabel("LbConcepto").Text = String.Format("Total {0}:", e.Row.DBCampo("Nombre").ToString) - 'End If - - If TotalPadre Then - CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3).Width = "1px" - 'CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells.Remove(CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3)) - CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3).Align = "Right" - CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(3).Width = "400px" - If e.Row.RowIndex + 1 = DtDatos.Rows.Count Then - CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(4).Attributes.Add("style", "border-top: 1px solid black;") - CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(5).Attributes.Add("style", "border-top: 1px solid black;") - CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(6).Attributes.Add("style", "border-top: 1px solid black;") - End If - e.Row.FCLabel("LbReferencia").Text = String.Format("Total {0}:", e.Row.DBCampo("Nombre").ToString) - - - Else - TotalPadre = True - e.Row.FCLabel("LbReferencia").Font.Bold = False - e.Row.FCLabel("LbReferencia").Text = "Total:" - CType(e.Row.FindControl("tr2"), HtmlTableRow).Cells(4).Align = "Right" - End If - - 'e.Row.FCLabel("LbReferencia").Text = String.Format("Total {0}:", If(e.Row.DBCampo("CtaMayor").ToString = "2", "", e.Row.DBCampo("Nombre").ToString)) - e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("Cargos").ToString.FormatoNumero(If("1" = "1", 2, 4)) - e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("Abonos").ToString.FormatoNumero(If("1" = "1", 2, 4)) - e.Row.FCLabel("LbSaldo").Text = e.Row.DBCampo("SaldoActual").ToString.FormatoNumero(If("1" = "1", 2, 4)) - End If - - Else - TotalPadre = False - e.Row.ControlStyle.Font.Bold = False - CType(e.Row.FindControl("tr1"), HtmlTableRow).Visible = False - e.Row.FCHyperLink("HLPoliza").NavigateUrl = String.Format("/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}", e.Row.DBCampo("CvePoliza")) - - If e.Row.DBCampo("CargosMovto").ToDouble <> 0 Then e.Row.FCLabel("LbCargos").Text = e.Row.DBCampo("CargosMovto").ToString.FormatoNumero(If("1" = "1", 2, 4)) - If e.Row.DBCampo("AbonosMovto").ToDouble <> 0 Then e.Row.FCLabel("LbAbonos").Text = e.Row.DBCampo("AbonosMovto").ToString.FormatoNumero(If("1" = "1", 2, 4)) - If e.Row.DBCampo("Saldo").ToDouble <> 0 Then e.Row.FCLabel("LbSaldo").Text = e.Row.DBCampo("Saldo").ToString.FormatoNumero(If("1" = "1", 2, 4)) - - End If - - - 'COLOREA NEGATIVOS - If e.Row.FCLabel("LbCargos").Text.ToDouble < 0 Then - e.Row.FCLabel("LbCargos").ForeColor = Drawing.Color.Red - Else - e.Row.FCLabel("LbCargos").ForeColor = Drawing.Color.Black - End If - - If e.Row.FCLabel("LbAbonos").Text.ToDouble < 0 Then - e.Row.FCLabel("LbAbonos").ForeColor = Drawing.Color.Red - Else - e.Row.FCLabel("LbAbonos").ForeColor = Drawing.Color.Black - End If - - If e.Row.FCLabel("LbSaldo").Text.ToDouble < 0 Then - e.Row.FCLabel("LbSaldo").ForeColor = Drawing.Color.Red - Else - e.Row.FCLabel("LbSaldo").ForeColor = Drawing.Color.Black - End If - - If e.Row.FCLabel("LbSaldoInicial").Text.ToDouble < 0 Then - e.Row.FCLabel("LbSaldoInicial").ForeColor = Drawing.Color.Red - Else - e.Row.FCLabel("LbSaldoInicial").ForeColor = Drawing.Color.Black - End If - - End If - End Sub - -#End Region - - 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 - FechaInicio = If(txtFechaI.Text = "" Or txtFechaI.Text = "__/__/____", NowADS(), txtFechaI.Text.ToDate) - FechaFin = If(txtFechaF.Text = "" Or txtFechaF.Text = "__/__/____", NowADS(), txtFechaF.Text.ToDate) - - DtDatos = DtDatos - ImprimirReporte() - End If - 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 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 - - -End Class diff --git a/Contabilidad/LibroMayorCI.aspx b/Contabilidad/LibroMayorCI.aspx new file mode 100644 index 000000000..f2fb39ccc --- /dev/null +++ b/Contabilidad/LibroMayorCI.aspx @@ -0,0 +1,116 @@ +<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="LibroMayorCI.aspx.vb" Inherits="Contabilidad_LibroMayorCI" %> + + + + + + + +
  • + Generar EXCEL +
  • +
  • + Imprimir +
  • +
    + + + + +
    +
    + + Libro Mayor + + + + + + + +
    +
    +
    + +
    +
    +
    + +
    +
    + + + + + + + + + + +
    +
    + +
    +
    + + + + + + + + + + +
    +
    + <%-- +
    + + +
    --%> +
    +
    +
    +
    + +
    +
    + + <%--
    +
    Buscar : + +
    --%> + + + + + + + + + + + + + + + + + + + + +
    + + + + diff --git a/Contabilidad/LibroMayorCI.aspx.vb b/Contabilidad/LibroMayorCI.aspx.vb new file mode 100644 index 000000000..4ab18ef8b --- /dev/null +++ b/Contabilidad/LibroMayorCI.aspx.vb @@ -0,0 +1,220 @@ +Option Explicit On +Option Strict On + +Imports System.Data +Imports Extensiones +Imports Microsoft.Reporting.WebForms + +Partial Class Contabilidad_LibroMayorCI + 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 +#End Region + + Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load + If Not Page.IsPostBack Then + + + + InicializaValores() + + If UsuarioActual.Empresa.UsaAC Then + BtnConsultar.Enabled = True + Else + + If UsuarioActual.Empresa.TipoContabilidad = 1 Then + BtnConsultar.Enabled = True + Else + Alert("La empresa no usa Armonización Contable", TipoMensaje.MsgError) + End If + + End If + + + + End If + End Sub + + Private Sub InicializaValores() + + TxtFechaDel.Text = $"01/01/{NowADS().Year}" + TxtFechaAl.Text = NowADS().ToShortDateString + + 'DdlMoneda.DataSource = GlobalDTMonedas + 'DdlMoneda.DataBind() + + End Sub + + Protected Sub BtnConsultar_Click(sender As Object, e As EventArgs) + CargaDatos() + End Sub + +#Region "C A R G A - D A T O S" + Private Sub CargaDatos() + + FechaInicio = If(IsDate(TxtFechaDel.Text), TxtFechaDel.Text.ToDate, MinFecha) + FechaFin = If(IsDate(TxtFechaAl.Text), TxtFechaAl.Text.ToDate, MaxFecha) + + + + + If UsuarioActual.Empresa.TipoContabilidad = 1 Then + + + Dim ObjConta As New ClsContabilidad + If ObjConta.GetLibroMayorSIG(-1, FechaInicio, FechaFin, 1, UsuarioActual.CveEmpresa) Then + DtDatos = ObjConta.DtResultados + Else + DtDatos = Nothing + End If + ObjConta.Dispose() + + + Else + Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) + If ObjConta.GetLibroMayor(1, FechaInicio, FechaFin, 1) Then + DtDatos = ObjConta.DtResultados + Else + DtDatos = Nothing + End If + ObjConta.Dispose() + End If + + + + If DtDatos IsNot Nothing Then + ImgExcel.Visible = True + Imprimir.Visible = True + CargaGrid() + Else + ImgExcel.Visible = False + Imprimir.Visible = False + End If + + End Sub +#End Region + + +#Region "G R I D - GV DATOS" + Private Sub CargaGrid() + GvDatos.DataSource = DtDatos + GvDatos.DataBind() + UpDatos.Update() + End Sub + Protected Sub GvDatos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDatos.RowDataBound + If e.Row.RowType = DataControlRowType.DataRow Then + + + '0 Fecha + '1 TipoPol + '2 Folio + '3 Concepto + '4 Cargos + '5 Abonos + '6 Saldo + + 'CABECERA + If e.Row.DBCampo("TipoRenglon") = "1" Then + e.Row.Font.Bold = True + e.Row.Cells(0).Text = "" + e.Row.Cells(1).Text = "" + e.Row.Cells(2).Text = "" + e.Row.Cells(3).Text = e.Row.DBCampo("Nombre") + e.Row.Cells(4).Text = "" + e.Row.Cells(5).Text = "Saldo inicial:" + e.Row.Cells(6).Text = e.Row.DBCampo("SaldoInicial").FormatoNumero + e.Row.CssClass = "Totales" + End If + + 'DETALLE + If e.Row.DBCampo("TipoRenglon") = "2" Then + + End If + + 'SUBTOTAL + If e.Row.DBCampo("TipoRenglon") = "3" Then + e.Row.Font.Bold = True + e.Row.Cells(1).Text = "" + e.Row.Cells(2).Text = "" + e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(3).Text = "SubTotal:" + e.Row.Cells(6).Text = "" + e.Row.CssClass = "SubTotales" + End If + + 'TOTAL + If e.Row.DBCampo("TipoRenglon") = "4" Then + e.Row.Font.Bold = True + e.Row.Cells(0).Text = "" + e.Row.Cells(1).Text = "" + e.Row.Cells(2).Text = "" + e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Right + e.Row.Cells(3).Text = $"Total ({e.Row.DBCampo("Nombre")}):" + e.Row.Cells(6).Text = "" + e.Row.CssClass = "Totales" + End If + + End If + End Sub + +#End Region + + +#Region " IMPRIMIR " + +#End Region + + Protected Sub Imprimir_click(sender As Object, e As EventArgs) Handles Imprimir.Click + FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate) + FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate) + DtDatos = DtDatos + ImprimirReporte() + End Sub + + Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click + FechaInicio = If(TxtFechaDel.Text = "" Or TxtFechaDel.Text = "__/__/____", NowADS(), TxtFechaDel.Text.ToDate) + FechaFin = If(TxtFechaAl.Text = "" Or TxtFechaAl.Text = "__/__/____", NowADS(), TxtFechaAl.Text.ToDate) + DtDatos = DtDatos + ImprimirReporte("EXCEL") + End Sub + + Private Sub ImprimirReporte(Optional Formato As String = "PDF") + 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) + + Dim lista = New List(Of CrystalParametro) + lista.Add(New CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa)) + lista.Add(New CrystalParametro("FechaInicio", FechaInicio.ToString("dd/MM/yyyy"))) + lista.Add(New CrystalParametro("FechaFin", FechaFin.ToString("dd/MM/yyyy"))) + lista.Add(New CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre)) + lista.Add(New CrystalParametro("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", ""))) + + ImprimirbytesPDF(ImprimirPDFCrystal(Server.MapPath("~/Empresas/Grales/Formatos/LibroMayor.rpt"), DtDatos, lista, "LibroMayor", Formato), "LibroMayor", Formato) + End Sub + +End Class diff --git a/Ventas/Promociones.aspx.vb b/Ventas/Promociones.aspx.vb index 990c5b017..e615c3279 100644 --- a/Ventas/Promociones.aspx.vb +++ b/Ventas/Promociones.aspx.vb @@ -158,7 +158,7 @@ Partial Class Ventas_Promociones PermisoAutorizPromocionPorcentaje = UsuarioActual.TienePermisoProceso(386) EmpresaFnc382 = If(UsuarioActual.Empresa.Funcionalidad(382) = "1", True, False) 'Grupo díaz - EmpresaFnc382 = True ''Para pruebas + 'EmpresaFnc382 = True ''Para pruebas If EmpresaFnc382 Then DVModalClasificacion.Visible = False @@ -1474,6 +1474,8 @@ Partial Class Ventas_Promociones LblUltimoCosto.Text = DTPSUltimoCosto.FiltroPrimeroValor("UltimoCosto", "").FormatoNumero(4) LblCostoPromedio.Text = DTPSUltimoCosto.FiltroPrimeroValor("CostoPromedio", "").FormatoNumero(4) + LbPUActual.Text = DTPSUltimoCosto.FiltroPrimeroValor("Importe", "").FormatoNumero(4) + UpAgregar.Update() End Sub