579 lines
24 KiB
VB.net
579 lines
24 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Data.SqlClient
|
|
Imports Extensiones
|
|
Partial Class Bancos_ProductosFinancieros
|
|
Inherits ClsPaginas
|
|
|
|
|
|
#Region " PROPIEDADES "
|
|
Private Property DtPresupuestosEgresos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtPresupuestosEgresos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPresupuestosEgresos") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtPresupuestosIngresos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtPresupuestosIngresos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPresupuestosIngresos") = value
|
|
End Set
|
|
End Property
|
|
Private Property CvePresupuestoEgresos As Integer
|
|
Get
|
|
Return ViewState("CvePresupuestoEgresos").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePresupuestoEgresos") = value
|
|
End Set
|
|
End Property
|
|
Private Property CvePresupuestoIngresos As Integer
|
|
Get
|
|
Return ViewState("CvePresupuestoIngresos").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePresupuestoIngresos") = value
|
|
End Set
|
|
End Property
|
|
Private Property Opcion As String
|
|
Get
|
|
Return ViewState("Opcion").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Opcion") = value
|
|
End Set
|
|
End Property
|
|
|
|
#Region "PROPIEDADES - AC NEW"
|
|
Private Property DtPresupuestos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtPresupuestos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtPresupuestos") = value
|
|
End Set
|
|
End Property
|
|
Private Property EjercicioAC As Integer
|
|
Get
|
|
Return ViewState("EjercicioAC").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("EjercicioAC") = value
|
|
End Set
|
|
End Property
|
|
Private Property IDCtaBeneficiario As Integer
|
|
Get
|
|
Return ViewState("IDCtaBeneficiario").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IDCtaBeneficiario") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
#End Region
|
|
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
Opcion = "-1"
|
|
|
|
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString <> "" Then
|
|
Opcion = Request("Opcion").ToString
|
|
If Opcion = "OE" Then
|
|
LtTitulo.Text = "Otros Egresos Presupuestales"
|
|
End If
|
|
End If
|
|
|
|
ActivaAC()
|
|
CargaDatos()
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub DdlTipoMovimiento_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
TrPI.Visible = False
|
|
TrPE.Visible = False
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
If DdlTipoMovimiento.SelectedValue = "15" Or DdlTipoMovimiento.SelectedValue = "17" Then
|
|
TrPE.Visible = True
|
|
ElseIf DdlTipoMovimiento.SelectedValue = "16" Then
|
|
TrPI.Visible = True
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " CARGA DATOS "
|
|
Private Sub CargaDatos()
|
|
CargaCuentas()
|
|
CargaTipoMovimientos()
|
|
CargaTipoTrasaccion()
|
|
End Sub
|
|
Private Sub CargaCuentas()
|
|
DdlCuentas.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
DdlCuentas.DataBind()
|
|
DdlCuentas.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaTipoMovimientos()
|
|
If Opcion = "OE" Then
|
|
DdlTipoMovimiento.Items.Insert(0, New ListItem("Pago Seguridad Social", "19"))
|
|
DdlTipoMovimiento.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
Else
|
|
DdlTipoMovimiento.DataSource = GlobalDTContaPlantillasPolizas(1, -1).FiltraParametros("CvePlantillaPoliza IN (15,16,17,50)")
|
|
DdlTipoMovimiento.DataBind()
|
|
DdlTipoMovimiento.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaTipoTrasaccion()
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones() '.FiltraParametros("Tipo='Egs'")
|
|
DdlTipoTransaccion.DataBind()
|
|
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " AC "
|
|
Private Sub ActivaAC()
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
HdnEjercicioAC.Value = UsuarioActual.Empresa.EjercicioActual.ToString
|
|
CargaPresupuestoEgresos(UsuarioActual.Empresa.EjercicioActual)
|
|
CargaPresupuestoIngresos()
|
|
LtEjercioTitulo.Visible = True
|
|
LtEjercicio.Text = UsuarioActual.Empresa.EjercicioActual.ToString
|
|
TxtFecha.Attributes.Add("onchange", "CambiaFecha();")
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnCambiaFecha_Click(sender As Object, e As EventArgs)
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
Dim AC As New ClsAC
|
|
If AC.GetPresupuestoEgresos(-1, True, HdnEjercicioAC.Value.ToEntero, UsuarioActual.CveEmpresa) Then
|
|
DtPresupuestosEgresos = AC.DtResultados.Copy
|
|
Else
|
|
Alert("Ocurrio un error al cargar los Presupuestos de Egresos. Por favor vuelva a cargar la página.", TipoMensaje.MsgError)
|
|
End If
|
|
AC.Dispose()
|
|
|
|
If DtPresupuestosEgresos.Rows.Count > 0 Then
|
|
DdlACGeneral1.DataSource = DtPresupuestosEgresos.FiltraParametros("", DistinctColumns:={"CveProgramaOperativo", "ProgramaOperativo"})
|
|
DdlACGeneral1.DataBind()
|
|
|
|
CalculaSaldoAC()
|
|
End If
|
|
End If
|
|
|
|
LtEjercicio.Text = HdnEjercicioAC.Value
|
|
End Sub
|
|
|
|
#Region " PRESUPUESTO EGRESOS "
|
|
Private Sub CargaPresupuestoEgresos(EjercicioActual As Integer)
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
Dim AC As New ClsAC
|
|
If AC.GetPresupuestoEgresos(-1, True, EjercicioActual, UsuarioActual.CveEmpresa) Then
|
|
DtPresupuestosEgresos = AC.DtResultados.Copy
|
|
Else
|
|
Alert("Ocurrio un error al cargar los Presupuestos de Egresos. Por favor vuelva a cargar la página.", TipoMensaje.MsgError)
|
|
End If
|
|
AC.Dispose()
|
|
|
|
If DtPresupuestosEgresos.Rows.Count > 0 Then
|
|
CargaDdlsAC()
|
|
CalculaSaldoAC()
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaDdlsAC()
|
|
'Panel General
|
|
DdlACGeneral1.DataSource = DtPresupuestosEgresos.FiltraParametros("", DistinctColumns:={"CveProgramaOperativo", "ProgramaOperativo"})
|
|
DdlACGeneral1.DataBind()
|
|
DdlACGeneral2.DataSource = DtPresupuestosEgresos.FiltraParametros("", DistinctColumns:={"CveUnidadAdministrativa", "UnidadAdministrativa"}, Orderby:="UnidadAdministrativa")
|
|
DdlACGeneral2.DataBind()
|
|
DdlACGeneral3.DataSource = DtPresupuestosEgresos.FiltraParametros("", DistinctColumns:={"CveFuenteFinanciamiento", "FuenteFinanciamiento"}, Orderby:="FuenteFinanciamiento")
|
|
DdlACGeneral3.DataBind()
|
|
DdlACGeneral4.DataSource = DtPresupuestosEgresos.FiltraParametros("", DistinctColumns:={"CveTipoGasto", "TipoGasto"})
|
|
DdlACGeneral4.DataBind()
|
|
DdlACGeneral5.DataSource = DtPresupuestosEgresos.FiltraParametros("NOT CodigoCOG like '1%'", DistinctColumns:={"CveClasificacion", "CodigoClasificacion"}, Orderby:="CodigoClasificacion")
|
|
DdlACGeneral5.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub DdlACGeneral_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
CalculaSaldoAC()
|
|
End Sub
|
|
|
|
Private Sub CalculaSaldoAC()
|
|
Dim ContPaq As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim DtPresupuestosTemp = DtPresupuestosEgresos.FiltraParametros(String.Format("CveProgramaOperativo = {0} and CveUnidadAdministrativa = {1} and CveFuenteFinanciamiento = {2} and CveTipoGasto= {3} and CveClasificacion = {4}", DdlACGeneral1.SelectedValue.ToString, DdlACGeneral2.SelectedValue.ToString, DdlACGeneral3.SelectedValue.ToString, DdlACGeneral4.SelectedValue.ToString, DdlACGeneral5.SelectedValue.ToString))
|
|
If DtPresupuestosTemp.Rows.Count > 0 Then
|
|
|
|
Dim IdCuenta = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero
|
|
|
|
LbACGeneralSaldo.Text = ContPaq.GetSaldoCuenta(IdCuenta, 0, TxtFecha.Text.ToDate.Year).ToString.FormatoNumero
|
|
|
|
CvePresupuestoEgresos = DtPresupuestosTemp.Rows(0)("CvePresupuestoEgreso").ToString.ToEntero
|
|
Else
|
|
LbACGeneralSaldo.Text = "0.00"
|
|
End If
|
|
ContPaq.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " PRESUPUESTO INGRESOS "
|
|
Private Sub CargaPresupuestoIngresos()
|
|
Dim AC As New ClsAC
|
|
If AC.GetPresupuestoIngresos(-1, -1, True, UsuarioActual.CveEmpresa) Then
|
|
DdlFuenteRecaudacion.DataSource = AC.DtResultados()
|
|
DtPresupuestosIngresos = AC.DtResultados()
|
|
End If
|
|
AC.Dispose()
|
|
|
|
DdlFuenteRecaudacion.DataBind()
|
|
End Sub
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CALCULA FOLIO "
|
|
Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
ObtieneFolio()
|
|
End Sub
|
|
Protected Sub DdlCuentas_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
ObtieneFolio()
|
|
End Sub
|
|
Private Sub ObtieneFolio()
|
|
Dim Banco As New ClsBancos
|
|
Dim Folio = Banco.GetNextFolio(DdlCuentas.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
Banco.Dispose()
|
|
TxtFolio.Text = Folio.ToString
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " GUARDAR "
|
|
|
|
Protected Sub BtnGuardar(sender As Object, e As System.EventArgs)
|
|
'Alert("EN PROCESO...", TipoMensaje.MsgAdvertencia)
|
|
'Exit Sub
|
|
|
|
If TrPE.Visible = True AndAlso Not LbACGeneralSaldo.Text.ToDouble > 0 Then
|
|
Alert("El Presupuesto de Egresos Seleccionado debe tener saldo. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
Exit Sub
|
|
End If
|
|
|
|
'Objetos Clase
|
|
Dim ObjBancos As New ClsBancos
|
|
Dim ObjMov As New ClsContabilidad(ObjBancos.IniciaTransacSQL)
|
|
|
|
|
|
Dim ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjContaAC.IniciaTransacSQL()
|
|
|
|
'Variables de controles
|
|
Dim Importe As Double = TxtImporte.Text.ToDouble
|
|
Dim CveMoneda As Integer = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta = {0}", DdlCuentas.SelectedValue))("CveMoneda").ToString.ToEntero()
|
|
Dim Fecha = TxtFecha.Text.ToDate
|
|
|
|
'Variables de error
|
|
Dim ErrorTransaccion = False
|
|
Dim ErrorAC = False
|
|
|
|
Dim CvePrePoliza = -1
|
|
Dim IdPoliza = -1
|
|
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Banc", DdlTipoMovimiento.SelectedValue.ToEntero, Importe, Importe, CveMoneda, TxtFecha.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
Dim CveIE As Integer = ObjBancos.AddBancos_IE(DdlCuentas.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFecha.Text.ToDate, TxtFolio.Text, "", Importe, CveMoneda, 0, TxtObservacion.Text.Trim, "", False, False, 0, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
'Dim TipoMovto As Boolean
|
|
|
|
'If DdlTipoMovimiento.SelectedValue = "15" Or DdlTipoMovimiento.SelectedValue = "17" Or DdlTipoMovimiento.SelectedValue = "50" Then
|
|
' TipoMovto = True
|
|
'ElseIf DdlTipoMovimiento.SelectedValue = "16" Then
|
|
' TipoMovto = False
|
|
'End If
|
|
|
|
'OBTIENE LA CUENTA CONTABLE DEL BANCO
|
|
Dim DtCuentas = GlobalDTBancosCuentas(-1, DdlCuentas.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "", {"CveCuenta", "IdCtaContable"})
|
|
Dim CtaCuenta = -1
|
|
|
|
If DtCuentas.Rows.Count = 1 Then
|
|
CtaCuenta = DtCuentas.Rows(0)("IdCtaContable").ToString.ToEntero
|
|
Else
|
|
ErrorTransaccion = True
|
|
End If
|
|
|
|
If CveIE > 0 Then
|
|
|
|
'MOVIMIENTOS PREPOLIZA
|
|
'If ObjMov.AddPrePolizasDetalle(CvePrePoliza, Not TipoMovto, Importe, "", DdlTipoMovimiento.SelectedValue.ToEntero, TxtConcepto.Text.Trim, NowADS(), 0, -1, CveIE) Then
|
|
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, "", 30, TxtConcepto.Text.Trim, NowADS(), 0, -1, CveIE) Then
|
|
' ErrorTransaccion = True
|
|
' End If
|
|
'Else
|
|
' ErrorTransaccion = True
|
|
'End If
|
|
|
|
Dim CvePlantilaPoliza = DdlTipoMovimiento.SelectedValue.ToString.ToEntero
|
|
Dim idCuentaContabilizacion As Long = 1
|
|
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
|
|
Dim CuentasContablesInvalidas As New StringBuilder
|
|
|
|
If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantilaPoliza) Then
|
|
For Each Row As DataRow In ObjMov.DtResultados.Rows
|
|
|
|
Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero
|
|
Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False)
|
|
Dim importeMovimiento As Decimal
|
|
|
|
Select Case ConceptoContable
|
|
Case 45, 46, 47, 67
|
|
importeMovimiento = Importe.ToString.ToDecimal
|
|
|
|
Case 30
|
|
importeMovimiento = Importe.ToString.ToDecimal
|
|
|
|
End Select
|
|
|
|
If importeMovimiento <> 0 Then
|
|
|
|
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TxtImporte.Text.ToDouble, TxtImporte.Text.ToDouble, ConceptoContable, "", TxtConcepto.Text, CveIE:=CveIE) Then
|
|
ErrorTransaccion = True
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
'Por el momento no hay movimiento para estas plantillas y no debe entrar aqui
|
|
If UsuarioActual.Empresa.Funcionalidad(200).ToEntero > 0 And Not ErrorTransaccion Then
|
|
If idCuentaContabilizacion > 0 Then
|
|
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, 0) Then
|
|
Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico")
|
|
End If
|
|
Else
|
|
Alert(String.Format("No se puede contabilizar la Prepoliza debido a que las siguientes cuentas son invalidas: {0}", CuentasContablesInvalidas))
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
Else
|
|
ErrorTransaccion = True
|
|
End If
|
|
|
|
|
|
''SI USA AC
|
|
If Not ErrorTransaccion AndAlso UsuarioActual.Empresa.UsaAC Then
|
|
|
|
If DdlTipoMovimiento.SelectedValue = "15" Or DdlTipoMovimiento.SelectedValue = "17" Or DdlTipoMovimiento.SelectedValue = "50" Then
|
|
'PRESUPUESTO EGRESOS
|
|
IdPoliza = ObjContaAC.AddPoliza(3, TxtConcepto.Text.Trim, Importe, Importe, UsuarioActual.CveUsuario, TxtFecha.Text.ToDate)
|
|
|
|
If IdPoliza > 0 Then
|
|
Dim DtPresupuestosTemp As DataTable
|
|
Dim IdCuentaComprometido, IdCuentaPorEjercer, IdCuentaDevengado, IdCuentaMatriz, IdCuentaEjercido, IdCuentaPagado As Integer
|
|
|
|
DtPresupuestosTemp = DtPresupuestosEgresos.FiltraParametros(String.Format("CvePresupuestoEgreso = {0}", CvePresupuestoEgresos))
|
|
If DtPresupuestosTemp.Rows.Count <> 1 Then
|
|
ErrorAC = True
|
|
End If
|
|
|
|
If Not ErrorAC Then
|
|
IdCuentaComprometido = DtPresupuestosTemp.Rows(0)("IdCuentaComprometido").ToString.ToEntero
|
|
IdCuentaPorEjercer = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjercer").ToString.ToEntero
|
|
IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero
|
|
IdCuentaEjercido = DtPresupuestosTemp.Rows(0)("IdCuentaEjercido").ToString.ToEntero
|
|
IdCuentaPagado = DtPresupuestosTemp.Rows(0)("IdCuentaPagado").ToString.ToEntero
|
|
IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero
|
|
|
|
|
|
'COMPROMETIDO
|
|
If Not ErrorAC Then
|
|
If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, False, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjercer, True, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
'DEVENGADO
|
|
If Not ErrorAC Then
|
|
If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaComprometido, True, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
'EJERCIDO
|
|
If Not ErrorAC Then
|
|
If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaEjercido, False, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, True, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
'PAGADO
|
|
If Not ErrorAC Then
|
|
If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPagado, False, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaEjercido, True, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
'MATRIZ EGRESOS
|
|
If Not ErrorAC Then
|
|
If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaMatriz, False, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
If Not ObjContaAC.AddMovimiento(IdPoliza, CtaCuenta, True, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
'TERMINA PRESUPUESTO EGRESOS
|
|
End If
|
|
|
|
|
|
If DdlTipoMovimiento.SelectedValue = "16" Then
|
|
'PRESUPUESTO INGRESOS
|
|
IdPoliza = ObjContaAC.AddPoliza(1, TxtConcepto.Text.Trim, Importe, Importe, UsuarioActual.CveUsuario, Fecha)
|
|
|
|
If IdPoliza > 0 Then
|
|
Dim DtPresupuestosTemp As DataTable
|
|
Dim IdCuentaPorEjecutar, IdCuentaDevengado, IdCuentaRecaudado, IdCuentaMatriz As Integer
|
|
|
|
DtPresupuestosTemp = DtPresupuestosIngresos.FiltraParametros(String.Format("CvePresupuestoIngreso = {0}", DdlFuenteRecaudacion.SelectedValue.ToEntero))
|
|
If DtPresupuestosTemp.Rows.Count <> 1 Then
|
|
ErrorAC = True
|
|
End If
|
|
|
|
|
|
If Not ErrorAC Then
|
|
IdCuentaPorEjecutar = DtPresupuestosTemp.Rows(0)("IdCuentaPorEjecutar").ToString.ToEntero
|
|
IdCuentaDevengado = DtPresupuestosTemp.Rows(0)("IdCuentaDevengado").ToString.ToEntero
|
|
IdCuentaRecaudado = DtPresupuestosTemp.Rows(0)("IdCuentaRecaudado").ToString.ToEntero
|
|
IdCuentaMatriz = DtPresupuestosTemp.Rows(0)("IdCuentaMatriz").ToString.ToEntero
|
|
|
|
'DEVENGADO
|
|
If Not ErrorAC Then
|
|
If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaPorEjecutar, False, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, True, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
'RECAUDADO
|
|
If Not ErrorAC Then
|
|
If ObjContaAC.AddMovimiento(IdPoliza, IdCuentaDevengado, False, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaRecaudado, True, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
'MATRIZ INGRESOS
|
|
If Not ErrorAC Then
|
|
If ObjContaAC.AddMovimiento(IdPoliza, CtaCuenta, False, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
If Not ObjContaAC.AddMovimiento(IdPoliza, IdCuentaMatriz, True, Importe, "", TxtConcepto.Text.Trim, 0, Fecha, "") Then
|
|
ErrorAC = True
|
|
End If
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Else
|
|
ErrorAC = True
|
|
End If
|
|
'TERMINA PRESUPUESTO INGRESOS
|
|
|
|
End If
|
|
|
|
'AJUSTA POLIZA
|
|
If Not ErrorAC Then
|
|
If Not ObjContaAC.AjustaPoliza(IdPoliza) Then
|
|
ErrorAC = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If ErrorTransaccion Or ErrorAC Then
|
|
ObjBancos.RollBack()
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
|
|
|
Alert(If(ErrorTransaccion, "Ocurrió un error al ingresar la PrePoliza. Por favor vuelva a intentar.", "Ocurrió un error al ingresar la Poliza. Por favor vuelva a intentar."), TipoMensaje.MsgError)
|
|
Else
|
|
ObjBancos.Commit()
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
|
|
LimpiaDatos()
|
|
UPRegistroIE.Update()
|
|
|
|
Dim TextoPoliza = If(UsuarioActual.Empresa.UsaAC, String.Format("<br/> <br/> <a Class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IdPoliza), "")
|
|
|
|
Alert(String.Format("Movimientos realizados con exito {0}", TextoPoliza), TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjBancos.Dispose()
|
|
ObjMov.Dispose()
|
|
If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose()
|
|
End Sub
|
|
|
|
Private Sub LimpiaDatos()
|
|
DdlCuentas.SelectedValue = "-1"
|
|
DdlTipoTransaccion.SelectedValue = "-1"
|
|
TxtFolio.Text = ""
|
|
TxtImporte.Text = ""
|
|
TxtFecha.Text = ""
|
|
DdlTipoMovimiento.SelectedValue = "-1"
|
|
TrPE.Visible = False
|
|
TrPI.Visible = False
|
|
TxtConcepto.Text = ""
|
|
TxtObservacion.Text = ""
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
End Class |