3329 lines
153 KiB
VB.net
3329 lines
153 KiB
VB.net
|
|
Imports System.Data
|
|
Imports System.Net.NetworkInformation
|
|
Imports ADSNetLibrary.SIGAPI.Models.OC.Response
|
|
'Imports DocumentFormat.OpenXml
|
|
Imports Extensiones
|
|
Imports GemBox.Spreadsheet
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class ContabilidadC_RegPrePolizaS
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region "Propiedades"
|
|
Public Property ArregloMovs As ArrayList
|
|
Get
|
|
Return CType(ViewState("ArregloMovs"), ArrayList)
|
|
End Get
|
|
Set(value As ArrayList)
|
|
ViewState("ArregloMovs") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtMovimientos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DtMovimientosEliminar As DataTable
|
|
Get
|
|
Return CType(ViewState("DtMovimientosEliminar"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtMovimientosEliminar") = value
|
|
End Set
|
|
End Property
|
|
Public Property DtCuentasContables As DataTable
|
|
Get
|
|
Return CType(ViewState("DtCuentasContables"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtCuentasContables") = value
|
|
End Set
|
|
End Property
|
|
Public Property TipoPlantilla As Integer
|
|
Get
|
|
Return CType(ViewState("TipoPlantilla"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoPlantilla") = value
|
|
End Set
|
|
End Property
|
|
Public Property CveMoneda As Integer
|
|
Get
|
|
Return CType(ViewState("CveMoneda"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMoneda") = value
|
|
End Set
|
|
End Property
|
|
Private ReadOnly Property CvePrePoliza As Integer
|
|
Get
|
|
Return ViewState("CvePrePoliza").ToString.ToEntero
|
|
End Get
|
|
End Property
|
|
|
|
Public Property DrConceptoContable As DataRow
|
|
Get
|
|
If ViewState("DrConceptoContable") IsNot Nothing Then
|
|
Return CType(ViewState("DrConceptoContable"), DataRow)
|
|
Else
|
|
Return Nothing
|
|
End If
|
|
|
|
End Get
|
|
Set(value As DataRow)
|
|
ViewState("DrConceptoContable") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveTipoTransaccion As Integer
|
|
Get
|
|
Return ViewState("CveTipoTransaccion").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveTipoTransaccion") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveCuenta As Integer
|
|
Get
|
|
Return ViewState("CveCuenta").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCuenta") = value
|
|
End Set
|
|
End Property
|
|
Private Property Folio As String
|
|
Get
|
|
Return ViewState("Folio").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Folio") = value
|
|
End Set
|
|
End Property
|
|
Private Property ImporteDocumento As Decimal
|
|
Get
|
|
Return ViewState("ImporteDocumento").ToString.ToDecimal
|
|
End Get
|
|
Set(value As Decimal)
|
|
ViewState("ImporteDocumento") = value
|
|
End Set
|
|
End Property
|
|
Private Property Observaciones As String
|
|
Get
|
|
Return ViewState("Observaciones").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Observaciones") = value
|
|
End Set
|
|
End Property
|
|
Private Property Beneficiario As String
|
|
Get
|
|
Return ViewState("Beneficiario").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Beneficiario") = value
|
|
End Set
|
|
End Property
|
|
Private Property RowIndex As Integer
|
|
Get
|
|
Return ViewState("RowIndex").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("RowIndex") = value
|
|
End Set
|
|
End Property
|
|
Private Property Actualizar As Boolean
|
|
Get
|
|
Return CBool(ViewState("Actualizar").ToString)
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("Actualizar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private ReadOnly Property CvePeriodo As Integer
|
|
Get
|
|
Return CType(ViewState("CvePeriodo"), Integer)
|
|
End Get
|
|
End Property
|
|
Private ReadOnly Property CveProyecto As Integer
|
|
Get
|
|
Return CType(ViewState("CveProyecto"), Integer)
|
|
End Get
|
|
End Property
|
|
Private ReadOnly Property CveSubProyecto As Integer
|
|
Get
|
|
Return CType(ViewState("CveSubProyecto"), Integer)
|
|
End Get
|
|
End Property
|
|
Private ReadOnly Property CveTurno As Integer
|
|
Get
|
|
Return CType(ViewState("CveTurno"), Integer)
|
|
End Get
|
|
End Property
|
|
Public Property IndiceGrid As Integer
|
|
Get
|
|
Return CType(ViewState("IndiceGrid"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IndiceGrid") = value
|
|
End Set
|
|
End Property
|
|
Public Property IdPoliza As Integer
|
|
Get
|
|
Return CType(ViewState("IdPoliza"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IdPoliza") = value
|
|
End Set
|
|
End Property
|
|
Public Property Tick As String
|
|
Get
|
|
Return CType(ViewState("Tick"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Tick") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property CveIE As Integer
|
|
Get
|
|
Return CType(ViewState("CveIE"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveIE") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property IDMovEditar As Integer
|
|
Get
|
|
Return CType(ViewState("IDMovEditar"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IDMovEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property TipoPoliza As String
|
|
Get
|
|
Return CType(ViewState("TipoPoliza"), String)
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("TipoPoliza") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property CvePlantillaPoliza As Integer
|
|
Get
|
|
If ViewState("CvePlantillaPoliza") Is Nothing Then
|
|
ViewState("CvePlantillaPoliza") = -1
|
|
End If
|
|
Return ViewState("CvePlantillaPoliza").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePlantillaPoliza") = value
|
|
End Set
|
|
|
|
End Property
|
|
|
|
|
|
Public Property CvePrePolizaOrigen As Integer
|
|
Get
|
|
If ViewState("CvePrePolizaOrigen") Is Nothing Then
|
|
ViewState("CvePrePolizaOrigen") = -1
|
|
End If
|
|
Return ViewState("CvePrePolizaOrigen").ToString.ToEntero
|
|
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePrePolizaOrigen") = value
|
|
End Set
|
|
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
|
|
If Not Page.IsPostBack Then
|
|
|
|
'If UsuarioActual.Empresa.Funcionalidad(282).ToEntero > 0 Then
|
|
' LnkImprimePDFResumen.Visible = True
|
|
' LnkImprimeExcelResumen.Visible = True
|
|
'End If
|
|
|
|
Tick = DateTime.Now.Ticks.ToString
|
|
|
|
CveMoneda = 1
|
|
ViewState("CvePrePoliza") = 0
|
|
ViewState("CvePeriodo") = "0"
|
|
|
|
CveTipoTransaccion = -1
|
|
CveCuenta = -1
|
|
Folio = "-1"
|
|
ImporteDocumento = -1
|
|
Observaciones = "-1"
|
|
Beneficiario = "-1"
|
|
Actualizar = False
|
|
IdPoliza = -1
|
|
CargaCtaContableE()
|
|
|
|
CargaConceptosContablesE()
|
|
CargaModalConceptoCuentas()
|
|
|
|
If IfNull(Request("Tipo"), "").ToString = "NOMPROV" Then
|
|
DivTipoGasto.Visible = True
|
|
ThTipoGasto.Visible = True
|
|
CargaTiposGasto()
|
|
End If
|
|
|
|
If Request("CvePrePoliza") IsNot Nothing AndAlso IsNumeric(Request("CvePrePoliza")) AndAlso Request("CvePrePoliza").ToEntero > 0 Then
|
|
|
|
ViewState("CvePrePoliza") = Request("CvePrePoliza").ToEntero
|
|
CreaDT()
|
|
CreaDTEliminar()
|
|
CargaPrePoliza()
|
|
If IfNull(Request("Tipo"), "").ToString <> "NOMPROV" Then
|
|
GvPrePoliza.Columns(5).Visible = False
|
|
DivTG.Visible = False
|
|
GvMov.Columns(5).Visible = False
|
|
End If
|
|
ValidaCrearAPartirDe()
|
|
DvPlantilla.Visible = False
|
|
|
|
|
|
If UsuarioActual.Empresa.TipoContabilidad = 1 Then
|
|
|
|
If Folio.ToEntero > 0 Then
|
|
BtnDescontabilizar.Visible = True
|
|
LnkFolioManual.Visible = False
|
|
Else
|
|
BtnDescontabilizar.Visible = False
|
|
LnkFolioManual.Visible = True
|
|
End If
|
|
|
|
End If
|
|
|
|
Exit Sub
|
|
|
|
ElseIf Request("CvePrePolizaOrigen") IsNot Nothing AndAlso IsNumeric(Request("CvePrePolizaOrigen")) AndAlso Request("CvePrePolizaOrigen").ToEntero > 0 Then
|
|
|
|
|
|
CvePrePolizaOrigen = Request("CvePrePolizaOrigen").ToEntero
|
|
CreaDT()
|
|
CargaPrePolizaOrigen()
|
|
|
|
OcultarControlesCrearApartirDe()
|
|
DvPlantilla.Visible = False
|
|
|
|
Exit Sub
|
|
|
|
Else
|
|
CreaDT()
|
|
BtnEliminar.Visible = False
|
|
LnkExcel.Visible = True
|
|
LnkImprimirPDF.Visible = False
|
|
DvPlantilla.Visible = True
|
|
|
|
TxtFechaDocumento.Text = Now.ToString("dd/MM/yyyy")
|
|
TxtFechaelaboracion.Text = Now.ToString("dd/MM/yyyy")
|
|
TxtConcepto.Enabled = True
|
|
TxtUsuarioElaboro.Text = UsuarioActual.Usuario
|
|
DvPlantilla.Visible = True
|
|
'LnkAddConcepto.Visible = False
|
|
|
|
'UpPrePoliza.Visible = False
|
|
|
|
End If
|
|
|
|
|
|
TipoPlantilla = -1
|
|
If IfNull(Request("Tipo"), "").ToString = "Ing" Then
|
|
TipoPlantilla = 1
|
|
LblEncabezado.Text = "Otros Ingresos"
|
|
End If
|
|
|
|
CargaPlantillas(TipoPlantilla)
|
|
|
|
'If UsuarioActual.CveRol = 1 Then trNotificar.Visible = True
|
|
|
|
CargaConceptos()
|
|
CargaSubProyectos()
|
|
CargaCuentasContables()
|
|
|
|
'crea tabla temporal
|
|
ArregloMovs = New ArrayList
|
|
|
|
CargaCuentas()
|
|
|
|
If IfNull(Request("Tipo"), "").ToString <> "NOMPROV" Then
|
|
GvPrePoliza.Columns(5).Visible = False
|
|
GvMov.Columns(5).Visible = False
|
|
End If
|
|
|
|
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CreaDT()
|
|
DtMovimientos = New DataTable("Movimientos")
|
|
Dim IDMov As DataColumn = DtMovimientos.Columns.Add("IdMov", Type.GetType("System.Int32")) : IDMov.AutoIncrement = True
|
|
With DtMovimientos.Columns
|
|
.Add("CodigoCuenta", Type.GetType("System.String"))
|
|
.Add("Cuenta", Type.GetType("System.String"))
|
|
.Add("Referencia", Type.GetType("System.String"))
|
|
.Add("Concepto", Type.GetType("System.String"))
|
|
.Add("Cargo", Type.GetType("System.Decimal"))
|
|
.Add("Abono", Type.GetType("System.Decimal"))
|
|
.Add("TipoMovto", Type.GetType("System.Boolean"))
|
|
.Add("ImporteMN", Type.GetType("System.Decimal"))
|
|
.Add("ImporteME", Type.GetType("System.Decimal"))
|
|
.Add("EsComodin", Type.GetType("System.Int32"))
|
|
.Add("CveSubProyecto", Type.GetType("System.Int32"))
|
|
.Add("Descripcion", Type.GetType("System.String"))
|
|
.Add("CveProveedor", Type.GetType("System.Int32"))
|
|
.Add("CvePersonal", Type.GetType("System.Int32"))
|
|
.Add("CveCompra", Type.GetType("System.Int32"))
|
|
.Add("CveCliente", Type.GetType("System.Int32"))
|
|
.Add("CveVenta", Type.GetType("System.Int32"))
|
|
.Add("CveIE", Type.GetType("System.Int32"))
|
|
.Add("CveClasificacion", Type.GetType("System.Int32"))
|
|
.Add("MultipleSubProyecto", Type.GetType("System.Boolean"))
|
|
.Add("CveTipoGasto", Type.GetType("System.Int32"))
|
|
.Add("CvePrePolizaDetalle", Type.GetType("System.Int32"))
|
|
.Add("CveConceptoContable", Type.GetType("System.Int32"))
|
|
.Add("IdCtaContable", Type.GetType("System.Int32"))
|
|
.Add("ConceptoContable", Type.GetType("System.String"))
|
|
.Add("CveCuenta", Type.GetType("System.Int32"))
|
|
.Add("CodigoNombreCuenta", Type.GetType("System.String"))
|
|
.Add("SubProyecto", Type.GetType("System.String"))
|
|
.Add("FolioFactura", Type.GetType("System.String"))
|
|
.Add("TipoGasto", Type.GetType("System.String"))
|
|
|
|
.Add("ContadoTipoTransaccion", Type.GetType("System.Int32"))
|
|
.Add("ContadoCuenta", Type.GetType("System.Int32"))
|
|
.Add("ContadoNumeroFolio", Type.GetType("System.String"))
|
|
.Add("ContadoImporte", Type.GetType("System.Decimal"))
|
|
.Add("ContadoBeneficiario", Type.GetType("System.String"))
|
|
.Add("ContadoObservaciones", Type.GetType("System.String"))
|
|
.Add("PorcentajeImpuesto", Type.GetType("System.Decimal"))
|
|
.Add("Modificado", Type.GetType("System.Boolean"))
|
|
.Add("EsComplementaria", Type.GetType("System.Boolean"))
|
|
.Add("EsMonedaExtranjera", Type.GetType("System.Boolean"))
|
|
.Add("TC", Type.GetType("System.Decimal"))
|
|
.Add("CvePrePoliza", Type.GetType("System.Int32"))
|
|
|
|
End With
|
|
|
|
If Not DtMovimientos.Columns.Contains("Cargo") Then
|
|
DtMovimientos.Columns.Add("Cargo", Type.GetType("System.Decimal"))
|
|
DtMovimientos.Columns.Add("Abono", Type.GetType("System.Decimal"))
|
|
End If
|
|
|
|
DtMovimientos.AcceptChanges()
|
|
|
|
End Sub
|
|
|
|
Private Sub CreaDTEliminar()
|
|
DtMovimientosEliminar = New DataTable("MovimientosEliminar")
|
|
With DtMovimientosEliminar.Columns
|
|
.Add("CvePrePolizaDetalle", GetType(Integer))
|
|
End With
|
|
DtMovimientosEliminar.AcceptChanges()
|
|
End Sub
|
|
Private Sub CargaPrePoliza()
|
|
BtnEliminar.Visible = True
|
|
LblEncabezado.Text = "Edición de Póliza"
|
|
|
|
Dim ObjContabilidad As New ClsContabilidad
|
|
If ObjContabilidad.GetPrePoliza(CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
|
Dim dr As DataRow = ObjContabilidad.DtResultados.FiltroPrimero("")
|
|
If dr IsNot Nothing Then
|
|
DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza")
|
|
TxtFechaDocumento.Text = dr("Fecha")
|
|
TxtConcepto.Text = dr("Concepto")
|
|
DivDatosPoliza.Visible = True
|
|
TipoPoliza = DdlTipoPoliza.SelectedItem.Text
|
|
Folio = dr("FolioPoliza").ToString
|
|
|
|
TxtFolio.Text = dr("FolioPoliza").ToString
|
|
TxtUsuarioElaboro.Text = dr("Usuario").ToString
|
|
TxtFechaelaboracion.Text = dr("FechaIng").ToString.ToDate.ToString("dd/MM/yyyy")
|
|
CvePlantillaPoliza = dr("CvePlantillaPoliza").ToString
|
|
|
|
If UsuarioActual.CveRol = 1 Then
|
|
TxtUsuarioElaboro.ToolTip = dr("Modulo").ToString
|
|
End If
|
|
|
|
If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then
|
|
LnkAddConcepto.Visible = True
|
|
CargaConceptos()
|
|
CargaSubProyectos()
|
|
CargaCuentasContables()
|
|
End If
|
|
|
|
ObjContabilidad.GetContabilizacionDiarioDetalle(CvePrePoliza)
|
|
DtMovimientos = ObjContabilidad.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
|
|
|
|
If dr("Modulo").ToString.Contiene("Banc/FluctuaA", "Banc/FluctuaC", "Banc/FluctuaV", "Banc/FluctuaFilial", "Banc/FluctuaAD") Then
|
|
BtnEliminar.Enabled = False
|
|
BtnEliminar.ToolTip = "No se puede eliminar al prepóliza, eliminarlos desde el módulo"
|
|
End If
|
|
|
|
If DtMovimientos IsNot Nothing AndAlso DtMovimientos.FiltraParametros("CveConceptoContable = 30 AND Contabilizable = 1").Rows.Count > 0 Then
|
|
BtnEliminar.Enabled = False
|
|
BtnEliminar.ToolTip = "No se puede eliminar al prepóliza, eliminarla desde el módulo de Bancos"
|
|
End If
|
|
|
|
GvPrePoliza.DataSource = DtMovimientos
|
|
If Not DtMovimientos.Columns.Contains("IdMov") Then
|
|
Dim workColumn As DataColumn = DtMovimientos.Columns.Add("IdMov", GetType(Integer))
|
|
workColumn.AutoIncrement = True
|
|
workColumn.AutoIncrementStep = 1
|
|
End If
|
|
|
|
If Not DtMovimientos.Columns.Contains("ContadoCuenta") Then
|
|
|
|
DtMovimientos.Columns.Add("ContadoCuenta", GetType(Integer))
|
|
DtMovimientos.Columns.Add("ContadoTipoTransaccion", GetType(Integer))
|
|
DtMovimientos.Columns.Add("ContadoNumeroFolio", GetType(String))
|
|
DtMovimientos.Columns.Add("ContadoBeneficiario", GetType(String))
|
|
DtMovimientos.Columns.Add("ContadoObservaciones", GetType(String))
|
|
DtMovimientos.Columns.Add("ContadoImporte", GetType(Decimal))
|
|
|
|
End If
|
|
|
|
If Not DtMovimientos.Columns.Contains("Cargo") Then
|
|
DtMovimientos.Columns.Add("Cargo", GetType(Decimal))
|
|
DtMovimientos.Columns.Add("Abono", GetType(Decimal))
|
|
End If
|
|
|
|
GvPrePoliza.DataBind()
|
|
|
|
If UsuarioActual.CveRol = 1 AndAlso DtMovimientos.COUNT("TC", "TC > 1") > 0 Then
|
|
GvPrePoliza.Columns(7).Visible = True
|
|
End If
|
|
|
|
If DtMovimientos.FiltraParametros("CveConceptoContable IN (2,17,292,308)").Rows.Count > 0 Then
|
|
LnkComplementoPago.Visible = True
|
|
End If
|
|
|
|
If dr("FolioPoliza").ToString = "" OrElse dr("FolioPoliza").ToString = "0" Then
|
|
BtnContabilizar.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.TipoContabilizacion = 1 Then
|
|
If dr("FolioPoliza").ToString.ToEntero > 0 AndAlso UsuarioActual.CveRol = 1 Then
|
|
divContabilizada.Visible = True
|
|
Folio = dr("FolioPoliza").ToString
|
|
End If
|
|
Else
|
|
If dr("IdPoliza").ToString.ToEntero > 0 AndAlso UsuarioActual.CveRol = 1 Then
|
|
HplContabilizada.NavigateUrl = String.Format("RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza"))
|
|
divContabilizada.Visible = True
|
|
IdPoliza = dr("IdPoliza").ToString.ToEntero
|
|
End If
|
|
End If
|
|
|
|
UpPrePoliza.Update()
|
|
RegistraScript("comparar();")
|
|
|
|
LnkExcel.Visible = False
|
|
LnkImprimirPDF.Visible = True
|
|
Else
|
|
Alert("El documento solicitado no existe, favor de revisar su búsqueda.", TipoMensaje.MsgAdvertencia)
|
|
BtnEliminar.Visible = False
|
|
End If
|
|
End If
|
|
|
|
ObjContabilidad.Dispose()
|
|
UpPoliza.Update()
|
|
End Sub
|
|
|
|
Private Sub GvPrePoliza_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvPrePoliza.RowDataBound
|
|
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
If e.Row.DataKey("IdCtaContable") <> "" Then
|
|
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", e.Row.DataKey("IdCtaContable")))
|
|
If drr IsNot Nothing Then
|
|
e.Row.FCLiteral("DdlCtaContable").Text = drr("CuentaFormato").ToString() + " - " + drr("Nombre").ToString()
|
|
End If
|
|
End If
|
|
|
|
TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDecimal + e.Row.FCLiteral("TxtCargo").Text.ToDecimal).ToString.FormatoNumero
|
|
TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDecimal + e.Row.FCLiteral("TxtAbono").Text.ToDecimal).ToString.FormatoNumero
|
|
|
|
Dim CveConceptoContable As Integer = e.Row.DataKey("CveConceptoContable").ToEntero
|
|
|
|
If CveConceptoContable.Contiene(1, 2, 13, 38, 207, 203, 39, 61, 62, 63, 4, 278, 291, 292, 293, 294, 272, 150, 251, 301) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Ventas/Ventas.aspx?CveVenta={0}", e.Row.DataKey("CveVenta"))
|
|
If CveConceptoContable.Contiene(5, 6, 17, 18, 14, 19, 25, 26, 60, 205, 225, 234, 235, 240, 305, 306, 307, 308, 309, 310, 311, 312, 201, 206, 341, 342, 304, 272, 259) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Compras/Compras.aspx?CveCompra={0}", e.Row.DataKey("CveCompra"))
|
|
If CveConceptoContable.Contiene(68) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Inventarios/EntradasSalidas.aspx?CveMovimiento={0}", e.Row.DBCampo("CveMovimientoAlmacen"))
|
|
If CveConceptoContable.Contiene(30, 204, 66, 92) Then e.Row.FCHyperLink("HlReferencia").NavigateUrl = String.Format("/Bancos/IE.aspx?CveIE={0}", e.Row.DBCampo("CveIE"))
|
|
|
|
'e.Row.FCHyperLink("HlReferencia").NavigateUrl = CveConceptoContable
|
|
If e.Row.DBCampo("Modificado") Then
|
|
e.Row.FCCheckBox("chkModificado").Checked = True
|
|
End If
|
|
End If
|
|
|
|
If e.Row.RowType = DataControlRowType.Header Then
|
|
'e.Row.FCDropDownList("DdlSubProyectoFiltro").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
'e.Row.FCDropDownList("DdlSubProyectoFiltro").DataBind()
|
|
'e.Row.FCDropDownList("DdlSubProyectoFiltro").Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaPlantillas(TipoPlantilla As Integer)
|
|
|
|
'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
|
'GvPlantillas.DataBind()
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(120) Then
|
|
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, -1)
|
|
DdlPlantilla2.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, -1)
|
|
|
|
Else
|
|
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
|
DdlPlantilla2.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
|
|
|
End If
|
|
|
|
|
|
DdlPlantilla.DataBind()
|
|
DdlPlantilla.Items.Insert(0, New ListItem("Plantilla Personalizada", "53"))
|
|
|
|
DdlPlantilla2.DataBind()
|
|
DdlPlantilla2.Items.Insert(0, New ListItem("Plantilla Personalizada", "53"))
|
|
End Sub
|
|
|
|
Private Sub CargaConceptos()
|
|
DdlConceptosContables.DataSource = GlobalDTContaConceptosContables(-1)
|
|
DdlConceptosContables.DataBind()
|
|
End Sub
|
|
|
|
Private Sub DdlConceptosContables_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConceptosContables.SelectedIndexChanged
|
|
|
|
Dim dr As DataRow = GlobalDTContaConceptosContables(DdlConceptosContables.SelectedValue.ToEntero).FiltroPrimero("")
|
|
|
|
If dr IsNot Nothing Then
|
|
If dr("AplicaTC").ToString = "True" Then
|
|
TxtTCPreP.Visible = True
|
|
LblTC.Visible = True
|
|
Else
|
|
TxtTCPreP.Visible = False
|
|
LblTC.Visible = False
|
|
End If
|
|
End If
|
|
|
|
If DdlConceptosContables.SelectedValue.ToEntero.Contiene(5, 17, 201, 206, 14, 15, 16, 19, 25, 26, 21) Then
|
|
CargaProveedores()
|
|
DdlProveedores.Visible = True
|
|
DdlCompras.Visible = True
|
|
Else
|
|
DdlProveedores.Visible = False
|
|
DdlCompras.Visible = False
|
|
End If
|
|
|
|
If DdlConceptosContables.SelectedValue.ToEntero.Contiene(28, 29) Then
|
|
CargaPersonal()
|
|
DdlPersonal.Visible = True
|
|
Else
|
|
DdlPersonal.Visible = False
|
|
End If
|
|
If DdlConceptosContables.SelectedValue.ToEntero.Contiene(1, 2, 203, 207, 13, 61, 8, 9, 62, 63, 38, 39, 12, 91, 291, 292) Then
|
|
CargaClientes()
|
|
DdlClientes.Visible = True
|
|
DdlVentas.Visible = True
|
|
Else
|
|
DdlClientes.Visible = False
|
|
DdlVentas.Visible = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub DdlProveedores_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedores.SelectedIndexChanged
|
|
CargaCompras(DdlProveedores.SelectedValue.ToEntero)
|
|
End Sub
|
|
|
|
Private Sub DdlClientes_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientes.selectedindexchange
|
|
CargaVentas(DdlClientes.SelectedValue.ToEntero)
|
|
End Sub
|
|
|
|
Private Sub CargaSubProyectos()
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyecto.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
DdlSubProyectoFiltroMov.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
DdlSubProyectoFiltroMov.DataBind()
|
|
DdlSubProyectoFiltroMov.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaCuentasContables()
|
|
Dim ObjConta As New ClsContabilidad
|
|
If ObjConta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then
|
|
DdlCuentaContableE.DataSource = ObjConta.DtResultados
|
|
DdlCuentaContable.DataSource = ObjConta.DtResultados
|
|
DtCuentasContables = ObjConta.DtResultados
|
|
End If
|
|
ObjConta.Dispose()
|
|
DdlCuentaContable.DataBind()
|
|
DdlCuentaContable.Items.Insert(0, New ListItem("Seleccione", "0"))
|
|
DdlCuentaContableE.DataBind()
|
|
DdlCuentaContableE.Items.Insert(0, New ListItem("Sin Asignar", "0"))
|
|
End Sub
|
|
|
|
Private Function CargaCuentasContpaq(CveCuenta As Integer) As Integer
|
|
Dim Retorno As Integer = -1
|
|
If CveCuenta > 0 Then
|
|
Dim ObjConta As New ClsContabilidad
|
|
If ObjConta.GetCuentas(CveCuenta, "-1", 1, UsuarioActual.CveEmpresa) Then
|
|
Retorno = ObjConta.DtResultados.Rows(0)("IdCompaq").ToString.ToEntero
|
|
End If
|
|
ObjConta.Dispose()
|
|
End If
|
|
Return Retorno
|
|
|
|
End Function
|
|
Private Sub CargaTiposGasto()
|
|
DdlTipoGasto.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
|
|
DdlTipoGasto.DataBind()
|
|
DdlTipoGasto.Items.Insert(0, New ListItem("Sin Asignar", "0"))
|
|
End Sub
|
|
|
|
Private Sub CargaProveedores()
|
|
DdlProveedores.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlProveedores.DataBind()
|
|
DdlProveedores.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaCompras(CveProveedor As Integer)
|
|
If DdlConceptosContables.SelectedValue.ToEntero.Contiene(5, 17, 305, 308, 310, 311, 312) Then
|
|
Dim ObjCompras As New ClsCompras
|
|
|
|
DdlCompras.ClearSelection()
|
|
If ObjCompras.GetCompras(-1, "-1", "-1", CveProveedor, -1, UsuarioActual.CveEmpresa) Then
|
|
DdlCompras.DataSource = ObjCompras.DtResultados.FiltraParametros("Saldo > 0")
|
|
DdlCompras.DataBind()
|
|
DdlCompras.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
Else
|
|
DdlCompras.DataSource = Nothing
|
|
DdlCompras.DataBind()
|
|
DdlCompras.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End If
|
|
ObjCompras.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaClientes()
|
|
DdlClientes.setEsWebService(True)
|
|
DdlClientes.Attributes.Add("data-metodo", "getcliente")
|
|
'DdlClientes.DataSource = GlobalDTCliente(UsuarioActual.CveEmpresa)
|
|
'DdlClientes.DataBind()
|
|
' DdlClientes.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaVentas(CveCliente As Integer)
|
|
Dim ObjVentas As New ClsVentas
|
|
|
|
DdlVentas.ClearSelection()
|
|
If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1", CveCliente, -1, -1, -1, "-1", "-1", "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
|
|
DdlVentas.DataSource = ObjVentas.DtResultados '.FiltraParametros("Saldo > 0")
|
|
DdlVentas.DataBind()
|
|
DdlVentas.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
Else
|
|
DdlVentas.DataSource = Nothing
|
|
DdlVentas.DataBind()
|
|
DdlVentas.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End If
|
|
ObjVentas.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaPersonal()
|
|
DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
|
|
DdlPersonal.DataBind()
|
|
DdlPersonal.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
|
|
|
|
Protected Sub DdlPlantilla_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPlantilla.SelectedIndexChanged
|
|
|
|
TxtTotalAbonos.Text = ""
|
|
TxtTotalCargos.Text = ""
|
|
|
|
If DdlPlantilla.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Seleccione un Movimiento Válido", TipoMensaje.MsgAdvertencia)
|
|
DdlPlantilla.SelectedValue = "-1"
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlPlantilla.SelectedValue.ToEntero = 53 Then 'Plantilla Personalizada
|
|
DivAgregarConceptos.Visible = True
|
|
LnkAddConcepto.Visible = True
|
|
If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then
|
|
'DivAgregarConceptos.Visible = True
|
|
LnkAddConcepto.Visible = True
|
|
CargaConceptos()
|
|
CargaSubProyectos()
|
|
CargaCuentasContables()
|
|
End If
|
|
GvPrePoliza.Visible = True
|
|
DivAgregarConceptos.Visible = False
|
|
divMovtos.Visible = False
|
|
UPMovs.Update()
|
|
|
|
Else
|
|
DivAgregarConceptos.Visible = False
|
|
divMovtos.Visible = True
|
|
UPMovs.Update()
|
|
End If
|
|
|
|
Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero
|
|
|
|
Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(UsuarioActual.CveEmpresa, CvePlantilla).FiltraParametros("", "Orden")
|
|
|
|
'Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla, UsuarioActual.CveEmpresa)
|
|
Dim Cuenta As String = ""
|
|
Dim IdCuenta As Integer = 0
|
|
Dim CodigoCuenta As String = ""
|
|
Dim NombreCuenta As String = ""
|
|
Dim EsComodin As Integer = 0
|
|
DtMovimientos.Clear()
|
|
|
|
For Each drt As DataRow In Dt.Rows
|
|
|
|
Cuenta = drt("ConceptoContable").ToString
|
|
IdCuenta = 0
|
|
CodigoCuenta = ""
|
|
NombreCuenta = ""
|
|
|
|
|
|
Dim dr As DataRow = DtMovimientos.NewRow
|
|
|
|
dr("CodigoCuenta") = drt("Codigo").ToString & "<br>" & drt("Nombre").ToString
|
|
dr("CodigoNombreCuenta") = drt("Codigo").ToString & "<br>" & drt("Nombre").ToString
|
|
dr("Cuenta") = Cuenta 'TxtCuentaContable.Text
|
|
dr("Referencia") = If(drt("CveConceptoContable").ToString.Contiene("29", "130"), drt("Personal"), drt("RazonSocial"))
|
|
dr("Concepto") = TxtConcepto.Text
|
|
dr("TipoMovto") = If(drt("TipoMovto").ToString = "False", 0, 1)
|
|
dr("EsComodin") = EsComodin
|
|
dr("CveConceptoContable") = drt("CveConceptoContable")
|
|
dr("CveSubProyecto") = drt("CveSubProyectoNegativo")
|
|
dr("Cargo") = TxtCargo.Text.ToDecimal
|
|
dr("Abono") = TxtAbono.Text.ToDecimal
|
|
dr("CveProveedor") = drt("CveProveedor")
|
|
dr("CvePersonal") = drt("CvePersonal")
|
|
dr("CveClasificacion") = -1
|
|
dr("MultipleSubProyecto") = drt("MultipleSubProyecto")
|
|
dr("CveCuenta") = drt("CveCuenta")
|
|
dr("EsComplementaria") = drt("EsComplementaria")
|
|
dr("EsMonedaExtranjera") = drt("EsMonedaExtranjera")
|
|
|
|
DtMovimientos.Rows.Add(dr)
|
|
Next
|
|
|
|
|
|
GvMov.DataSource = DtMovimientos
|
|
GvMov.DataBind()
|
|
GvPrePoliza.DataBind() ''limpio el grid
|
|
UpPrePoliza.Update()
|
|
UPMovs.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvMov_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMov.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Height = Unit.Pixel(1)
|
|
e.Row.Cells(0).ToolTip = e.Row.DBCampo("CveCuenta")
|
|
|
|
If e.Row.DBCampo("TipoMovto") = "True" Then
|
|
e.Row.FCTextBox("TxtAbono").Visible = True
|
|
Else
|
|
e.Row.FCTextBox("TxtCargo").Visible = True
|
|
End If
|
|
|
|
e.Row.FCTextBox("TxtAbono").Text = If(e.Row.DBCampo("Abono") = 0, "", e.Row.DBCampo("Abono"))
|
|
e.Row.FCTextBox("TxtCargo").Text = If(e.Row.DBCampo("Cargo") = 0, "", e.Row.DBCampo("Cargo"))
|
|
e.Row.FCTextBox("TxtConcepto").Text = e.Row.DBCampo("Descripcion")
|
|
|
|
If CvePeriodo > 0 Then
|
|
e.Row.FCTextBox("TxtCargo").Enabled = False
|
|
e.Row.FCTextBox("TxtAbono").Enabled = False
|
|
End If
|
|
|
|
e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("DdlSubProyecto").DataBind()
|
|
e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem(" - ", "-1"))
|
|
e.Row.FCDropDownList("DdlSubProyecto").SelectedValue = e.Row.DBCampo("CveSubProyecto")
|
|
|
|
'Asignamos los Tipos de Gasto
|
|
e.Row.FCDropDownList("DdlTipoGasto").DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
|
|
e.Row.FCDropDownList("DdlTipoGasto").DataBind()
|
|
e.Row.FCDropDownList("DdlTipoGasto").Items.Insert(0, New ListItem("Sin Asignar", "-1"))
|
|
e.Row.FCDropDownList("DdlTipoGasto").SelectedValue = e.Row.DBCampo("CveTipoGasto")
|
|
|
|
If DdlPlantilla.SelectedValue.ToEntero = 53 Then 'Plantilla Personalizada
|
|
e.Row.FCDropDownList("DdlSubProyecto").Enabled = True
|
|
e.Row.FCLinkButton("imgD").Visible = True
|
|
Else
|
|
e.Row.FCDropDownList("DdlSubProyecto").Enabled = False
|
|
End If
|
|
|
|
If e.Row.DBCampo("MultipleSubProyecto") = "True" Then
|
|
e.Row.FCDropDownList("DdlSubProyecto").Enabled = True
|
|
End If
|
|
|
|
If e.Row.DBCampo("EsComplementaria") = "True" Then
|
|
If e.Row.DBCampo("TipoMovto") = "False" Then e.Row.FindControl("divCargoME").Visible = True
|
|
If e.Row.DBCampo("TipoMovto") = "True" Then e.Row.FindControl("divAbonoME").Visible = True
|
|
End If
|
|
|
|
|
|
'Agregamos la opcion para vincular los movimientos bancarios
|
|
If e.Row.DataKey("CveConceptoContable").ToEntero.Contiene(41) Then
|
|
Dim ObjMovimientos As New ClsMovimientos
|
|
Dim DdlSaldos As DropDownList = e.Row.FCDropDownList("DdlSaldos")
|
|
|
|
Select Case e.Row.DataKey("CveConceptoContable").ToEntero
|
|
|
|
'Acreedores
|
|
Case 41
|
|
If (ObjMovimientos.GetAcreedoresSaldosDetalles(-1, CveMoneda, UsuarioActual.CveEmpresa)) Then
|
|
DdlSaldos.Visible = True
|
|
DdlSaldos.DataSource = ObjMovimientos.DtResultados.FiltraParametros($"CveIE > 0 AND CveProveedor = {e.Row.DataKey("CveProveedor").ToEntero}")
|
|
DdlSaldos.DataBind()
|
|
DdlSaldos.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
|
|
End Select
|
|
|
|
ObjMovimientos.Dispose()
|
|
End If
|
|
|
|
If e.Row.DataKey("CveConceptoContable").ToEntero.Contiene(30) Then
|
|
e.Row.FCLinkButton("ImgBancos").Visible = True
|
|
|
|
If e.Row.DataKey("ContadoTipoTransaccion").ToEntero > 0 And e.Row.DataKey("ContadoCuenta").ToEntero > 0 And e.Row.DataKey("ContadoNumeroFolio").ToString.Length > 0 And
|
|
e.Row.DataKey("ContadoImporte").ToDecimal > 0 And e.Row.DataKey("ContadoBeneficiario").ToString.Length > 0 Then
|
|
e.Row.FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green"
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
|
|
|
|
Dim FolioPoliza As Integer = -1
|
|
Dim CvePrePolizaInsertada As Integer = -1
|
|
|
|
If CvePrePolizaOrigen > 0 Then
|
|
CrearPrePolizaApartirDe()
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim TotalCargos, TotalAbonos As Decimal
|
|
|
|
If CvePrePoliza > 0 Then
|
|
TotalCargos = TxtTotalCargos.Text.ToDecimal
|
|
TotalAbonos = TxtTotalAbonos.Text.ToDecimal
|
|
Else
|
|
For Each Gvr As GridViewRow In GvMov.Rows
|
|
TotalCargos += Gvr.FCTextBox("TxtCargo").Text.ToDecimal
|
|
TotalAbonos += Gvr.FCTextBox("TxtAbono").Text.ToDecimal
|
|
Next
|
|
End If
|
|
|
|
'validaciones
|
|
If Not (TotalCargos = TotalAbonos AndAlso (GvPrePoliza.Rows.Count > 0 Or GvMov.Rows.Count > 0)) AndAlso UsuarioActual.CveRol <> 1 Then
|
|
Alert($"La suma de los movimientos no son iguales ({TotalCargos}-{TotalAbonos})", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
If Not CvePrePoliza > 0 Then
|
|
|
|
For Each Gvr As GridViewRow In GvMov.Rows
|
|
If Gvr.DataKey("CveConceptoContable") = "30" AndAlso (Gvr.FCTextBox("TxtCargo").Text.ToDecimal <> 0 OrElse Gvr.FCTextBox("TxtAbono").Text.ToDecimal <> 0) Then 'si es movimietno de bancos, y tiene cantidad, deben de especificarse los datos del IE
|
|
If Gvr.DataKey("ContadoCuenta").ToEntero = 0 OrElse Gvr.DataKey("ContadoTipoTransaccion").ToEntero = 0 Then
|
|
Alert("No se han especificado las condiciones de pago ", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
'terminan validaciones
|
|
|
|
If CvePrePoliza > 0 Then
|
|
ActualizarPrePoliza()
|
|
Else
|
|
Dim MensajeAlert = New StringBuilder
|
|
Dim ObjIE As New ClsBancos()
|
|
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
|
' Dim ObjNom As New ClsNominas(ObjIE.IniciaTransacSQL)
|
|
Dim Conta As ClsContPAQi = Nothing
|
|
Dim IDPoliza As Integer = 0
|
|
Dim MsgError As String = ""
|
|
Dim CveIE As Integer
|
|
Dim FolioIE As String = ""
|
|
Dim ContRegInsertados As Integer = 0
|
|
|
|
Dim TmpCargo As Decimal = 0D
|
|
Dim TmpAbono As Decimal = 0D
|
|
Dim DifCargoAbono As Decimal = 0D
|
|
Dim TipoGrid As Integer = 0 ' 0 - GvMov, 1 - GvPrePoliza
|
|
|
|
Try
|
|
|
|
Dim ConceptoPoliza As String = TxtConcepto.Text
|
|
CvePrePolizaInsertada = ObjMov.AddPrePolizas("Contabilidad/RegPrePoliza", DdlPlantilla.SelectedValue.ToEntero, TotalCargos, TotalAbonos, 1, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=DdlTipoPoliza.SelectedValue.ToEntero, AgregarFolio:=True)
|
|
|
|
If CvePrePolizaInsertada > 0 Then
|
|
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
|
|
Dim idCuentaContabilizacion As Long = 1
|
|
Dim Importe As Decimal = 0
|
|
Dim ImporteME As Decimal = 0
|
|
Dim TipoCambio As Decimal = 1
|
|
Dim TipoMovto As Boolean = False
|
|
Dim IdCtaContable As Integer = 0
|
|
|
|
FolioPoliza = ObjMov.FolioPoliza
|
|
|
|
Dim Gv As GridView = GvMov
|
|
If DdlPlantilla.SelectedValue = "53" OrElse GvPrePoliza.Visible = True Then
|
|
If GvPrePoliza.Rows.Count > 0 Then
|
|
Gv = GvPrePoliza
|
|
TipoGrid = 1
|
|
End If
|
|
|
|
End If
|
|
|
|
'inserto las compras que voy a pagarDdlSaldos
|
|
For Each gvr As GridViewRow In Gv.Rows
|
|
'If gvr.DataKey("IDCuenta").ToEntero > 0 Then
|
|
' IdCtaContable = gvr.DataKey("IDCuenta")
|
|
'End If
|
|
|
|
'Registra movimieno bancario
|
|
If gvr.DataKey("CveConceptoContable").ToEntero = 30 AndAlso (gvr.DataKey("ContadoImporte").ToDecimal <> 0 OrElse TipoGrid = 1) Then
|
|
Dim tFolio As String = gvr.DataKey("ContadoNumeroFolio").ToString
|
|
If tFolio.ToEntero = 0 Then tFolio = SiguienteFolioBancos(gvr.DataKey("ContadoCuenta").ToEntero, gvr.DataKey("ContadoTipoTransaccion").ToEntero)
|
|
|
|
|
|
Dim tCveMoneda As Integer = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveCuenta:=DdlCuenta.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda").ToEntero
|
|
|
|
|
|
CveIE = ObjIE.AddBancos_IE(gvr.DataKey("ContadoCuenta").ToEntero, gvr.DataKey("ContadoTipoTransaccion").ToEntero, TxtFechaDocumento.Text, tFolio,
|
|
gvr.DataKey("ContadoBeneficiario"), gvr.DataKey("ContadoImporte").ToDecimal, tCveMoneda, 0, gvr.DataKey("ContadoObservaciones"), "",
|
|
False, False, 0, CvePrePolizaInsertada, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveIE < 0 Then
|
|
MsgError = "No se pudo registrar movimiento bancario"
|
|
Exit For
|
|
Else
|
|
|
|
If tFolio > 0 Then
|
|
FolioIE = tFolio
|
|
Else
|
|
FolioIE = ObjIE.Folio
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
ImporteME = 0
|
|
TipoCambio = 1
|
|
|
|
If gvr.DataKey("TipoMovto") = "True" Then
|
|
If TipoGrid = 0 Then 'gvmov
|
|
Importe = gvr.FCTextBox("TxtAbono").Text.ToDecimal
|
|
TmpAbono = TmpAbono + Importe
|
|
TipoMovto = True
|
|
|
|
If gvr.DataKey("EsComplementaria") = "True" Then ImporteME = gvr.FCTextBox("TxtAbonoME").Text.ToDecimal
|
|
If gvr.DataKey("EsMonedaExtranjera") = "True" Then TipoCambio = gvr.FCTextBox("TxtTC").Text.ToDecimal
|
|
|
|
Else
|
|
Importe = gvr.DataKey("Abono").ToDecimal
|
|
TmpAbono = TmpAbono + Importe
|
|
TipoMovto = True
|
|
|
|
If gvr.DataKey("EsComplementaria") = "True" Then ImporteME = gvr.DataKey("ImporteME").ToDecimal
|
|
If gvr.DataKey("EsMonedaExtranjera") = "True" Then TipoCambio = gvr.DataKey("TC").ToDecimal
|
|
|
|
End If
|
|
Else
|
|
If TipoGrid = 0 Then 'gvmov
|
|
Importe = gvr.FCTextBox("TxtCargo").Text.ToDecimal
|
|
TmpCargo = TmpCargo + Importe
|
|
TipoMovto = False
|
|
|
|
If gvr.DataKey("EsComplementaria") = "True" Then ImporteME = gvr.FCTextBox("TxtCargoME").Text.ToDecimal
|
|
If gvr.DataKey("EsMonedaExtranjera") = "True" Then TipoCambio = gvr.FCTextBox("TxtTC").Text.ToDecimal
|
|
Else
|
|
Importe = gvr.DataKey("Cargo").ToDecimal
|
|
TmpCargo = TmpCargo + Importe
|
|
TipoMovto = False
|
|
|
|
If gvr.DataKey("EsComplementaria") = "True" Then ImporteME = gvr.DataKey("ImporteME").ToDecimal
|
|
If gvr.DataKey("EsMonedaExtranjera") = "True" Then TipoCambio = gvr.DataKey("TC").ToDecimal
|
|
End If
|
|
End If
|
|
|
|
If Not gvr.DataKey("CveConceptoContable").Contiene("30", "10", "204") Then ' 30-bancos, 10-anticipos proveedores, 204- blancos complementaria
|
|
|
|
If gvr.DataKey("CveConceptoContable").ToEntero = 41 Then
|
|
CveIE = gvr.FCDropDownList("DdlSaldos").SelectedValue.ToEntero
|
|
Else
|
|
CveIE = -1
|
|
End If
|
|
|
|
End If
|
|
|
|
If idCuentaContabilizacion = 1 AndAlso (IdCtaContable = 0) Then
|
|
idCuentaContabilizacion = 0
|
|
End If
|
|
If Importe <> 0 OrElse TipoGrid = 1 Then 'si es diferente de cero o si viene de grid prepolizas, que registre todo
|
|
Dim tCveCuenta As Integer = gvr.DataKey("CveCuenta").ToEntero
|
|
Dim tReferencia, tConcepto As String
|
|
Dim tCveSubProyecto, tCveTipoGasto As Integer
|
|
|
|
If TipoGrid = 0 Then 'gvmov
|
|
tReferencia = gvr.FCLiteral("LtlReferencia").Text
|
|
tConcepto = gvr.FCTextBox("TxtConcepto").Text
|
|
tCveSubProyecto = gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero
|
|
tCveTipoGasto = gvr.FCDropDownList("DdlTipoGasto").SelectedValue.ToEntero
|
|
Else
|
|
tReferencia = gvr.DataKey("Referencia")
|
|
tConcepto = gvr.DataKey("Concepto")
|
|
tCveSubProyecto = gvr.DataKey("CveSubProyecto").ToEntero
|
|
tCveTipoGasto = gvr.DataKey("CveTipoGasto").ToEntero
|
|
End If
|
|
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePolizaInsertada, TipoMovto, Importe, tReferencia, gvr.DataKey("CveConceptoContable").ToEntero, tConcepto,
|
|
TxtFechaDocumento.Text.ToDate, IdCtaContable, -1, CveSubProyecto:=tCveSubProyecto, CveIE:=CveIE,
|
|
CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, CveCompra:=gvr.DataKey("CveCompra").ToEntero,
|
|
CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero,
|
|
ImporteMX:=Importe, ImporteME:=ImporteME, TipoCambio:=TipoCambio,
|
|
CveTipoGasto:=tCveTipoGasto,
|
|
CveCliente:=gvr.DataKey("CveCliente").ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCuenta:=tCveCuenta, PorcentajeImpuesto:=gvr.DataKey("PorcentajeImpuesto").ToDecimal) Then
|
|
ContRegInsertados = ContRegInsertados + 1
|
|
|
|
Else
|
|
MsgError = "No se pudo insertar el detalle de la póliza2"
|
|
Exit For
|
|
End If
|
|
End If
|
|
If CveIE > 0 AndAlso gvr.DataKey("CveConceptoContable").ToEntero = 30 Then
|
|
MensajeAlert.AppendFormat("<br/><br/>Folio Bancario: <b><a href = ""/Bancos/IE.aspx?CveIE={0}"" class=""Texto"" target=""_blank"" >{1}</a></b>", CveIE, FolioIE)
|
|
End If
|
|
|
|
Next
|
|
|
|
If MsgError = "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePolizaInsertada, 1) Then
|
|
If ObjMov.ValorPolizaDescuadre > 0 Then
|
|
GuardaLogAD($"Contabilidad/RegPrePolizas | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePolizaInsertada}", "LogPrePolizas")
|
|
MsgError = ObjMov.MensajePolizaDescuadre
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
Catch ex As Exception
|
|
MsgError = $"Error {ex.Message}"
|
|
End Try
|
|
|
|
If ContRegInsertados = 0 Then
|
|
MsgError = $"No se insertaron registros (Revise que los importes de los registros contengan valores)"
|
|
End If
|
|
|
|
If MsgError = "" Then
|
|
'MENSAJE IE
|
|
|
|
'If CveIE Then
|
|
' Alert(MensajeAlert.ToString, ModExtensiones.TipoMensaje.MsgInformacion, "window.location.reload()")
|
|
'Else
|
|
' Alert(If(MensajeAlert.ToString = "", "Se registro con exito.", MensajeAlert.ToString), TipoMensaje.MsgInformacion, "window.location.reload()")
|
|
'End If
|
|
|
|
Alert(If(MensajeAlert.ToString = "", $"Se registro con exito <b>{If(FolioPoliza > 0, " Folio " & FolioPoliza & ".", "")}</b>", $"Se registro con exito <b>{If(FolioPoliza > 0, " Folio " & FolioPoliza & ".", "")} </b><br>" & MensajeAlert.ToString), TipoMensaje.MsgInformacion, $"window.location.href=""./RegPrePolizaS.aspx?CvePrePoliza={CvePrePolizaInsertada}""", ShowCloseButton:=False)
|
|
|
|
|
|
ObjIE.Commit()
|
|
If Conta IsNot Nothing Then Conta.Commit()
|
|
|
|
TxtConcepto.Text = ""
|
|
'GvMov.DataBind()
|
|
DdlPlantilla_SelectedIndexChanged(Nothing, Nothing)
|
|
|
|
TxtFechaDocumento.Text = ""
|
|
|
|
Else
|
|
Alert(MsgError.ToString, ModExtensiones.TipoMensaje.MsgError)
|
|
ObjIE.RollBack()
|
|
If Conta IsNot Nothing Then Conta.RollBack()
|
|
End If
|
|
|
|
ObjIE.Dispose()
|
|
ObjMov.Dispose()
|
|
If Conta IsNot Nothing Then Conta.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ActualizarPrePoliza()
|
|
Dim contador As Integer = 0
|
|
Dim OcurrioError As Boolean = False
|
|
Dim ObjContabilidad As New ClsContabilidad
|
|
ObjContabilidad.IniciaTransacSQL()
|
|
|
|
Try
|
|
|
|
|
|
Dim Retorno As Boolean = ObjContabilidad.UpdatePrePoliza(MinFecha, -1, DdlTipoPoliza.SelectedValue.ToEntero, -1, CvePrePoliza, UsuarioActual.CveEmpresa, Concepto:=TxtConcepto.Text, FechaPoliza:=TxtFechaDocumento.Text.ToDate, CveUsuarioModifico:=UsuarioActual.CveUsuario)
|
|
|
|
If Retorno Then
|
|
If Not ObjContabilidad.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False) Then
|
|
OcurrioError = True
|
|
End If
|
|
|
|
If DtMovimientosEliminar IsNot Nothing AndAlso DtMovimientosEliminar.Rows.Count > 0 Then
|
|
For Each RowEliminar As DataRow In DtMovimientosEliminar.Rows
|
|
If Not ObjContabilidad.RemovePrePolizasDetalle(Me.CvePrePoliza, RowEliminar("CvePrePolizaDetalle").ToString().ToEntero()) Then
|
|
OcurrioError = True
|
|
Exit For
|
|
End If
|
|
Next
|
|
End If
|
|
|
|
If Not OcurrioError Then
|
|
Dim CveIEAgregado As Integer = -1
|
|
For Each row As GridViewRow In GvPrePoliza.Rows
|
|
If row.DataKey("CvePrePolizaDetalle").ToEntero > 0 Then
|
|
If row.FCCheckBox("chkModificado").Checked Then
|
|
contador = contador + 1
|
|
|
|
Dim ImporteIE As Decimal = If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal)
|
|
|
|
If row.DataKey("CveConceptoContable").ToEntero = 30 AndAlso ImporteIE > 0 AndAlso row.DataKey("CveIE").ToDecimal <= 0 Then
|
|
Dim ObjIE As New ClsBancos(ObjContabilidad.IniciaTransacSQL)
|
|
CveIEAgregado = ObjIE.AddBancos_IE(row.DataKey("ContadoCuenta").ToEntero, row.DataKey("ContadoTipoTransaccion").ToEntero, TxtFechaDocumento.Text, row.DataKey("ContadoNumeroFolio"),
|
|
row.DataKey("ContadoBeneficiario"), ImporteIE, CveMoneda, 0, row.DataKey("ContadoObservaciones"), "",
|
|
False, False, 0, row.DataKey("CvePrePoliza").ToEntero, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveIEAgregado < 0 Then
|
|
'MsgError = "No se pudo registrar movimiento bancario"
|
|
OcurrioError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
If Not ObjContabilidad.UpdatePrePolizasDetalle(row.DataKey("CvePrePolizaDetalle").ToEntero, row.FCLiteral("TxtConcepto").Text, row.DataKey("CveSubProyecto").ToEntero,
|
|
row.DataKey("IdCtaContable").ToEntero, If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
|
|
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), CveTipoGasto:=If(DdlTipoGasto.Visible, row.DataKey("CveTipoGasto").ToEntero, row.DataKey("CveTipoGasto").ToEntero),
|
|
CveConceptoContable:=row.DataKey("CveConceptoContable").ToEntero, CveProveedor:=row.DataKey("CveProveedor").ToEntero, CveCompra:=row.DataKey("CveCompra").ToEntero,
|
|
CveCliente:=row.DataKey("CveCliente").ToEntero, CveVenta:=row.DataKey("CveVenta").ToEntero,
|
|
CvePersonal:=row.DataKey("CvePersonal").ToEntero, Referencia:=row.FCLiteral("TxtRef").Text, CveCuenta:=row.DataKey("CveCuenta").ToEntero, CveUsuarioModifico:=UsuarioActual.CveUsuario, CveIE:=CveIEAgregado) Then
|
|
OcurrioError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
Else
|
|
contador = contador + 1
|
|
|
|
|
|
Dim ImporteIE As Decimal = If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal)
|
|
|
|
If row.DataKey("CveConceptoContable").ToEntero = 30 AndAlso ImporteIE > 0 AndAlso row.DataKey("CveIE").ToDecimal <= 0 Then
|
|
Dim ObjIE As New ClsBancos(ObjContabilidad.IniciaTransacSQL)
|
|
CveIEAgregado = ObjIE.AddBancos_IE(row.DataKey("ContadoCuenta").ToEntero, row.DataKey("ContadoTipoTransaccion").ToEntero, TxtFechaDocumento.Text, row.DataKey("ContadoNumeroFolio"),
|
|
row.DataKey("ContadoBeneficiario"), ImporteIE, CveMoneda, 0, row.DataKey("ContadoObservaciones"), "",
|
|
False, False, 0, row.DataKey("CvePrePoliza").ToEntero, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveIEAgregado < 0 Then
|
|
'MsgError = "No se pudo registrar movimiento bancario"
|
|
OcurrioError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
If Not ObjContabilidad.AddPrePolizasDetalle(CvePrePoliza, If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0, False, True), If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
|
|
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), row.DataKey("Referencia").ToString,
|
|
row.DataKey("CveConceptoContable").ToEntero, row.FCLiteral("TxtConcepto").Text, Now,
|
|
row.DataKey("IdCtaContable").ToEntero, 0, CveSubProyecto:=row.DataKey("CveSubProyecto").ToEntero,
|
|
CveTipoGasto:=If(DdlTipoGasto.Visible, row.DataKey("CveTipoGasto").ToEntero, row.DataKey("CveTipoGasto").ToEntero),
|
|
ImporteMX:=If(row.FCLiteral("TxtCargo").Text.ToDecimal <> 0,
|
|
row.FCLiteral("TxtCargo").Text.ToDecimal, row.FCLiteral("TxtAbono").Text.ToDecimal), CveProveedor:=row.DataKey("CveProveedor").ToEntero,
|
|
CveCompra:=row.DataKey("CveCompra").ToEntero, CveCliente:=row.DataKey("CveCliente").ToEntero, CveVenta:=row.DataKey("CveVenta").ToEntero,
|
|
CvePersonal:=row.DataKey("CvePersonal").ToEntero, CveCuenta:=row.DataKey("CveCuenta").ToEntero, PorcentajeImpuesto:=row.DataKey("PorcentajeImpuesto").ToDecimal, CveIE:=CveIEAgregado) Then
|
|
OcurrioError = True
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
End If
|
|
Else
|
|
OcurrioError = True
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
OcurrioError = True
|
|
OnError("Ocurrío un error al actualizar la PrePoliza", ex)
|
|
End Try
|
|
|
|
If Not OcurrioError Then
|
|
ObjContabilidad.Commit()
|
|
Alert("La PrePoliza se actualizó correctamente.", TipoMensaje.MsgInformacion, JSBtnAceptar:=$"window.location.href=""./RegPrePolizaS.aspx?CvePrePoliza={Me.CvePrePoliza}""", ShowCloseButton:=False)
|
|
Else
|
|
ObjContabilidad.RollBack()
|
|
Alert("Ocurrio un error al actualizar la PrePoliza.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContabilidad.Dispose()
|
|
CargaPrePoliza()
|
|
|
|
If Not OcurrioError Then
|
|
If IdPoliza > 0 AndAlso contador Then
|
|
Contabilizar()
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
Protected Sub LnkAddConcepto_Click(sender As Object, e As EventArgs)
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivEditConcepto"))
|
|
LtlTitulo.Text = "Agregar Concepto"
|
|
BtnAceptar.Text = "Agregar"
|
|
LimpiaCampos()
|
|
|
|
'CargaConceptosContablesE()
|
|
CargaSubProyectoE()
|
|
CargaTipoGastoE()
|
|
|
|
UpModalConcepto.Update()
|
|
End Sub
|
|
|
|
|
|
Protected Sub GvPrePoliza_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvPrePoliza.RowUpdating
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivEditConcepto"))
|
|
LtlTitulo.Text = "Editar Concepto"
|
|
BtnAceptar.Text = "Aceptar"
|
|
LimpiaCampos()
|
|
IndiceGrid = e.RowIndex
|
|
|
|
Dim CveConceptoContable As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveConceptoContable").ToEntero
|
|
Dim CveProveedor As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveProveedor").ToEntero
|
|
Dim CveCompra As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveCompra").ToEntero
|
|
Dim CvePersonal As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CvePersonal").ToEntero
|
|
Dim CveCliente As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveCliente").ToEntero
|
|
Dim CveVenta As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveVenta").ToEntero
|
|
'Dim FolioFactura As String = GvPrePoliza.Rows(IndiceGrid).FCHyperLink("HlReferencia").Text
|
|
Dim Concepto As String = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtConcepto").Text
|
|
Dim Referencia As String = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtRef").Text
|
|
Dim CveSubProyecto As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveSubProyecto").ToString.ToEntero
|
|
Dim CveTipoGasto As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveTipoGasto").ToString.ToEntero
|
|
Dim CveCuenta As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveCuenta").ToString.ToEntero
|
|
Dim Cargo As Decimal = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtCargo").Text.ToDecimal
|
|
Dim Abono As Decimal = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtAbono").Text.ToDecimal
|
|
Dim PorcentajeImpuesto As Decimal = GvPrePoliza.Rows(IndiceGrid).DataKey("PorcentajeImpuesto").ToDecimal
|
|
Dim CveClasificacion As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("CveClasificacion").ToEntero
|
|
Dim MonedaExtr As Decimal = GvPrePoliza.Rows(IndiceGrid).FCLiteral("TxtCargo").Text.ToDecimal
|
|
|
|
'CargaConceptosContablesE()
|
|
'CargaModalConceptoCuentas()
|
|
|
|
DdlConceptosContablesE.SelectedValueExist(CveConceptoContable)
|
|
DdlConceptosContablesE_SelectedIndexChanged(DdlConceptosContablesE, e)
|
|
|
|
|
|
TxtTipoCambio.Text = GvPrePoliza.Rows(IndiceGrid).DataKey("TC").ToString.ToDecimal.ToString("###,###,###.00")
|
|
|
|
TxtME.Text = GvPrePoliza.Rows(IndiceGrid).DataKey("ImporteME").ToDecimal.FormatoNumero
|
|
|
|
DdlPorcentajeIVAE.SelectedValueExist(PorcentajeImpuesto)
|
|
|
|
DdlProveedoresE.SelectedValueExist(CveProveedor)
|
|
DdlProveedoresE_SelectedIndexChanged(DdlProveedoresE, e)
|
|
DdlComprasE.SelectedValueExist(CveCompra)
|
|
|
|
DdlPersonalE.SelectedValueExist(CvePersonal)
|
|
|
|
If CveCliente > 0 Then
|
|
DvModalconceptoCliente.Visible = True
|
|
|
|
'DdlClientesE.SelectedText = GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=CveCliente).FiltroPrimeroValor("NombreComercial", "")
|
|
DdlClientesE.ddl.Items.Insert(0, New ListItem(GlobalDTCliente(UsuarioActual.CveEmpresa, CveCliente:=CveCliente).FiltroPrimeroValor("NombreComercial", ""), CveCliente))
|
|
DdlClientesE.SelectedValue = CveCliente
|
|
|
|
CargaVentasE(CveCliente)
|
|
End If
|
|
If CveVenta > 0 Then
|
|
DdlVentasE.SelectedValueExist(CveVenta)
|
|
End If
|
|
|
|
If CveClasificacion > 0 Then
|
|
DdlClasificacionesE.SelectedValue = CveClasificacion
|
|
End If
|
|
TxtConceptoE.Text = Concepto
|
|
TxtReferenciaE.Text = Referencia
|
|
|
|
CargaSubProyectoE()
|
|
DdlSubProyectoE.SelectedValueExist(CveSubProyecto)
|
|
CargaTipoGastoE()
|
|
DdlTipoGastoE.SelectedValueExist(CveTipoGasto)
|
|
|
|
DdlCuentaContableE.SelectedValueExist(CveCuenta)
|
|
|
|
If Cargo <> 0 Then
|
|
TxtCargoE.Text = Cargo
|
|
End If
|
|
|
|
If Abono <> 0 Then
|
|
TxtAbonoE.Text = Abono
|
|
End If
|
|
|
|
If CveConceptoContable = 30 Then
|
|
If Abono = 0 Then
|
|
CargaModalConceptoTipoTransaccion("Ing")
|
|
Else
|
|
CargaModalConceptoTipoTransaccion("Egs")
|
|
End If
|
|
DdlModalConceptoTipoTransaccion.SelectedValueExist(GvPrePoliza.Rows(IndiceGrid).DataKey("ContadoTipoTransaccion"))
|
|
DdlModalConceptoCuenta.SelectedValueExist(GvPrePoliza.Rows(IndiceGrid).DataKey("ContadoCuenta"))
|
|
TxtModalConceptoDocumentoFolio.Text = GvPrePoliza.Rows(IndiceGrid).DataKey("ContadoNumeroFolio")
|
|
TxtModalConceptoDocumentoBeneficiario.Text = GvPrePoliza.Rows(IndiceGrid).DataKey("ContadoBeneficiario")
|
|
TxtModalConceptoDocumentoObservaciones.Text = GvPrePoliza.Rows(IndiceGrid).DataKey("ContadoObservaciones")
|
|
TxtModalConceptoDocumentoImporte.Text = GvPrePoliza.Rows(IndiceGrid).DataKey("ContadoImporte").ToDecimal.ToString("###,###,###.00")
|
|
|
|
End If
|
|
|
|
|
|
If DdlConceptosContablesE.SelectedValue.ToEntero = 30 AndAlso CvePrePoliza > 0 Then
|
|
DdlConceptosContablesE.Enabled = False
|
|
Else
|
|
DdlConceptosContablesE.Enabled = True
|
|
End If
|
|
|
|
UpModalConcepto.Update()
|
|
|
|
End Sub
|
|
Private Sub LimpiaCampos()
|
|
IndiceGrid = -1
|
|
TxtConceptoE.Text = ""
|
|
TxtCargoE.Text = ""
|
|
TxtAbonoE.Text = ""
|
|
TxtReferenciaE.Text = ""
|
|
End Sub
|
|
Private Sub CargaConceptosContablesE()
|
|
DdlConceptosContablesE.DataSource = GlobalDTContaConceptosContables(-1)
|
|
DdlConceptosContablesE.DataBind()
|
|
DdlConceptosContablesE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
Private Sub CargaSubProyectoE()
|
|
DdlSubProyectoE.DataSource = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
DdlSubProyectoE.DataBind()
|
|
DdlSubProyectoE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
Private Sub CargaTipoGastoE()
|
|
DdlTipoGastoE.DataSource = GlobalDTTiposGastos(UsuarioActual.CveEmpresa)
|
|
DdlTipoGastoE.DataBind()
|
|
DdlTipoGastoE.Items.Insert(0, New ListItem("Sin Asignar", "0"))
|
|
End Sub
|
|
Private Sub CargaCtaContableE()
|
|
Dim ObjConta As New ClsContabilidad
|
|
If ObjConta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then
|
|
DdlCuentaContableE.DataSource = ObjConta.DtResultados
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
DdlCuentaContableE.DataBind()
|
|
DdlCuentaContableE.Items.Insert(0, New ListItem("Sin Asignar", "0"))
|
|
End Sub
|
|
|
|
|
|
Private Sub DdlConceptosContablesE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConceptosContablesE.SelectedIndexChanged
|
|
|
|
'Aquii hay que consultar el concepto y determinar que es lo que se vba aplicar
|
|
|
|
Dim CveConceptoContableInsertar As Integer = DdlConceptosContablesE.SelectedValue.ToEntero
|
|
Dim DT_Concepto As DataTable
|
|
|
|
If CveConceptoContableInsertar > 0 Then
|
|
|
|
DT_Concepto = GlobalDTContaConceptosContables(CveConceptoContableInsertar)
|
|
DrConceptoContable = GlobalDTContaConceptosContables(CveConceptoContableInsertar).FiltroPrimero("")
|
|
|
|
Dim AplicaActivoFijo As Boolean = False
|
|
Dim AplicaAlmacen As Boolean = False
|
|
Dim AplicaBancos As Boolean = False 'ok
|
|
Dim AplicaClasificacion As Boolean = False 'ok
|
|
Dim AplicaCliente As Boolean = False 'ok
|
|
Dim AplicaCompra As Boolean = False
|
|
Dim AplicaImpuesto As Boolean = False
|
|
Dim AplicaNomina As Boolean = False
|
|
Dim AplicaPersonal As Boolean = False
|
|
Dim AplicaProveedor As Boolean = False
|
|
Dim AplicaSubProyecto As Boolean = False
|
|
Dim AplicaTC As Boolean = False 'ok
|
|
Dim AplicaVenta As Boolean = False
|
|
Dim AplicaComplementaria As Boolean = False 'ok
|
|
Dim AplicaME As Boolean = False 'ok
|
|
|
|
AplicaActivoFijo = Boolean.Parse(DT_Concepto.Rows(0)("AplicaActivoFijo").ToString)
|
|
AplicaAlmacen = Boolean.Parse(DT_Concepto.Rows(0)("AplicaAlmacen").ToString)
|
|
|
|
AplicaBancos = Boolean.Parse(DT_Concepto.Rows(0)("AplicaBancos").ToString)
|
|
AplicaClasificacion = Boolean.Parse(DT_Concepto.Rows(0)("AplicaClasificacion").ToString)
|
|
AplicaCliente = Boolean.Parse(DT_Concepto.Rows(0)("AplicaCliente").ToString)
|
|
AplicaCompra = Boolean.Parse(DT_Concepto.Rows(0)("AplicaCompra").ToString)
|
|
|
|
AplicaImpuesto = Boolean.Parse(DT_Concepto.Rows(0)("AplicaImpuesto").ToString)
|
|
AplicaNomina = Boolean.Parse(DT_Concepto.Rows(0)("AplicaNomina").ToString)
|
|
AplicaPersonal = Boolean.Parse(DT_Concepto.Rows(0)("AplicaPersonal").ToString)
|
|
AplicaProveedor = Boolean.Parse(DT_Concepto.Rows(0)("AplicaProveedor").ToString)
|
|
AplicaSubProyecto = Boolean.Parse(DT_Concepto.Rows(0)("AplicaSubProyecto").ToString)
|
|
AplicaTC = Boolean.Parse(DT_Concepto.Rows(0)("AplicaTC").ToString)
|
|
AplicaVenta = Boolean.Parse(DT_Concepto.Rows(0)("AplicaVenta").ToString)
|
|
AplicaComplementaria = Boolean.Parse(DT_Concepto.Rows(0)("EsComplementaria").ToString)
|
|
|
|
|
|
|
|
|
|
|
|
'AplicaME = Boolean.Parse(DT_Concepto.Rows(0)("EsMonedaExtranjera").ToString)
|
|
|
|
|
|
If AplicaImpuesto Then
|
|
DvModalconceptoProcentajeIVA.Visible = True
|
|
DdlPorcentajeIVAE.Visible = True
|
|
Else
|
|
DvModalconceptoProcentajeIVA.Visible = False
|
|
DdlPorcentajeIVAE.Visible = False
|
|
End If
|
|
|
|
If AplicaProveedor Then
|
|
CargaProveedoresE()
|
|
DvmodalconceptoProveddor.Visible = True
|
|
DvModalconceptoCompra.Visible = True
|
|
|
|
Else
|
|
DvmodalconceptoProveddor.Visible = False
|
|
DvModalconceptoCompra.Visible = False
|
|
|
|
End If
|
|
|
|
If AplicaPersonal Then
|
|
CargaPersonalE()
|
|
DvModalconceptoPersonal.Visible = True
|
|
Else
|
|
DvModalconceptoPersonal.Visible = False
|
|
End If
|
|
|
|
If AplicaClasificacion Then
|
|
CargaClasificacionesE()
|
|
DvModalconceptoClasificacion.Visible = True
|
|
'DdlClasificacionesE.Visible = True
|
|
Else
|
|
DvModalconceptoClasificacion.Visible = False
|
|
'DdlClasificacionesE.Visible = False
|
|
End If
|
|
|
|
If AplicaVenta Then
|
|
DvModalconceptoVenta.Visible = True
|
|
Else
|
|
DvModalconceptoVenta.Visible = False
|
|
End If
|
|
|
|
If AplicaCliente Then
|
|
CargaClientesE()
|
|
DvModalconceptoCliente.Visible = True
|
|
Else
|
|
DvModalconceptoCliente.Visible = False
|
|
End If
|
|
|
|
If AplicaBancos AndAlso Not AplicaComplementaria Then
|
|
TxtCargoE.AutoPostBack = True
|
|
TxtAbonoE.AutoPostBack = True
|
|
CargaModalConceptoTipoTransaccion("Egs")
|
|
'DivModalConceptoAncho.Attributes.Add("style", "width:1000px")
|
|
DvMoldalConceptoSeccion1.Attributes.Add("class", "col-md-6")
|
|
DvMoldalConceptoSeccion2.Visible = True
|
|
RegistraScript("$('#DivModalConceptoAncho').attr('style','width:1000px');")
|
|
Else
|
|
' DivModalConceptoAncho.Attributes.Add("style", "width:450px")
|
|
DvMoldalConceptoSeccion1.Attributes.Add("class", "col-md-12")
|
|
RegistraScript("$('#DivModalConceptoAncho').attr('style','width:450px');")
|
|
DvMoldalConceptoSeccion2.Visible = False
|
|
TxtCargoE.AutoPostBack = False
|
|
TxtAbonoE.AutoPostBack = False
|
|
End If
|
|
|
|
If AplicaTC Then
|
|
DVmodalConceptoTipoCambio.Visible = True
|
|
Else
|
|
DVmodalConceptoTipoCambio.Visible = False
|
|
End If
|
|
|
|
If AplicaComplementaria Then
|
|
DivMonedaExtranjera.Visible = True
|
|
Else
|
|
DivMonedaExtranjera.Visible = False
|
|
End If
|
|
CargaCuentaConcepto(CveConceptoContableInsertar)
|
|
|
|
End If
|
|
|
|
UpModalConcepto.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaCuentaConcepto(CveConcepto As Integer)
|
|
Dim ObjConta As New ClsContabilidad
|
|
If ObjConta.GetCuentasAsignacionesSistema(UsuarioActual.CveEmpresa, -1, 1, CveConcepto) Then
|
|
Dim dr As DataRow = ObjConta.DtResultados.FiltroPrimero("")
|
|
If dr IsNot Nothing Then
|
|
DdlCuentaContableE.SelectedValueExist(dr("CveCuenta"))
|
|
Else
|
|
If ObjConta.GetCuentasGlobales(UsuarioActual.CveEmpresa, CveConcepto) Then
|
|
Dim drY As DataRow = ObjConta.DtResultados.FiltroPrimero("")
|
|
If drY IsNot Nothing Then
|
|
DdlCuentaContableE.SelectedValueExist(drY("CveCuenta"))
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
End Sub
|
|
Private Sub CargaProveedoresE()
|
|
DdlProveedoresE.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
|
|
DdlProveedoresE.DataBind()
|
|
DdlProveedoresE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
Private Sub CargaComprasE(CveProveedor As Integer)
|
|
If DdlConceptosContablesE.SelectedValue.ToEntero.Contiene(5, 17, 305, 308, 310, 311, 312) Then
|
|
Dim ObjCompras As New ClsCompras
|
|
|
|
DdlComprasE.ClearSelection()
|
|
If ObjCompras.GetCompras(-1, "-1", "-1", CveProveedor, -1, UsuarioActual.CveEmpresa) Then
|
|
DdlComprasE.DataSource = ObjCompras.DtResultados.FiltraParametros("Saldo > 0")
|
|
DdlComprasE.DataBind()
|
|
DdlComprasE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
Else
|
|
DdlComprasE.DataSource = Nothing
|
|
DdlComprasE.DataBind()
|
|
DdlComprasE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End If
|
|
ObjCompras.Dispose()
|
|
End If
|
|
End Sub
|
|
Private Sub CargaClientesE()
|
|
DdlClientesE.setEsWebService(True)
|
|
|
|
DdlClientesE.Attributes.Add("data-metodo", "getcliente")
|
|
|
|
End Sub
|
|
Private Sub CargaVentasE(CveCliente As Integer)
|
|
If CveCliente <= 0 Then Exit Sub
|
|
|
|
If DrConceptoContable IsNot Nothing Then
|
|
Dim AplicaME = Boolean.Parse(DrConceptoContable("EsMonedaExtranjera").ToString)
|
|
Dim AplicaVenta = Boolean.Parse(DrConceptoContable("AplicaVenta").ToString)
|
|
If AplicaME Then
|
|
CveMoneda = 2
|
|
End If
|
|
If Not AplicaVenta Then Exit Sub
|
|
End If
|
|
|
|
DvModalconceptoVenta.Visible = True
|
|
DdlVentasE.DataSource = Nothing
|
|
DdlVentasE.ClearSelection()
|
|
|
|
Dim ObjVentas As New ClsVentas
|
|
If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1", CveCliente, -1, -1, -1, "-1", "-1", "-1", CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
|
|
If CveMoneda = 2 Then
|
|
DdlVentasE.DataSource = ObjVentas.DtResultados.FiltraParametros("CveMoneda = 2")
|
|
Else
|
|
DdlVentasE.DataSource = ObjVentas.DtResultados.FiltraParametros("CveMoneda = 1")
|
|
End If
|
|
DdlVentasE.DataBind()
|
|
DdlVentasE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
Else
|
|
DdlVentasE.DataSource = Nothing
|
|
DdlVentasE.DataBind()
|
|
DdlVentasE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End If
|
|
ObjVentas.Dispose()
|
|
End Sub
|
|
Private Sub CargaPersonalE()
|
|
DdlPersonalE.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
|
|
DdlPersonalE.DataBind()
|
|
DdlPersonalE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaClasificacionesE()
|
|
DdlClasificacionesE.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
|
|
DdlClasificacionesE.DataBind()
|
|
DdlClasificacionesE.Items.Insert(0, New ListItem(" - ", "-1"))
|
|
End Sub
|
|
Private Sub DdlProveedoresE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlProveedoresE.SelectedIndexChanged
|
|
CargaComprasE(DdlProveedoresE.SelectedValue.ToEntero)
|
|
End Sub
|
|
Private Sub DdlClientesE_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlClientesE.selectedindexchange
|
|
|
|
If DdlClientesE.SelectedValue.ToEntero > 0 Then CargaVentasE(DdlClientesE.SelectedValue.ToEntero)
|
|
|
|
End Sub
|
|
|
|
Private Function CargaValidacionesConcepto() As Boolean
|
|
Dim Retorno As Boolean = True
|
|
|
|
If DdlConceptosContablesE.SelectedValue <= 0 Then
|
|
Alert("No se ha especificado el concepto", TipoMensaje.ToastAdventencia)
|
|
Return False
|
|
End If
|
|
|
|
If DrConceptoContable IsNot Nothing Then
|
|
Dim AplicaComplementaria = Boolean.Parse(DrConceptoContable("EsComplementaria").ToString)
|
|
Dim AplicaBancos = Boolean.Parse(DrConceptoContable("AplicaBancos").ToString)
|
|
|
|
If AplicaComplementaria Then
|
|
Dim Importe As Decimal = IIf(TxtCargoE.Text.ToDecimal <> 0, TxtCargoE.Text.ToDecimal, TxtAbonoE.Text.ToDecimal)
|
|
'valida Mon Extranjera por el TC - Mon Extranjera
|
|
Dim dif As Decimal = ((TxtME.Text.ToDecimal * TxtTipoCambio.Text.ToDecimal).RoundSQL - TxtME.Text.ToDecimal).RoundSQL - Importe
|
|
|
|
If dif <> 0 Then
|
|
Alert("El importe moneda extranjera no coinciden con el TC ")
|
|
Retorno = False
|
|
Else
|
|
Retorno = True
|
|
End If
|
|
End If
|
|
|
|
If AplicaBancos AndAlso Not AplicaComplementaria Then
|
|
If DdlModalConceptoTipoTransaccion.SelectedValue.ToEntero <= 0 Then
|
|
Alert("seleccione las opciones de bancos ")
|
|
Retorno = False
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
Return Retorno
|
|
End Function
|
|
|
|
|
|
Protected Sub BtnAceptar_Click(sender As Object, e As EventArgs) Handles BtnAceptar.Click
|
|
|
|
'asdasdasd
|
|
If Not CargaValidacionesConcepto() Then
|
|
Exit Sub
|
|
End If
|
|
ChkSeguir.Visible = False
|
|
|
|
If IndiceGrid = -1 Then
|
|
ChkSeguir.Visible = True
|
|
If DtMovimientos Is Nothing Then CreaDT()
|
|
|
|
Dim IdCtaContable As Integer = CargaCuentasContpaq(DdlCuentaContableE.SelectedValue.ToEntero)
|
|
Dim dr As DataRow = DtMovimientos.NewRow
|
|
dr("IdCtaContable") = IdCtaContable
|
|
dr("CveCuenta") = DdlCuentaContableE.SelectedValue
|
|
'dr("CodigoCuenta") = CodigoCuenta & "<br>" & NombreCuenta
|
|
dr("CodigoNombreCuenta") = DdlCuentaContableE.SelectedItem.Text
|
|
dr("ConceptoContable") = DdlConceptosContablesE.SelectedItem.Text
|
|
dr("CveConceptoContable") = DdlConceptosContablesE.SelectedValue
|
|
dr("Concepto") = TxtConceptoE.Text
|
|
dr("Referencia") = TxtReferenciaE.Text
|
|
dr("TipoMovto") = If(Math.Abs(TxtCargoE.Text.ToDecimal) > 0, False, True)
|
|
dr("Cargo") = TxtCargoE.Text.ToDecimal
|
|
dr("Abono") = TxtAbonoE.Text.ToDecimal
|
|
dr("ImporteMN") = If(Math.Abs(TxtCargoE.Text.ToDecimal) > 0, TxtCargoE.Text.ToDecimal, TxtAbonoE.Text.ToDecimal)
|
|
dr("CveSubProyecto") = DdlSubProyectoE.SelectedValue
|
|
dr("SubProyecto") = DdlSubProyectoE.SelectedItem.Text
|
|
dr("CveProveedor") = DdlProveedoresE.SelectedValue.ToEntero
|
|
dr("CveCompra") = DdlComprasE.SelectedValue.ToEntero
|
|
dr("CvePersonal") = DdlPersonalE.SelectedValue.ToEntero
|
|
dr("CveCliente") = DdlClientesE.SelectedValue.ToEntero
|
|
dr("CveVenta") = DdlVentasE.SelectedValue.ToEntero
|
|
If DdlComprasE.Visible = True AndAlso DdlComprasE.SelectedValue.ToEntero > 0 Then dr("FolioFactura") = DdlComprasE.SelectedItem.ToString()
|
|
If DdlVentasE.Visible = True AndAlso DdlVentasE.SelectedValue.ToEntero > 0 Then dr("FolioFactura") = DdlVentasE.SelectedItem.ToString()
|
|
dr("Modificado") = True
|
|
dr("TC") = TxtTipoCambio.Text.ToDecimal
|
|
|
|
dr("ContadoCuenta") = DdlModalConceptoCuenta.SelectedValue.ToEntero
|
|
dr("ContadoTipoTransaccion") = DdlModalConceptoTipoTransaccion.SelectedValue.ToEntero
|
|
dr("ContadoNumeroFolio") = TxtModalConceptoDocumentoFolio.Text
|
|
dr("ContadoBeneficiario") = TxtModalConceptoDocumentoBeneficiario.Text
|
|
dr("ContadoObservaciones") = TxtModalConceptoDocumentoObservaciones.Text
|
|
dr("ContadoImporte") = dr("ImporteMN").ToString
|
|
|
|
If DrConceptoContable IsNot Nothing Then
|
|
dr("EsComplementaria") = DrConceptoContable("EsComplementaria")
|
|
dr("EsMonedaExtranjera") = DrConceptoContable("EsMonedaExtranjera")
|
|
|
|
If dr("EsMonedaExtranjera") = "True" Then dr("ImporteME") = TxtME.Text.ToDecimal
|
|
End If
|
|
|
|
If DdlPorcentajeIVAE.Visible Then
|
|
dr("PorcentajeImpuesto") = DdlPorcentajeIVAE.SelectedValue.ToDecimal
|
|
End If
|
|
|
|
DtMovimientos.Rows.Add(dr)
|
|
DtMovimientos.AcceptChanges()
|
|
|
|
If CvePrePoliza > 0 Or CvePrePolizaOrigen Then
|
|
GvPrePoliza.DataSource = DtMovimientos
|
|
GvPrePoliza.DataBind()
|
|
UpPrePoliza.Visible = True
|
|
End If
|
|
|
|
TxtTotalCargos.Text = DtMovimientos.SUMD("Cargo").ToString.FormatoNumero
|
|
TxtTotalAbonos.Text = DtMovimientos.SUMD("Abono").ToString.FormatoNumero
|
|
UpTotalCargo.Update()
|
|
UpTotalAbono.Update()
|
|
If Not ChkSeguir.Checked Then RegistraScript("$('#DivEditConcepto').modal('hide')", "hidemodal")
|
|
Alert("Concepto Registrado", TipoMensaje.ToastInformacion)
|
|
Else
|
|
Dim CvePrePolizaDetalle As Integer = GvPrePoliza.DataKeys(IndiceGrid).Value.ToString.ToEntero
|
|
|
|
Dim Rows As DataRow() = DtMovimientos.Select("CvePrePolizaDetalle = " & CvePrePolizaDetalle)
|
|
If CvePrePolizaDetalle <= 0 Then
|
|
Dim IdMov As Integer = GvPrePoliza.Rows(IndiceGrid).DataKey("IdMov").ToEntero
|
|
Rows = DtMovimientos.Select("IdMov = " & IdMov)
|
|
End If
|
|
If Rows.Count > 0 Then
|
|
Dim dr As DataRow = Rows(0)
|
|
Dim IdCtaContable As Integer = CargaCuentasContpaq(DdlCuentaContableE.SelectedValue.ToEntero)
|
|
dr("IdCtaContable") = IdCtaContable
|
|
dr("CveCuenta") = DdlCuentaContableE.SelectedValue
|
|
dr("CodigoNombreCuenta") = DdlCuentaContableE.SelectedItem.Text
|
|
dr("ConceptoContable") = DdlConceptosContablesE.SelectedItem.Text
|
|
dr("CveConceptoContable") = DdlConceptosContablesE.SelectedValue
|
|
dr("Concepto") = TxtConceptoE.Text
|
|
dr("Referencia") = TxtReferenciaE.Text
|
|
dr("TipoMovto") = If(Math.Abs(TxtCargoE.Text.ToDecimal) > 0, False, True)
|
|
dr("ImporteMN") = If(Math.Abs(TxtCargoE.Text.ToDecimal) > 0, TxtCargoE.Text.ToDecimal, TxtAbonoE.Text.ToDecimal)
|
|
dr("CveSubProyecto") = DdlSubProyectoE.SelectedValue
|
|
dr("SubProyecto") = DdlSubProyectoE.SelectedItem.Text
|
|
dr("CveProveedor") = DdlProveedoresE.SelectedValue.ToEntero
|
|
dr("CveCompra") = DdlComprasE.SelectedValue.ToEntero
|
|
dr("CvePersonal") = DdlPersonalE.SelectedValue.ToEntero
|
|
dr("CveCliente") = DdlClientesE.SelectedValue.ToEntero
|
|
dr("CveVenta") = DdlVentasE.SelectedValue.ToEntero
|
|
dr("FolioFactura") = If(DdlComprasE.Visible = True AndAlso DdlComprasE.SelectedItem IsNot Nothing, DdlComprasE.SelectedItem.ToString, If(DdlVentasE.Visible = True AndAlso DdlVentasE.SelectedItem IsNot Nothing, DdlVentasE.SelectedItem.ToString, ""))
|
|
dr("Modificado") = True
|
|
|
|
dr("ContadoCuenta") = DdlModalConceptoCuenta.SelectedValue.ToEntero
|
|
dr("ContadoTipoTransaccion") = DdlModalConceptoTipoTransaccion.SelectedValue.ToEntero
|
|
dr("ContadoNumeroFolio") = TxtModalConceptoDocumentoFolio.Text
|
|
dr("ContadoBeneficiario") = TxtModalConceptoDocumentoBeneficiario.Text
|
|
dr("ContadoObservaciones") = TxtModalConceptoDocumentoObservaciones.Text
|
|
dr("ContadoImporte") = TxtModalConceptoDocumentoImporte.Text.ToDecimal
|
|
|
|
dr("TC") = TxtTipoCambio.Text.ToDecimal
|
|
|
|
If DrConceptoContable IsNot Nothing Then
|
|
dr("EsComplementaria") = DrConceptoContable("EsComplementaria")
|
|
dr("EsMonedaExtranjera") = DrConceptoContable("EsMonedaExtranjera")
|
|
|
|
If dr("EsMonedaExtranjera") = "True" Then dr("ImporteME") = TxtME.Text.ToDecimal
|
|
|
|
End If
|
|
|
|
dr("PorcentajeImpuesto") = DdlPorcentajeIVAE.SelectedValue.ToDecimal
|
|
|
|
If TxtCargoE.Text <> "" Then
|
|
dr("Cargo") = TxtCargoE.Text.ToDecimal
|
|
dr("Abono") = 0
|
|
Else
|
|
dr("Abono") = TxtAbonoE.Text.ToDecimal
|
|
dr("Cargo") = 0
|
|
End If
|
|
|
|
DtMovimientos.AcceptChanges()
|
|
GvPrePoliza.EditIndex = -1
|
|
|
|
GvPrePoliza.DataSource = DtMovimientos
|
|
GvPrePoliza.DataBind()
|
|
UpPrePoliza.Update()
|
|
GvPrePoliza.Visible = True
|
|
|
|
GvPrePoliza.Columns(11).Visible = True
|
|
GvPrePoliza.Rows(IndiceGrid).FCCheckBox("chkModificado").Checked = True
|
|
|
|
TxtTotalCargos.Text = DtMovimientos.SUMD("Cargo").ToString.FormatoNumero
|
|
TxtTotalAbonos.Text = DtMovimientos.SUMD("Abono").ToString.FormatoNumero
|
|
UpTotalCargo.Update()
|
|
UpTotalAbono.Update()
|
|
DdlClientesE.ddl.Items.Clear()
|
|
DdlClientesE.SelectedText = ""
|
|
|
|
End If
|
|
RegistraScript("$('#DivEditConcepto').modal('hide')", "hidemodal")
|
|
End If
|
|
UpPrePoliza.Update()
|
|
|
|
End Sub
|
|
Protected Sub GvMov_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvMov.RowDeleting
|
|
|
|
Dim idMov As Integer = GvMov.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
Dim Rows As DataRow() = DtMovimientos.Select("IDMov = " & idMov)
|
|
If Rows.Count > 0 Then
|
|
DtMovimientos.Rows.Remove(Rows(0))
|
|
DtMovimientos.AcceptChanges()
|
|
End If
|
|
GvMov.DataSource = DtMovimientos
|
|
GvMov.DataBind()
|
|
|
|
TxtTotalAbonos.Text = DtMovimientos.SUM("Abono").FormatoNumero
|
|
TxtTotalCargos.Text = DtMovimientos.SUM("Cargo").FormatoNumero
|
|
|
|
'saco de la póliza el importe del cheque, que coincida la cuenta contable con la bancaria
|
|
|
|
End Sub
|
|
|
|
Private Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
|
|
|
|
If DtMovimientos Is Nothing Then CreaDT()
|
|
|
|
If Actualizar Then
|
|
|
|
Dim Rows As DataRow() = DtMovimientos.Select("IDMov = " & HdnCve.Value)
|
|
|
|
If Rows.Count > 0 Then
|
|
Dim dr As DataRow = Rows(0)
|
|
Dim CodigoCuenta As String = ""
|
|
Dim NombreCuenta As String = ""
|
|
dr("CveCuenta") = DdlCuentaContable.SelectedValue
|
|
|
|
If DdlCuentaContable.SelectedValue.ToEntero > 0 Then
|
|
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("CveCuenta={0}", DdlCuentaContable.SelectedValue))
|
|
If drr IsNot Nothing Then
|
|
CodigoCuenta = drr("CuentaFormato").ToString()
|
|
NombreCuenta = drr("Nombre").ToString()
|
|
End If
|
|
End If
|
|
|
|
dr("CodigoCuenta") = CodigoCuenta & "<br>" & NombreCuenta
|
|
dr("Cuenta") = DdlConceptosContables.SelectedItem
|
|
dr("Referencia") = TxtReferencia.Text
|
|
dr("Concepto") = TxtConcepto.Text
|
|
dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDecimal) > 0, False, True)
|
|
dr("EsComodin") = 0
|
|
dr("CveConceptoContable") = DdlConceptosContables.SelectedValue
|
|
dr("Cargo") = TxtCargo.Text.ToDecimal
|
|
dr("Abono") = TxtAbono.Text.ToDecimal
|
|
dr("Descripcion") = TxtDescripcion.Text
|
|
dr("CveSubProyecto") = DdlSubProyecto.SelectedValue
|
|
dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero
|
|
dr("CveCompra") = DdlCompras.SelectedValue.ToEntero
|
|
dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero
|
|
dr("CveClasificacion") = -1
|
|
dr("CveCliente") = DdlClientes.SelectedValue.ToEntero
|
|
dr("CveVenta") = DdlVentas.SelectedValue.ToEntero
|
|
End If
|
|
GvMov.DataSource = DtMovimientos
|
|
GvMov.DataBind()
|
|
UPMovs.Update()
|
|
LbCancelarEdicion.Visible = False
|
|
LbAgregar.Text = "Agregar"
|
|
|
|
Else
|
|
|
|
If CvePrePoliza > 0 Then
|
|
Dim dr As DataRow = DtMovimientos.NewRow
|
|
dr("IdCtaContable") = -1 'DdlCtaContable.SelectedValue
|
|
dr("CveCuenta") = DdlCuentaContable.SelectedValue
|
|
dr("ConceptoContable") = DdlConceptosContables.SelectedItem.Text
|
|
dr("CveConceptoContable") = DdlConceptosContables.SelectedValue
|
|
dr("Concepto") = TxtDescripcion.Text
|
|
dr("Referencia") = TxtReferencia.Text
|
|
dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDecimal) > 0, False, True)
|
|
dr("Cargo") = TxtCargo.Text.ToDecimal
|
|
dr("Abono") = TxtAbono.Text.ToDecimal
|
|
dr("ImporteMN") = If(Math.Abs(TxtCargo.Text.ToDecimal) > 0, TxtCargo.Text.ToDecimal, TxtAbono.Text.ToDecimal)
|
|
dr("CveSubProyecto") = DdlSubProyecto.SelectedValue
|
|
dr("SubProyecto") = DdlSubProyecto.SelectedItem.Text
|
|
dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero
|
|
dr("CveCompra") = DdlCompras.SelectedValue.ToEntero
|
|
dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero
|
|
dr("CveCliente") = DdlClientes.SelectedValue.ToEntero
|
|
dr("CveVenta") = DdlVentas.SelectedValue.ToEntero
|
|
|
|
TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDecimal + TxtAbono.Text.ToDecimal).ToString.FormatoNumero
|
|
TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDecimal + TxtCargo.Text.ToDecimal).ToString.FormatoNumero
|
|
DtMovimientos.Rows.Add(dr)
|
|
DtMovimientos.AcceptChanges()
|
|
|
|
If CvePrePoliza > 0 Then
|
|
GvPrePoliza.DataSource = DtMovimientos
|
|
GvPrePoliza.DataBind()
|
|
UpPrePoliza.Update()
|
|
End If
|
|
Else
|
|
Dim dr As DataRow = DtMovimientos.NewRow
|
|
Dim CodigoCuenta As String = ""
|
|
Dim NombreCuenta As String = ""
|
|
|
|
dr("CveCuenta") = DdlCuentaContable.SelectedValue
|
|
|
|
If DdlCuentaContable.SelectedValue.ToEntero > 0 Then
|
|
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("CveCuenta={0}", DdlCuentaContable.SelectedValue))
|
|
If drr IsNot Nothing Then
|
|
CodigoCuenta = drr("CuentaFormato").ToString()
|
|
NombreCuenta = drr("Nombre").ToString()
|
|
End If
|
|
End If
|
|
|
|
dr("CodigoCuenta") = CodigoCuenta & "<br>" & NombreCuenta
|
|
dr("Cuenta") = DdlConceptosContables.SelectedItem.Text
|
|
dr("Referencia") = TxtReferencia.Text
|
|
dr("Concepto") = TxtConcepto.Text
|
|
dr("TipoMovto") = If(Math.Abs(TxtCargo.Text.ToDecimal) > 0, False, True)
|
|
dr("EsComodin") = 0
|
|
dr("CveConceptoContable") = DdlConceptosContables.SelectedValue
|
|
dr("ConceptoContable") = DdlConceptosContables.SelectedItem.Text
|
|
dr("Cargo") = TxtCargo.Text.ToDecimal
|
|
dr("Abono") = TxtAbono.Text.ToDecimal
|
|
dr("Descripcion") = TxtDescripcion.Text
|
|
dr("CveSubProyecto") = DdlSubProyecto.SelectedValue
|
|
dr("CveProveedor") = DdlProveedores.SelectedValue.ToEntero
|
|
dr("CveCompra") = DdlCompras.SelectedValue.ToEntero
|
|
dr("CvePersonal") = DdlPersonal.SelectedValue.ToEntero
|
|
dr("CveClasificacion") = -1
|
|
dr("CveCliente") = DdlClientes.SelectedValue.ToEntero
|
|
dr("CveVenta") = DdlVentas.SelectedValue.ToEntero
|
|
|
|
TxtTotalAbonos.Text = (TxtTotalAbonos.Text.ToDecimal + TxtAbono.Text.ToDecimal).ToString.FormatoNumero
|
|
TxtTotalCargos.Text = (TxtTotalCargos.Text.ToDecimal + TxtCargo.Text.ToDecimal).ToString.FormatoNumero
|
|
DtMovimientos.Rows.Add(dr)
|
|
DtMovimientos.AcceptChanges()
|
|
|
|
GvMov.DataSource = DtMovimientos
|
|
GvMov.DataBind()
|
|
UPMovs.Update()
|
|
Actualizar = False
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
TxtCargo.Text = ""
|
|
TxtAbono.Text = ""
|
|
TxtReferencia.Text = ""
|
|
TxtDescripcion.Text = ""
|
|
End Sub
|
|
|
|
#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE"
|
|
Public Sub Bancos_Click(sender As Object, e As EventArgs)
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
RowIndex = GvRow.RowIndex
|
|
|
|
If GvRow.FCTextBox("TxtAbono").Visible Then
|
|
CargaTipoTransaccion("Egs")
|
|
Else
|
|
CargaTipoTransaccion("Ing")
|
|
End If
|
|
|
|
Dim IdMov As Integer = GvRow.DataKey("IdMov").ToString.ToEntero
|
|
Dim Rows As DataRow() = DtMovimientos.Select("IdMov = " & IdMov)
|
|
IDMovEditar = IdMov
|
|
|
|
If Rows.Count > 0 Then
|
|
Dim dr As DataRow = Rows(0)
|
|
DdlTipoTransaccion.SelectedValueExist(dr("ContadoTipoTransaccion").ToString.ToEntero)
|
|
DdlCuenta.SelectedValueExist(dr("ContadoCuenta").ToString.ToEntero)
|
|
TxtDocumentoFolio.Text = dr("ContadoNumeroFolio").ToString
|
|
TxtDocumentoObservaciones.Text = dr("ContadoObservaciones").ToString
|
|
TxtDocumentoBeneficiario.Text = dr("ContadoBeneficiario").ToString
|
|
End If
|
|
|
|
TxtDocumentoImporte.Text = If(GvRow.FCTextBox("TxtAbono").Text = "", GvRow.FCTextBox("TxtCargo").Text.FormatoNumero, GvRow.FCTextBox("TxtAbono").Text.FormatoNumero)
|
|
UpBancos.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivContadoModal"))
|
|
End Sub
|
|
Private Sub CargaTipoTransaccion(Tipo As String)
|
|
DdlTipoTransaccion.Items.Clear()
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros($"Tipo = '{Tipo}' AND Estatus = 1 ")
|
|
DdlTipoTransaccion.DataBind()
|
|
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
|
|
End Sub
|
|
Private Sub CargaCuentas()
|
|
DdlCuenta.Items.Clear()
|
|
DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) '.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", DdlMoneda.SelectedValue))
|
|
DdlCuenta.DataBind()
|
|
DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
Private Sub BtnContado_Click(sender As Object, e As EventArgs) Handles BtnContado.Click
|
|
Dim Rows As DataRow() = DtMovimientos.Select("IdMov = " & IDMovEditar)
|
|
|
|
If Rows.Count > 0 Then
|
|
Dim dr As DataRow = Rows(0)
|
|
|
|
dr("ContadoTipoTransaccion") = DdlTipoTransaccion.SelectedValue.ToEntero
|
|
dr("ContadoCuenta") = DdlCuenta.SelectedValue.ToEntero
|
|
dr("ContadoNumeroFolio") = TxtDocumentoFolio.Text
|
|
dr("ContadoImporte") = TxtDocumentoImporte.Text.ToDecimal
|
|
dr("ContadoBeneficiario") = TxtDocumentoBeneficiario.Text
|
|
dr("ContadoObservaciones") = TxtDocumentoObservaciones.Text
|
|
End If
|
|
|
|
DtMovimientos.AcceptChanges()
|
|
|
|
If Not DtMovimientos.Columns.Contains("Cargo") Then
|
|
DtMovimientos.Columns.Add("Cargo", GetType(Decimal))
|
|
DtMovimientos.Columns.Add("Abono", GetType(Decimal))
|
|
End If
|
|
|
|
Dim IndexX As Integer = 0
|
|
For Each PGvRow As GridViewRow In GvMov.Rows
|
|
|
|
If PGvRow.RowType = DataControlRowType.DataRow Then
|
|
|
|
DtMovimientos.Rows(IndexX)("Cargo") = PGvRow.FCTextBox("TxtCargo").Text.ToDecimal
|
|
DtMovimientos.Rows(IndexX)("Abono") = PGvRow.FCTextBox("TxtAbono").Text.ToDecimal
|
|
|
|
IndexX = IndexX + 1
|
|
End If
|
|
Next
|
|
|
|
GvMov.DataSource = DtMovimientos
|
|
GvMov.DataBind()
|
|
|
|
|
|
'CveTipoTransaccion = DdlTipoTransaccion.SelectedValue.ToEntero
|
|
'CveCuenta = DdlCuenta.SelectedValue.ToEntero
|
|
'Folio = TxtDocumentoFolio.Text
|
|
'ImporteDocumento = TxtDocumentoImporte.Text.ToDecimal
|
|
'Observaciones = TxtDocumentoObservaciones.Text
|
|
'Beneficiario = TxtDocumentoBeneficiario.Text
|
|
|
|
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivContadoModal"))
|
|
GvMov.Rows(RowIndex).FCLinkButton("ImgBancos").CssClass = "btn btn-circle btn-sm green"
|
|
UPMovs.Update()
|
|
End Sub
|
|
|
|
Private Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
|
|
Dim ObjContabilidad As New ClsContabilidad
|
|
|
|
If ObjContabilidad.RemovePrePolizas(CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
|
Alert("La Prepóliza ha sido eliminada", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("La Prepóliza ha podido ser eliminada", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjContabilidad.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
Protected Sub DdlTipoGasto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
If UpPrePoliza.Visible Then
|
|
|
|
|
|
For Each dRow As DataRow In DtMovimientos.Rows
|
|
dRow("CveTipoGasto") = DdlTipoGasto.SelectedValue
|
|
dRow("TipoGasto") = DdlTipoGasto.SelectedItem.Text
|
|
Next
|
|
|
|
DtMovimientos.AcceptChanges()
|
|
GvPrePoliza.DataSource = DtMovimientos
|
|
GvPrePoliza.DataBind()
|
|
|
|
For Each Gvr As GridViewRow In GvPrePoliza.Rows
|
|
'Gvr.FCDropDownList("DdlTipoGasto").SelectedValueExist(DdlTipoGasto.SelectedValue)
|
|
Gvr.FCCheckBox("chkModificado").Checked = True
|
|
|
|
Next
|
|
|
|
UpPrePoliza.Update()
|
|
End If
|
|
If divMovtos.Visible Then
|
|
For Each Gvr As GridViewRow In GvMov.Rows
|
|
Gvr.FCDropDownList("DdlTipoGasto").SelectedValueExist(DdlTipoGasto.SelectedValue)
|
|
Next
|
|
UPMovs.Update()
|
|
End If
|
|
End Sub
|
|
Protected Sub DdlSubProyectoFiltro_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
Dim Ddl As DropDownList = CType(sender, DropDownList)
|
|
For Each Gvr As GridViewRow In GvPrePoliza.Rows
|
|
If Ddl.SelectedValue.ToEntero > 0 Then
|
|
If Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero = Ddl.SelectedValue.ToEntero Or Not Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero > 0 Then
|
|
Gvr.Visible = True
|
|
Else
|
|
Gvr.Visible = False
|
|
End If
|
|
Else
|
|
Gvr.Visible = True
|
|
End If
|
|
Next
|
|
UpPrePoliza.Update()
|
|
RegistraScript("calculateAbono()", "cargo")
|
|
RegistraScript("calculateCargo()", "abono")
|
|
RegistraScript("comparar()", "compara")
|
|
End Sub
|
|
Protected Sub DdlSubProyectoFiltroMov_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
For Each Gvr As GridViewRow In GvMov.Rows
|
|
If DdlSubProyectoFiltroMov.SelectedValue.ToEntero > 0 Then
|
|
If Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero = DdlSubProyectoFiltroMov.SelectedValue.ToEntero Or Not Gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero > 0 Then
|
|
Gvr.Visible = True
|
|
Else
|
|
Gvr.Visible = False
|
|
End If
|
|
Else
|
|
Gvr.Visible = True
|
|
End If
|
|
Next
|
|
UpPrePoliza.Update()
|
|
RegistraScript("calculateAbono()", "cargo")
|
|
RegistraScript("calculateCargo()", "abono")
|
|
RegistraScript("comparar()", "compara")
|
|
End Sub
|
|
|
|
Private Sub GvMov_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvMov.RowEditing
|
|
Actualizar = True
|
|
GvMov.DataKeys(e.NewEditIndex).Value.ToString.ToEntero
|
|
Dim idMov As Integer = GvMov.DataKeys(e.NewEditIndex).Value.ToString.ToEntero
|
|
|
|
Dim DrM As DataRow = DtMovimientos.Rows(e.NewEditIndex)
|
|
|
|
If DrM IsNot Nothing Then
|
|
HdnCve.Value = idMov.ToString
|
|
|
|
DdlCuentaContable.SelectedValueExist(DrM("CveCuenta").ToString)
|
|
TxtReferencia.Text = DrM("Referencia").ToString
|
|
TxtConcepto.Text = DrM("Concepto")
|
|
' (Math.Abs(TxtCargo.Text.ToDouble) > 0, 0, 1) = dr("TipoMovto")
|
|
DrM("EsComodin") = 0
|
|
DdlConceptosContables.SelectedValueExist(DrM("CveConceptoContable").ToString)
|
|
TxtCargo.Text = DrM("Cargo").ToString
|
|
TxtAbono.Text = DrM("Abono").ToString
|
|
TxtDescripcion.Text = DrM("Descripcion").ToString
|
|
DdlSubProyecto.SelectedValueExist(DrM("CveSubProyecto").ToString)
|
|
DdlProveedores.SelectedValueExist(DrM("CveProveedor").ToString)
|
|
DdlCompras.SelectedValueExist(DrM("CveCompra").ToString)
|
|
DdlPersonal.SelectedValueExist(DrM("CvePersonal").ToString)
|
|
' DrM("CveClasificacion") = -1
|
|
|
|
DdlClientes.txtValue.Value = DrM("CveCliente").ToString
|
|
'DdlClientes.txtText.Value = DrM("CveCliente").ToString
|
|
|
|
DdlVentas.SelectedValueExist(DrM("CveVenta").ToString)
|
|
LbCancelarEdicion.Visible = True
|
|
LbAgregar.Text = "Actualizar"
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub LbCancelarEdicion_Click(sender As Object, e As EventArgs) Handles LbCancelarEdicion.Click
|
|
LbCancelarEdicion.Visible = False
|
|
TxtConcepto.Text = ""
|
|
Actualizar = False
|
|
LbAgregar.Text = "Agregar"
|
|
End Sub
|
|
|
|
|
|
|
|
#Region "COMPLEMENTO DE PAGO"
|
|
|
|
Private Sub GeneraTimbre(CvePrePoliza As Integer)
|
|
Dim Str As New StringBuilder
|
|
Dim Banco As New ClsBancos
|
|
Banco.IniciaTransacSQL()
|
|
If Banco.GeneraTimbrePago(-1, -1, UsuarioActual, CvePrePoliza:=CvePrePoliza) Then
|
|
If Banco.Mensaje = "" Then
|
|
Banco.Commit()
|
|
PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False)
|
|
Str.AppendFormat("Folio: <b>{0}</b> ", Banco.ComplementoSerieFolio)
|
|
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">XML <i class=""fa fa-file""></i></i></a> ", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
|
|
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">PDF <i class=""fa fa-ad-pdf""></i></i></i></a> ", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
|
|
MandaCorreo(Banco.ComplementoSerieFolio, Banco.CobranzaCorreo)
|
|
End If
|
|
Else
|
|
Banco.RollBack()
|
|
Str.AppendFormat("No se genero complemento por el siguiente motivo: {0}", Banco.Mensaje)
|
|
End If
|
|
Banco.Dispose()
|
|
Alert(Str.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();")
|
|
End Sub
|
|
|
|
Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True)
|
|
Try
|
|
Dim Msg As String = ""
|
|
If NombreArchivo <> "-1" Then '
|
|
Dim ObjMail As New ClsSisMail()
|
|
Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo)
|
|
Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo)
|
|
Dim Cuerpo As String = "Se hace entrega del comprobante de pago"
|
|
Dim Asunto As String = "Entrega de comprobante de pago"
|
|
If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then
|
|
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
|
|
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF})
|
|
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML})
|
|
If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then
|
|
If ConAlerta Then
|
|
'RegistraScript("$('#ModalDivMail').modal('hide');")
|
|
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
Else
|
|
Msg = "No se pudo enviar el correo electrónico."
|
|
End If
|
|
Else
|
|
Msg = "No se pudo adjuntar el correo electrónico."
|
|
End If
|
|
End If
|
|
If ConAlerta AndAlso Msg <> "" Then
|
|
Alert(Msg, TipoMensaje.MsgError)
|
|
End If
|
|
Catch ex As Exception
|
|
OnError("Ocurrió error al mandar MAIL", ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Protected Sub LnkComplementoPago_Click(sender As Object, e As EventArgs)
|
|
GeneraTimbre(CvePrePoliza)
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
#Region "E X C E L"
|
|
|
|
|
|
Private Sub LnkExcel_Click(sender As Object, e As EventArgs) Handles LnkExcel.Click
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivCargaExcel"))
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnDescargar_Click(sender As Object, e As EventArgs) Handles BtnDescargar.Click
|
|
Dim NombreArchivo As String
|
|
SpreadsheetInfo.SetLicense(ModExtensiones.SerialGemBoxSpreadsheet)
|
|
Dim workbook As New ExcelFile()
|
|
Dim NombreHoja As String = DdlPlantilla2.SelectedItem.Text.ToString
|
|
If NombreHoja.Length > 30 Then
|
|
NombreHoja = NombreHoja.Substring(0, 29)
|
|
End If
|
|
Dim worksheet = workbook.Worksheets.Add(NombreHoja)
|
|
|
|
Dim CvePlantilla As Integer = DdlPlantilla2.SelectedValue.ToEntero
|
|
'Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla, UsuarioActual.CveEmpresa)
|
|
Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(UsuarioActual.CveEmpresa, CvePlantilla).FiltraParametros("", "Orden")
|
|
|
|
|
|
Dim DtExcel As DataTable = (From row As DataRow In Dt.Rows
|
|
Select New With
|
|
{
|
|
.ConceptoAdministrativo = row.Item("ConceptoContable"),
|
|
.Cuenta = row.Item("Codigo"),
|
|
.NombreCuenta = row.Item("NombreCuenta"),
|
|
.Cargo = "",
|
|
.Abono = "",
|
|
.Referencia = "",
|
|
.Concepto = "",
|
|
.SubProyecto = row.Item("SubProyecto"),
|
|
.Folio = "",
|
|
.TipoTransferencia = "",
|
|
.CveConceptoContable = row.Item("CveConceptoContable"),
|
|
.CveSubProyecto = IIf(row.Item("CveSubProyecto").ToString.ToEntero > 0, row.Item("CveSubProyecto"), -1),
|
|
.IdCtaContable = IIf(row.Item("IdCtaContable").ToString.ToEntero > 0, row.Item("IdCtaContable"), -1),
|
|
.CveCuenta = row.Item("CveCuenta")
|
|
}).QueryToDataTable(True)
|
|
|
|
worksheet.InsertDataTable(DtExcel, New InsertDataTableOptions() With
|
|
{
|
|
.ColumnHeaders = True,
|
|
.StartRow = 0,
|
|
.StartColumn = 0
|
|
})
|
|
|
|
Dim columnCount = worksheet.CalculateMaxUsedColumns()
|
|
For i = 0 To columnCount
|
|
worksheet.Columns(i).AutoFit(1, worksheet.Rows(0), worksheet.Rows(worksheet.Rows.Count - 1))
|
|
Next
|
|
worksheet.Columns("K").Hidden = True
|
|
worksheet.Columns("L").Hidden = True
|
|
worksheet.Columns("M").Hidden = True
|
|
worksheet.Columns("N").Hidden = True
|
|
|
|
|
|
NombreArchivo = DdlPlantilla2.SelectedItem.Text.ToString
|
|
workbook.Save(Response, $"{NombreArchivo}.xlsx", SaveOptions.XlsxDefault)
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnCargaExcel_Click(sender As Object, e As EventArgs) Handles BtnCargaExcel.Click
|
|
If TxtExcel.getfiles().Archivos.Count > 0 Then
|
|
Dim file As Archivo = TxtExcel.getfiles().Archivos(0)
|
|
|
|
Dim Directorio As String = Server.MapPath("~") & file.path
|
|
|
|
Dim Tipo As String = If(file.Extension.Contiene("xlsx", "xlsx", "xlsm", "xlsb"), "EXCEL", "CSV")
|
|
CargarArchivo(Directorio, file.filename, Tipo)
|
|
Else
|
|
Alert("No existe el archivo.Favor de subir un archivo csv o excel a la plataforma", TipoMensaje.MsgError)
|
|
End If
|
|
End Sub
|
|
Private Sub CargarArchivo(Ruta As String, FileName As String, Tipo As String)
|
|
Dim dt As New DataTable
|
|
' Conexion As Odbc.OdbcConnection = Nothing
|
|
Dim ErrorArchivo = False
|
|
Dim ErrorExcel = False
|
|
DdlPlantilla.SelectedValue = DdlPlantilla2.SelectedValue
|
|
dt = ReadExcelFile(Ruta + FileName, True, 0)
|
|
|
|
If Not ErrorArchivo Then
|
|
|
|
If Not dt.Columns(0).ColumnName.ToUpper = "CONCEPTOADMINISTRATIVO" Then
|
|
Alert("El nombre de la primera columna debe ser 'ConceptoAdministrativo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(1).ColumnName.ToUpper = "CUENTA" Then
|
|
Alert("El nombre de la segunda columna debe ser 'Cuenta'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(2).ColumnName.ToUpper = "NOMBRECUENTA" Then
|
|
Alert("El nombre de la tercera columna debe ser 'NombreCuenta'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(3).ColumnName.ToUpper = "CARGO" Then
|
|
Alert("El nombre de la cuarta columna debe ser 'Cargo'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(4).ColumnName.ToUpper = "ABONO" Then
|
|
Alert("El nombre de la quinta columna debe ser 'Abono' .Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(5).ColumnName.ToUpper = "REFERENCIA" Then
|
|
Alert("El nombre de la sexta columna debe ser 'Referencia'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(6).ColumnName.ToUpper = "CONCEPTO" Then
|
|
Alert("El nombre de la séptima columna debe ser 'Concepto'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(7).ColumnName.ToUpper = "SUBPROYECTO" Then
|
|
Alert("El nombre de la octava columna debe ser 'SubProyecto'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(8).ColumnName.ToUpper = "FOLIO" Then
|
|
Alert("El nombre de la novena columna debe ser 'Folio'.Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
If Not dt.Columns(9).ColumnName.ToUpper = "TIPOTRANSFERENCIA" Then
|
|
Alert("El nombre de la decima columna debe ser 'TipoTransferencia'. Favor de corregirlo", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorArchivo Then
|
|
|
|
DtMovimientos.Clear()
|
|
|
|
Try
|
|
|
|
Dim ContadorRegistros As Integer = 2
|
|
|
|
For Each Row As DataRow In dt.FiltraParametros("ConceptoAdministrativo <> ''").Rows
|
|
|
|
Dim NombreCuenta As String = Row("NombreCuenta").ToString
|
|
Dim Cuenta As String = Row("Cuenta").ToString
|
|
Dim ConceptoAdministrativo As String = Row("ConceptoAdministrativo").ToString
|
|
|
|
Dim CveSubProyecto As Integer = -1
|
|
Dim TipoMovto As Boolean = If(Row("Cargo").ToString.ToDecimal <> 0, False, True)
|
|
Dim CveConceptoContable As Integer = GlobalDTContaConceptosContables(-1).FiltroPrimeroValor("CveConceptoContable", String.Format("ConceptoContable ='{0}'", Row("ConceptoAdministrativo").ToString.Trim)).ToEntero ' Row("CveConceptoContable").ToString.ToEntero
|
|
'Dim IdCtaContable As Integer = Row("IdCtaContable").ToString.ToEntero
|
|
Dim CveClasificacion As Integer = -1
|
|
Dim CveCuentaExcel As Integer = -1
|
|
Dim ObjConta2 As New ClsContabilidad
|
|
Dim FolioExcel As Long = -1
|
|
Dim TipoMov As Integer = -1
|
|
Dim TipoNaturaleza As String = ""
|
|
Dim CveBancoCuenta As Integer = -1
|
|
If ObjConta2.GetCuentas(-1, Row("Cuenta").ToString.Replace("-", "").Trim, 1, UsuarioActual.CveEmpresa) Then
|
|
CveCuentaExcel = ObjConta2.DtResultados.FiltroPrimeroValor("CveCuenta", "").ToEntero
|
|
NombreCuenta = ObjConta2.DtResultados.FiltroPrimeroValor("CtaCodigo", "")
|
|
End If
|
|
ObjConta2.Dispose()
|
|
|
|
If CveCuentaExcel <= 0 AndAlso CveConceptoContable <> 30 Then ' concepto 30-Bancos, tomará la cuetna de las especificaciones que se hagan enel modal
|
|
Alert(String.Format("La cuenta <b>{0}</b> no se reconoció, favor de verificar el archivo.", Row("Cuenta").ToString))
|
|
DtMovimientos.Clear()
|
|
Exit For
|
|
End If
|
|
|
|
If CveConceptoContable = 30 AndAlso Row("TipoTransferencia").ToString <> "" Then
|
|
|
|
Dim objconta3 As New ClsContabilidad
|
|
objconta3.GetConta_CuentasDataContabilidad(CveCuentaExcel, UsuarioActual.CveEmpresa)
|
|
If objconta3.DtResultados.Rows.Count > 0 Then
|
|
Dim rowcc As DataRow = objconta3.DtResultados.Rows(0)
|
|
CveBancoCuenta = rowcc("CveBancoCuenta").ToString().ToEntero()
|
|
Else
|
|
CveBancoCuenta = 0
|
|
End If
|
|
objconta3.Dispose()
|
|
|
|
If CveBancoCuenta = 0 Then
|
|
Alert(String.Format("La cuenta <b>{0}</b> no está vinculada a una cuenta bancaria administrativa favor de verificar el archivo.", Row("Cuenta").ToString), TipoMensaje.MsgAdvertencia)
|
|
DtMovimientos.Clear()
|
|
Exit For
|
|
End If
|
|
|
|
TipoMov = GlobalDTTipoTransacciones.FiltroPrimeroValor("CveTipoTransaccion", String.Format("TipoTransaccion = '{0}' ", Row("TipoTransferencia"))).ToEntero
|
|
TipoNaturaleza = GlobalDTTipoTransacciones.FiltroPrimeroValor("Tipo", String.Format("TipoTransaccion = '{0}' ", Row("TipoTransferencia")))
|
|
|
|
FolioExcel = Row("Folio").ToString.ToEntero
|
|
CveTipoTransaccion = TipoMov
|
|
CveCuenta = CveBancoCuenta
|
|
'carga el consecutivo
|
|
|
|
If FolioExcel = 0 Then
|
|
FolioExcel = SiguienteFolioBancos(CveBancoCuenta, TipoMov)
|
|
End If
|
|
|
|
Folio = FolioExcel
|
|
ImporteDocumento = IIf(Row("Abono").ToString.ToDecimal <> 0, Row("Abono").ToString.ToDecimal, Row("Cargo").ToString.ToDecimal)
|
|
Observaciones = Row("Referencia").ToString
|
|
Beneficiario = Row("Concepto").ToString
|
|
|
|
If Not TipoMov > 0 Then
|
|
Alert(String.Format("El Tipo de Transferencia no fue encontrado: <br/> <b>Tipo Transferencia: <b/> {0} <br/> <b>Folio: <b/> {1} <br/> <b>Importe: <b/> {2} ", Row("TipoTransferencia").ToString(), FolioExcel, ImporteDocumento), TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
If Not (TipoNaturaleza = "Ing" And ((TipoMovto = False And ImporteDocumento >= 0) Or (TipoMovto = True And ImporteDocumento <= 0)) Or
|
|
TipoNaturaleza = "Egs" And ((TipoMovto = True And ImporteDocumento >= 0) Or (TipoMovto = False And ImporteDocumento <= 0))) Then
|
|
Alert($"El movimiento con cuenta: {NombreCuenta} , importe: {ImporteDocumento.ToString("###,###,###.00")} (registro {ContadorRegistros}), no tiene la naturaleza correcta", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
|
|
End If
|
|
|
|
'If Row("Abono").ToString.ToDecimal > 0 And TipoNaturaleza = "Ing" Or Row("Cargo").ToString.ToDecimal > 0 And TipoNaturaleza = "Egs" Then
|
|
' Alert($"El movimiento con cuenta: {NombreCuenta} , importe: {ImporteDocumento.ToString("###,###,###.00")} (registro {ContadorRegistros}), no tiene la naturaleza correcta", TipoMensaje.MsgAdvertencia)
|
|
' Exit Sub
|
|
'End If
|
|
|
|
End If
|
|
|
|
If Row("Abono").ToString.ToDecimal > 0 And Row("Cargo").ToString.ToDecimal > 0 Then
|
|
Alert($"Se detecto un error en el registro {ContadorRegistros}, se tiene un valor en cargo({Row("Cargo").ToString.ToDecimal.ToString("###,###,###.00")}) y abono({Row("Abono").ToString.ToDecimal.ToString("###,###,###.00")})", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If CveConceptoContable = 30 AndAlso Row("TipoTransferencia").ToString = "" Then
|
|
Alert($" El registro {ContadorRegistros} es movimiento bancario y no se especifica el tipo de transferencia , importe: {ImporteDocumento.ToString("###,###,###.00")}", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'sino viene el cveconcepto, busca por le nombre del concepto
|
|
If CveConceptoContable = 0 Then
|
|
Alert(String.Format("El concepto <b>{0}</b> no se reconoció, favor de verificar el archivo.", Row("ConceptoAdministrativo")))
|
|
DtMovimientos.Clear()
|
|
Exit For
|
|
End If
|
|
|
|
If Row("SubProyecto").ToString.Trim <> "" Then
|
|
CveSubProyecto = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa, Estatus:=-1).FiltroPrimeroValor("CveSubProyecto", String.Format("SubProyecto = '{0}'", Row("SubProyecto").ToString.Trim)).ToEntero 'Row("CveSubProyecto").ToString.ToEntero
|
|
|
|
If CveSubProyecto = 0 Then
|
|
Alert(String.Format("El subproyecto <b>{0}</b> no se reconoció, favor de verificar el archivo.", Row("SubProyecto")))
|
|
DtMovimientos.Clear()
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
|
|
If CveConceptoContable = 69 Then
|
|
CveClasificacion = GlobalDTClasificaciones(UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveClasificacion", "").ToEntero
|
|
End If
|
|
|
|
Dim dr As DataRow = DtMovimientos.NewRow
|
|
Dim CodigoCuenta As String = ""
|
|
|
|
dr("CodigoCuenta") = NombreCuenta
|
|
dr("CodigoNombreCuenta") = NombreCuenta
|
|
dr("Cuenta") = ConceptoAdministrativo
|
|
dr("Referencia") = Row("Referencia").ToString
|
|
dr("Concepto") = Row("Concepto").ToString
|
|
dr("TipoMovto") = TipoMovto
|
|
dr("EsComodin") = 0
|
|
dr("CveConceptoContable") = CveConceptoContable
|
|
dr("ConceptoContable") = Row("ConceptoAdministrativo").ToString
|
|
dr("Cargo") = Row("Cargo").ToString.ToDecimal.RoundSQL
|
|
dr("Abono") = Row("Abono").ToString.ToDecimal.RoundSQL
|
|
dr("ImporteME") = 0
|
|
dr("ImporteMN") = IIf(Row("Cargo").ToString.ToDecimal <> 0, Row("Cargo").ToString.ToDecimal, Row("Abono").ToString.ToDecimal)
|
|
dr("Descripcion") = Row("Concepto").ToString
|
|
dr("SubProyecto") = Row("SubProyecto").ToString.Trim
|
|
dr("CveSubProyecto") = CveSubProyecto
|
|
dr("CveProveedor") = -1
|
|
dr("CveCompra") = -1
|
|
dr("CvePersonal") = -1
|
|
dr("CveClasificacion") = CveClasificacion
|
|
dr("CveCliente") = -1
|
|
dr("CveVenta") = -1
|
|
dr("CveCuenta") = CveCuentaExcel
|
|
dr("CveTipoGasto") = -1
|
|
dr("CvePrePolizaDetalle") = -1
|
|
dr("PorcentajeImpuesto") = 0D
|
|
dr("TC") = 1
|
|
dr("EsComplementaria") = 0
|
|
dr("Modificado") = 1
|
|
|
|
dr("ContadoTipoTransaccion") = CveTipoTransaccion
|
|
dr("ContadoCuenta") = CveBancoCuenta
|
|
dr("ContadoNumeroFolio") = FolioExcel
|
|
dr("ContadoImporte") = ImporteDocumento
|
|
dr("ContadoBeneficiario") = Beneficiario
|
|
dr("ContadoObservaciones") = Observaciones
|
|
|
|
If Row("Cargo").ToString.ToDecimal <> 0 OrElse Row("Abono").ToString.ToDecimal <> 0 Then
|
|
DtMovimientos.Rows.Add(dr)
|
|
DtMovimientos.AcceptChanges()
|
|
End If
|
|
ContadorRegistros = ContadorRegistros + 1
|
|
Next
|
|
|
|
GvMov.DataBind()
|
|
divMovtos.Visible = False
|
|
GvPrePoliza.DataSource = DtMovimientos
|
|
GvPrePoliza.DataBind()
|
|
UpPrePoliza.Update()
|
|
|
|
TxtTotalCargos.Text = DtMovimientos.SUMD("Cargo").ToString.FormatoNumero
|
|
TxtTotalAbonos.Text = DtMovimientos.SUMD("Abono").ToString.FormatoNumero
|
|
|
|
Catch ex As Exception
|
|
Alert("No se pudo cargar el excel", TipoMensaje.MsgAdvertencia)
|
|
GuardaLog(ex.Message)
|
|
End Try
|
|
ArregloCuentasFolios = Nothing
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "Siguiente Folio"
|
|
Public Property ArregloCuentasFolios As DataTable
|
|
Get
|
|
|
|
If ViewState("ArregloCuentasFolios") Is Nothing Then
|
|
Dim dt = New DataTable("CuentasBancos")
|
|
With dt.Columns
|
|
.Add("CveCuenta", Type.GetType("System.Int32"))
|
|
.Add("CveTipoTransaccion", Type.GetType("System.Int32"))
|
|
.Add("Folio", Type.GetType("System.Double"))
|
|
End With
|
|
ViewState("ArregloCuentasFolios") = dt
|
|
End If
|
|
|
|
Return CType(ViewState("ArregloCuentasFolios"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("ArregloCuentasFolios") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Public Function SiguienteFolioBancos(CveCuentaBancos As Integer, CveTipoTransaccionBancos As Integer) As String
|
|
Dim Retorno As String = "0"
|
|
|
|
Dim Folio As Long = ArregloCuentasFolios.FiltroPrimeroValor("Folio", String.Format("CveCuenta = {0} and CveTipoTransaccion = {1}", CveCuentaBancos, CveTipoTransaccionBancos)).ToLong
|
|
|
|
If Folio = 0 Then
|
|
Dim Banco As New ClsBancos
|
|
Folio = Banco.GetNextFolio(CveCuentaBancos, CveTipoTransaccionBancos)
|
|
Banco.Dispose()
|
|
End If
|
|
|
|
Folio += 1
|
|
|
|
Dim a As DataRow() = ArregloCuentasFolios.Select(String.Format("CveCuenta = {0} and CveTipoTransaccion = {1}", CveCuentaBancos, CveTipoTransaccionBancos))
|
|
|
|
If a.Count = 0 Then
|
|
Dim dr As DataRow = ArregloCuentasFolios.NewRow
|
|
dr("Folio") = Folio
|
|
dr("CveCuenta") = CveCuentaBancos
|
|
dr("CveTipoTransaccion") = CveTipoTransaccionBancos
|
|
ArregloCuentasFolios.Rows.Add(dr)
|
|
Else
|
|
a(0)("Folio") = Folio 'actualizo el folio
|
|
End If
|
|
|
|
ArregloCuentasFolios.AcceptChanges()
|
|
|
|
Return Folio
|
|
End Function
|
|
#End Region
|
|
|
|
Private Sub BtnContabilizar_Click(sender As Object, e As EventArgs) Handles BtnContabilizar.Click
|
|
|
|
Contabilizar()
|
|
|
|
End Sub
|
|
|
|
Private Sub Contabilizar()
|
|
|
|
Dim ObjConta As New ClsContabilidad
|
|
|
|
If UsuarioActual.Empresa.TipoContabilidad = 1 Then
|
|
|
|
If Folio.ToEntero = 0 Then
|
|
|
|
Dim FolioManual As Integer = If(TxtFolio.Text.ToEntero > 0, TxtFolio.Text.ToEntero, -1)
|
|
|
|
If ObjConta.ContabilizaDesContabilizaPrePoliza(CvePrePoliza, True, UsuarioActual.CveEmpresa, Folio:=FolioManual) Then
|
|
|
|
Alert($"Contabilizado Correctamente Folio <b>{ ObjConta.ContaFolio.ToString()}.</b>", TipoMensaje.MsgInformacion)
|
|
|
|
TxtFolio.Text = ObjConta.ContaFolio.ToString()
|
|
LnkFolioManual.Visible = False
|
|
BtnContabilizar.Visible = False
|
|
BtnDescontabilizar.Visible = True
|
|
UpPoliza.Update()
|
|
UpGuardar.Update()
|
|
|
|
End If
|
|
|
|
End If
|
|
|
|
Else
|
|
|
|
If IdPoliza > 0 Then 'si está bloqueada, lo desbloqueaprimero
|
|
ObjConta.UpdatePrePolizasDetalleBloquear(CvePrePoliza, False)
|
|
End If
|
|
|
|
If ObjConta.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, pIDPoliza:=If(IdPoliza > 0, IdPoliza, -1), Concepto:=TxtConcepto.Text, Fecha:=TxtFechaDocumento.Text.ToDateTime()) Then
|
|
If UsuarioActual.Empresa.TipoContabilizacion = 1 Then
|
|
Alert(String.Format("Prepóliza contabilizada. <br/><br/>Folio: <b>{0}</b> ", ObjConta.FolioPoliza), ModExtensiones.TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert(String.Format("Prepóliza contabilizada. <br/><br/>Folio:<a Class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", ObjConta.ContaIdPoliza), ModExtensiones.TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
Else
|
|
|
|
Alert($"Ocurrio un error al contabilizar {ObjConta.AlertaMensaje}", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
|
|
End If
|
|
|
|
ObjConta.Dispose()
|
|
End Sub
|
|
|
|
|
|
#Region "Paquete Egresos"
|
|
Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs)
|
|
|
|
|
|
If UsuarioActual.Empresa.Funcionalidad(282).ToEntero = 1 Then
|
|
|
|
ImprimePrePolizasDetalleResumen("PDF")
|
|
Else
|
|
ImprimirPolizaPDF(IdPoliza)
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub ImprimirPolizaPDF(IdPoliza As Integer)
|
|
|
|
'Dim ObjPoliza As New ClsContPAQi(UsuarioActual.Empresa)
|
|
|
|
Dim Archivo As New System.IO.FileInfo(String.Format("{0}Formatos/Polizas.rdlc", UsuarioActual.Empresa.Ruta))
|
|
Dim params As New List(Of ReportParameter)
|
|
Dim Bytes As Byte() = Nothing
|
|
|
|
|
|
Dim ObjConta As New ClsContabilidad
|
|
'If ObjPoliza.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjPoliza.DtResultados.Rows.Count > 0 Then
|
|
If ObjConta.GetPrePolizasDetalle(CvePrePoliza, UsuarioActual.CveEmpresa) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
|
|
Dim dtVC As DataTable
|
|
Dim dr As DataRow
|
|
dtVC = ObjConta.DtResultados.FiltraParametros("Contabilizable = 1", "Orden")
|
|
dr = dtVC.Rows(0)
|
|
Dim ruta As String = ""
|
|
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("TipoPoliza", dr("TipoPoliza").ToString))
|
|
params.Add(New ReportParameter("Finicio", dr("Fecha").ToString.ToDate.ToShortDateString))
|
|
params.Add(New ReportParameter("FFin", dr("Fecha").ToString.ToDate.ToShortDateString))
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(141) Then
|
|
params.Add(New ReportParameter("Fecha", dr("Fecha").ToString.ToDate.ToString("dd/MM/yyyy hh:mm:ss")))
|
|
Else
|
|
params.Add(New ReportParameter("Fecha", dr("Fecha").ToString.ToDate.ToShortDateString))
|
|
End If
|
|
|
|
|
|
|
|
params.Add(New ReportParameter("Numero", dr("FolioPoliza").ToString))
|
|
params.Add(New ReportParameter("Moneda", ""))
|
|
params.Add(New ReportParameter("CodigoPostal", ""))
|
|
|
|
If UsuarioActual.CveEmpresa.Contiene(119, 141) Then
|
|
params.Add(New ReportParameter("UsuarioRegistro", GlobalDTUsuarios(dr("CveUsuario").ToString.ToEntero).FiltroPrimeroValor("Nombre")))
|
|
End If
|
|
If UsuarioActual.CveEmpresa.Contiene(140, 141) Then
|
|
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
|
|
End If
|
|
|
|
If Archivo.Exists Then
|
|
ruta = UsuarioActual.Empresa.Ruta & "Formatos/Polizas.rdlc"
|
|
Else
|
|
ruta = "Empresas/Grales/Formatos/Polizas.rdlc"
|
|
End If
|
|
ImprimirbytesPDF(StreamPDF(ruta, dtVC, params, "ppoliza"), String.Format("{0}-{1}", TipoPoliza, dr("FolioPoliza").ToString), "PDF", True)
|
|
|
|
End If
|
|
|
|
|
|
'Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)
|
|
ObjConta.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "Crear A Partier de"
|
|
|
|
|
|
Private Sub OcultarControlesCrearApartirDe()
|
|
|
|
BtnEliminar.Visible = False
|
|
'BtnContabilizar.Visible = False
|
|
GvPrePoliza.Columns(5).Visible = False
|
|
DivTG.Visible = False
|
|
GvMov.Columns(5).Visible = False
|
|
|
|
TxtConcepto.Enabled = True
|
|
TxtFechaDocumento.Text = Now.ToString("dd/MM/yyyy")
|
|
TxtFechaelaboracion.Text = Now.ToString("dd/MM/yyyy")
|
|
|
|
TxtUsuarioElaboro.Text = UsuarioActual.Usuario
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
Private Function ValidaCrearAPartirDe() As Boolean
|
|
|
|
Dim Respuesta As Boolean = False
|
|
|
|
If CvePlantillaPoliza > 0 Then
|
|
|
|
Dim TmpCvePlantillaPoliza As Integer = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, -1).FiltroPrimeroValor("CvePlantillaPoliza", $"CvePlantillaPoliza = {CvePlantillaPoliza}").ToEntero
|
|
|
|
If TmpCvePlantillaPoliza > 0 Then
|
|
Respuesta = True
|
|
LnkCrearAPartirDe.Visible = True
|
|
End If
|
|
|
|
End If
|
|
|
|
Return Respuesta
|
|
|
|
End Function
|
|
|
|
|
|
Private Sub CargaPrePolizaOrigen()
|
|
BtnEliminar.Visible = True
|
|
LblEncabezado.Text = "Crear a partir de"
|
|
|
|
Dim ObjContabilidad As New ClsContabilidad
|
|
If ObjContabilidad.GetPrePoliza(CvePrePolizaOrigen, UsuarioActual.CveEmpresa) Then
|
|
Dim dr As DataRow = ObjContabilidad.DtResultados.FiltroPrimero("")
|
|
If dr IsNot Nothing Then
|
|
DivAgregarConceptos.Visible = False
|
|
DdlTipoPoliza.SelectedValue = dr("CveTipoPoliza")
|
|
TxtFechaDocumento.Text = dr("Fecha")
|
|
TxtConcepto.Text = dr("Concepto")
|
|
DivDatosPoliza.Visible = True
|
|
TipoPoliza = DdlTipoPoliza.SelectedItem.Text
|
|
Folio = dr("FolioPoliza").ToString
|
|
|
|
TxtFolio.Text = ""
|
|
TxtUsuarioElaboro.Text = dr("Usuario").ToString
|
|
TxtFechaelaboracion.Text = dr("FechaIng").ToString.ToDate.ToString("dd/MM/yyyy")
|
|
' TxtEstatus.Text = If(Boolean.Parse(dr("Estatus").ToString), "Activa", "Inactiva")
|
|
CvePlantillaPoliza = dr("CvePlantillaPoliza").ToString
|
|
|
|
If UsuarioActual.CveRol = 1 OrElse UsuarioActual.TienePermisoProceso(221) Then
|
|
'DivAgregarConceptos.Visible = True
|
|
LnkAddConcepto.Visible = True
|
|
CargaConceptos()
|
|
CargaSubProyectos()
|
|
CargaCuentasContables()
|
|
End If
|
|
|
|
ObjContabilidad.GetContabilizacionDiarioDetalle(CvePrePolizaOrigen)
|
|
DtMovimientos = ObjContabilidad.DtResultados.FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa}")
|
|
|
|
|
|
If Not DtMovimientos.Columns.Contains("ContadoCuenta") Then
|
|
|
|
DtMovimientos.Columns.Add("ContadoCuenta", GetType(Integer))
|
|
DtMovimientos.Columns.Add("ContadoTipoTransaccion", GetType(Integer))
|
|
DtMovimientos.Columns.Add("ContadoNumeroFolio", GetType(String))
|
|
DtMovimientos.Columns.Add("ContadoBeneficiario", GetType(String))
|
|
DtMovimientos.Columns.Add("ContadoObservaciones", GetType(String))
|
|
DtMovimientos.Columns.Add("ContadoImporte", GetType(Decimal))
|
|
|
|
|
|
End If
|
|
|
|
|
|
If Not DtMovimientos.Columns.Contains("Cargo") Then
|
|
DtMovimientos.Columns.Add("Cargo", GetType(Decimal))
|
|
DtMovimientos.Columns.Add("Abono", GetType(Decimal))
|
|
End If
|
|
|
|
GvPrePoliza.DataSource = DtMovimientos
|
|
GvPrePoliza.DataBind()
|
|
|
|
If UsuarioActual.CveRol = 1 AndAlso DtMovimientos.COUNT("TC", "TC > 1") > 0 Then
|
|
GvPrePoliza.Columns(7).Visible = True
|
|
End If
|
|
|
|
If DtMovimientos.FiltraParametros("CveConceptoContable IN (2,17)").Rows.Count > 0 Then
|
|
LnkComplementoPago.Visible = True
|
|
End If
|
|
|
|
If UsuarioActual.Empresa.TipoContabilizacion = 1 Then
|
|
If dr("FolioPoliza").ToString.ToEntero > 0 Then
|
|
divContabilizada.Visible = True
|
|
Folio = dr("FolioPoliza").ToString
|
|
|
|
End If
|
|
Else
|
|
If dr("IdPoliza").ToString.ToEntero > 0 Then
|
|
HplContabilizada.NavigateUrl = String.Format("RegPoliza.aspx?IdPoliza={0}", dr("IdPoliza"))
|
|
divContabilizada.Visible = True
|
|
IdPoliza = dr("IdPoliza").ToString.ToEntero
|
|
ElseIf TxtTotalCargos.Text.ToDecimal = TxtTotalAbonos.Text.ToDecimal Then
|
|
'sino está contabilizada, se activa el botón
|
|
'BtnContabilizar.Visible = True
|
|
End If
|
|
End If
|
|
|
|
|
|
'divDatosPrincipales.Visible = False
|
|
'divObservaciones.Visible = False
|
|
|
|
UpPrePoliza.Update()
|
|
|
|
RegistraScript("comparar();")
|
|
|
|
If Request("Tipo") IsNot Nothing AndAlso IsNumeric(Request("Tipo")) AndAlso Request("Tipo").ToEntero = 1 AndAlso UsuarioActual.CveUsuario <> 100 Then
|
|
'For Each row As GridViewRow In GvPrePoliza.Rows
|
|
' row.FCTextBox("TxtCargo").Enabled = False
|
|
' row.FCTextBox("TxtAbono").Enabled = False
|
|
'Next
|
|
End If
|
|
LnkExcel.Visible = False
|
|
LnkImprimirPDF.Visible = True
|
|
Else
|
|
Alert("El documento solicitado no existe, favor de revisar su búsqueda.", TipoMensaje.MsgAdvertencia)
|
|
BtnEliminar.Visible = False
|
|
End If
|
|
|
|
End If
|
|
|
|
ObjContabilidad.Dispose()
|
|
UpPoliza.Update()
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkCrearAPartirDe_Click(sender As Object, e As EventArgs)
|
|
Response.Redirect($"./RegPrePolizaS.aspx?CvePrePolizaOrigen={CvePrePoliza}")
|
|
End Sub
|
|
|
|
|
|
Private Sub CrearPrePolizaApartirDe()
|
|
Dim CvePrePoliza As Integer
|
|
Dim FolioPoliza As Integer
|
|
|
|
Dim TotalCargos, TotalAbonos As Decimal
|
|
|
|
For Each Gvr As GridViewRow In GvPrePoliza.Rows
|
|
TotalCargos += Gvr.FCLiteral("TxtCargo").Text.ToDecimal
|
|
TotalAbonos += Gvr.FCLiteral("TxtAbono").Text.ToDecimal
|
|
Next
|
|
|
|
|
|
'validaciones
|
|
If Not (TotalCargos = TotalAbonos AndAlso (GvPrePoliza.Rows.Count > 0)) Then
|
|
Alert($"La suma de los movimientos no son iguales ({TotalCargos}-{TotalAbonos})", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
'terminan validaciones
|
|
|
|
If CvePrePoliza > 0 Then
|
|
ActualizarPrePoliza()
|
|
Else
|
|
Dim MensajeAlert = New StringBuilder
|
|
Dim ObjIE As New ClsBancos()
|
|
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
|
' Dim ObjNom As New ClsNominas(ObjIE.IniciaTransacSQL)
|
|
Dim Conta As ClsContPAQi = Nothing
|
|
Dim IDPoliza As Integer = 0
|
|
Dim MsgError As String = ""
|
|
Dim CveIE As Integer
|
|
Dim FolioIE As String = ""
|
|
|
|
Try
|
|
|
|
Dim ConceptoPoliza As String = TxtConcepto.Text
|
|
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Contabilidad/RegPrePolizaCrear", CvePlantillaPoliza, TotalCargos, TotalAbonos, 1, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=DdlTipoPoliza.SelectedValue.ToEntero, AgregarFolio:=True)
|
|
|
|
If CvePrePoliza > 0 Then
|
|
|
|
FolioPoliza = ObjMov.FolioPoliza
|
|
|
|
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
|
|
Dim idCuentaContabilizacion As Long = 1
|
|
Dim Importe As Decimal = 0
|
|
Dim ImporteME As Decimal = 0
|
|
Dim TipoCambio As Decimal = 1
|
|
Dim TipoMovto As Boolean = False
|
|
Dim IdCtaContable As Integer = 0
|
|
|
|
|
|
'inserto las compras que voy a pagarDdlSaldos
|
|
For Each gvr As GridViewRow In GvPrePoliza.Rows
|
|
|
|
ImporteME = 0
|
|
TipoCambio = 1
|
|
|
|
If Boolean.Parse(gvr.DataKey("TipoMovto")) Then
|
|
|
|
Importe = gvr.FCLiteral("TxtAbono").Text.ToDecimal
|
|
TipoMovto = True
|
|
|
|
If gvr.DataKey("EsComplementaria") = "True" Then
|
|
ImporteME = gvr.FCLiteral("TxtAbono").Text.ToDecimal 'me
|
|
TipoCambio = gvr.FCTextBox("TxtModalConceptoDocumentoImporte").Text.ToDecimal
|
|
End If
|
|
|
|
Else
|
|
Importe = gvr.FCLiteral("TxtCargo").Text.ToDecimal
|
|
TipoMovto = False
|
|
|
|
If gvr.DataKey("EsComplementaria") = "True" Then
|
|
ImporteME = gvr.FCTextBox("TxtCargo").Text.ToDecimal 'me
|
|
TipoCambio = gvr.FCTextBox("TxtModalConceptoDocumentoImporte").Text.ToDecimal
|
|
End If
|
|
|
|
End If
|
|
|
|
If gvr.DataKey("CveConceptoContable").ToEntero = 30 Then
|
|
|
|
Dim tFolio As String = gvr.DataKey("ContadoNumeroFolio").ToString
|
|
If tFolio.ToEntero = 0 Then tFolio = SiguienteFolioBancos(gvr.DataKey("ContadoCuenta").ToEntero, gvr.DataKey("ContadoTipoTransaccion").ToEntero)
|
|
|
|
CveIE = ObjIE.AddBancos_IE(gvr.DataKey("ContadoCuenta").ToEntero, gvr.DataKey("ContadoTipoTransaccion").ToEntero, TxtFechaDocumento.Text, tFolio,
|
|
gvr.DataKey("ContadoBeneficiario").ToString, Importe, CveMoneda, 0, gvr.DataKey("ContadoObservaciones").ToString, "",
|
|
False, False, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
FolioIE = gvr.DataKey("ContadoNumeroFolio").ToString
|
|
If CveIE < 0 Then
|
|
MsgError = "No se pudo registrar movimiento bancario"
|
|
Exit For
|
|
End If
|
|
|
|
End If
|
|
|
|
If gvr.DataKey("CveConceptoContable").ToEntero <> 30 Then
|
|
|
|
If gvr.DataKey("CveConceptoContable").ToEntero = 41 Then
|
|
CveIE = gvr.FCDropDownList("DdlSaldos").SelectedValue.ToEntero
|
|
Else
|
|
CveIE = -1
|
|
End If
|
|
|
|
End If
|
|
|
|
If idCuentaContabilizacion = 1 AndAlso (IdCtaContable = 0) Then
|
|
idCuentaContabilizacion = 0
|
|
End If
|
|
If Importe <> 0 Then
|
|
Dim tCveCuenta As Integer = gvr.DataKey("CveCuenta").ToEntero
|
|
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, gvr.DataKey("Referencia"), gvr.DataKey("CveConceptoContable").ToEntero, gvr.DataKey("Concepto"),
|
|
TxtFechaDocumento.Text.ToDate, IdCtaContable, -1, CveSubProyecto:=gvr.DataKey("CveSubProyecto").ToEntero, CveIE:=CveIE,
|
|
CveProveedor:=gvr.DataKey("CveProveedor").ToEntero, CveCompra:=gvr.DataKey("CveCompra").ToEntero,
|
|
CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero,
|
|
ImporteMX:=Importe, ImporteME:=ImporteME, TipoCambio:=TipoCambio, CveTipoGasto:=gvr.DataKey("CveTipoGasto").ToEntero,
|
|
CveCliente:=gvr.DataKey("CveCliente").ToEntero, CveVenta:=gvr.DataKey("CveVenta").ToEntero, CveCuenta:=tCveCuenta) Then
|
|
|
|
Else
|
|
MsgError = "No se pudo insertar el detalle de la póliza2"
|
|
Exit For
|
|
End If
|
|
End If
|
|
If CveIE > 0 AndAlso gvr.DataKey("CveConceptoContable").ToEntero = 30 Then
|
|
MensajeAlert.AppendFormat("<br/><br/>Folio Bancario: <b><a href = ""/Bancos/IE.aspx?CveIE={0}"" class=""texto"" target=""_blank"" >{1}</a></b>", CveIE, FolioIE)
|
|
End If
|
|
Next
|
|
|
|
If MsgError = "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 1) Then
|
|
If ObjMov.ValorPolizaDescuadre > 0 Then
|
|
GuardaLogAD($"Contabilidad/RegPrePolizas | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
|
|
MsgError = ObjMov.MensajePolizaDescuadre
|
|
End If
|
|
End If
|
|
Else
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
Catch ex As Exception
|
|
MsgError = "Error"
|
|
End Try
|
|
|
|
If MsgError = "" Then
|
|
If Not ObjMov.UpdatePrePolizasOrdenamiento(CvePrePoliza, UsuarioActual.CveEmpresa) Then
|
|
MsgError = "Orror al ordenar polzia"
|
|
End If
|
|
End If
|
|
|
|
If MsgError = "" Then
|
|
|
|
Alert(If(MensajeAlert.ToString = "", $"Se registro con exito. {If(FolioPoliza > 0, " Folio " & FolioPoliza & ".", "")}", $"Se registro con exito. {If(FolioPoliza > 0, " Folio " & FolioPoliza & ".", "")} <br>" & MensajeAlert.ToString), TipoMensaje.MsgInformacion, $"window.location.href=""./RegPrePolizaS.aspx?CvePrePoliza={CvePrePoliza}""")
|
|
|
|
ObjIE.Commit()
|
|
If Conta IsNot Nothing Then Conta.Commit()
|
|
|
|
TxtConcepto.Text = ""
|
|
GvMov.DataBind()
|
|
TxtFechaDocumento.Text = ""
|
|
|
|
Else
|
|
Alert(MsgError.ToString, ModExtensiones.TipoMensaje.MsgError)
|
|
ObjIE.RollBack()
|
|
If Conta IsNot Nothing Then Conta.RollBack()
|
|
End If
|
|
|
|
ObjIE.Dispose()
|
|
ObjMov.Dispose()
|
|
If Conta IsNot Nothing Then Conta.Dispose()
|
|
End If
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub LnkGvPrePolizaEliminar_Click(sender As Object, e As EventArgs)
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
|
|
|
If CvePrePoliza > 0 Then
|
|
Dim RowEliminar As DataRow = DtMovimientosEliminar.NewRow()
|
|
RowEliminar("CvePrePolizaDetalle") = GvRow.DataKey("CvePrePolizaDetalle")
|
|
DtMovimientosEliminar.Rows.Add(RowEliminar)
|
|
End If
|
|
|
|
DtMovimientos.Rows(GvRow.RowIndex).Delete()
|
|
DtMovimientos.AcceptChanges()
|
|
|
|
GvPrePoliza.DataSource = DtMovimientos
|
|
GvPrePoliza.DataBind()
|
|
|
|
|
|
TxtTotalCargos.Text = DtMovimientos.SUMD("Cargo").ToString.FormatoNumero
|
|
TxtTotalAbonos.Text = DtMovimientos.SUMD("Abono").ToString.FormatoNumero
|
|
UpTotalCargo.Update()
|
|
UpTotalAbono.Update()
|
|
|
|
UpPrePoliza.Update()
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaModalConceptoTipoTransaccion(Tipo As String)
|
|
|
|
DdlModalConceptoTipoTransaccion.Items.Clear()
|
|
|
|
DdlModalConceptoTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros($"Tipo = '{Tipo}' AND Estatus = 1 ")
|
|
DdlModalConceptoTipoTransaccion.SelectedIndex = -1
|
|
DdlModalConceptoTipoTransaccion.ClearSelection()
|
|
DdlModalConceptoTipoTransaccion.SelectedValue = Nothing
|
|
DdlModalConceptoTipoTransaccion.DataBind()
|
|
DdlModalConceptoTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
|
|
|
|
End Sub
|
|
Private Sub CargaModalConceptoCuentas()
|
|
DdlModalConceptoCuenta.Items.Clear()
|
|
DdlModalConceptoCuenta.ClearSelection()
|
|
DdlModalConceptoCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa) '.FiltraParametros(String.Format("CveMoneda = {0} AND CveTipoCuenta <> 1", DdlMoneda.SelectedValue))
|
|
DdlModalConceptoCuenta.SelectedValue = Nothing
|
|
DdlModalConceptoCuenta.DataBind()
|
|
DdlModalConceptoCuenta.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
Private Sub BtnDescontabilizar_Click(sender As Object, e As EventArgs) Handles BtnDescontabilizar.Click
|
|
|
|
Dim ObjConta As New ClsContabilidad
|
|
|
|
If ObjConta.ContabilizaDesContabilizaPrePoliza(CvePrePoliza, False, UsuarioActual.CveEmpresa) Then
|
|
|
|
Alert("Descontabilizado Correctamente.", TipoMensaje.MsgInformacion)
|
|
TxtFolio.Text = ""
|
|
LnkFolioManual.Visible = True
|
|
BtnDescontabilizar.Visible = False
|
|
BtnContabilizar.Visible = True
|
|
End If
|
|
|
|
ObjConta.Dispose()
|
|
|
|
UpPoliza.Update()
|
|
UpGuardar.Update()
|
|
|
|
End Sub
|
|
|
|
Private Sub LnkFolioManual_Click(sender As Object, e As EventArgs) Handles LnkFolioManual.Click
|
|
|
|
TxtFolio.Enabled = True
|
|
TxtFolio.Focus()
|
|
UpPoliza.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub DdlVentasE_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
Dim Venta As New ClsVentas
|
|
If Venta.GetVenta(DdlVentasE.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
Dim dr As DataRow = Venta.DtResultados.FiltroPrimero("")
|
|
If dr IsNot Nothing Then
|
|
TxtTipoCambio.Text = dr("TipoCambioValuacion")
|
|
End If
|
|
End If
|
|
|
|
Venta.Dispose()
|
|
End Sub
|
|
|
|
Private Sub TxtCargoE_TextChanged(sender As Object, e As EventArgs) Handles TxtCargoE.TextChanged
|
|
If TxtCargoE.Text.ToDecimal <> 0 Then CargaModalConceptoTipoTransaccion("Ing")
|
|
End Sub
|
|
|
|
Private Sub TxtAbonoE_TextChanged(sender As Object, e As EventArgs) Handles TxtAbonoE.TextChanged
|
|
If TxtAbonoE.Text.ToDecimal <> 0 Then CargaModalConceptoTipoTransaccion("Egs")
|
|
End Sub
|
|
|
|
|
|
Private Sub ImprimePrePolizasDetalleResumen(Optional Tipo As String = "PDF")
|
|
|
|
Dim Archivo As System.IO.FileInfo
|
|
Dim params As New List(Of ReportParameter)
|
|
Dim Bytes As Byte() = Nothing
|
|
|
|
Dim ImpresionPersonalizada As Integer = UsuarioActual.Empresa.Funcionalidad(282).ToEntero
|
|
Dim ConceptoPoliza As String = TxtConcepto.Text
|
|
|
|
|
|
Archivo = New System.IO.FileInfo(String.Format("{0}Formatos/PolizasResumen.rdlc", UsuarioActual.Empresa.Ruta))
|
|
Dim Logo As New System.IO.FileInfo(String.Format("{0}Logo.png", UsuarioActual.Empresa.Ruta))
|
|
|
|
|
|
Dim ObjConta As New ClsContabilidad
|
|
'If ObjPoliza.GetPoliza(IdPoliza, -1, -1, -1, -1) AndAlso ObjPoliza.DtResultados.Rows.Count > 0 Then
|
|
If ObjConta.GetPrePolizasDetalleResumen(CvePrePoliza, UsuarioActual.CveEmpresa, ImpresionPersonalizada) AndAlso ObjConta.DtResultados.Rows.Count > 0 Then
|
|
Dim dtVC As DataTable
|
|
Dim dr As DataRow
|
|
|
|
dtVC = ObjConta.DtResultados '.FiltraParametros("Contabilizable = 1", "Orden")
|
|
dr = dtVC.Rows(0)
|
|
|
|
params.Add(New ReportParameter("Empresa", UsuarioActual.Empresa.Empresa))
|
|
params.Add(New ReportParameter("TipoPoliza", DdlTipoPoliza.SelectedItem.Text))
|
|
params.Add(New ReportParameter("Finicio", TxtFechaDocumento.Text))
|
|
params.Add(New ReportParameter("FFin", TxtFechaDocumento.Text))
|
|
|
|
params.Add(New ReportParameter("Fecha", TxtFechaDocumento.Text))
|
|
|
|
params.Add(New ReportParameter("Numero", TxtFolio.Text))
|
|
params.Add(New ReportParameter("Moneda", If(CveMoneda = 2, "Dolar", "Peso Mexicano")))
|
|
params.Add(New ReportParameter("CodigoPostal", ""))
|
|
|
|
params.Add(New ReportParameter("UsuarioRegistro", TxtUsuarioElaboro.Text))
|
|
params.Add(New ReportParameter("ConceptoPoliza", ConceptoPoliza))
|
|
|
|
params.Add(New ReportParameter("Folio", TxtFolio.Text))
|
|
|
|
|
|
|
|
|
|
|
|
If Logo.Exists Then
|
|
params.Add(New ReportParameter("pImg", $"file://{Logo.FullName}"))
|
|
Else
|
|
params.Add(New ReportParameter("pImg", ""))
|
|
End If
|
|
|
|
|
|
|
|
|
|
Dim RutaReprote As String
|
|
If Archivo.Exists Then
|
|
RutaReprote = Archivo.FullName
|
|
Else
|
|
RutaReprote = $"{DirectorioEmpresas}Grales\Formatos\PolizasResumen.rdlc"
|
|
End If
|
|
|
|
Dim TipoPolizaString = ""
|
|
|
|
Select Case DdlTipoPoliza.SelectedValue.ToEntero
|
|
Case 1
|
|
TipoPolizaString = "I"
|
|
Exit Select
|
|
Case 2
|
|
TipoPolizaString = "E"
|
|
Exit Select
|
|
|
|
Case Else
|
|
TipoPolizaString = "D"
|
|
Exit Select
|
|
|
|
End Select
|
|
|
|
|
|
ImprimirbytesPDF(StreamPDF(RutaReprote, dtVC, params, "PrePoliza", Formato:=Tipo), $"P{TipoPolizaString}{TxtFolio.Text}", Formato:=Tipo, Descarga:=True)
|
|
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
Protected Sub LnkImprimePDFResumen_Click(sender As Object, e As EventArgs)
|
|
ImprimePrePolizasDetalleResumen("PDF")
|
|
End Sub
|
|
|
|
'Protected Sub LnkImprimeExcelResumen_Click(sender As Object, e As EventArgs)
|
|
' ImprimePrePolizasDetalleResumen("Excel")
|
|
'End Sub
|
|
|
|
|
|
|
|
End Class
|
|
|