-- generar prepóliza en base a poliza.
This commit is contained in:
@@ -548,6 +548,7 @@
|
||||
<tr>
|
||||
<td style="width: 100%; text-align: center;">
|
||||
<asp:HiddenField runat="server" ID="HdnGuardar" ClientIDMode="Static" />
|
||||
<asp:HyperLink ID="HplCvePrep" runat="server" Visible="false" Target="_blank">Prep </asp:HyperLink>
|
||||
<%--<asp:Button ID="BtnGuardar" runat="server" Text="Guardar" CausesValidation="true" ValidationGroup="GrpGuardar" Width="80px" UseSubmitBehavior="False" class="btn btn-primary"/>--%>
|
||||
<asp:LinkButton ID="BtnGuardar" runat="server" Text="<i class='fa fa-check'></i> Guardar" CausesValidation="true" ValidationGroup="GrpGuardar" UseSubmitBehavior="False" class="btn btn-primary"></asp:LinkButton>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.Drawing
|
||||
Imports Extensiones
|
||||
'Imports System.Activities.Statements
|
||||
'Imports msExcel = Microsoft.Office.Interop.Excel
|
||||
@@ -11,8 +12,7 @@ Imports Extensiones
|
||||
Partial Class RegPoliza
|
||||
Inherits ClsPaginas
|
||||
|
||||
Private Shared missing As Object = System.Reflection.Missing.Value
|
||||
'Dim RemoveMovimientos As New ArrayList()
|
||||
|
||||
#Region "P R O P E R T Y"
|
||||
Private Property NumRow As Integer
|
||||
Private Property IDPoliza As Integer
|
||||
@@ -213,6 +213,8 @@ Partial Class RegPoliza
|
||||
End If
|
||||
|
||||
ObjConta.Dispose()
|
||||
|
||||
|
||||
Else
|
||||
Alert("Este módulo requiere el uso de Contabilidad.", TipoMensaje.MsgAdvertencia)
|
||||
BtnConsultar.Enabled = False
|
||||
@@ -624,110 +626,6 @@ Partial Class RegPoliza
|
||||
|
||||
End Sub
|
||||
|
||||
'#Region "E X C E L"
|
||||
' Private Function GetMacro() As String
|
||||
' Dim SB As New StringBuilder
|
||||
' SB.Append(" Sub AddRow(Row As String) " & vbLf)
|
||||
' SB.Append(" Rows(Row & "":"" & Row).Select " & vbLf)
|
||||
' SB.Append(" Selection.Copy " & vbLf)
|
||||
' SB.Append(" Selection.Insert Shift:=xlDown " & vbLf)
|
||||
' SB.Append(" Rows(Row+1 & "":"" & Row+1).Select " & vbLf)
|
||||
' SB.Append(" Selection.ClearContents " & vbLf)
|
||||
' SB.Append(" End Sub " & vbLf)
|
||||
' Return SB.ToString
|
||||
' End Function
|
||||
|
||||
' Private Sub GeneraPDF()
|
||||
' Dim Msg As New StringBuilder
|
||||
' Dim Excel As msExcel.Application = New msExcel.Application()
|
||||
' Dim VB_Module As VBComponent = Nothing
|
||||
' Excel.Visible = True
|
||||
' Excel.ScreenUpdating = True
|
||||
' Excel.DisplayAlerts = True
|
||||
' Dim ArchivoBase As New System.IO.FileInfo(ModExtensiones.DirectorioBaseEmpresas & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza.xlsm")
|
||||
' 'ArchivoBase.CopyTo(ModExtensiones.DirectorioBaseEmpresas & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & LtlNumeroPoliza.Text.ToString() & ".xlsm", True)
|
||||
' ArchivoBase.CopyTo(ModExtensiones.DirectorioBaseEmpresas & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & TxtNumeroPoliza.Text.ToString() & ".xlsm", True)
|
||||
' 'Dim ArchivoTemp As New System.IO.FileInfo(ModExtensiones.DirectorioBaseEmpresas & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & LtlNumeroPoliza.Text.ToString() & ".xlsm")
|
||||
' Dim ArchivoTemp As New System.IO.FileInfo(ModExtensiones.DirectorioBaseEmpresas & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & TxtNumeroPoliza.Text.ToString() & ".xlsm")
|
||||
|
||||
' Dim Libro As msExcel.Workbook = Excel.Workbooks.Open(ArchivoTemp.FullName, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
|
||||
' Libro.Activate()
|
||||
|
||||
' Dim Hoja As msExcel.Worksheet = CType(Libro.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
|
||||
' Hoja.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible
|
||||
' Hoja.Activate()
|
||||
' VB_Module = CType(Libro.VBProject.VBComponents.Add(Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_StdModule), VBComponent)
|
||||
' VB_Module.CodeModule.AddFromString(GetMacro)
|
||||
|
||||
' 'Encabezado
|
||||
' Hoja.Range("A1:A1").Value = UsuarioActual.Empresa.Empresa.ToString.Trim
|
||||
' Hoja.Range("F2:F2").Value = "Impresión de póliza del " + TxtFechaPoliza.Text.Trim.ToDate.ToShortDateString + " al " + TxtFechaPoliza.Text.Trim.ToDate.ToShortDateString
|
||||
' Hoja.Range("K2:K2").Value = TxtFechaPoliza.Text.Trim.ToDate.ToShortDateString
|
||||
|
||||
' 'Linea 1 datos de la poliza
|
||||
' Dim CeldaI As Integer = 9
|
||||
' Dim CeldaF As Integer = 9
|
||||
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Value = TxtFechaPoliza.Text.Trim.ToDate.ToShortDateString
|
||||
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Value = DdlTipoPoliza.SelectedItem.ToString.Trim
|
||||
' 'Hoja.Range("E" & CeldaF & ":E" & CeldaF).Value = LtlNumeroPoliza.Text.Trim
|
||||
' Hoja.Range("E" & CeldaF & ":E" & CeldaF).Value = TxtNumeroPoliza.Text.Trim
|
||||
' Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = TxtConcepto.Text.Trim
|
||||
|
||||
' CeldaF = CeldaF + 1
|
||||
' 'Movimientos de la poliza Debe de haceptar 36 renglones de excel
|
||||
' For Each Row As DataRow In TmpDT.Rows
|
||||
' Libro.Application.Run("AddRow", (CeldaF - 1).ToString, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
|
||||
' missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
|
||||
' Hoja.Range("A" & CeldaF & ":A" & CeldaF).Value = Row("NumMovto").ToString.Trim
|
||||
' Hoja.Range("B" & CeldaF & ":B" & CeldaF).Value = Row("Referencia").ToString.Trim
|
||||
' Hoja.Range("D" & CeldaF & ":D" & CeldaF).Value = Row("CuentaFormato").ToString.Trim
|
||||
' Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = Row("Cuenta").ToString.Trim
|
||||
' If Row("Cargo").ToString.ToDouble <> 0 Then
|
||||
' Hoja.Range("J" & CeldaF & ":J" & CeldaF).Value = Row("Cargo").ToString.FormatoNumero
|
||||
' End If
|
||||
' If Row("Abono").ToString.ToDouble <> 0 Then
|
||||
' Hoja.Range("K" & CeldaF & ":K" & CeldaF).Value = Row("Abono").ToString.FormatoNumero
|
||||
' End If
|
||||
' CeldaF = CeldaF + 1
|
||||
' Libro.Application.Run("AddRow", (CeldaF - 1).ToString, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
|
||||
' missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
|
||||
' Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = Row("Concepto").ToString.Trim
|
||||
' CeldaF = CeldaF + 1
|
||||
' Next
|
||||
' Hoja.Range("J" & CeldaF & ":J" & CeldaF).Value = TmpDT.SUM("Cargo").FormatoNumero
|
||||
' Hoja.Range("K" & CeldaF & ":K" & CeldaF).Value = TmpDT.SUM("Abono").FormatoNumero
|
||||
|
||||
' 'Exportar PDF
|
||||
' 'Dim pdfFileOut As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & LtlNumeroPoliza.Text.ToString() & ".pdf"
|
||||
' Dim pdfFileOut As String = ModExtensiones.DirectorioBaseEmpresas & "Empresas\" & UsuarioActual.CveEmpresa & "\Formatos\Poliza_" & TxtNumeroPoliza.Text.ToString() & ".pdf"
|
||||
' Dim outputFileName As Object = pdfFileOut
|
||||
' Dim fileFormat As msExcel.XlFixedFormatType = msExcel.XlFixedFormatType.xlTypePDF
|
||||
' Libro.ExportAsFixedFormat(fileFormat, outputFileName, missing, missing, missing, missing, missing, missing, missing)
|
||||
' System.Runtime.InteropServices.Marshal.ReleaseComObject(Hoja)
|
||||
' Hoja = Nothing
|
||||
' Dim saveChanges As Object = msExcel.XlSaveAction.xlDoNotSaveChanges
|
||||
' CType(Libro, msExcel._Workbook).Close(saveChanges, missing, missing)
|
||||
' System.Runtime.InteropServices.Marshal.ReleaseComObject(Libro)
|
||||
' Libro = Nothing
|
||||
' Excel.Quit()
|
||||
' System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
|
||||
' Excel = Nothing
|
||||
' GC.Collect()
|
||||
' GC.WaitForPendingFinalizers()
|
||||
' ArchivoTemp.Delete()
|
||||
|
||||
' Dim Descargas As New StringBuilder()
|
||||
' 'Descargas.AppendFormat("<li><a class=""Texto"" href=""/Empresas/{0}/Formatos/Poliza_{1}.pdf"" target=""_blank"">PDF</a></li>", UsuarioActual.CveEmpresa, LtlNumeroPoliza.Text)
|
||||
' Descargas.AppendFormat("<li><a class=""Texto"" href=""/Empresas/{0}/Formatos/Poliza_{1}.pdf"" target=""_blank"">PDF</a></li>", UsuarioActual.CveEmpresa, TxtNumeroPoliza.Text)
|
||||
|
||||
' Alert("<br />La impresión se generó correctamente.<br /><br /><br />Descargas:<ul>" & Descargas.ToString & "</ul>", TipoMensaje.MsgInformacion)
|
||||
' 'RegistraScript("AbrirVentana('/Ventas/PopUpImprimir.aspx?CveVenta=" & If(EsVistaPrevia, UsuarioActual.CveUsuario.ToString, VentaFolio) & "&Ext=PDF', 700, 400, 'N', 'ImpVenta')")
|
||||
|
||||
|
||||
' End Sub
|
||||
|
||||
'#End Region
|
||||
|
||||
|
||||
#Region " P O L I Z A S - C O M P L E M E N T A R I A S "
|
||||
Private Sub CargaPolizaComplementaria(tIDPoliza As Integer)
|
||||
@@ -982,6 +880,13 @@ Partial Class RegPoliza
|
||||
If ObjConta.GetPrePoliza(-1, UsuarioActual.CveEmpresa, IDPoliza) Then
|
||||
If ObjConta.DtResultados.Rows.Count > 0 Then
|
||||
CvePrePoliza = ObjConta.DtResultados.Rows(0)("CvePrePoliza").ToString.ToEntero
|
||||
If UsuarioActual.CveRol = 1 Then
|
||||
BtnNuevo.BackColor = Color.Yellow
|
||||
BtnNuevo.ToolTip = CvePrePoliza.ToString
|
||||
HplCvePrep.Visible = True
|
||||
HplCvePrep.NavigateUrl = "/Contabilidad/RegPrePolizas.aspx?CvePrePoliza=" & CvePrePoliza
|
||||
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
@@ -990,7 +895,9 @@ Partial Class RegPoliza
|
||||
End If
|
||||
' CargaDevoluciones()
|
||||
End If
|
||||
|
||||
If Request("Regenera") IsNot Nothing AndAlso Request("Regenera").ToString = "1" Then
|
||||
GeneraPrePoliza(tIDPoliza, DT, CvePrePoliza)
|
||||
End If
|
||||
|
||||
End If
|
||||
ObjPoliza.Dispose()
|
||||
@@ -1244,6 +1151,82 @@ Partial Class RegPoliza
|
||||
ObjContabilidad.Dispose()
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub GeneraPrePoliza(tIdPoliza As Integer, dtt As DataTable, tCvePrePoliza As Integer)
|
||||
Dim ObjConta As New ClsContabilidad()
|
||||
ObjConta.IniciaTransacSQL()
|
||||
Dim ObjContaq As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
ObjContaq.IniciaTransacSQL()
|
||||
Dim ErrorRegistro As Boolean = False
|
||||
Dim dr As DataRow = dtt.FiltroPrimero("")
|
||||
Dim tCvePrePolizaOriginal As Integer = tCvePrePoliza
|
||||
|
||||
If tCvePrePoliza <= 0 Then
|
||||
tCvePrePoliza = ObjConta.AddPrePolizas("RegPreP/Man", 53, 0, 0, 1, dr("FechaPol").ToString.ToDate, If(dr("ConceptoPoliza").ToString = "", ".", dr("ConceptoPoliza").ToString), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa,
|
||||
FolioFijo:=dr("Folio").ToString.ToEntero)
|
||||
Else
|
||||
'ocultar los que ya están registrados en la prepóliza
|
||||
If ObjConta.GetPrePolizasDetalle(tCvePrePoliza, UsuarioActual.CveEmpresa) Then
|
||||
For Each drtt As DataRow In ObjConta.DtResultados.FiltraParametros("Contabilizable = 1").Rows
|
||||
ObjConta.UpdateContabilizable(drtt("CvePrePolizaDetalle").ToString.ToEntero, False)
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
If tCvePrePoliza > 0 Then
|
||||
Dim dtc As DataTable = Nothing
|
||||
If ObjConta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then
|
||||
dtc = ObjConta.DtResultados
|
||||
End If
|
||||
|
||||
For Each drt As DataRow In dtt.Rows
|
||||
'PrePólizaDetalle
|
||||
Dim tCveCuenta As Integer = dtc.FiltroPrimeroValor("CveCuenta", $"IdCompaq={drt("IdCuenta")}").ToEntero
|
||||
Dim tCveSub As Integer = If(drt("IdSegNeg").ToString <> "", GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto", $"SubProyecto ='{drt("SegNeg")}'").ToEntero, -1)
|
||||
'If tCveSub <= 0 AndAlso drt("IdSegNeg").ToString.ToEntero = 0 Then 'toma el primero
|
||||
' tCveSub = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveSubProyecto").ToEntero
|
||||
'End If
|
||||
If ObjConta.AddPrePolizasDetalle(tCvePrePoliza, drt("TipoMovto").ToString = "True",
|
||||
drt("Importe").ToString.ToDecimal,
|
||||
drt("Concepto").ToString, 299,
|
||||
drt("Concepto").ToString, Now,
|
||||
drt("IdCuenta").ToString.ToEntero, 0,
|
||||
CveSubProyecto:=tCveSub,
|
||||
ImporteMX:=drt("Importe").ToString.ToDecimal, CveCuenta:=tCveCuenta) Then
|
||||
'registro
|
||||
If Not ObjContaq.UpdateMovimientoPrePolizaDetalle(drt("IdPoliza").ToString.ToEntero,
|
||||
drt("Id").ToString.ToEntero,
|
||||
ObjConta.CvePrePolizaDetalle) Then
|
||||
ErrorRegistro = True
|
||||
Exit For
|
||||
End If
|
||||
Else
|
||||
ErrorRegistro = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
If Not ErrorRegistro AndAlso tCvePrePolizaOriginal <= 0 AndAlso Not ObjConta.UpdatePrePoliza(dr("FechaPol").ToString.ToDate, dr("Folio").ToString.ToEntero, -1, tIdPoliza, tCvePrePoliza, UsuarioActual.CveEmpresa, CveUsuarioModifico:=UsuarioActual.CveUsuario) Then
|
||||
ErrorRegistro = True
|
||||
End If
|
||||
Else
|
||||
ErrorRegistro = True
|
||||
End If
|
||||
|
||||
If Not ErrorRegistro Then
|
||||
Alert($"<a Class=""Texto"" target='_blank' href=""/Contabilidad/RegPrePolizaS.aspx?CvePrePoliza={tCvePrePoliza}"">Ver Póliza</a> ")
|
||||
ObjConta.Commit()
|
||||
ObjContaq.Commit()
|
||||
Else
|
||||
ObjConta.RollBack()
|
||||
ObjContaq.RollBack()
|
||||
End If
|
||||
|
||||
ObjConta.Dispose()
|
||||
ObjContaq.Dispose()
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Historial de Modificacion"
|
||||
@@ -1259,53 +1242,6 @@ Partial Class RegPoliza
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
'Protected Sub TxtNumeroPoliza_TextChanged(sender As Object, e As EventArgs) Handles TxtNumeroPoliza.TextChanged
|
||||
' If HdnFolioPoliza.Value.ToEntero <> TxtNumeroPoliza.Text.Trim.ToEntero Then
|
||||
' BtnGuardar.OnClientClick = "return confirm('Intenta cambiar el número de la póliza?')"
|
||||
' Else
|
||||
' BtnGuardar.OnClientClick = ""
|
||||
' End If
|
||||
' upDatos.Update()
|
||||
'End Sub
|
||||
|
||||
'Protected Sub TxtFechaPoliza_TextChanged(sender As Object, e As EventArgs) Handles TxtFechaPoliza.TextChanged
|
||||
' If HdnFechaPoliza.Value.ToDate.ToShortDateString <> TxtFechaPoliza.Text.ToDate.ToShortDateString Then
|
||||
' BtnGuardar.OnClientClick = "return confirm('Intenta cambiar la fecha de la póliza?')"
|
||||
' Else
|
||||
' BtnGuardar.OnClientClick = ""
|
||||
' End If
|
||||
' upDatos.Update()
|
||||
' upTitulos.Update()
|
||||
'End Sub
|
||||
|
||||
'Protected Sub DdlTipoPoliza_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoPoliza.SelectedIndexChanged
|
||||
' If HdnTipoPoliza.Value <> DdlTipoPoliza.SelectedValue Then
|
||||
' BtnGuardar.OnClientClick = "return confirm('Intenta Cambiar el tipo de póliza?')"
|
||||
' Else
|
||||
' BtnGuardar.OnClientClick = ""
|
||||
' End If
|
||||
' upDatos.Update()
|
||||
' upTitulos.Update()
|
||||
'End Sub
|
||||
|
||||
'TmpDT = Nothing
|
||||
'GvDatos.DataBind()
|
||||
'TxtFechaPoliza.Text = ""
|
||||
'TxtFecha.Text = ""
|
||||
'DdlTipoPoliza.SelectedIndex = 0
|
||||
'TxtNumero.Text = ""
|
||||
''LtlNumeroPoliza.Text = "-"
|
||||
'TxtNumeroPoliza.Text = "-"
|
||||
'HdnIdPoliza.Value = ""
|
||||
'TxtConcepto.Text = ""
|
||||
'TxtReferencia.Text = ""
|
||||
'DdlCuenta.SelectedIndex = 0
|
||||
'DdlSegNeg.SelectedIndex = 0
|
||||
'TxtNombreConcepto.Text = ""
|
||||
'TxtCargo.Text = ""
|
||||
'TxtAbono.Text = ""
|
||||
'LblCargo.Text = "0.00"
|
||||
'LblAbono.Text = "0.00"
|
||||
|
||||
Private Sub limpia()
|
||||
HdnCveCuenta.Value = ""
|
||||
|
||||
Reference in New Issue
Block a user