656 lines
30 KiB
VB.net
656 lines
30 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.Activities.Statements
|
|
Partial Class AC_RegNomina
|
|
Inherits ClsPaginas
|
|
|
|
#Region "PROPIEDADES"
|
|
Private Property DtDetalle As DataTable
|
|
Get
|
|
DtDetalle = DirectCast(ViewState("DtDetalle"), DataTable)
|
|
End Get
|
|
|
|
Set(ByVal value As DataTable)
|
|
ViewState("DtDetalle") = value
|
|
End Set
|
|
End Property
|
|
Private Property DtPresupuestos As DataTable
|
|
Get
|
|
DtPresupuestos = DirectCast(ViewState("DtPresupuestos"), DataTable)
|
|
End Get
|
|
|
|
Set(ByVal value As DataTable)
|
|
ViewState("DtPresupuestos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property Opc As String
|
|
Get
|
|
Opc = ViewState("Opc").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Opc") = 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
|
|
'Opc = IfNull(Request("Opc"), "Otro").ToString
|
|
Opc = "Nom"
|
|
|
|
'If Opc = "Nom" Then
|
|
' LbTitulo.Text = "Nómina"
|
|
'Else
|
|
' LbTitulo.Text = "Comprometido Otros"
|
|
'End If
|
|
TxtFecha.Text = Now.ToShortDateString
|
|
|
|
CargaPresupuestos()
|
|
CargaMeta()
|
|
CargaCombosIE()
|
|
TxtImporte.Enabled = False
|
|
CreaDTDetalles()
|
|
BtnAgregar.Enabled = False
|
|
|
|
LtEjercicio.Text = UsuarioActual.Empresa.EjercicioActual.ToString
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CreaDTDetalles()
|
|
DtDetalle = New DataTable
|
|
DtDetalle.Columns.Add("Meta", GetType(String))
|
|
DtDetalle.Columns.Add("UnidadAdministrativa", GetType(String))
|
|
DtDetalle.Columns.Add("FuenteFinanciamiento", GetType(String))
|
|
DtDetalle.Columns.Add("ClasificadorOG", GetType(String))
|
|
DtDetalle.Columns.Add("CodigoClasificacion", GetType(String))
|
|
DtDetalle.Columns.Add("TipoGasto", GetType(String))
|
|
DtDetalle.Columns.Add("Disponible", GetType(Double))
|
|
DtDetalle.Columns.Add("Importe", GetType(Double))
|
|
|
|
DtDetalle.Columns.Add("CvePresupuestoEgreso", GetType(Integer))
|
|
DtDetalle.Columns.Add("IdCuentaPorEjercer", GetType(Integer))
|
|
DtDetalle.Columns.Add("IdCuentaComprometido", GetType(Integer))
|
|
DtDetalle.Columns.Add("IdCuentaDevengado", GetType(Integer))
|
|
DtDetalle.Columns.Add("IdCuentaEjercido", GetType(Integer))
|
|
DtDetalle.Columns.Add("IdCuentaPagado", GetType(Integer))
|
|
|
|
End Sub
|
|
Protected Sub CargaDatosDetalles()
|
|
GvD.DataSource = DtDetalle
|
|
GvD.DataBind()
|
|
UPPDetalle.Update()
|
|
End Sub
|
|
|
|
Private Sub CargaPresupuestos()
|
|
Dim AC As New ClsAC
|
|
|
|
If AC.GetPresupuestoEgresos(-1, True, UsuarioActual.Empresa.EjercicioActual, UsuarioActual.CveEmpresa) Then
|
|
DtPresupuestos = AC.DtResultados.Copy
|
|
Else
|
|
Alert("Ocurrio un error al cargar los Presupuestos. Por favor vuelva a cargar la página", TipoMensaje.MsgError)
|
|
End If
|
|
AC.Dispose()
|
|
|
|
If Opc = "Nom" Then
|
|
DtPresupuestos = DtPresupuestos.FiltraParametros("CodigoCOG like '1%'")
|
|
Else
|
|
DtPresupuestos = DtPresupuestos.FiltraParametros("NOT CodigoCOG like '1%'")
|
|
End If
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
#Region "CARGA COMBOS EN CASCADA"
|
|
Private Sub CargaMeta()
|
|
CboMeta.DataSource = DtPresupuestos.FiltraParametros("", DistinctColumns:={"CveProgramaOperativo", "ProgramaOperativo"})
|
|
CboMeta.DataBind()
|
|
CboMeta.Items.Insert(0, New ListItem("Seleccionar", "-1"))
|
|
End Sub
|
|
Protected Sub CargaUnidadAdministrativa(sender As Object, e As EventArgs)
|
|
CboUnidadAdministrativa.Items.Clear()
|
|
CboFuenteFinanciamiento.Items.Clear()
|
|
CboClasificacionOG.Items.Clear()
|
|
CboTipoGasto.Items.Clear()
|
|
LtDisponible.Text = "$"
|
|
TxtImporte.Enabled = False
|
|
If CboMeta.SelectedValue.ToEntero > 0 Then
|
|
Dim Filtro As New StringBuilder
|
|
Filtro.AppendFormat("CveProgramaOperativo= {0}", CboMeta.SelectedValue.ToString)
|
|
|
|
CboUnidadAdministrativa.DataSource = (DtPresupuestos.FiltraParametros(Filtro.ToString)).FiltraParametros("", DistinctColumns:={"CveUnidadAdministrativa", "UnidadAdministrativa"})
|
|
CboUnidadAdministrativa.DataBind()
|
|
CboUnidadAdministrativa.Items.Insert(0, New ListItem("Seleccionar", "-1"))
|
|
End If
|
|
End Sub
|
|
Protected Sub CargaFuenteFinanciamiento(sender As Object, e As EventArgs)
|
|
CboFuenteFinanciamiento.Items.Clear()
|
|
CboClasificacionOG.Items.Clear()
|
|
CboTipoGasto.Items.Clear()
|
|
LtDisponible.Text = "$"
|
|
TxtImporte.Enabled = False
|
|
If CboUnidadAdministrativa.SelectedValue.ToEntero > 0 Then
|
|
Dim Filtro As New StringBuilder
|
|
Filtro.AppendFormat("CveProgramaOperativo= {0} and CveUnidadAdministrativa= {1}", CboMeta.SelectedValue.ToString, CboUnidadAdministrativa.SelectedValue.ToString)
|
|
|
|
CboFuenteFinanciamiento.DataSource = (DtPresupuestos.FiltraParametros(Filtro.ToString)).FiltraParametros("", DistinctColumns:={"CveFuenteFinanciamiento", "FuenteFinanciamiento"})
|
|
CboFuenteFinanciamiento.DataBind()
|
|
CboFuenteFinanciamiento.Items.Insert(0, New ListItem("Seleccionar", "-1"))
|
|
End If
|
|
End Sub
|
|
Protected Sub CargaClasificacionOG(sender As Object, e As EventArgs)
|
|
CboClasificacionOG.Items.Clear()
|
|
CboTipoGasto.Items.Clear()
|
|
LtDisponible.Text = "$"
|
|
TxtImporte.Enabled = False
|
|
If CboFuenteFinanciamiento.SelectedValue.ToEntero > 0 Then
|
|
Dim Filtro As New StringBuilder
|
|
Filtro.AppendFormat("CveProgramaOperativo= {0} and CveUnidadAdministrativa= {1} and CveFuenteFinanciamiento= {2}", CboMeta.SelectedValue.ToString, CboUnidadAdministrativa.SelectedValue.ToString, CboFuenteFinanciamiento.SelectedValue.ToString)
|
|
|
|
CboClasificacionOG.DataSource = (DtPresupuestos.FiltraParametros(Filtro.ToString)).FiltraParametros("", "CodigoClasificacion", {"CveClasificacion", "CodigoClasificacion"})
|
|
CboClasificacionOG.DataBind()
|
|
CboClasificacionOG.Items.Insert(0, New ListItem("Seleccionar", "-1"))
|
|
End If
|
|
End Sub
|
|
Protected Sub CargaTipoGasto(sender As Object, e As EventArgs)
|
|
CboTipoGasto.Items.Clear()
|
|
LtDisponible.Text = "$"
|
|
TxtImporte.Enabled = False
|
|
If CboClasificacionOG.SelectedValue.ToEntero > 0 Then
|
|
Dim Filtro As New StringBuilder
|
|
Filtro.AppendFormat("CveProgramaOperativo= {0} and CveUnidadAdministrativa= {1} and CveFuenteFinanciamiento= {2} and CveClasificacion= {3}", CboMeta.SelectedValue.ToString, CboUnidadAdministrativa.SelectedValue.ToString, CboFuenteFinanciamiento.SelectedValue.ToString, CboClasificacionOG.SelectedValue.ToString)
|
|
|
|
CboTipoGasto.DataSource = (DtPresupuestos.FiltraParametros(Filtro.ToString)).FiltraParametros("", DistinctColumns:={"CveTipoGasto", "TipoGasto"})
|
|
CboTipoGasto.DataBind()
|
|
CboTipoGasto.Items.Insert(0, New ListItem("Seleccionar", "-1"))
|
|
End If
|
|
End Sub
|
|
Protected Sub CargaDisponible(sender As Object, e As EventArgs)
|
|
CargaDisponible()
|
|
End Sub
|
|
|
|
Protected Sub CargaDisponible()
|
|
Dim ContPaq As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim Filtro As New StringBuilder
|
|
Dim disponible As Double
|
|
Dim ColumnaSaldo As String = "IdCuentaComprometido"
|
|
Filtro.AppendFormat("CveProgramaOperativo= {0} and CveUnidadAdministrativa= {1} and CveFuenteFinanciamiento= {2} and CveClasificacion= {3} and CveTipoGasto= {4}", CboMeta.SelectedValue.ToString, CboUnidadAdministrativa.SelectedValue.ToString, CboFuenteFinanciamiento.SelectedValue.ToString, CboClasificacionOG.SelectedValue.ToString, CboTipoGasto.SelectedValue.ToString)
|
|
|
|
'cuando se esta pagando al personal, toma el saldo del devengado, proque ya esta comprometido
|
|
If RBLPago.SelectedValue = "4" Then ColumnaSaldo = "IdCuentaDevengado"
|
|
|
|
|
|
For Each dr As DataRow In DtPresupuestos.FiltraParametros(Filtro.ToString).Rows
|
|
disponible = ContPaq.GetSaldoCuenta(dr(ColumnaSaldo).ToString.ToEntero, 0, TxtFecha.Text.ToDate.Year)
|
|
HdnCuentaPorEjercer.Value = dr("IdCuentaPorEjercer").ToString
|
|
HdnCuentaComprometido.Value = dr("IdCuentaComprometido").ToString
|
|
HdnCuentaDevengado.Value = dr("IdCuentaDevengado").ToString
|
|
HdnCuentaEjercido.Value = dr("IdCuentaEjercido").ToString
|
|
HdnCuentaPagado.Value = dr("IdCuentaPagado").ToString
|
|
HdnCvePresupuestoEgreso.Value = dr("CvePresupuestoEgreso").ToString
|
|
Next
|
|
|
|
Filtro.Clear()
|
|
Filtro.AppendFormat("IdCuentaComprometido= {0}", HdnCuentaPorEjercer.Value)
|
|
For Each dr As DataRow In DtDetalle.FiltraParametros(Filtro.ToString).Rows
|
|
disponible -= dr("Importe").ToString.ToDouble
|
|
Next
|
|
|
|
If disponible <> 0 Then
|
|
TxtImporte.Enabled = True
|
|
BtnAgregar.Enabled = True
|
|
End If
|
|
LtDisponible.Text = disponible.FormatoNumero()
|
|
ContPaq.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
Protected Sub BtnAgregar_click(sender As Object, e As EventArgs)
|
|
If DtDetalle IsNot Nothing Then
|
|
If LtDisponible.Text.ToDouble >= TxtImporte.Text.ToDouble Then
|
|
Dim dr As DataRow = DtDetalle.NewRow
|
|
dr("Meta") = CboMeta.SelectedItem.ToString
|
|
dr("UnidadAdministrativa") = CboUnidadAdministrativa.SelectedItem.ToString
|
|
dr("FuenteFinanciamiento") = CboFuenteFinanciamiento.SelectedItem.ToString
|
|
dr("ClasificadorOG") = CboClasificacionOG.SelectedItem.ToString
|
|
dr("TipoGasto") = CboTipoGasto.SelectedItem.ToString
|
|
dr("Disponible") = LtDisponible.Text.ToDouble
|
|
dr("Importe") = TxtImporte.Text.ToDouble
|
|
dr("IdCuentaPorEjercer") = HdnCuentaPorEjercer.Value
|
|
dr("IdCuentaComprometido") = HdnCuentaComprometido.Value
|
|
dr("IdCuentaDevengado") = HdnCuentaDevengado.Value
|
|
dr("IdCuentaEjercido") = HdnCuentaEjercido.Value
|
|
dr("IdCuentaPagado") = HdnCuentaPagado.Value
|
|
dr("CvePresupuestoEgreso") = HdnCvePresupuestoEgreso.Value
|
|
|
|
DtDetalle.Rows.Add(dr)
|
|
CargaDatosDetalles()
|
|
Dim total As Double = LbTotal.Text.ToDouble
|
|
LbTotal.Text = (total + dr("Importe").ToString.ToDouble).ToString.FormatoNumero
|
|
|
|
If RBLPago.selectedvalue = "1" Then
|
|
txttotal.text = LbTotal.Text.todecimal.FormatoNumero
|
|
End If
|
|
|
|
CboMeta.SelectedIndex = -1
|
|
CboUnidadAdministrativa.Items.Clear()
|
|
CboFuenteFinanciamiento.Items.Clear()
|
|
CboClasificacionOG.Items.Clear()
|
|
CboTipoGasto.Items.Clear()
|
|
LtDisponible.Text = "$"
|
|
TxtImporte.Text = ""
|
|
TxtImporte.Enabled = False
|
|
BtnAgregar.Enabled = False
|
|
|
|
|
|
Else
|
|
Alert("El importe supera el capital disponible. Por favor de revisar y modificar", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Protected Sub GvD_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvD.RowDeleting
|
|
Dim Filtro As New StringBuilder
|
|
Filtro.AppendFormat("IdCuentaPorEjercer= {0} and Importe= {1}", GvD.Rows(e.RowIndex).DataKey("IdCuentaPorEjercer").ToString.ToEntero, GvD.Rows(e.RowIndex).DataKey("Importe").ToString.ToDouble)
|
|
Dim dr As DataRow() = DtDetalle.Select(Filtro.ToString)
|
|
Dim total As Double = LbTotal.Text.ToDouble
|
|
LbTotal.Text = (total - dr(0).Item("Importe").ToString.ToDouble).ToString.FormatoNumero
|
|
dr(0).Delete()
|
|
|
|
If Not LtDisponible.Text = "$" Then
|
|
CargaDisponible()
|
|
End If
|
|
CargaDatosDetalles()
|
|
End Sub
|
|
|
|
Private Sub RBLPago_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLPago.SelectedIndexChanged
|
|
|
|
Select Case RBLPago.SelectedValue
|
|
Case "1"
|
|
PnlNomina.Visible = True : PnlFiniquito.Visible = False
|
|
ChkDevengar.Checked = True : ChkEjercer.Checked = True : ChkPagar.Checked = True
|
|
ChkEjercer.Enabled = True : ChkPagar.Enabled = True
|
|
tbGeneral.Visible = True
|
|
TbIEPersonal.visible = False
|
|
PnlFiniquito.visible = True
|
|
CargaCombosIE()
|
|
Case "2"
|
|
PnlNomina.Visible = False : PnlFiniquito.Visible = True
|
|
ChkEjercer.Checked = False : ChkEjercer.Enabled = False
|
|
ChkPagar.Checked = False : ChkPagar.Enabled = False
|
|
|
|
ChkDevengar.Checked = True
|
|
trGasto.Visible = True
|
|
tbGeneral.Visible = True
|
|
TbIEPersonal.visible = True
|
|
DdlNominaPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltraParametros("IdCtaContPersonal > 0")
|
|
DdlNominaPersonal.DataBind()
|
|
TbIE.Visible = False
|
|
Case "3", "4"
|
|
PnlNomina.Visible = False : PnlFiniquito.Visible = True
|
|
ChkDevengar.Checked = True : ChkEjercer.Checked = True : ChkPagar.Checked = True
|
|
trGasto.Visible = False
|
|
tbGeneral.Visible = False
|
|
CargaCombosIE()
|
|
|
|
If RBLPago.SelectedValue = "4" Then
|
|
trGasto.Visible = True
|
|
tbGeneral.Visible = True
|
|
ChkDevengar.Checked = False : ChkDevengar.Enabled = False
|
|
End If
|
|
|
|
End Select
|
|
|
|
End Sub
|
|
|
|
Public Sub CargaCombosIE()
|
|
|
|
DdlTipoTransaccion.Items.Clear()
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros(String.Format("Tipo = '{0}' and Estatus = 1", If(RBLPago.SelectedValue = "3", "Ing", "Egs")))
|
|
DdlTipoTransaccion.DataBind()
|
|
|
|
DdlNominaPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltraParametros("IdCtaContPersonal > 0")
|
|
DdlNominaPersonal.DataBind()
|
|
DdlNominaPersonal.items.insert(0, New listitem("-", "-1"))
|
|
|
|
DdlCuenta.Items.Clear()
|
|
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("CveTipoCuenta <> 1") ' quito las cajas chicas
|
|
DdlCuenta.DataSource = dt
|
|
DdlCuenta.DataBind()
|
|
TbIE.Visible = True
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged
|
|
'Dim valor As Integer = DirectCast(sender, DropDownList).SelectedValue.ToEntero
|
|
'Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
|
|
|
|
Dim Folio As Long
|
|
Dim Banco As New ClsBancos
|
|
Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
Banco.Dispose()
|
|
TxtFolio.Text = Folio.ToString
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
|
|
|
|
'si solo es de egreso el movimiento debe de generar el siguiente folio.
|
|
Dim Folio As Long
|
|
Dim Banco As New ClsBancos
|
|
Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
Banco.Dispose()
|
|
TxtFolio.Text = (Folio + 1).ToString
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
|
|
Dim Seleccion As String = RBLPago.SelectedValue
|
|
|
|
If DtDetalle.Rows.Count = 0 And Seleccion.Contiene("1", "2") Then
|
|
Alert("No hay registros que guardar", TipoMensaje.MsgInformacion)
|
|
Exit Sub
|
|
End If
|
|
Dim TieneError As Boolean = False
|
|
Dim MensajeError = ""
|
|
Dim IDPoliza As Integer
|
|
Dim objAC As New ClsContPAQi(UsuarioActual.Empresa) : objAC.IniciaTransacSQL()
|
|
Dim ObjIE As ClsBancos = Nothing
|
|
Dim Total As Decimal = DtDetalle.SUMD("Importe")
|
|
Dim Fecha As Date = TxtFecha.Text.ToDate
|
|
Dim Concepto As String = TxtConcepto.Text.Trim
|
|
Dim GeneraIE As Boolean = False
|
|
|
|
|
|
Dim IdCtaISPT As Integer = 640
|
|
Dim IdCtaCreditoSalario As Integer = 635
|
|
Dim IdCtaDevolucionISPT As Integer = 1745
|
|
Dim IdCtaMatriz As Integer
|
|
Dim IdCtaCuotaSindical As Integer = 644
|
|
Dim IdCtaInfonavit As Integer = 2018
|
|
Dim IdCtaFonacot As Integer = 646
|
|
Dim IdCtaServicioMedico As Integer = 643
|
|
Dim IdCtaPension As Integer = 643
|
|
Dim IdCtaISRAsimilados As Integer = 4442
|
|
|
|
Dim Importe As Double
|
|
Dim MsgError As String = ""
|
|
'sumo la cantidad de esos movimientos
|
|
'If ChkEjercer.Checked Then Total += LbTotal.Text.ToDouble
|
|
'If ChkPagar.Checked Then Total += LbTotal.Text.ToDouble
|
|
|
|
|
|
Dim CtaCliente As Integer = 634 ' Municipio de hermosillo
|
|
Dim CvePresupuestoIngreso As Integer = 214 ' 2015: 12, 2016: 152, 2017: 160, 2018: 183, 2019: 195
|
|
Dim CtaPuente As Integer = 1774 ' INGRESO RECAUDADO PARA NOMINA EN MUNICIPIO, fijo
|
|
Dim CtaServiciosPersonales As Integer = 1778 ' 2111 -- fijo
|
|
Dim IdCtaPersonal As Integer = 0
|
|
Dim IdCtaBancaria As Integer = 0
|
|
Dim CveIE As Integer = 0
|
|
|
|
|
|
If Seleccion.Contiene("2", "3", "4") Then
|
|
|
|
Dim dr As DataRow = GlobalDTRHPersonal(UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CvePersonal = {0}", DdlNominaPersonal.SelectedValue))
|
|
If dr IsNot Nothing Then
|
|
IdCtaPersonal = dr("IdCtaContPersonal").ToString.ToEntero
|
|
End If
|
|
Else
|
|
If Seleccion = "1" Then
|
|
CtaPuente = 0
|
|
GeneraIE = True
|
|
End If
|
|
|
|
End If
|
|
|
|
If Seleccion.Contiene("1", "3", "4") Then
|
|
|
|
Dim dr As DataRow
|
|
dr = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
|
|
If dr IsNot Nothing Then
|
|
'DdlMoneda.SelectedValue = dr("CveMoneda").ToString
|
|
IdCtaBancaria = dr("IdCtaContable").ToString.ToEntero
|
|
End If
|
|
End If
|
|
|
|
|
|
Dim drt As DataRow
|
|
|
|
IDPoliza = objAC.AddPoliza(3, TxtConcepto.Text.Trim, 0, 0, UsuarioActual.CveUsuario, Fecha)
|
|
If IDPoliza > 0 Then
|
|
|
|
|
|
For Each dr As DataRow In DtDetalle.Rows
|
|
|
|
'registro el movimiento contable
|
|
|
|
Importe = dr("Importe").ToString.ToDouble
|
|
Dim drp As DataRow = DtPresupuestos.FiltroPrimero(String.Format("CvePresupuestoEgreso = {0}", dr("CvePresupuestoEgreso")))
|
|
|
|
If ChkDevengar.Checked Then
|
|
|
|
If drp IsNot Nothing Then IdCtaMatriz = drp("IdCuentaMatriz").ToString.ToEntero
|
|
|
|
If Not objAC.AddMovimiento(IDPoliza, dr("IdCuentaComprometido").ToString.ToEntero, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For
|
|
'actualizo el idcuenta del presupuesto
|
|
If Not objAC.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, False, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For
|
|
|
|
If RBLPago.SelectedValue = "1" AndAlso Not objAC.AddMovimiento(IDPoliza, drp("IdCuentaMatrizAbono").ToString.ToEntero, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For ' CtaServiciosPersonales
|
|
|
|
If Not objAC.AddMovimiento(IDPoliza, IdCtaMatriz, False, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For
|
|
|
|
End If
|
|
|
|
|
|
If ChkEjercer.Checked Then
|
|
If Not objAC.AddMovimiento(IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For
|
|
'actualizo el idcuenta del presupuesto
|
|
If Not objAC.AddMovimiento(IDPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For
|
|
|
|
End If
|
|
|
|
If ChkPagar.Checked Then
|
|
If Not objAC.AddMovimiento(IDPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For
|
|
'actualizo el idcuenta del presupuesto
|
|
If Not objAC.AddMovimiento(IDPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For
|
|
|
|
If Seleccion = "1" AndAlso Not objAC.AddMovimiento(IDPoliza, drp("IdCuentaMatrizAbono").ToString.ToEntero, False, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True : Exit For ' CtaServiciosPersonales
|
|
|
|
End If
|
|
Next
|
|
|
|
If TieneError Then MensajeError = "Error Tipo 1"
|
|
|
|
'If Seleccion.Contiene("1", "2", "3") Then
|
|
|
|
' Total = DtDetalle.SUMD("Importe")
|
|
' If Seleccion = "3" Then Total = TxtTotal.Text.ToDecimal
|
|
' Dim objACPI As New ClsAC()
|
|
|
|
' If objACPI.GetPresupuestoIngresos(CvePresupuestoIngreso, UsuarioActual.Empresa.EjercicioActual, True, UsuarioActual.CveEmpresa) Then
|
|
' If objACPI.DtResultados.Rows.Count > 0 Then
|
|
' drt = objACPI.DtResultados.Rows(0)
|
|
|
|
' If RBLPago.SelectedValue.Contiene("1", "2") Then
|
|
|
|
' 'se debe de registrar el ingreso
|
|
' 'DEVENGO EL INGRESO
|
|
' If Not objAC.AddMovimiento(IDPoliza, drt("IdCuentaPorEjecutar").ToString.ToEntero, False, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
' If Not objAC.AddMovimiento(IDPoliza, drt("IdCuentaDevengado").ToString.ToEntero, True, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
' 'CARGO la deuda del cliente
|
|
' 'If Not objAC.AddMovimiento(IDPoliza, CtaCliente, False, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
' 'abono,
|
|
|
|
' If Not objAC.AddMovimiento(IDPoliza, CtaCliente, False, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
' If Not objAC.AddMovimiento(IDPoliza, drt("IdCuentaMatriz").ToString.ToEntero, True, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
|
|
|
|
' End If
|
|
' If RBLPago.SelectedValue.Contiene("1", "3") Then
|
|
' 'RECAUDO EL INGRESO
|
|
' If Not objAC.AddMovimiento(IDPoliza, drt("IdCuentaDevengado").ToString.ToEntero, False, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
' If Not objAC.AddMovimiento(IDPoliza, drt("IdCuentaRecaudado").ToString.ToEntero, True, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
' If Seleccion = "1" AndAlso Not objAC.AddMovimiento(IDPoliza, CtaPuente, False, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
' If Not objAC.AddMovimiento(IDPoliza, CtaCliente, True, Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
' End If
|
|
|
|
' Else
|
|
' TieneError = True
|
|
' End If
|
|
' Else
|
|
' TieneError = True
|
|
' End If
|
|
|
|
' objACPI.Dispose()
|
|
|
|
'End If
|
|
|
|
If IdCtaPersonal > 0 Then
|
|
|
|
'registro los movimientos de cobro de cliente y que estan pendientes de pagarse al FyE
|
|
Importe = DtDetalle.SUM("Importe")
|
|
'cuando es el pago a personal, se carga, los demas casos se abona
|
|
If Seleccion.Contiene("1", "2", "4") Then If Not objAC.AddMovimiento(IDPoliza, IdCtaPersonal, If(Seleccion = "4", False, True), Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
CtaPuente = 0 ' para que no se inserte mas abajo
|
|
GeneraIE = True
|
|
End If
|
|
|
|
If Seleccion.Contiene("1", "3", "4") AndAlso GeneraIE Then
|
|
'registro un IE
|
|
ObjIE = New ClsBancos
|
|
ObjIE.IniciaTransacSQL()
|
|
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
|
Dim CvePrePoliza = ObjMov.AddPrePolizas("Banc/RegNomina", 2, Importe, Importe, 1, Fecha, TxtConcepto.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
Dim Obs As String = TxtConcepto.Text
|
|
Dim Folio As String
|
|
|
|
Folio = TxtFolio.Text.Trim
|
|
Dim CveConceptoCargo As Integer = 30
|
|
Dim CveConceptoAbono As Integer = 28
|
|
Total = TxtTotal.Text.ToDecimal
|
|
|
|
If Seleccion = "4" Then Total = DtDetalle.SUMD("Importe")
|
|
|
|
'cuando saco el egreso invierto los concepto
|
|
If Seleccion = "3" Then
|
|
CveConceptoCargo = 29
|
|
CveConceptoAbono = 30
|
|
ElseIf Seleccion = "1" Then
|
|
CveConceptoCargo = 95
|
|
CveConceptoAbono = 30
|
|
Obs = "NOMINA PAGADA"
|
|
End If
|
|
|
|
'lo envia como transferencia recibida
|
|
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, Fecha, Folio, Obs, Total, 1, 1.0, Obs, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
If CveIE > 0 Then
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, Total, "", CveConceptoCargo, Obs, Fecha, 0, -1, CveIE, CvePersonal:=DdlNominaPersonal.SelectedValue.ToEntero, ImporteMX:=Total) Then
|
|
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Total, "", CveConceptoAbono, Obs, Fecha, 0, -1, CveIE, CvePersonal:=DdlNominaPersonal.SelectedValue.ToEntero, ImporteMX:=Total) Then
|
|
MsgError = "no se pudo insertar el detalle de la póliza 2"
|
|
End If
|
|
Else
|
|
MsgError = "no se pudo insertar el detalle de la póliza"
|
|
End If
|
|
|
|
ObjIE.UpdateIEPrePoliza(Fecha, objAC.Folio.ToString, IDPoliza, CvePrePoliza, CveIE, -1)
|
|
Else
|
|
MsgError = "no se pudo agregar el movimiento bancario"
|
|
TieneError = True
|
|
End If
|
|
|
|
'Registra el movimiento total
|
|
If Not objAC.AddMovimiento(IDPoliza, IdCtaBancaria, If(Seleccion = "3", False, True), Total, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
End If
|
|
|
|
'Registra el movimiento total
|
|
Importe = DtDetalle.SUM("Importe")
|
|
If CtaPuente > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, CtaPuente, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
'Registra el movimiento de ISPT
|
|
Importe = TxtISPT.Text.ToDouble
|
|
If Importe > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaISPT, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
|
|
'Registro mov. credito al salario
|
|
Importe = TxtCredSalario.Text.ToDouble
|
|
If Importe > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaCreditoSalario, False, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
|
|
'Registro Cuotas Sindicales
|
|
Importe = TxtSindical.Text.ToDouble
|
|
If Importe > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaCuotaSindical, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
'Registro Prestamo infonavit
|
|
Importe = txtInfonavit.Text.ToDouble
|
|
If Importe > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaInfonavit, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
'Registro Fonacot
|
|
Importe = txtFonacot.Text.ToDouble
|
|
If Importe > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaFonacot, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
'Registro Servicio Medico
|
|
Importe = txtServicioMedico.Text.ToDouble
|
|
If Importe > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaServicioMedico, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
'Registro Pensión
|
|
Importe = txtPension.Text.ToDouble
|
|
If Importe > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaPension, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
'Registro ISR Asimilados
|
|
Importe = TxtISRAsimilados.Text.ToDouble
|
|
If Importe > 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaISRAsimilados, True, Importe, "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
|
|
''Registro del Mov Devolución
|
|
'Importe = TxtISPT.Text.ToDouble - TxtCredSalario.Text.ToDouble
|
|
'If Importe <> 0 AndAlso Not objAC.AddMovimiento(IDPoliza, IdCtaDevolucionISPT, If(Importe > 0, False, True), Math.Abs(Importe), "", Concepto, 0, Fecha, "") Then TieneError = True
|
|
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
objAC.AjustaPoliza(IDPoliza)
|
|
|
|
objAC.Commit()
|
|
If ObjIE IsNot Nothing Then ObjIE.Commit()
|
|
GvD.DataBind()
|
|
UPPDetalle.Update()
|
|
DtDetalle.Rows.Clear()
|
|
LbTotal.Text = "0.00"
|
|
|
|
|
|
Dim Descargas As New StringBuilder
|
|
If IDPoliza > 0 Then Descargas.AppendFormat("<br /><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}""> Ver Poliza</a>", IDPoliza)
|
|
If CveIE > 0 Then Descargas.AppendFormat("<br /><a class=""Texto"" target='_blank' href=""/Bancos/IE.aspx?CveIE={0}""> Movimiento Bancario</a>", CveIE)
|
|
|
|
Dim Msg As String = String.Format("<br />La poliza se registró correctamente.<br /> {0}", Descargas.ToString) 'TipoMensaje.MsgInformacion
|
|
|
|
Msg.Alert(Msg, TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Error al agregar los Movimientos. Agregar presupuesto del año siguiente (LN 368)." & MensajeError, TipoMensaje.MsgError)
|
|
objAC.RollBack()
|
|
If ObjIE IsNot Nothing Then ObjIE.RollBack()
|
|
End If
|
|
objAC.Dispose()
|
|
If ObjIE IsNot Nothing Then ObjIE.Dispose()
|
|
End Sub
|
|
End Class
|