From 34c0b61235ffee12bd612829118a15e07de4c596 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Fri, 13 Sep 2024 17:30:20 -0700 Subject: [PATCH 01/11] --FIX. BDH Promociones en distruibuidores --- Ventas/Ventas.aspx.vb | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/Ventas/Ventas.aspx.vb b/Ventas/Ventas.aspx.vb index b9860250f..cdef1106b 100644 --- a/Ventas/Ventas.aspx.vb +++ b/Ventas/Ventas.aspx.vb @@ -9457,7 +9457,7 @@ Partial Class Ventas End If 'SI SE ELIMINA EL LUBRICANTE, ELIMINAR LOS FILTROS CON PROMOCION - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Not ClienteEsDistribuidor Then If TmpDT.Rows(e.RowIndex)("CveClasificacion").ToString().ToString().Contiene("20516") Then Dim RowsFiltros = TmpDT.Select("CveClasificacion IN(20515) AND Descuento > 0") For Each Row As DataRow In RowsFiltros @@ -19830,15 +19830,17 @@ Partial Class Ventas End Sub Private Sub CalculaPSPromocionFiltrosLubricantes(ByRef RowEdit As DataRow) - If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then + If UsuarioActual.Empresa.Funcionalidad(531) = "1" AndAlso Not ClienteEsDistribuidor Then Dim CantidadMinValidaPromoFiltro As Decimal = 4 Dim CantidadMinValidaPromoLubricantes As Decimal = 5 + Dim CantidadDescuento As Decimal = 0 + 'Dim AgregaDescuentos As Boolean = False 'DESCUENTO EN LUBRICANTES If RowEdit IsNot Nothing AndAlso RowEdit("CveClasificacion").ToString().Contiene("20516") Then Dim Cantidad As Decimal = RowEdit("Cantidad").ToString().ToDecimal() 'CALCULA LA CANTIDAD DE DESCUENTO, REDONDEO HACIA ABAJO - Dim CantidadDescuento As Decimal = Math.DivRem(Cantidad.ToString().ToEntero(), CantidadMinValidaPromoLubricantes.ToString().ToEntero(), 1).ToString().ToDecimal() + CantidadDescuento = Math.DivRem(Cantidad.ToString().ToEntero(), CantidadMinValidaPromoLubricantes.ToString().ToEntero(), 1).ToString().ToDecimal() Dim Descuentos = CantidadDescuento * RowEdit("PU").ToString().ToDecimal() @@ -19864,6 +19866,9 @@ Partial Class Ventas Next End If + 'AGREGA LOS DESCUENTOS ADICIONALES + 'AgregaDescuentos = True + End If ' DESCUENTO EN FILTROS @@ -19875,7 +19880,7 @@ Partial Class Ventas 'SI HAY LUBRICANTES, 1 FILTRO DEBE SER GRATIS If TotalLubricantes >= CantidadMinValidaPromoFiltro Then 'CALCULA LA CANTIDAD DE DESCUENTO, REDONDEO HACIA ABAJO - Dim CantidadDescuento As Decimal = Math.DivRem(TotalLubricantes.ToString().ToEntero(), CantidadMinValidaPromoFiltro.ToString().ToEntero(), 1).ToString().ToDecimal() + CantidadDescuento = Math.DivRem(TotalLubricantes.ToString().ToEntero(), CantidadMinValidaPromoFiltro.ToString().ToEntero(), 1).ToString().ToDecimal() 'VERIFICA QUE AUN SE PUEDA APLICAR DESCUENTO If TotalFiltrosDescuento < CantidadDescuento Then @@ -19901,12 +19906,36 @@ Partial Class Ventas RowEdit("Total") = (Cantidad * PU) RowEdit("TotalImporte") = (Cantidad * PU).RoundSQL(NumeroDecimales) RowEdit("TotalConImpuestos") = (RowEdit("Total").ToString().ToDecimal() - RowEdit("Descuento").ToString().ToDecimal() + RowEdit("ImporteIVA").ToString().ToDecimal()).RoundSQL(2) + + 'AGREGA LOS DESCUENTOS ADICIONALES + 'AgregaDescuentos = True End If End If End If + 'VERIFICA SI APLICAN OTROS DESCUENTOS + 'If AgregaDescuentos Then + ' Dim ObjDescuento As Modelos.VentaDescuentos = CalcularDescuentos(RowEdit("CvePS").ToString().ToEntero(), RowEdit("Cantidad").ToString().ToDecimal(), RowEdit("PU").ToString().ToDecimal()) + ' If ObjDescuento.ImporteDescuento > 0 AndAlso Not ObjDescuento.EsPUModificado Then + ' Dim Cantidad As Decimal = RowEdit("Cantidad").ToString().ToDecimal() + ' Dim PU As Decimal = RowEdit("PU").ToString().ToDecimal() + ' Dim Descuentos = RowEdit("Descuento").ToString().ToDecimal() + ObjDescuento.ImporteDescuento + + ' If Descuentos < (Cantidad * PU) Then + ' Dim TotalCalculableImpuestos As Decimal = ((Cantidad * PU) - (Descuentos)) + ' Dim TotalCalculableImpuestosIVA As Decimal = 0 + ' TotalCalculableImpuestosIVA = TotalCalculableImpuestos * (1 + RowEdit("PorcentajeIEPS").ToString().ToDecimal) + + ' RowEdit("Descuento") = Descuentos + ' RowEdit("ImporteIVA") = (RowEdit("PorcentajeIVA").ToString().ToDecimal * TotalCalculableImpuestosIVA).RoundSQL(NumeroDecimales) + ' RowEdit("TotalConImpuestos") = (RowEdit("Total").ToString().ToDecimal() - RowEdit("Descuento").ToString().ToDecimal() + RowEdit("ImporteIVA").ToString().ToDecimal()).RoundSQL(2) + ' End If + + ' End If + 'End If + End If End Sub From 7f9da6400b8d4a7300b6675d0596f2c0060a6b9c Mon Sep 17 00:00:00 2001 From: rrene Date: Tue, 17 Sep 2024 17:15:21 -0700 Subject: [PATCH 02/11] =?UTF-8?q?--=20al=20crear=20remisi=C3=B3n=20pasar?= =?UTF-8?q?=20el=20par=C3=A1metro=20de=20almacendestino?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OS/OrdenesServicios.aspx.vb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OS/OrdenesServicios.aspx.vb b/OS/OrdenesServicios.aspx.vb index 88a756aea..d6b582596 100644 --- a/OS/OrdenesServicios.aspx.vb +++ b/OS/OrdenesServicios.aspx.vb @@ -318,6 +318,7 @@ Partial Class OS_OrdenesServicios Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then + 'DATOS CLIENTE CveCliente = 0 NombreCliente = "" @@ -3535,6 +3536,7 @@ Partial Class OS_OrdenesServicios ObjFactura.Paciente = TxtPacienteModal.Text.Trim ObjFactura.Episodio = TxtEpisodioModal.Text.Trim ObjFactura.Alfa1 = TxtFolioRemisionModal.Text.Trim + ObjFactura.CveAlmacenTraspasoDestino = GlobalDTAlmacen(UsuarioActual.CveEmpresa, CveTipoAlmacen:=10).FiltroPrimeroValor("CveAlmacen").ToEntero ObjFactura.CveVendedor = tCveVendedor Dim TmpDTMat As New DataTable @@ -3578,7 +3580,7 @@ Partial Class OS_OrdenesServicios If ProcesoOK Then ObjFactura.CalculaTotales() Dim Resp As New Modelos.Factura.MMensajeFactura - Resp = ObjFactura.EmitirFactura(False, Transac:=TransaccionSQL) + Resp = ObjFactura.EmitirFactura(False, Transac:=TransaccionSQL, Modulo:="OS/Remision") If Resp.CveVenta > 0 Then Respuesta.CveVenta = Resp.CveVenta From ec348a28356e8d8a365aa16914c7ca4ec9179627 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Tue, 17 Sep 2024 17:22:08 -0700 Subject: [PATCH 03/11] Promociones, LibroMayorCI --- App_Code/ClsPaginas.vb | 3 +- Contabilidad/LibroMayor.aspx | 275 ++++++++--- Contabilidad/LibroMayor.aspx.vb | 766 +++++++++++++++++++++++++----- Contabilidad/LibroMayor2.aspx | 265 ----------- Contabilidad/LibroMayor2.aspx.vb | 746 ----------------------------- Contabilidad/LibroMayorCI.aspx | 116 +++++ Contabilidad/LibroMayorCI.aspx.vb | 220 +++++++++ Ventas/Promociones.aspx.vb | 4 +- 8 files changed, 1200 insertions(+), 1195 deletions(-) delete mode 100644 Contabilidad/LibroMayor2.aspx delete mode 100644 Contabilidad/LibroMayor2.aspx.vb create mode 100644 Contabilidad/LibroMayorCI.aspx create mode 100644 Contabilidad/LibroMayorCI.aspx.vb 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 From f35a5fd2d5ef62ce98834c93635264b9ab539494 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Tue, 17 Sep 2024 20:40:17 -0700 Subject: [PATCH 04/11] Puntos GDiaz: --Selectivas --- App_Code/ClsPaginas.vb | 1 + App_Code/ClsProductosServicios.vb | 120 ++++++++++++++++++++++++++- Inventarios/InventarioFisico.aspx | 57 +++++++------ Inventarios/InventarioFisico.aspx.vb | 45 ++++++++++ Ventas/CatSelectivas.aspx | 85 +++++++++++++++++++ Ventas/CatSelectivas.aspx.vb | 91 ++++++++++++++++++++ Ventas/ProductosServicios.aspx | 8 +- Ventas/ProductosServicios.aspx.vb | 18 +++- 8 files changed, 395 insertions(+), 30 deletions(-) create mode 100644 Ventas/CatSelectivas.aspx create mode 100644 Ventas/CatSelectivas.aspx.vb diff --git a/App_Code/ClsPaginas.vb b/App_Code/ClsPaginas.vb index a1016870a..5c271e406 100644 --- a/App_Code/ClsPaginas.vb +++ b/App_Code/ClsPaginas.vb @@ -10821,6 +10821,7 @@ Public Class ClsPaginas PaginaDict.Add("/Ventas/CatMotivosDevoluciones.aspx".ToUpper(), 786) PaginaDict.Add("/Ventas/CatPSSubProyectosVendedores.aspx".ToUpper(), 787) PaginaDict.Add("/Ventas/CatMotivosCancelacion.aspx".ToUpper(), 788) + PaginaDict.Add("/Ventas/CatSelectivas.aspx".ToUpper(), 897) #End Region #Region "VIA" diff --git a/App_Code/ClsProductosServicios.vb b/App_Code/ClsProductosServicios.vb index 0c659229c..511e9125e 100644 --- a/App_Code/ClsProductosServicios.vb +++ b/App_Code/ClsProductosServicios.vb @@ -415,7 +415,7 @@ Public Class ClsProductosServicios Optional RegistroRSCO As String = "-1", Optional FechaVigenciaRSCO As Date = MinFecha, Optional VigenciaIndeterminadaRSCO As Boolean = False, Optional CveTipoEmpacado As Integer = -1, Optional CveTipoOrganico As Integer = -1, Optional NombreComercial As String = "", Optional NotasAdicionales As String = "", Optional EcommerceEtiquetas As String = "", Optional ActivoEcommerce As Boolean = False, Optional EcommercePrecio As Decimal = 0, Optional CveClasificacionEcommerce As Integer = -1, Optional EcommerceCantidad As Decimal = 0, Optional CodigoAlterno As String = "-1", Optional PSAlterno As String = "-1", Optional ProductoExhibicion As Boolean = False, - Optional Imagen As String = "", Optional PorcentajeMinimoUtilidad As Decimal = 0) As Integer + Optional Imagen As String = "", Optional PorcentajeMinimoUtilidad As Decimal = 0, Optional CveSelectiva As Integer = -1) As Integer Dim Retorno As Integer = -1 DataAdapter("PA_ProductosServiciosAdd") @@ -526,6 +526,7 @@ Public Class ClsProductosServicios .Add("@ProductoExhibicion", SqlDbType.Bit).Value = ProductoExhibicion .Add("@Imagen", SqlDbType.VarChar).Value = Imagen .Add("@PorcentajeMinimoUtilidad", SqlDbType.Decimal).Value = PorcentajeMinimoUtilidad + .Add("@CveSelectiva", SqlDbType.Int).Value = CveSelectiva End With Try @@ -682,7 +683,8 @@ Public Class ClsProductosServicios Optional CveMaterialPeligroso As Integer = -1, Optional CveEmbalaje As Integer = -1, Optional PesoKg As Decimal = -1, Optional Dimensiones As String = "", Optional CveObjetoImpuesto As Integer = 0, Optional RegistroRSCO As String = "-1", Optional FechaVigenciaRSCO As Date = MinFecha, Optional VigenciaIndeterminadaRSCO As Boolean = False, Optional CveTipoEmpacado As Integer = -1, Optional CveTipoOrganico As Integer = -1, Optional NombreComercial As String = "", Optional NotasAdicionales As String = "", Optional EcommerceEtiquetas As String = "", Optional ActivoEcommerce As Boolean = False, Optional EcommercePrecio As Decimal = 0, - Optional CveClasificacionEcommerce As Integer = -1, Optional EcommerceCantidad As Decimal = 0, Optional CodigoAlterno As String = "-1", Optional PSAlterno As String = "-1", Optional ProductoExhibicion As Boolean = False, Optional Imagen As String = "", Optional PorcentajeMinimoUtilidad As Decimal = 0) As Boolean + Optional CveClasificacionEcommerce As Integer = -1, Optional EcommerceCantidad As Decimal = 0, Optional CodigoAlterno As String = "-1", Optional PSAlterno As String = "-1", Optional ProductoExhibicion As Boolean = False, Optional Imagen As String = "", Optional PorcentajeMinimoUtilidad As Decimal = 0, + Optional CveSelectiva As Integer = -1) As Boolean Dim Retorno As Boolean = False @@ -792,6 +794,7 @@ Public Class ClsProductosServicios .Add("@ProductoExhibicion", SqlDbType.Bit).Value = ProductoExhibicion .Add("@Imagen", SqlDbType.VarChar).Value = Imagen .Add("@PorcentajeMinimoUtilidad", SqlDbType.Decimal).Value = PorcentajeMinimoUtilidad + .Add("@CveSelectiva", SqlDbType.Int).Value = CveSelectiva End With Try @@ -1663,6 +1666,119 @@ Public Class ClsProductosServicios End Function + Public Function AddSelectiva(Selectiva As String, CveUsuario As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_SelectivasAdd") + + With SqlAdapter.SelectCommand.Parameters + .Add("@Selectiva", SqlDbType.VarChar).Value = Selectiva + .Add("@CveUsuario", SqlDbType.Int).Value = CveUsuario + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al Guardar la Selectiva.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Selectiva.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function UpdateSelectiva(CveSelectiva As Integer, Selectiva As String, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_SelectivasUpdate") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSelectiva", SqlDbType.Int).Value = CveSelectiva + .Add("@Selectiva", SqlDbType.VarChar).Value = Selectiva + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al Guardar la Selectiva.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al Guardar la Selectiva.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetSelectiva(CveSelectiva As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_SelectivasGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSelectiva", SqlDbType.Int).Value = CveSelectiva + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al obtener las selectivas.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al obtener las selectivas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function RemoveSelectiva(CveSelectiva As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_SelectivasRemove") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSelectiva", SqlDbType.Int).Value = CveSelectiva + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al eliminar las selectivas.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al eliminar las selectivas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + Public Function GetPSSelectiva(CveSelectiva As Integer, CveEmpresa As Integer) As Boolean + Dim Retorno As Boolean = False + + DataAdapter("PA_Gral_SelectivasPSGet") + + With SqlAdapter.SelectCommand.Parameters + .Add("@CveSelectiva", SqlDbType.Int).Value = CveSelectiva + .Add("@CveEmpresa", SqlDbType.Int).Value = CveEmpresa + End With + + Try + SqlAdapter.Fill(Data) + Retorno = True + Catch Ex1 As SqlException + Me.OnError("Ocurrió un error al obtener las selectivas.", Ex1, SqlAdapter.SelectCommand.Parameters.ParametrosInfo()) + Catch ex As Exception + OnError("Ocurrió un error al obtener las selectivas.", ex, SqlAdapter.SelectCommand.Parameters.ParametrosInfo) + End Try + + Return Retorno + End Function + + #Region "IMPUESTOS LOCALES" Public Function GetPSImpuestosLocales(CvePS As Integer, CveEmpresa As Integer) As Boolean Dim Retorno As Boolean = False diff --git a/Inventarios/InventarioFisico.aspx b/Inventarios/InventarioFisico.aspx index ab41787cf..95b1574df 100644 --- a/Inventarios/InventarioFisico.aspx +++ b/Inventarios/InventarioFisico.aspx @@ -28,7 +28,8 @@
    -
    SubProyecto:
    +
    + SubProyecto:
    @@ -89,9 +90,9 @@ - + - + @@ -218,7 +219,7 @@
    - + @@ -254,8 +255,7 @@
    - - +
    @@ -263,11 +263,22 @@
    +
    +
    +
    + +
    + +
    + +
    +
    +
    - + @@ -314,7 +325,7 @@ - + @@ -345,11 +356,10 @@
    - - +
    -
    +
    @@ -390,23 +400,22 @@
    - - +
    -
    +
    - +
    - + - + @@ -420,7 +429,7 @@
    -
    +
    @@ -438,12 +447,12 @@
    - +
    -
    +
    @@ -460,12 +469,12 @@ - + - + @@ -483,11 +492,11 @@
    - +
    - +
    +
    + + + + +
    @@ -276,7 +282,6 @@
    -
    @@ -350,6 +355,7 @@
    +
    diff --git a/Ventas/ProductosServicios.aspx.vb b/Ventas/ProductosServicios.aspx.vb index f2f5634ac..a1a86883c 100644 --- a/Ventas/ProductosServicios.aspx.vb +++ b/Ventas/ProductosServicios.aspx.vb @@ -450,6 +450,9 @@ Partial Class ProductosyServicios DivPSAdicionales.Visible = True DivTipoAdicional.Visible = True DivPorMinimoUtilidad.Visible = True + DivSelectiva.Visible = True + + CargaSelectivas() End If CvePSAdicional = -1 @@ -473,7 +476,15 @@ Partial Class ProductosyServicios End If End Sub - + Private Sub CargaSelectivas() + Using ObjPS As New ClsProductosServicios + If ObjPS.GetSelectiva(-1, UsuarioActual.CveEmpresa) Then + DdlSelectiva.DataSource = ObjPS.DtResultados + End If + End Using + DdlSelectiva.DataBind() + DdlSelectiva.Items.Insert(0, New ListItem("-", "-1")) + End Sub Private Sub CargaCombosPSComplementos() DdlClaveSectorCOFEPRIS.DataSource = GlobalDT_SAT_CP_SectorCOFEPRIS @@ -1152,6 +1163,7 @@ Partial Class ProductosyServicios If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then TxtPorMinimoUtilidad.Text = ObjProductosServicios.DtResultados.Rows(0)("PorcentajeMinimoUtilidad").ToString + DdlSelectiva.SelectedValueExist(ObjProductosServicios.DtResultados.Rows(0)("CveSelectiva").ToString) End If Else Alert("El Producto o Servicio Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia) @@ -1550,7 +1562,7 @@ Partial Class ProductosyServicios CveObjetoImpuesto:=DdlObjetoImpuesto.SelectedValue.ToEntero, Litraje:=TxtLitraje.Text.ToDecimal, RegistroRSCO:=TxtRegistroRSCO.Text, FechaVigenciaRSCO:=TxtFechaVigenciaRSCO.Text.ToDate, VigenciaIndeterminadaRSCO:=ChkFechaIndeterminadaRSCO.Checked, NombreComercial:=TxtNombreComercial.Text.Trim, NotasAdicionales:=TxtEcommerceNota.Text.Trim, EcommerceEtiquetas:=TxtEcommerceEtiquetas.Text.Trim.Replace(".", ""), EcommercePrecio:=TxtEcommercePrecio.Text.Trim.ToDecimal, CveClasificacionEcommerce:=DdlEcommerceClasificacion.SelectedValue.ToEntero, EcommerceCantidad:=TxtEcommerceCantidad.Text.Trim.ToDecimal, CodigoAlterno:=TxtCodigoAlterno.Text.Trim, PSAlterno:=TxtPSAlterno.Text.Trim, ProductoExhibicion:=ChkPSExhibicion.Checked, - PorcentajeMinimoUtilidad:=TxtPorMinimoUtilidad.Text.ToDecimal()) > 0 Then + PorcentajeMinimoUtilidad:=TxtPorMinimoUtilidad.Text.ToDecimal(), CveSelectiva:=DdlSelectiva.SelectedValue.ToEntero()) > 0 Then ViewState("CvePS") = ObjProductosServicios.CvePS For Each GVR As GridViewRow In GvImpuestosLocales.Rows If GVR.FCCheckBox("ChkDeduccion").Checked Then @@ -1624,7 +1636,7 @@ Partial Class ProductosyServicios RegistroRSCO:=TxtRegistroRSCO.Text, FechaVigenciaRSCO:=TxtFechaVigenciaRSCO.Text.ToDate, VigenciaIndeterminadaRSCO:=ChkFechaIndeterminadaRSCO.Checked, NombreComercial:=TxtNombreComercial.Text.Trim, NotasAdicionales:=TxtEcommerceNota.Text.Trim, EcommerceEtiquetas:=TxtEcommerceEtiquetas.Text.Trim.Replace(".", ""), ActivoEcommerce:=ChkActivoEcommerce.Checked, EcommercePrecio:=TxtEcommercePrecio.Text.Trim.ToDecimal, CveClasificacionEcommerce:=DdlEcommerceClasificacion.SelectedValue.ToEntero, EcommerceCantidad:=TxtEcommerceCantidad.Text.Trim.ToDecimal, - CodigoAlterno:=TxtCodigoAlterno.Text.Trim, PSAlterno:=TxtPSAlterno.Text.Trim, ProductoExhibicion:=ChkPSExhibicion.Checked, PorcentajeMinimoUtilidad:=TxtPorMinimoUtilidad.Text.ToDecimal()) Then + CodigoAlterno:=TxtCodigoAlterno.Text.Trim, PSAlterno:=TxtPSAlterno.Text.Trim, ProductoExhibicion:=ChkPSExhibicion.Checked, PorcentajeMinimoUtilidad:=TxtPorMinimoUtilidad.Text.ToDecimal(), CveSelectiva:=DdlSelectiva.SelectedValue.ToEntero()) Then If Not ObjProductosServicios.LimpiaImpuestosLocales(CvePS) Then TieneError = True From 43934cc841de83715f53a8e43adf097377f50e32 Mon Sep 17 00:00:00 2001 From: Jonathan Alexis Perez Morales Date: Wed, 18 Sep 2024 09:28:46 -0700 Subject: [PATCH 05/11] --FIX. interfaz --- Inventarios/InventarioFisico.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventarios/InventarioFisico.aspx.vb b/Inventarios/InventarioFisico.aspx.vb index b07f869f8..50c7e1a23 100644 --- a/Inventarios/InventarioFisico.aspx.vb +++ b/Inventarios/InventarioFisico.aspx.vb @@ -112,7 +112,7 @@ Partial Class Inventarios_InventarioFisico End If End Using DdlSelectiva.DataBind() - DdlSelectiva.Items.Insert(0, New ListItem("-", "-1")) + DdlSelectiva.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub From 00326453556ad8f8eda2e6abb8f7afae5a8c4ecc Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 18 Sep 2024 19:16:02 -0700 Subject: [PATCH 06/11] -- MEJORA EN PAGO DE COMpra con venta en USD --- Bancos/PopIECompras.aspx | 4 ++-- Bancos/PopIECompras.aspx.vb | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Bancos/PopIECompras.aspx b/Bancos/PopIECompras.aspx index 5f33cdea9..09ee2d437 100644 --- a/Bancos/PopIECompras.aspx +++ b/Bancos/PopIECompras.aspx @@ -703,11 +703,11 @@ total = total * TC; } - debugger + debugger; if ($("#" + Chk.id).is(":checked")) { $('#' + Obj).attr('disabled', false); if (ToDouble($get('TxtImporte').value) != total) { - + if ((ToDouble($get('TxtImporte').value) + saldo) > total) { $('#' + Obj).val(saldo - (ToDouble($get('TxtImporte').value) + saldo - total)); $get('TxtImporte').value = (total / TC).toFixed(2) diff --git a/Bancos/PopIECompras.aspx.vb b/Bancos/PopIECompras.aspx.vb index 1190b4409..5d3eb3332 100644 --- a/Bancos/PopIECompras.aspx.vb +++ b/Bancos/PopIECompras.aspx.vb @@ -1181,7 +1181,7 @@ Partial Class Bancos_PopIECompras e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();") e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN") - Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator) + 'Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator) End If End Sub #End Region @@ -1456,12 +1456,13 @@ Partial Class Bancos_PopIECompras End If If MsgError = "" Then + Dim tc As Decimal = If(rw.DataKey("CveMoneda").ToEntero = 1, 1, TxtTipoCambio.Text.Trim.ToDecimal) Dim VentaActual As New Venta(UsuarioActual) With {.CveVenta = rw.DataKey("CveVenta").ToEntero, .ClienteNombre = NombreCliente, .SerieFolio = rw.DataKey("SerieFolio"), .CveCliente = rw.DataKey("CveCliente").ToEntero, .IVA = rw.DataKey("IVA").ToDecimal, .IEPS = rw.DataKey("IEPS").ToDecimal, .RetIVA = rw.DataKey("RetIVA").ToDecimal, .RetISR = rw.DataKey("RetISR").ToDecimal, .Total = rw.DataKey("Total").ToDecimal, .PorcentajeIVA = rw.DataKey("PorcentajeIVA").ToDecimal, .CveSubProyecto = rw.DataKey("CveSubProyecto").ToEntero, .CveMoneda = rw.DataKey("CveMoneda").ToEntero, .TC = rw.DataKey("TipoCambio").ToDecimal} Dim PagoVenta As New VentaPago PagoVenta.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero PagoVenta.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal PagoVenta.ImportePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal - PagoVenta.TCPago = rw.DataKey("TipoCambio").ToDecimal + PagoVenta.TCPago = tc PagoVenta.CveCompraRelacionada = CompraActual.CveCompra PagoVenta.TipoPago = "Venta" If AplicaPrePolizaPagoVenta(VentaActual, PagoVenta, CvePrePoliza, ObjMov) Then From 3c962444e5c48f01652a27d0748bae7804082b49 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 18 Sep 2024 19:16:42 -0700 Subject: [PATCH 07/11] -- en el listado de productos del calendario, que se visualicen los solicitados. no solo los entregados y usados --- OS/RepServiciosMedicos.aspx | 5 +++-- OS/RepServiciosMedicos.aspx.vb | 16 +++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/OS/RepServiciosMedicos.aspx b/OS/RepServiciosMedicos.aspx index a48100e0f..29d05c90f 100644 --- a/OS/RepServiciosMedicos.aspx +++ b/OS/RepServiciosMedicos.aspx @@ -468,9 +468,10 @@
    - + + - +
    diff --git a/OS/RepServiciosMedicos.aspx.vb b/OS/RepServiciosMedicos.aspx.vb index c26877e5e..fbd4ad598 100644 --- a/OS/RepServiciosMedicos.aspx.vb +++ b/OS/RepServiciosMedicos.aspx.vb @@ -609,18 +609,24 @@ Partial Class OS_RepServiciosMedicos Dim tCve As Integer = ObjOS.CveVenta 'busca la remisión If tCve <= 0 Then tCve = ObjOS.CveCotizacion 'sino hay remisión toma el pedido If tCve > 0 Then - 'Dim objv As New ClsVentas Dim dttps As New DataTable If ObjOS.GetDetalleMateriales(-1, CveOsConsultar) Then dttps = ObjOS.DtResultados End If - 'If objv.GetVentaDetalle(tCve) Then - ' dttps = objv.DtResultados - 'End If - 'objv.Dispose() + GvPS.DataSource = dttps GvPS.DataBind() + + 'sino hay información, cargamos los productos a surtir + 'If dttps IsNot Nothing AndAlso dttps.Rows.Count > 0 AndAlso ObjOS.CveCotizacion > 0 Then + ' Dim objv As New ClsVentas + ' If objv.GetVentaDetalle(tCve) Then + ' dttps = objv.DtResultados + ' End If + ' objv.Dispose() + 'End If + End If Dim TipoEstatus As Integer = 0 TipoEstatus = GlobalDTEstatusOrdenServicios(UsuarioActual.CveEmpresa).FiltroPrimeroValor("TipoEstatus", String.Format("CveEstatusOrdenServicio = {0}", ObjOS.CveEstatusOrdenServicio), "CveEstatusOrdenServicio ASC").ToEntero From 9df225c7beb6e7bd6b7836b2b1b72a8e3215ac95 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 18 Sep 2024 19:16:53 -0700 Subject: [PATCH 08/11] --mejora en lectura de xml, --- Compras/Proveedores.aspx.vb | 93 ++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/Compras/Proveedores.aspx.vb b/Compras/Proveedores.aspx.vb index 6c937d58b..84d5c9695 100644 --- a/Compras/Proveedores.aspx.vb +++ b/Compras/Proveedores.aspx.vb @@ -724,19 +724,33 @@ Partial Class Compras_Proveedores Dim ObjeFacturas As New ClsCompras If ObjeFacturas.GetFacturas(CveFactura, "-1", NowADS().AddYears(-2), NowADS(), "-1", "-1", -1, -1, -1, -1, "-1", UsuarioActual.CveEmpresa) Then Dim XMLDoc As New XmlDocument - + Dim SXML As String + Dim dr As DataRow = ObjeFacturas.DtResultados.Rows(0) + Dim Archivo As String = String.Format("{0}Compras\{1}\{2}", UsuarioActual.Empresa.Ruta, dr("RFCDe"), dr("XML")) Try - Dim dr As DataRow = ObjeFacturas.DtResultados.Rows(0) - - - Dim SXML As String = File.ReadAllText(UsuarioActual.Empresa.Ruta & "Compras\" & dr("RFCDe").ToString & "\" & dr("XML").ToString) + SXML = File.ReadAllText(Archivo).Replace("<br>", "").Replace("<", "").Replace("o;?", "").Replace(ChrW(&HFEFF), "") 'SXML = SXML.TrimStart(vbCr, vbLf, vbNullChar) 'SXML = SXML.TrimEnd(vbCr, vbLf, vbNullChar) SXML = SXML.Trim(New Char() {""c}) SXML = SXML.Replace("o;?", "") XMLDoc.LoadXml(SXML) - Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) + Catch ex As Exception + Try + Dim oReader As New StreamReader(Archivo, Encoding.GetEncoding("ISO-8859-1")) + XMLDoc.Load(oReader) + oReader.Dispose() + Catch ex2 As Exception + GuardaLog("Error al intentar leer el XML del SAT. Error:" & ex2.ToString()) + End Try + End Try + + If XMLDoc.InnerXml = "" Then + Alert("No se pudo procesar el archivo xml.", TipoMensaje.MsgError) + Return 0 + End If + + Dim Prefijo As String = If(XMLDoc.DocumentElement.Prefix = "", "cfd", XMLDoc.DocumentElement.Prefix) Dim cfdVer As String = "http://www.sat.gob.mx/cfd/3" Dim namespaces As New XmlNamespaceManager(XMLDoc.NameTable) @@ -756,55 +770,51 @@ Partial Class Compras_Proveedores 'If Prefijo.ToLower <> "cfdi" Then cfdVer = "http://www.sat.gob.mx/cfd/2" namespaces.AddNamespace(Prefijo, cfdVer) + ' XMLDoc.LoadXml(File.ReadAllText(Archivo).Replace("<br>", "").Replace("<", "").Replace("o;?", "").Replace(ChrW(&HFEFF), "")) Dim node As XmlNode node = XMLDoc.SelectSingleNode(String.Format("//{0}:Emisor", Prefijo), namespaces) - If node IsNot Nothing Then - TxtRFC.Text = ValorXml(node, "rfc") + If node IsNot Nothing Then + TxtRFC.Text = ValorXml(node, "rfc") - If Version = "3.3" Or Version = "4.0" Then - TxtRazonSocial.Text = HttpUtility.HtmlDecode(ValorXml(node, "Nombre")) - TxtNombreComercial.Text = HttpUtility.HtmlDecode(ValorXml(node, "Nombre")) - ChkEstado.Checked = True + If Version = "3.3" Or Version = "4.0" Then + TxtRazonSocial.Text = HttpUtility.HtmlDecode(ValorXml(node, "Nombre")) + TxtNombreComercial.Text = HttpUtility.HtmlDecode(ValorXml(node, "Nombre")) + ChkEstado.Checked = True - Dim CodigoRegimenFiscal As String = ValorXml(node, "RegimenFiscal") + Dim CodigoRegimenFiscal As String = ValorXml(node, "RegimenFiscal") - If Version = "4.0" Or CodigoRegimenFiscal.Trim.Length > 0 Then + If Version = "4.0" Or CodigoRegimenFiscal.Trim.Length > 0 Then - Dim CveRegimenFiscal As Integer = GlobalDTRegimenesFiscales(-1).FiltroPrimeroValor("CveRegimenFiscal", $" CodigoRegimenFiscal = '{ CodigoRegimenFiscal }'").ToEntero - DdlRegimenFiscal.SelectedValueExist(CveRegimenFiscal) + Dim CveRegimenFiscal As Integer = GlobalDTRegimenesFiscales(-1).FiltroPrimeroValor("CveRegimenFiscal", $" CodigoRegimenFiscal = '{ CodigoRegimenFiscal }'").ToEntero + DdlRegimenFiscal.SelectedValueExist(CveRegimenFiscal) - End If + End If - Else - TxtRazonSocial.Text = HttpUtility.HtmlDecode(ValorXml(node, "nombre")) - TxtNombreComercial.Text = HttpUtility.HtmlDecode(ValorXml(node, "nombre")) - Dim nodeDomicilio As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:DomicilioFiscal", Prefijo), namespaces) - TxtDireccion.Text = ValorXml(nodeDomicilio, "calle") & " " & ValorXml(nodeDomicilio, "noExterior") - ChkEstado.Checked = True + Else + TxtRazonSocial.Text = HttpUtility.HtmlDecode(ValorXml(node, "nombre")) + TxtNombreComercial.Text = HttpUtility.HtmlDecode(ValorXml(node, "nombre")) + Dim nodeDomicilio As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:DomicilioFiscal", Prefijo), namespaces) + TxtDireccion.Text = ValorXml(nodeDomicilio, "calle") & " " & ValorXml(nodeDomicilio, "noExterior") + ChkEstado.Checked = True - node = XMLDoc.SelectSingleNode(String.Format("//{0}:Impuestos", Prefijo), namespaces) - If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then - 'Dim nodeRetenciones As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Retencion", Prefijo), namespaces) - 'Dim nodeRet As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Retenciones", Prefijo), namespaces) + node = XMLDoc.SelectSingleNode(String.Format("//{0}:Impuestos", Prefijo), namespaces) + If node IsNot Nothing AndAlso node.ChildNodes.Count > 0 Then + 'Dim nodeRetenciones As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Retencion", Prefijo), namespaces) + 'Dim nodeRet As XmlNode = XMLDoc.SelectSingleNode(String.Format("//{0}:Retenciones", Prefijo), namespaces) - Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Traslado", Prefijo), namespaces) - For Each traslado As XmlNode In nodeTraslados - If traslado.Attributes("impuesto").Value = "IVA" Then - TxtIVA.Text = traslado.Attributes("tasa").Value.ToDouble.ToString("N2") - 'Retenciones - End If - Next - End If + Dim nodeTraslados As XmlNodeList = XMLDoc.SelectNodes(String.Format("//{0}:Traslado", Prefijo), namespaces) + For Each traslado As XmlNode In nodeTraslados + If traslado.Attributes("impuesto").Value = "IVA" Then + TxtIVA.Text = traslado.Attributes("tasa").Value.ToDouble.ToString("N2") + 'Retenciones + End If + Next End If End If - - Catch ex As Exception - Alert(String.Format("No se pudo cargar la información ({0})", ex.Message), TipoMensaje.MsgAdvertencia) - Return 0 - End Try + End If End If Return 1 @@ -5847,11 +5857,8 @@ Partial Class Compras_Proveedores Protected Sub LnkDownLoadDoc_Click(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim Adjunto As String = GvRow.DataKey("Adjunto") - - Dim stringDescargaDocumento As String = UsuarioActual.Empresa.Ruta & String.Format("Edoc\\Proveedor\{0}\{1}", CveProveedor, Adjunto) - Dim File As New FileInfo(stringDescargaDocumento) If File.Exists Then From bbbb8c6f0901bb85ffe344a4c17e99c9d9c35974 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 18 Sep 2024 19:17:03 -0700 Subject: [PATCH 09/11] -- proceso para buscar por serie --- Inventarios/PopUpExistenciasAlmacen.aspx.vb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Inventarios/PopUpExistenciasAlmacen.aspx.vb b/Inventarios/PopUpExistenciasAlmacen.aspx.vb index 99b2f1985..2df14d506 100644 --- a/Inventarios/PopUpExistenciasAlmacen.aspx.vb +++ b/Inventarios/PopUpExistenciasAlmacen.aspx.vb @@ -54,7 +54,7 @@ Partial Class Inventarios_Default DivListasPrecios2.Visible = True End If - If UsuarioActual.CveRol = 1 Then + If UsuarioActual.TienePermisoProceso(387) Then LnkBsucarSerie.Visible = True End If From 9982474dd814c456f99a2cb253a0d5b0f77285b2 Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 18 Sep 2024 19:17:40 -0700 Subject: [PATCH 10/11] =?UTF-8?q?--facturaci=C3=B3n=20masiva=20STF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ashx/SIGFacturacion.ashx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ashx/SIGFacturacion.ashx b/Ashx/SIGFacturacion.ashx index 6a88e43ea..2bb590348 100644 --- a/Ashx/SIGFacturacion.ashx +++ b/Ashx/SIGFacturacion.ashx @@ -126,7 +126,7 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState If DTClientes IsNot Nothing Then 'QUITAR CLIENTES QUE NO DEBEN DE ESTAR - DTClientes = DTClientes.FiltraParametros("CveCliente NOT IN (265989,265991,265994,266010,266011,266013) ") + DTClientes = DTClientes.FiltraParametros("CveCliente NOT IN (1285420,1285423,1285424) ") For Each RowCliente As DataRow In DTClientes.Rows Dim CveCliente As Integer = RowCliente("CveCliente").ToString().ToEntero() @@ -276,7 +276,7 @@ Public Class SIGFacturacion : Implements IHttpHandler, IRequiresSessionState ObjFactura.Serie = Serie ObjFactura.Folio = Folio.ToEntero() ObjFactura.TipoMensajeRespuesta = TipoMensajeRespuesta.TextoLimpio - ObjFactura.Version = "3.3" + ObjFactura.Version = "4.0" ObjFactura.FolioFiscal = "" ObjFactura.CveUsuario = UsuarioActual.CveUsuario ObjFactura.CveEmpresa = UsuarioActual.CveEmpresa From 7a4c97573b2d3874d96fd3e818aefc26fdf4f647 Mon Sep 17 00:00:00 2001 From: rakcsle Date: Fri, 20 Sep 2024 16:01:46 -0700 Subject: [PATCH 11/11] Recepcion Almacen Bitacora recarga despues de guaraddo parcial --- Inventarios/RecepcionAlmacen.aspx | 19 ++- Inventarios/RecepcionAlmacen.aspx.vb | 225 ++++++++++++++++++++------ Ventas/RepVentasUtilidadPadre.aspx | 125 +++++++++++++- Ventas/RepVentasUtilidadPadre.aspx.vb | 70 +++++++- 4 files changed, 372 insertions(+), 67 deletions(-) diff --git a/Inventarios/RecepcionAlmacen.aspx b/Inventarios/RecepcionAlmacen.aspx index 937f907e0..55ecc0e26 100644 --- a/Inventarios/RecepcionAlmacen.aspx +++ b/Inventarios/RecepcionAlmacen.aspx @@ -19,14 +19,25 @@
  •  
  • -
  • - Cargar Excel -
  • + + <%-- +
  • + Cargar Excel +
  • + --%> + + + +
  • + Cargar Excel +
  • +
    +
  • - Cargar Bitácora + Cargar Bitácora
  • diff --git a/Inventarios/RecepcionAlmacen.aspx.vb b/Inventarios/RecepcionAlmacen.aspx.vb index 03e109ac7..672cdf830 100644 --- a/Inventarios/RecepcionAlmacen.aspx.vb +++ b/Inventarios/RecepcionAlmacen.aspx.vb @@ -7,6 +7,7 @@ Imports System.Text Imports Extensiones Imports GemBox.Spreadsheet Imports Microsoft.Reporting.WebForms +Imports Org.BouncyCastle.Asn1.X509 Partial Class Inventarios_RecepcionAlmacen Inherits ClsPaginas @@ -154,12 +155,21 @@ Partial Class Inventarios_RecepcionAlmacen ViewState("PUSerie") = value End Set End Property - Private Property CveConsecSerie As Integer + 'Private Property CveConsecSerie As Integer + ' Get + ' Return CType(ViewState("CveConsecSerie"), Integer) + ' End Get + ' Set(value As Integer) + ' ViewState("CveConsecSerie") = value + ' End Set + 'End Property + + Private Property CveCompraDetalle As Integer Get - Return CType(ViewState("CveConsecSerie"), Integer) + Return CType(ViewState("CveCompraDetalle"), Integer) End Get Set(value As Integer) - ViewState("CveConsecSerie") = value + ViewState("CveCompraDetalle") = value End Set End Property Private Property TotalGV As Decimal @@ -412,6 +422,11 @@ Partial Class Inventarios_RecepcionAlmacen End Property Private Property ArchivoBitacora As String Get + + If ViewState("ArchivoBitacora") Is Nothing Then + ViewState("ArchivoBitacora") = "" + End If + Return CType(ViewState("ArchivoBitacora"), String) End Get Set(value As String) @@ -420,6 +435,10 @@ Partial Class Inventarios_RecepcionAlmacen End Property Private Property ArchivoBitacoraDetalle As String Get + If ViewState("ArchivoBitacoraDetalle") Is Nothing Then + ViewState("ArchivoBitacoraDetalle") = "" + End If + Return CType(ViewState("ArchivoBitacoraDetalle"), String) End Get Set(value As String) @@ -1461,11 +1480,12 @@ Partial Class Inventarios_RecepcionAlmacen 'If e.Row.DBCampo("CveMetodoInventario").ToString = "5" Then e.Row.FCButton("BtnSerie").Visible = True - e.Row.FCButton("BtnSerie").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PU"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec")) + e.Row.FCButton("BtnSerie").CommandArgument = String.Format("{0}°{1}°{2}°{3}°{4}°{5}°{6}", e.Row.DBCampo("CvePS"), e.Row.DBCampo("CveUM"), e.Row.DBCampo("PU"), e.Row.DBCampo("PS"), e.Row.DBCampo("CantidadF"), e.Row.DBCampo("Consec"), e.Row.DBCampo("CveCompraDetalle")) e.Row.FCTextBox("TbCantidadF").Enabled = False e.Row.FCCheckBox("cbInv").Enabled = False - Dim Contador As Integer = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DataKey("Consec"))).Rows.Count + 'Dim Contador As Integer = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", e.Row.DataKey("Consec"))).Rows.Count + Dim Contador As Integer = DtDatosDetalle.FiltraParametros(String.Format("CveCompraDetalle = {0}", e.Row.DataKey("CveCompraDetalle"))).Rows.Count e.Row.FCTextBox("TbCantidadF").Text = Contador.ToString '' Empresa Acumuladores @@ -1617,7 +1637,8 @@ Partial Class Inventarios_RecepcionAlmacen TdSeriePS.Visible = True TxtSeriePS.Focus() - CveConsecSerie = Gvr.DataKey("Consec").ToEntero + 'CveConsecSerie = Gvr.DataKey("Consec").ToEntero + CveCompraDetalle = Gvr.DataKey("CveCompraDetalle").ToEntero CvePSSerie = Gvr.DataKey("CvePS").ToEntero CveUMSerie = Gvr.DataKey("CveUM").ToEntero Exit Sub @@ -1717,7 +1738,8 @@ Partial Class Inventarios_RecepcionAlmacen CvePSSerie = Argumentos(0).ToEntero CveUMSerie = Argumentos(1).ToEntero PUSerie = Argumentos(2).ToDecimal - CveConsecSerie = Argumentos(5).ToEntero + 'CveConsecSerie = Argumentos(5).ToEntero + CveCompraDetalle = Argumentos(6).ToEntero CargaSerie(1) @@ -1732,6 +1754,8 @@ Partial Class Inventarios_RecepcionAlmacen DtDatosDetalle.Columns.Add("PU", GetType(Decimal)) DtDatosDetalle.Columns.Add("Serie", GetType(String)) DtDatosDetalle.Columns.Add("FechaCaducidad", GetType(String)) + DtDatosDetalle.Columns.Add("CveCompraDetalle", GetType(Integer)) + End If End Sub @@ -1747,11 +1771,13 @@ Partial Class Inventarios_RecepcionAlmacen 'RegistraScript("document.getElementById(""TxtSerie"").focus();") RegistraScript("$('#DivSerie').modal();", "ModalLote") - GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie), "Consec DESC") + 'GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie), "Consec DESC") + GvSerie.DataSource = DtDatosDetalle.FiltraParametros(String.Format("CveCompraDetalle = {0}", CveCompraDetalle), "Consec DESC") GvSerie.DataBind() 'VALIDA QUE SIGA AGREGANDO - If Not DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie)).Rows.Count < LbCantidad.Text.ToEntero Then + 'If Not DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie)).Rows.Count < LbCantidad.Text.ToEntero Then + If Not DtDatosDetalle.FiltraParametros(String.Format("CveCompraDetalle = {0}", CveCompraDetalle)).Rows.Count < LbCantidad.Text.ToEntero Then BtnAgregarPS.Enabled = True If CerrarCompletado Then RegistraScript("$('#DivSerie').modal('hide');") @@ -1764,7 +1790,9 @@ Partial Class Inventarios_RecepcionAlmacen Dim Contador As Integer = 0 For Each Gvr As GridViewRow In GvInv.Rows If Gvr.DataKey("CvePS").ToEntero = CvePSSerie Then - Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count + 'Contador = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))).Rows.Count + Contador = DtDatosDetalle.FiltraParametros(String.Format("CveCompraDetalle = {0}", Gvr.DataKey("CveCompraDetalle"))).Rows.Count + Gvr.FCCheckBox("cbInv").Enabled = False Gvr.FCTextBox("TbCantidadF").Enabled = False If DtDatosDetalle IsNot Nothing AndAlso Contador > 0 Then @@ -1776,7 +1804,8 @@ Partial Class Inventarios_RecepcionAlmacen End If End If - Dim Dr As DataRow = DtInv.Select($"Consec = {Gvr.DataKey("Consec")}")(0) + 'Dim Dr As DataRow = DtInv.Select($"Consec = {Gvr.DataKey("Consec")}")(0) + Dim Dr As DataRow = DtInv.Select($"CveCompraDetalle = {Gvr.DataKey("CveCompraDetalle")}")(0) Dr("CantidadSurtidaPantalla") = Gvr.FCTextBox("TbCantidadF").Text.ToDecimal DtInv.AcceptChanges() Next @@ -1810,7 +1839,10 @@ Partial Class Inventarios_RecepcionAlmacen Dim dr As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSSerie).FiltroPrimero("", "PS") For Each Serie In SeriesArreglo - DtDuplicado = DtDatosDetalle.FiltraParametros($"ConsecId = {CveConsecSerie} AND Serie = '{Serie}'") + 'DtDuplicado = DtDatosDetalle.FiltraParametros($"ConsecId = {CveConsecSerie} AND Serie = '{Serie}'") + DtDuplicado = DtDatosDetalle.FiltraParametros($"CveCompraDetalle = {CveCompraDetalle} AND Serie = '{Serie}'") + + If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then MensajeAlert.Append($"
    El numero de Serie ""{Serie}"" proporcionado ya se encuentra ingresado.") TxtSerie.Text = "" @@ -1836,7 +1868,8 @@ Partial Class Inventarios_RecepcionAlmacen Dim Index As Integer = 0 Dim Cantidad As Integer = LbCantidad.Text.ToEntero - If CargaMasivaSeries Then Cantidad = DtInv.FiltroPrimeroValor("CantidadF", "Consec = " & CveConsecSerie).ToEntero + 'If CargaMasivaSeries Then Cantidad = DtInv.FiltroPrimeroValor("CantidadF", "Consec = " & CveConsecSerie).ToEntero + If CargaMasivaSeries Then Cantidad = DtInv.FiltroPrimeroValor("CantidadF", "CveCompraDetalle = " & CveCompraDetalle).ToEntero 'DtInv For Each Serie In SeriesArreglo @@ -1847,7 +1880,8 @@ Partial Class Inventarios_RecepcionAlmacen If Index > Cantidad Then Exit For 'VALIDA QUE SIGA AGREGANDO - If Not DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie)).Rows.Count < Cantidad Then + 'If Not DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie)).Rows.Count < Cantidad Then + If Not DtDatosDetalle.FiltraParametros(String.Format("CveCompraDetalle = {0}", CveCompraDetalle)).Rows.Count < Cantidad Then MensajeAlert.Append("series cargadas en su totalidad") : Exit For End If @@ -1867,7 +1901,8 @@ Partial Class Inventarios_RecepcionAlmacen End If End If - Row("ConsecId") = CveConsecSerie + 'Row("ConsecId") = CveConsecSerie + Row("CveCompraDetalle") = CveCompraDetalle Row("Consec") = DtDatosDetalle.Rows.Count + 1 Row("CvePS") = CvePSSerie Row("CveUM") = CveUMSerie @@ -1922,6 +1957,10 @@ Partial Class Inventarios_RecepcionAlmacen Dim dtt As New DataTable dtt.ReadXml(ArchivoBitacoraDetalle) DtDatosDetalle = dtt + If Not DtDatosDetalle.Columns.Contains("CveCompraDetalle") Then + DtDatosDetalle.Columns.Add("CveCompraDetalle", GetType(Integer)) + DtDatosDetalle.AcceptChanges() + End If Alert("Registro(s) Recuperados", TipoMensaje.ToastInformacion) End If CargaGVInv() @@ -1975,18 +2014,21 @@ Partial Class Inventarios_RecepcionAlmacen CvePSSerie = Argumentos(0).ToEntero CveUMSerie = Argumentos(1).ToEntero PUSerie = Argumentos(2).ToDecimal - CveConsecSerie = Argumentos(5).ToEntero + 'CveConsecSerie = Argumentos(5).ToEntero + CveCompraDetalle = Argumentos(6).ToEntero CargaLote(1) End Sub Private Sub CargaLote(Tipo As Integer, Optional CerrarCompletado As Boolean = False) RegistraScript("$('#DivLote').modal();", "ModalLote") GvLote.Columns(2).HeaderText = UsuarioActual.Empresa.Funcionalidad(147) - GvLote.DataSource = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie), "Consec DESC") + 'GvLote.DataSource = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", CveConsecSerie), "Consec DESC") + GvLote.DataSource = DtDatosLoteDetalle.FiltraParametros(String.Format("CveCompraDetalle = {0}", CveCompraDetalle), "Consec DESC") GvLote.DataBind() 'VALIDA QUE SIGA AGREGANDO - If Not DtDatosLoteDetalle.SUM("Cantidad", String.Format("ConsecId = {0}", CveConsecSerie)) < LbLoteCantidad2.Text.ToDecimal Then + 'If Not DtDatosLoteDetalle.SUM("Cantidad", String.Format("ConsecId = {0}", CveConsecSerie)) < LbLoteCantidad2.Text.ToDecimal Then + If Not DtDatosLoteDetalle.SUM("Cantidad", String.Format("CveCompraDetalle = {0}", CveCompraDetalle)) < LbLoteCantidad2.Text.ToDecimal Then BtnAddPSLote.Enabled = False If CerrarCompletado Then RegistraScript("$('#DivLote').modal('hide');") @@ -1999,7 +2041,9 @@ Partial Class Inventarios_RecepcionAlmacen Dim Contador As Decimal = 0 For Each Gvr As GridViewRow In GvInv.Rows If Gvr.DataKey("CvePS").ToEntero = CvePSSerie Then - Contador = DtDatosLoteDetalle.SUMD("Cantidad", String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))) + 'Contador = DtDatosLoteDetalle.SUMD("Cantidad", String.Format("ConsecId = {0}", Gvr.DataKey("Consec"))) + Contador = DtDatosLoteDetalle.SUMD("Cantidad", String.Format("CveCompraDetalle = {0}", Gvr.DataKey("CveCompraDetalle"))) + Gvr.FCCheckBox("cbInv").Enabled = False Gvr.FCTextBox("TbCantidadF").Enabled = False If DtDatosLoteDetalle IsNot Nothing AndAlso Contador > 0 Then @@ -2049,7 +2093,8 @@ Partial Class Inventarios_RecepcionAlmacen Dim DtSeriesNuevas As New DataTable DtSeriesNuevas.Columns.Add("Serie", GetType(String)) - DtDuplicado = DtDatosLoteDetalle.FiltraParametros($"ConsecId = {CveConsecSerie} AND Lote = '{Lote}' ") + 'DtDuplicado = DtDatosLoteDetalle.FiltraParametros($"ConsecId = {CveConsecSerie} AND Lote = '{Lote}' ") + DtDuplicado = DtDatosLoteDetalle.FiltraParametros($"CveCompraDetalle = {CveCompraDetalle} AND Lote = '{Lote}' ") If DtDuplicado IsNot Nothing AndAlso DtDuplicado.Rows.Count > 0 Then Alert($"
    El numero de Lote ""{Lote}"" proporcionado ya se encuentra ingresado.", TipoMensaje.MsgAdvertencia) RegistraScript("playsonidito('142608__autistic-lucario__error.wav')") @@ -2078,7 +2123,8 @@ Partial Class Inventarios_RecepcionAlmacen End If End If - Row("ConsecId") = CveConsecSerie + 'Row("ConsecId") = CveConsecSerie + Row("CveCompraDetalle") = CveCompraDetalle Row("Consec") = DtDatosDetalle.Rows.Count + 1 Row("Cantidad") = CantidadLote Row("CvePS") = CvePSSerie @@ -2716,8 +2762,12 @@ Partial Class Inventarios_RecepcionAlmacen PUExtranjero = DtInv.Rows(gvr.RowIndex)("PUExtranjero").ToString.ToDecimal 'SI FUE POR SERIE LOTE - DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec").ToEntero)) - DtDetalleLote = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec").ToEntero)) + 'DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec").ToEntero)) + 'DtDetalleLote = DtDatosLoteDetalle.FiltraParametros(String.Format("ConsecId = {0}", gvr.DataKey("Consec").ToEntero)) + + DtDetalle = DtDatosDetalle.FiltraParametros(String.Format("CveCompraDetalle = {0}", gvr.DataKey("CveCompraDetalle").ToEntero)) + DtDetalleLote = DtDatosLoteDetalle.FiltraParametros(String.Format("CveCompraDetalle = {0}", gvr.DataKey("CveCompraDetalle").ToEntero)) + If DtDetalle.Rows.Count > 0 Then Dim ContDt As Integer = 0 ' por redondeo @@ -3655,7 +3705,9 @@ Partial Class Inventarios_RecepcionAlmacen ErrorMovInv = True End Try - + If Not ErrorMovInv Then + RenombrarBitacoras() + End If 'FINAL If Not ErrorMovInv Then @@ -3759,6 +3811,26 @@ Partial Class Inventarios_RecepcionAlmacen If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose() End Sub + Private Sub RenombrarBitacoras() + + + Dim fechaActual As String = DateTime.Now.ToString("yyyyMMddHHmmss") + + Dim fib As New FileInfo(ArchivoBitacora) + Dim fibd As New FileInfo(ArchivoBitacoraDetalle) + + If fib.Exists() Then + Dim nuevoNombre As String = Path.Combine(fib.DirectoryName, Path.GetFileNameWithoutExtension(fib.Name) & "_" & fechaActual & ".xml") + fib.MoveTo(nuevoNombre) + End If + + If fibd.Exists() Then + Dim nuevoNombreDetalle As String = Path.Combine(fibd.DirectoryName, Path.GetFileNameWithoutExtension(fibd.Name) & "_" & fechaActual & ".xml") + fibd.MoveTo(nuevoNombreDetalle) + End If + + End Sub + Private Function GenerarMovimientoAlmacenVenta(CveAlmacen As Integer, CveConceptoAlmacen As Integer, CveVenta As Integer, CveMovimientoRelacionado As Integer, DtDetalle As DataTable, ObjInventario As ClsInventarios, ObjConta As ClsContabilidad, EsContabilizable As Boolean, Modulo As String) As MMovimientoAlmacen Dim ErrorMovInv As Boolean = False Dim Retorno As New MMovimientoAlmacen @@ -4816,7 +4888,7 @@ Partial Class Inventarios_RecepcionAlmacen Alert("El nombre de la segunda columna debe ser 'Codigo'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If - If Not dt.Columns(2).ColumnName = "Producto" Then + If Not (dt.Columns(2).ColumnName = "Producto" Or dt.Columns(2).ColumnName = "Producto/Servicio") Then Alert("El nombre de la tercera columna debe ser 'Producto'. Favor de corregirlo", TipoMensaje.MsgError) Exit Sub End If @@ -4851,7 +4923,8 @@ Partial Class Inventarios_RecepcionAlmacen Dim CveProducto As Integer = RowPS("CvePS").ToString().ToEntero() Dim CveUnidadMedida As Integer = RowPS("CveUM").ToString().ToEntero() CvePSSerie = CveProducto - CveConsecSerie = DtInv.FiltroPrimeroValor("Consec", "CvePS=" & CvePSSerie).ToEntero + 'CveConsecSerie = DtInv.FiltroPrimeroValor("Consec", "CvePS=" & CvePSSerie).ToEntero + CveCompraDetalle = DtInv.FiltroPrimeroValor("CveCompraDetalle", "CvePS=" & CvePSSerie).ToEntero Dim Cantidad As Double = RowExcel("Cantidad").ToString().ToDecimal() Dim Serie As String = RowExcel("Serie").ToString() @@ -4875,7 +4948,8 @@ Partial Class Inventarios_RecepcionAlmacen If Valido Then - CveConsecSerie = RowPS("Consec").ToString.ToEntero + 'CveConsecSerie = RowPS("Consec").ToString.ToEntero + CveCompraDetalle = RowPS("CveCompraDetalle").ToString.ToEntero AgregaSerie(RowExcel("Serie").ToString, 1, False) 'AgregarPS(Cantidad, CveProducto, CveUnidadMedida, Observaciones, CveSeccionAlmacen:=DdlSeccionAlmacen.SelectedValue.ToEntero, SeccionAlmacen:=DdlSeccionAlmacen.SelectedItem.Text, Serie:=If(Not String.IsNullOrEmpty(Serie), Serie, ""), Lote:=Lote, FechaCaducidad:=FechaCaducidad, Limpia:=False) @@ -4887,7 +4961,7 @@ Partial Class Inventarios_RecepcionAlmacen Else RowsNoCargados = RowsNoCargados + 1 - ProductosNoCargados.AppendFormat("{0},", RowExcel("Producto").ToString()) + ProductosNoCargados.AppendFormat("{0},", RowExcel("Producto/Servicio").ToString()) End If End If Next @@ -4896,12 +4970,20 @@ Partial Class Inventarios_RecepcionAlmacen Finally Dim MensajeFinal As New StringBuilder() + If RowsNoCargados = 0 AndAlso RowsCargados > 0 Then MensajeFinal.Append("Los productos se cargaron correctamente.

    ") End If + If RowsCargados > 0 Then MensajeFinal.Append("Se cargaron " & RowsCargados & " productos correctamente.") + + TxtExcel.Text = "[]" + UpConcepto.Update() + RegistraScript("$('#DivCargaExcel').modal('hide');") + End If + If RowsNoCargados > 0 Then MensajeFinal.Append("No se pudieron cargar " & RowsNoCargados & " productos.
    Los siguientes productos no se pudieron cargar: " & ProductosNoCargados.ToString()) End If @@ -4922,32 +5004,67 @@ Partial Class Inventarios_RecepcionAlmacen End Sub Public Sub DescargarFormato() - Dim Directorio As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoRecepcionAlmacen.xlsx" - Dim dtt As New DataTable - dtt = DtInv.Copy() - dtt.Columns.Remove("Cantidad") - dtt.Columns("CantidadF").ColumnName = "Cantidad" - dtt.Columns("PS").ColumnName = "Producto" - dtt.Columns("Codigo").ColumnName = "Código" + Dim PathArchivo As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\Grales\Formatos\FormatoRecepcionAlmacen.xlsx" - Dim existingcol As New List(Of String) '= {"Cantidad", "Producto", "Código"} + If System.IO.File.Exists(PathArchivo) Then - For Each col As DataColumn In dtt.Columns - If Not col.ColumnName.Contiene("Cantidad", "Producto", "Código") Then - existingcol.Add(col.ColumnName) - End If - Next + Response.Clear() + Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + Response.AddHeader("Content-Disposition", "attachment; filename=FormatoRecepcionAlmacen.xlsx") + Response.TransmitFile(Directorio) + Response.End() - For Each colName As String In existingcol - dtt.Columns.Remove(colName) - Next + End If - dtt.Columns("Cantidad").SetOrdinal(0) - dtt.Columns("Código").SetOrdinal(1) - dtt.Columns("Producto").SetOrdinal(2) - dtt.Columns.Add("Serie", GetType(String)) - dtt.ExportToExcel("FormatoRecepcionAlmacen.xlsx") + 'Dim dtt As New DataTable + 'dtt = DtInv.Copy() + + 'If dtt.Columns.Contains("Cantidad") Then + ' dtt.Columns.Remove("Cantidad") + 'End If + + 'If dtt.Columns.Contains("CantidadF") Then + ' dtt.Columns("CantidadF").ColumnName = "Cantidad" + 'End If + + 'If dtt.Columns.Contains("PS") Then + ' dtt.Columns("PS").ColumnName = "Producto" + 'End If + + 'If dtt.Columns.Contains("Codigo") Then + ' dtt.Columns("Codigo").ColumnName = "Código" + 'End If + + + 'Dim existingcol As New List(Of String) '= {"Cantidad", "Producto", "Código"} + + 'For Each col As DataColumn In dtt.Columns + ' If Not col.ColumnName.Contiene("Cantidad", "Producto", "Código") Then + ' existingcol.Add(col.ColumnName) + ' End If + 'Next + + 'For Each colName As String In existingcol + ' dtt.Columns.Remove(colName) + 'Next + + 'Try + ' dtt.Columns("Cantidad").SetOrdinal(0) + ' dtt.Columns("Código").SetOrdinal(1) + ' dtt.Columns("Producto").SetOrdinal(2) + 'Catch ex As Exception + + 'End Try + + + 'If Not dtt.Columns.Contains("PS") Then + ' dtt.Columns.Add("Serie", GetType(String)) + 'End If + + + + 'dtt.ExportToExcel("FormatoRecepcionAlmacen.xlsx") End Sub @@ -4957,7 +5074,7 @@ Partial Class Inventarios_RecepcionAlmacen 'Create a DataTable. Dim dt As New DataTable() - dt.Columns.AddRange(New DataColumn(9) {New DataColumn("CodBarra", GetType(String)), + dt.Columns.AddRange(New DataColumn(10) {New DataColumn("CodBarra", GetType(String)), New DataColumn("OVenta", GetType(String)), New DataColumn("Factura", GetType(String)), New DataColumn("FechaFac", GetType(String)), @@ -4966,7 +5083,8 @@ Partial Class Inventarios_RecepcionAlmacen New DataColumn("Producto", GetType(String)), New DataColumn("Serie", GetType(String)),'CodigoUnico New DataColumn("Cantidad", GetType(Integer)), - New DataColumn("Código", GetType(String))}) + New DataColumn("Código", GetType(String)), + New DataColumn("CveCompraDetalle", GetType(Integer))}) FolioFactura = FolioFactura.Replace("-", "") 'Read the contents of CSV file. @@ -5049,5 +5167,10 @@ Partial Class Inventarios_RecepcionAlmacen End Class + Protected Sub LnkAgregarExcel_Click(sender As Object, e As EventArgs) + TxtExcel.Text = "[]" + UpConcepto.Update() + RegistraScript("$('#DivCargaExcel').modal('show');") + End Sub End Class diff --git a/Ventas/RepVentasUtilidadPadre.aspx b/Ventas/RepVentasUtilidadPadre.aspx index e6bb4b11e..286745018 100644 --- a/Ventas/RepVentasUtilidadPadre.aspx +++ b/Ventas/RepVentasUtilidadPadre.aspx @@ -56,6 +56,9 @@
  • Ver Grafica
  • +
  • + Consultar porcentajes +
  • @@ -275,6 +278,106 @@ + + + + + + + diff --git a/Ventas/RepVentasUtilidadPadre.aspx.vb b/Ventas/RepVentasUtilidadPadre.aspx.vb index 81df03936..9b41dca55 100644 --- a/Ventas/RepVentasUtilidadPadre.aspx.vb +++ b/Ventas/RepVentasUtilidadPadre.aspx.vb @@ -32,19 +32,37 @@ Partial Class Ventas_RepVentasUtilidadPadre Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not IsPostBack Then - 'If UsuarioActual.Empresa.Funcionalidad(382) <> "1" Then - ' GvDatos.Columns(3).Visible = False - ' GvDatos.Columns(5).Visible = False - 'End If + If UsuarioActual.Empresa.Funcionalidad(382) = "1" Then + LnkModalPorcentajes.Visible = True + End If CargaCombos() End If End Sub + Private Property SubProyectoConf As String + Get + If ViewState("SubProyectoConf") Is Nothing Then + ViewState("SubProyectoConf") = "" + End If + Return ViewState("SubProyectoConf").ToString + End Get + + Set(value As String) + ViewState("SubProyectoConf") = value + End Set + End Property + + + + #Region " INICIALIZA VALORES " Private Sub CargaCombos() + TxtModalFechaInicio.Text = NowADS().FirstDayOfMonth.ToShortDateString + TxtModalFechaFin.Text = NowADS().LastDayOfMonth.ToShortDateString + txtFechaI.Text = NowADS().FirstDayOfMonth.ToShortDateString txtFechaF.Text = NowADS().LastDayOfMonth.ToShortDateString @@ -108,6 +126,12 @@ Partial Class Ventas_RepVentasUtilidadPadre LblNeto.Text = "0" LblPorNeto.Text = "0" + + + Dim LblSubProyectoConf As New Label + CargarCentrosDeCosto(Nothing, Nothing, Nothing, LblSubProyectoConf) + SubProyectoConf = LblSubProyectoConf.Text + End Sub Protected Sub DdlCategoria_SelectedIndexChanged(sender As Object, e As EventArgs) @@ -315,4 +339,42 @@ Partial Class Ventas_RepVentasUtilidadPadre #End Region + + Protected Sub LnkModalPorcentajes_Click(sender As Object, e As EventArgs) + + GvPorcentajes.DataSource = Nothing + GvPorcentajes.DataBind() + UpModalPorcentajes.Update() + RegistraScript("$('#DivModalPorcetajes').modal(`show`);") + End Sub + + + + Protected Sub BtnModalConsultaPorcentaje_Click(sender As Object, e As EventArgs) + + Dim ObjVentas As New ClsVentas() + Dim FechaI As Date = TxtModalFechaInicio.Text.ToDate + Dim FechaF As Date = TxtModalFechaFin.Text.ToDate + If TxtModalFechaInicio.Text = "" Then FechaI = MinFecha + If TxtModalFechaFin.Text = "" Then FechaF = MaxFecha + + If ObjVentas.GetReporteVentasUtilidad("-1", -1, "-1", FechaI, FechaF, UsuarioActual.CveEmpresa, -1, -1, -1, -1, -1) Then + GvPorcentajes.DataSource = ObjVentas.DtResultados.FiltraParametros($" CveVenta > 0 AND PorNeto <= {TxtModalPorcentaje.Text.ToDecimal} AND TipoDocto = 'Ing' AND CveEstatusFactura IN(2,3) ") + End If + + ObjVentas.Dispose() + GvPorcentajes.DataBind() + + ObjVentas.Dispose() + UpModalPorcentajes.Update() + + End Sub + + Protected Sub GvPorcentajes_RowDataBound(sender As Object, e As GridViewRowEventArgs) + + If e.Row.RowType = DataControlRowType.Header Then + e.Row.Cells(0).Text = SubProyectoConf + End If + + End Sub End Class