Files
SIG/Bancos/PolizaCheque.aspx.vb
2021-12-01 18:56:12 -07:00

1250 lines
58 KiB
VB.net

Imports System.Data
Imports Extensiones
Imports System.IO
Imports System.Linq
Imports System.Web.Services
Partial Class Bancos_PolizaCheque
Inherits ClsPaginas
' Private Shared missing As Object = System.Reflection.Missing.Value
#Region "Propiedades"
Private Property NombreArchivo As String
Get
Return ViewState("NombreArchivo").ToString
End Get
Set(value As String)
ViewState("NombreArchivo") = value
End Set
End Property
Private Property TextoCompleto As String
Get
Return ViewState("TextoCompleto").ToString
End Get
Set(value As String)
ViewState("TextoCompleto") = value
End Set
End Property
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 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 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
#End Region
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ViewState("CveProveedor") = "-1"
ViewState("CvePeriodo") = "0"
CveMoneda = 1
If UsuarioActual.Empresa.Funcionalidad(200) <> "" Then ChkContabilizar.Enabled = False : ChkContabilizar.Checked = True
DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True
Dim dt As DataTable = Nothing
If UsuarioActual.Empresa.UsaContabilidad Then
Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
If Conta.GetCuentas(-1, "-1", 1) Then
dt = Conta.DtResultados
DtCuentasContables = Conta.DtResultados
Session("DtCuentas") = Conta.DtResultados
End If
Conta.Dispose()
End If
TipoPlantilla = 0
If IfNull(Request("Tipo"), "").ToString = "Ing" Then
TipoPlantilla = 1
LblEncabezado.Text = "Otros Ingresos"
TrPaguese.Visible = False
ChkAbonoCuenta.Visible = False
Else
TxtImporte.Attributes.Add("onkeyup", String.Format("FncImporteCuenta(this)"))
End If
CargaPlantillas(TipoPlantilla)
CargaTipoTransaccion(TipoPlantilla)
CargaCuenta()
If UsuarioActual.CveEmpresa = 66 Then trNotificar.Visible = True
'crea tabla temporal
ArregloMovs = New ArrayList
DtMovimientos = New DataTable("Movimientos")
Dim IDMov As DataColumn = DtMovimientos.Columns.Add("IdMov", Type.GetType("System.Int32")) : IDMov.AutoIncrement = True
With DtMovimientos.Columns
.Add("IdCuenta", Type.GetType("System.Int32"))
.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.Double"))
.Add("Abono", Type.GetType("System.Double"))
.Add("TipoMovto", Type.GetType("System.Int32"))
.Add("EsComodin", Type.GetType("System.Int32"))
.Add("CveConcepto", Type.GetType("System.Int32"))
.Add("CveProveedor", Type.GetType("System.Int32"))
.Add("RazonSocial", Type.GetType("System.String"))
.Add("SubProyecto", Type.GetType("System.String"))
.Add("Proyecto", Type.GetType("System.String"))
.Add("Personal", Type.GetType("System.String"))
.Add("CvePersonal", Type.GetType("System.Int32"))
.Add("CveSubProyecto", Type.GetType("System.Int32"))
End With
GvMov.DataBind()
UPMovs.Update()
If Request("CvePeriodo") IsNot Nothing AndAlso IsNumeric(Request("CvePeriodo")) AndAlso Request("CvePeriodo").ToEntero > 0 Then
ViewState("CvePeriodo") = Request("CvePeriodo").ToEntero
ViewState("CveProyecto") = Request("CveProyecto").ToEntero
ViewState("CveSubProyecto") = Request("CveSubProyecto").ToEntero
ViewState("CveTurno") = Request("CveTurno").ToEntero
DdlPlantilla.Items.Add(New ListItem("Pago Nomina", "36"))
DdlPlantilla.SelectedValue = "36"
DdlPlantilla.Enabled = False
End If
End If
End Sub
Protected Sub BtnBuscarProveedor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBuscarProveedor.Click
ViewState("CveProveedor") = HdnCveProveedor.Value.ToEntero
CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1")
DdlPlantilla_SelectedIndexChanged(DdlPlantilla, e)
End Sub
Private Sub CargaProveedor(ByVal CveProveedor As Integer, RFC As String)
Dim ObjProveedor As New ClsCompProveedores()
If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, CveProveedor, "-1", "-1", "-1", "-1", RFC, "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
If ObjProveedor.DtResultados.Rows.Count > 0 Then
TxtPagueseA.Text = ObjProveedor.RazonSocial
TxtNotificarA.Text = ObjProveedor.NotificarA.Trim
Else
Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
End If
End If
ObjProveedor.Dispose()
End Sub
Private Sub CargaPlantillas(TipoPlantilla As Integer)
'GvPlantillas.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
'GvPlantillas.DataBind()
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
DdlPlantilla.DataBind()
DdlPlantilla.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
Private Sub CargaCuenta()
DdlCuenta.Items.Clear()
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
'If DdlTipoTransaccion.SelectedValue.ToEntero = 3 Then
' dt = dt.FiltraParametros("CveTipoCuenta = 7")
'End If
'cuando es layout
If DdlTipoTransaccion.SelectedValue.ToEntero = 9 Then
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1))
dt = dt.FiltraParametros("UsaLayout = 1")
End If
'cuando es layout Por Grupos
If DdlTipoTransaccion.SelectedValue.ToEntero = 17 Then
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1))
dt = dt.FiltraParametros("UsaLayoutGrupos = 1")
End If
DdlCuenta.DataSource = dt 'GlobalDTBancosCuentas(UsuarioActual.CveUsuario)
DdlCuenta.DataBind()
DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1"))
UPPDocumento.Update()
End Sub
Private Sub CargaTipoTransaccion(TipoPlantilla As Integer)
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros(String.Format("Tipo = '{0}' ", If(TipoPlantilla = 0, "Egs", "Ing")))
DdlTipoTransaccion.DataBind()
End Sub
'Private Sub CargaProyecto()
' DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa)
' DdlProyecto.DataBind()
'End Sub
'Private Sub CargaSubProyecto()
' DdlSubProyecto.Items.Clear()
' DdlSubProyecto.DataSource = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToEntero)
' DdlSubProyecto.DataBind()
' DdlSubProyecto.Items.Insert(0, New ListItem("Seleccione", "-1"))
'End Sub
'Protected Sub DdlProyectoAsignado_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
' CargaSubProyecto()
'End Sub
Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged
'CargaFolio()
CargaCuenta()
End Sub
Private Sub CargaFolio()
If HdnTipoTransaccion.Value = "" Then CargaHdnTipoTransaccion()
'If HdnTipoTransaccion.Value = "Egs" Then
If DdlTipoTransaccion.SelectedValue.ToEntero > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then
If UsuarioActual.CveEmpresa = 119 AndAlso IfNull(Request("Tipo"), "") = "Ing" Then
Dim ObjFolios As New ClsGralFolios
If ObjFolios.GetFolios("RMF", UsuarioActual.CveEmpresa) Then
Dim DT As DataTable = ObjFolios.DtResultados.FiltraParametros(String.Format(" Estado = 'Activo'"))
If DT.Rows.Count > 0 Then
TxtFolio.Text = DT.Rows(0)("FActual").ToString
End If
End If
ObjFolios.Dispose()
Else
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 If
End If
'Else
'TxtFolio.Text = ""
'End If
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
If dr IsNot Nothing Then
CveMoneda = dr("CveMoneda").ToString.ToEntero
End If
End Sub
Private Sub CargaHdnTipoTransaccion()
Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
If dr IsNot Nothing Then
HdnTipoTransaccion.Value = dr("Tipo").ToString
End If
End Sub
Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
CargaFolio()
If CvePeriodo > 0 Then
CargaNomina()
End If
End Sub
<WebMethodAttribute()> <Script.Services.ScriptMethodAttribute()>
Public Shared Function wsGetCuentas(ByVal prefixText As String, ByVal count As Integer) As String()
'Dim dt As DataTable = CType(Session("DtCuentas"), DataTable)
'Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
'dt = Conta.getCuentasCheque(Prefijo)
'Conta.Dispose()
Dim items As New List(Of String)(count)
Dim dbrows As DataRow()
dbrows = DirectCast(HttpContext.Current.Session("DtCuentas"), DataTable).Select(String.Format("nombre like '%{0}%'", prefixText))
For i As Integer = 0 To count - 1
If dbrows.Length > i Then
items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dbrows(i)("Nombre").ToString, dbrows(i)("Id").ToString))
Else
Exit For
End If
Next
Return items.ToArray()
End Function
<WebMethodAttribute()> <Script.Services.ScriptMethodAttribute()>
Public Shared Function wsGetNombreCuenta(ByVal contextKey As System.String) As System.String
Dim Retorno As String = ""
Dim dr As DataRow = DirectCast(HttpContext.Current.Session("DtCuentas"), DataTable).FiltroPrimero("Id = " & contextKey)
If dr IsNot Nothing Then
Retorno = dr("nombre").ToString
End If
Return Retorno
End Function
Protected Sub DdlPlantilla_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPlantilla.SelectedIndexChanged
Dim IdCtaFondoGarantia As Integer
If ViewState("CveProveedor").ToString.ToEntero > 0 Then
Dim ObjProv As New ClsCompProveedores()
If ObjProv.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, ViewState("CveProveedor"), "-1", "-1", "-1", "-1", "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
IdCtaFondoGarantia = ObjProv.DtResultados.Rows(0)("IdCtaContFondoGarantia").ToString.ToEntero
End If
ObjProv.Dispose()
End If
If DdlCuenta.SelectedValue.ToEntero <= 0 Then
If UsuarioActual.CveEmpresa <> 126 Then
Alert("Seleccione la Cuenta Bancaria", TipoMensaje.MsgAdvertencia)
DdlPlantilla.SelectedValue = "-1"
Exit Sub
End If
End If
If DdlPlantilla.SelectedValue.ToEntero <= 0 Then
Alert("Seleccione un Movimiento Válido", TipoMensaje.MsgAdvertencia)
DdlPlantilla.SelectedValue = "-1"
Exit Sub
End If
Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero
Dim Dt As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla).FiltraParametros(String.Format("CveEmpresa={0}", UsuarioActual.CveEmpresa), "Orden")
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 = ""
If UsuarioActual.Empresa.UsaContabilidad Then
If drt("IdCtaContable").ToString.ToEntero > 0 Then 'DtCuentasContables
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", drt("IdCtaContable").ToString))
If drr IsNot Nothing Then
IdCuenta = drt("IdCtaContable").ToString.ToEntero
CodigoCuenta = drr("CuentaFormato").ToString()
NombreCuenta = drr("Nombre").ToString()
'Cuenta = drr("Nombre").ToString()
End If
EsComodin = 0
ElseIf drt("CveConcepto").ToString = "30" Then
'saco la clave de la cuenta bancaria seleccionada
If DdlCuenta.SelectedValue.ToEntero > 0 And drt("CveConcepto").ToString = "30" Then 'DtCuentasContables
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", IdCuentaBancos(DdlCuenta.SelectedValue.ToEntero)))
If drr IsNot Nothing Then
IdCuenta = drr("Id").ToString.ToEntero
CodigoCuenta = drr("CuentaFormato").ToString()
NombreCuenta = drr("Nombre").ToString()
' Cuenta = drr("Nombre").ToString()
EsComodin = 1
Else
' Rad.Checked = False
If UsuarioActual.CveEmpresa <> 126 Then
Alert("La Cuenta Bancaria no se ha vinculado a la cuenta contable", TipoMensaje.MsgAdvertencia)
GvMov.DataBind()
UPMovs.Update()
Exit Sub
End If
End If
End If
ElseIf drt("CveConcepto").ToString.ToEntero = 135 And IdCtaFondoGarantia > 0 Then
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", IdCtaFondoGarantia))
IdCuenta = IdCtaFondoGarantia
CodigoCuenta = drr("CuentaFormato").ToString()
NombreCuenta = drr("Nombre").ToString()
'Cuenta = drr("Nombre").ToString()
EsComodin = 0
End If
End If
Dim dr As DataRow = DtMovimientos.NewRow
dr("IdCuenta") = IdCuenta
dr("CodigoCuenta") = CodigoCuenta & "<br>" & NombreCuenta
dr("Cuenta") = Cuenta 'TxtCuentaContable.Text
dr("RazonSocial") = drt("RazonSocial")
dr("Concepto") = TxtObservaciones.Text
dr("TipoMovto") = If(drt("TipoMovto").ToString = "False", 0, 1)
dr("EsComodin") = EsComodin
dr("CveConcepto") = drt("CveConcepto")
dr("CveProveedor") = drt("CveProveedor")
dr("SubProyecto") = drt("SubProyecto")
dr("CveSubProyecto") = drt("CveSubProyecto")
dr("Proyecto") = drt("Proyecto")
dr("Personal") = drt("Personal")
dr("CvePersonal") = drt("CvePersonal")
'dr("CveConcepto") = drt("CveConcepto")
DtMovimientos.Rows.Add(dr)
Next
GvMov.DataSource = DtMovimientos
GvMov.DataBind()
UPMovs.Update()
End Sub
Private Sub CargaNomina()
Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero
Dim ObjNomina As New ClsNominas
Dim ObjConta As New ClsContabilidad
trAjuste.Visible = True
Dim Dt As DataTable = Nothing
Dim Cuenta As String = ""
Dim Concepto As String = ""
Dim IdCuenta As Integer = 0
Dim TipoMovto As Integer
Dim CveConcepto As Integer
Dim CodigoCuenta As String = ""
Dim NombreCuenta As String = ""
Dim TotalProceso As Decimal = 0
Dim EsComodin As Integer = 0
DtMovimientos.Clear()
If ObjNomina.GetPagoNomina(CveProyecto, CveSubProyecto, CveTurno, CvePeriodo, UsuarioActual.CveEmpresa) Then
Dt = ObjNomina.DtResultados
For Each drt As DataRow In Dt.Rows
Dim dr As DataRow = DtMovimientos.NewRow
If drt("CveNomina").ToString.ToEntero > 0 Then
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", If(ObjConta.GetRetCuenta(31, UsuarioActual.CveEmpresa), ObjConta.DtResultados.Rows(0)("IdCtaContable").ToString.ToEntero, -1)))
TipoMovto = 0
CveConcepto = 31
IdCuenta = If(drr IsNot Nothing, drr("Id").ToString.ToEntero, -1)
CodigoCuenta = If(drr IsNot Nothing, drr("CuentaFormato").ToString(), "")
NombreCuenta = If(drr IsNot Nothing, drr("Nombre").ToString(), "")
Concepto = drt("NombreCompleto")
dr("Cargo") = drt("Total").ToString.ToDecimal.FormatoNumero(2)
TotalProceso += drt("Total").ToString.ToDecimal.FormatoNumero(2)
Else
Dim drr As DataRow = DtCuentasContables.FiltroPrimero(String.Format("Id={0}", IdCuentaBancos(DdlCuenta.SelectedValue.ToEntero)))
TipoMovto = 1
CveConcepto = 30
IdCuenta = If(drr IsNot Nothing, drr("Id").ToString.ToEntero, -1)
CodigoCuenta = If(drr IsNot Nothing, drr("CuentaFormato").ToString(), "")
NombreCuenta = If(drr IsNot Nothing, drr("Nombre").ToString(), "")
Concepto = "Pago Nómina"
dr("Abono") = TotalProceso
EsComodin = 1
TxtTotalAbonos.Text = TotalProceso.FormatoNumero(2)
TxtTotalCargos.Text = TotalProceso.FormatoNumero(2)
TxtImporte.Text = TotalProceso.FormatoNumero(2)
HdnImporte.Value = TotalProceso.FormatoNumero(2)
TxtImporte.Enabled = False
TxtTotalAbonos.Enabled = False
TxtTotalCargos.Enabled = False
End If
dr("IdCuenta") = IdCuenta
dr("CodigoCuenta") = CodigoCuenta & "<br>" & NombreCuenta
dr("Cuenta") = Cuenta
dr("RazonSocial") = ""
dr("Concepto") = Concepto
dr("TipoMovto") = TipoMovto
dr("EsComodin") = EsComodin
dr("CveConcepto") = CveConcepto
dr("CveProveedor") = "-1"
dr("SubProyecto") = drt("SubProyecto")
dr("Proyecto") = ""
dr("Personal") = ""
dr("CveSubProyecto") = drt("CveSubProyecto")
dr("CvePersonal") = drt("CvePersonal")
DtMovimientos.Rows.Add(dr)
Next
'Dim drtt As DataRow = DtMovimientos.NewRow
'drtt("IdCuenta") = 0
'drtt("CodigoCuenta") = ""
'drtt("Cuenta") = Cuenta
'drtt("RazonSocial") = ""
'drtt("Concepto") = ""
'drtt("TipoMovto") = 0
'drtt("EsComodin") = EsComodin
'drtt("CveConcepto") = 44
'drtt("CveProveedor") = "-1"
'drtt("SubProyecto") = ""
'drtt("Proyecto") = ""
'drtt("Personal") = ""
'drtt("CveSubProyecto") = -1
'drtt("CvePersonal") = -1
'DtMovimientos.Rows.Add(drtt)
ObjNomina.Dispose()
ObjConta.Dispose()
GvMov.DataSource = DtMovimientos
GvMov.DataBind()
UPMovs.Update()
GeneraLayout()
End If
End Sub
#Region "LAYOUT"
Private Function CreaArchivo() As Boolean
DirectoryExistsCreate(String.Format("{0}Layout", UsuarioActual.Empresa.Ruta))
NombreArchivo = String.Format("{2}{1}{0}.txt", UsuarioActual.CveUsuario, Date.Now.ToString("yyyyMMdd-HH-mm"), "LAYOUTPAGONOMINA")
Dim path As String = String.Format("{0}Layout\{1}", UsuarioActual.Empresa.Ruta, NombreArchivo)
Dim fs As FileStream = File.Create(path)
' Add text to the file.
Dim info As Byte() = New UTF8Encoding(True).GetBytes(TextoCompleto)
fs.Write(info, 0, info.Length)
fs.Close()
Return True
End Function
Private Sub GeneraLayout()
Dim ObjPersonal As New ClsRH()
TextoCompleto = ""
'Encabezado
Dim Identificador As String = "1"
Dim NumRegistros As String = GeneraCampoInverso(DtMovimientos.FiltraParametros("CvePersonal > 0").Rows.Count, 7, "0")
Dim ImporteRegistros As String = GeneraCampoInverso(DecimalesSinPunto(TxtImporte.Text), 15, "0")
Dim RegistrosInc As String = "0000000"
Dim ImporteRegistrosInc As String = "000000000000000"
Dim ContratoPagel As String = "000000000000"
Dim NumeroEmpresa As String = "4200976091" 'Requiere cuadre
Dim CodigoPago As String = "R23"
Dim TipoServicio As String = "110"
Dim ClaveEntrada As String = "1"
Dim FechaArchivo As String = Date.Now.ToString("yyyyMMdd")
Dim FechaPago As String = TxtFechaDocumento.ToDate.ToString("yyyyMMdd")
Dim Filler As String = GeneraCampo("", 142)
TextoCompleto = Identificador + NumRegistros + ImporteRegistros + RegistrosInc + ImporteRegistrosInc + ContratoPagel + NumeroEmpresa + CodigoPago + TipoServicio + ClaveEntrada + FechaArchivo + FechaPago + Filler + vbNewLine
'Detalle
For Each dr As DataRow In DtMovimientos.FiltraParametros("CvePersonal > 0").Rows
TextoCompleto += GeneraLineaLayout(dr("CvePersonal"), dr("Cargo"), dr("Concepto"), ObjPersonal) + vbNewLine
Next
'CreaArchivo()
ObjPersonal.Dispose()
End Sub
Private Function GeneraLineaLayout(CvePersonal As Integer, Importe As String, Concepto As String, ObjPersonal As ClsRH) As String
Dim Retorno As String = ""
If ObjPersonal.GetPersonal(CvePersonal, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
Dim Identidicador As String = "3"
Dim ReferenciaNumerica As String = GeneraCampo("", 7)
Dim Curp As String = GeneraCampo(ObjPersonal.DtResultados(0)("CURP").ToString, 18)
Dim TipoCuenta As String = "98"
Dim BancoDestino As String = GeneraCampo(ObjPersonal.DtResultados(0)("CveSATBanco").ToString, 3)
Dim PlazaDestino As String = "000"
Dim NumeroCuenta As String = GeneraCampo(ObjPersonal.DtResultados(0)("CuentaBancaria").ToString, 16)
Dim ImporteAbono As String = GeneraCampoInverso(DecimalesSinPunto(Importe), 15, "0")
Dim EstadoPago As String = "0000000"
Dim DescripcionPago As String = GeneraCampo(Concepto, 80)
Dim TitularCuenta As String = GeneraCampo(ObjPersonal.DtResultados(0)("Nombre").ToString, 40)
Dim MotivoPago As String = GeneraCampo(TxtObservaciones.Text, 40)
Retorno = Identidicador + ReferenciaNumerica + Curp + TipoCuenta + BancoDestino + PlazaDestino + NumeroCuenta + ImporteAbono + EstadoPago + DescripcionPago + TitularCuenta + MotivoPago
End If
Return Retorno
End Function
Private Function DecimalesSinPunto(Importe As String) As String
Dim Retorno As String = ""
Importe = Importe.Replace(",", "")
Dim PosicionD As Integer = Importe.IndexOf(".")
Dim Decimales As Integer = Importe.Substring(PosicionD + 1).Length
If PosicionD > 0 Then
If Decimales = 1 Then
Retorno = Importe.ToString.Replace(".", "") + "0"
Else
Retorno = Importe.ToString.Replace(".", "")
End If
Else
Retorno = Importe.ToString + "00"
End If
Return Retorno
End Function
'Genera los campos con un relleno a la derecha
Private Function GeneraCampo(Texto As String, Tamaño As Integer, Optional Caracter As Char = " "c) As String
Dim Retorno As String = ""
If Texto.Length >= Tamaño Then
Retorno = Texto.Substring(0, Tamaño)
Else
Retorno = Texto
For i As Integer = Texto.Length + 1 To Tamaño
Retorno += Caracter
Next
End If
Return UCase(Retorno)
End Function
'Genera el campo con un relleno a la izquierda
Private Function GeneraCampoInverso(Texto As String, Tamaño As Integer, Optional Caracter As Char = " "c) As String
Dim Retorno As String = ""
If Texto.Length >= Tamaño Then
Retorno = Texto.Substring(0, Tamaño)
Else
Retorno = Texto
For i As Integer = Texto.Length + 1 To Tamaño
Retorno = Caracter + Retorno
Next
End If
Return UCase(Retorno)
End Function
'Este metodo es el de las altas
'Private Function GeneraLineaLayout(CvePersonal As Integer, ObjPersonal As ClsRH) As String
' Dim Retorno As String = ""
' If ObjPersonal.GetPersonal(CvePersonal, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, "-1", -1, -1, -1, -1, -1, -1, "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
' Dim TipoRegistro As String = "02" 'Estatico
' Dim Nombre As String = GeneraCampo(ObjPersonal.DtResultados(0)("Nombres").ToString, 20)
' Dim ApellidoPaterno As String = GeneraCampo(ObjPersonal.DtResultados(0)("APaterno").ToString, 20)
' Dim ApellidoMaterno As String = GeneraCampo(ObjPersonal.DtResultados(0)("AMaterno").ToString, 20)
' Dim FechaNacimiento As String = ObjPersonal.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("yyyy-MM-dd")
' Dim EstadoCivil As String = "S" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
' Dim Curp As String = GeneraCampo(ObjPersonal.DtResultados(0)("CURP").ToString, 18)
' Dim Sexo As String = GeneraCampo(ObjPersonal.DtResultados(0)("Genero").ToString, 1)
' Dim Nacionalidad As String = GeneraCampo("M", 3) 'Requiere cuadre entre nuestra tabla y el catalogo del banco
' Dim PaisOrigen As String = "MEX" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
' Dim Ocupacion As String = "OFI" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
' Dim FechaIngreso As String = ObjPersonal.DtResultados(0)("FechaIngreso").ToString.ToDate.ToString("yyyy-MM-dd")
' Dim Calle As String = GeneraCampo(ObjPersonal.DtResultados(0)("Calle").ToString, 50)
' Dim NumeroExterior As String = GeneraCampo(ObjPersonal.DtResultados(0)("NumExt").ToString, 8)
' Dim NumeroInterior As String = GeneraCampo(ObjPersonal.DtResultados(0)("NumInt").ToString, 8)
' Dim Colonia As String = GeneraCampo(ObjPersonal.DtResultados(0)("Colonia").ToString, 30)
' Dim CP As String = GeneraCampo(ObjPersonal.DtResultados(0)("CP").ToString, 5)
' Dim Poblacion As String = GeneraCampo("MEXICO", 30)
' Dim Estado As String = GeneraCampo(ObjPersonal.DtResultados(0)("Estado").ToString, 25)
' Dim TelefonoParticular As String = GeneraCampo(ObjPersonal.DtResultados(0)("Telefono").ToString, 10)
' Dim TelefonoOficina As String = GeneraCampo(ObjPersonal.DtResultados(0)("Telefono").ToString, 10)
' Dim ExtensionOficina As String = "000000" 'No tenemos este campo
' Dim Celular As String = GeneraCampo(ObjPersonal.DtResultados(0)("Celular").ToString, 10)
' Dim CorreoElectronico As String = GeneraCampo(ObjPersonal.DtResultados(0)("Correo").ToString, 50)
' Dim TipoProducto As String = "A0" 'Estatico
' Dim SubProducto As String = "245" 'Estatico
' Dim CuentaUniversal As String = GeneraCampo("", 2) 'Este valor se captura vacío
' Dim TipoCuenta As String = GeneraCampo("A", 2) 'Requiere cuadre entre nuestra tabla y el catalogo del banco
' Dim NumeroTDD As String = GeneraCampo("0000" + ObjPersonal.DtResultados(0)("Correo").ToString, 20)
' Dim Oficina As String = GeneraCampo(ObjPersonal.DtResultados(0)("Sucursal").ToString, 4)
' Dim MontoDisperciones As String = "000000000000000" 'Estatico
' Dim NumeroDisperciones As String = "0" 'Estatico
' Dim OficinaEntrega As String = "0000" 'Estatico
' Dim Beneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("Nombres").ToString, 20)
' Dim ApellidoPaternoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("APaterno").ToString, 20)
' Dim ApellidoMaternoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("AMaterno").ToString, 20)
' Dim ParentescoBeneficiario As String = "SD" 'Requiere cuadre entre nuestra tabla y el catalogo del banco
' Dim SexoBeneficiario As String = GeneraCampo(ObjPersonal.DtResultados(0)("Genero").ToString, 1)
' Dim FechaNacimientoBeneficiario As String = ObjPersonal.DtResultados(0)("FechaNacimiento").ToString.ToDate.ToString("yyyy-MM-dd")
' Retorno = TipoRegistro + Nombre + ApellidoPaterno + ApellidoMaterno + FechaNacimiento + EstadoCivil + Curp + Sexo + Nacionalidad + PaisOrigen + Ocupacion + FechaIngreso + Calle + NumeroExterior + NumeroInterior +
' Colonia + CP + Poblacion + Estado + TelefonoParticular + TelefonoOficina + ExtensionOficina + Celular + CorreoElectronico + TipoProducto + SubProducto + CuentaUniversal + TipoCuenta + NumeroTDD + Oficina +
' MontoDisperciones + NumeroDisperciones + OficinaEntrega + Beneficiario + ApellidoPaternoBeneficiario + ApellidoMaternoBeneficiario + ParentescoBeneficiario + SexoBeneficiario + FechaNacimientoBeneficiario
' End If
' Return Retorno
'End Function
#End Region
Protected Sub GvMov_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMov.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.RowIndex = 0 Then
e.Row.Cells(0).Width = Unit.Pixel(110)
e.Row.Cells(1).Width = Unit.Pixel(200)
'e.Row.Cells(2).Width = Unit.Pixel(150)
'e.Row.Cells(3).Width = Unit.Pixel(150)
e.Row.Cells(2).Width = Unit.Pixel(120)
e.Row.Cells(3).Width = Unit.Pixel(303)
e.Row.Cells(4).Width = Unit.Pixel(72)
e.Row.Cells(5).Width = Unit.Pixel(72)
End If
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
e.Row.Cells(0).ToolTip = e.Row.DBCampo("IdCuenta")
If e.Row.DBCampo("TipoMovto") = "1" Then e.Row.FCTextBox("TxtAbono").Visible = True Else e.Row.FCTextBox("TxtCargo").Visible = True
If CvePeriodo > 0 Then
e.Row.FCLiteral("LtlCargo").Visible = False
e.Row.FCTextBox("TxtCargo").Enabled = False
e.Row.FCLiteral("LtlAbono").Visible = False
e.Row.FCTextBox("TxtAbono").Enabled = False
End If
If e.Row.DBCampo("Cuenta") = "Comprobación Personal" And e.Row.DBCampo("Personal") <> "" Then e.Row.FCLiteral("LtlCuenta").Text = $"{e.Row.DBCampo("Cuenta")} - {e.Row.DBCampo("Personal")}"
e.Row.FCDropDownList("DdlSubProyecto").DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1)
e.Row.FCDropDownList("DdlSubProyecto").DataBind()
e.Row.FCDropDownList("DdlSubProyecto").SelectedValue = e.Row.DBCampo("CveSubProyecto")
e.Row.FCDropDownList("DdlSubProyecto").Items.Insert(0, New ListItem("Sin SubProyecto Asignado", "-1"))
If UsuarioActual.CveEmpresa = 119 Then
e.Row.FCLiteral("LtlSP").Visible = False
e.Row.FCDropDownList("DdlSubProyecto").Visible = True
End If
'cuando se modifica el importe de la cuenta bancaria que se actualice el importe del documento
'If e.Row.DBCampo("EsComodin") = "1" Then
' If e.Row.DBCampo("TipoMovto") = "1" Then
' e.Row.FCTextBox("TxtAbono").Attributes.Add("onkeyup", "FncImporte('TxtImporte',this.id,2)")
' e.Row.FCTextBox("TxtAbono").Text = TxtImporte.Text
' Else
' e.Row.FCTextBox("TxtCargo").Attributes.Add("onkeyup", "FncImporte('TxtImporte',this.id,2)")
' e.Row.FCTextBox("TxtCargo").Text = TxtImporte.Text
' End If
' TxtImporte.Attributes.Add("onkeyup", String.Format("FncImporte(this.id,'{0}',1)", e.Row.FCTextBox(If(e.Row.DBCampo("TipoMovto") = "1", "TxtAbono", "TxtCargo")).ClientID))
' UPPImporte.Update()
'End If
End If
End Sub
Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
Dim TotalCargos, TotalAbonos, ImporteDocumento As Decimal
Dim CvePrePoliza As Integer
Dim ValidaConcepto30 As Boolean = False
If DdlCuenta.SelectedValue.ToEntero <= 0 Then
If UsuarioActual.CveEmpresa <> 126 Then
Alert("Seleccione la Cuenta Bancaria", TipoMensaje.MsgAdvertencia)
DdlPlantilla.SelectedValue = "-1"
Exit Sub
End If
End If
For Each Gvr As GridViewRow In GvMov.Rows
TotalCargos += Gvr.FCTextBox("TxtCargo").Text.ToDecimal
TotalAbonos += Gvr.FCTextBox("TxtAbono").Text.ToDecimal
Next
For Each Gvr As GridViewRow In GvMov.Rows
If Gvr.DataKey("CveConcepto").ToEntero = 30 Then
If Gvr.FCTextBox("TxtAbono").Text.ToDecimal = TxtImporte.Text.ToDecimal Or Gvr.FCTextBox("TxtCargo").Text.ToDecimal = TxtImporte.Text.ToDecimal Then
ValidaConcepto30 = True
End If
End If
Next
If Not ValidaConcepto30 Then
Alert("El importe no coicide con el concepto de bancos.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim filesgral As List(Of Archivo) = Anexo.getfiles().Archivos
Dim filemove As String = ""
Dim Comprobante As String = ""
For Each fileItem As Archivo In filesgral
Comprobante = IO.Path.GetExtension(String.Format("{0}Temp\{1}", AppDomain.CurrentDomain.BaseDirectory, fileItem.filename)).Replace(".", "")
filemove = fileItem.filename
Next
If TotalCargos = TotalAbonos Then
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 CveIE As Integer
Dim MsgError As String = ""
Dim idCuentaContabilizacion As Long = 1
'If ChkContabilizar.Checked AndAlso UsuarioActual.Empresa.UsaContabilidad Then
' Conta = New ClsContPAQi(UsuarioActual.Empresa)
' Conta.IniciaTransacSQL()
' IDPoliza = Conta.AddPoliza(2, TxtObservaciones.Text, TotalCargos, TotalAbonos, UsuarioActual.CveUsuario, TxtFechaDocumento.Text.ToDate)
' 'inserto la póliza
' NumPoliza = Conta.Folio
' If IDPoliza = 0 Then
' MsgError = "No se pudo insertar la póliza contable."
' End If
'End If
If MsgError = "" Then
ImporteDocumento = TxtImporte.Text.ToDecimal
If ImporteDocumento > 0 Then
Try
Dim ConceptoPoliza As String = TxtObservaciones.Text
If ConceptoPoliza = "" Then ConceptoPoliza = TxtPagueseA.Text
Dim CveMoneda As Integer = 1
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
If dr IsNot Nothing Then
CveMoneda = dr("CveMoneda").ToString.ToEntero
End If
Dim TC As Decimal = If(CveMoneda > 1, GlobalTipoCambio(TxtFechaDocumento.Text.ToDate), 1)
Dim CveTipoPoliza As Integer = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla).FiltroPrimeroValor("TipoPoliza", String.Format("CvePlantillaPoliza={0}", DdlPlantilla.SelectedValue)).ToEntero
CvePrePoliza = ObjMov.AddPrePolizas("PolizaCheque/Guardar", DdlPlantilla.SelectedValue.ToEntero, TotalCargos, TotalAbonos, 1, TxtFechaDocumento.Text.ToDate, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=CveTipoPoliza)
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImporteDocumento, CveMoneda, If(CveMoneda > 1, TC, 0.0), TxtObservaciones.Text.Trim, TxtNotificarA.Text.Trim, ChkAbonoCuenta.Checked, True, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
If CveIE > 0 Then
'inserto los movimientos de la conta para abonar al saldo
If CvePrePoliza > 0 Then
Dim alertaContabilizacion As String = "Se enviaron correctamente las siguientes pólizas:<br><br>"
Dim Importe As Double = 0
Dim TipoMovto As Boolean = False
Dim IdCtaContable As Integer = 0
Dim CveProveedor As Integer = -1
'inserto las compras que voy a pagar
For Each gvr As GridViewRow In GvMov.Rows
If gvr.DataKey("IDCuenta").ToEntero > 0 Then
IdCtaContable = gvr.DataKey("IDCuenta")
End If
If gvr.DataKey("TipoMovto").ToDouble > 0 Then
Importe = gvr.FCTextBox("TxtAbono").Text.ToDouble
TipoMovto = True
Else
Importe = gvr.FCTextBox("TxtCargo").Text.ToDouble
TipoMovto = False
End If
CveProveedor = gvr.DataKey("CveProveedor").ToEntero
If HdnCveProveedor.Value.ToEntero > 0 Then CveProveedor = HdnCveProveedor.Value.ToEntero
If Importe <> 0 Then
'If ChkContabilizar.Checked AndAlso UsuarioActual.Empresa.UsaContabilidad Then
' If Not Conta.AddMovimiento(IDPoliza, gvr.DataKey("IDCuenta").ToEntero, TipoMovto, Importe, gvr.FCLiteral("LtlReferencia").Text, gvr.FCTextBox("TxtConcepto").Text, 0, TxtFechaDocumento.Text.ToDate, "") Then
' MsgError = "No se pudo insertar movimiento contable"
' Exit For
' End If
'End If
If MsgError = "" Then
If idCuentaContabilizacion = 1 AndAlso (IdCtaContable = 0) Then
idCuentaContabilizacion = 0
End If
'aplica el ajuste en el concepto 30
Dim Referencia As String = gvr.FCTextBox("TxtConcepto").Text
If gvr.DataKey("CveConcepto").ToEntero = 30 Then
Importe = Importe - TxtAjuste.Text.ToDecimal
Referencia = ObjIE.Folio
ElseIf CveMoneda > 1 Then
Importe = Importe * TC
End If
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, Referencia, gvr.DataKey("CveConcepto").ToEntero, TxtObservaciones.Text, Now, gvr.DataKey("IDCuenta").ToEntero, -1, CveIE, CveProveedor:=CveProveedor, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, ImporteMX:=Importe, CveCuenta:=If(UsuarioActual.Empresa.UsaContabilidad AndAlso UsuarioActual.Empresa.UsaContabilidadSIG, ObtenerCuentaDobleConta(gvr.DataKey("IDCuenta").ToEntero, UsuarioActual.CveEmpresa), -1), TipoCambio:=TC) Then
MsgError = "no se pudo insertar el detalle de la póliza2"
End If
If gvr.DataKey("CveConcepto").ToEntero = 30 Then
If CveMoneda > 1 AndAlso UsuarioActual.CveEmpresa = 119 Then
'Agregamos complementaria
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, 0, gvr.FCTextBox("TxtConcepto").Text, 204, TxtObservaciones.Text, Now, dr("IDCtaContableComplementaria").ToString.ToEntero, -1, CveIE:=CveIE, CveProveedor:=CveProveedor, CveSubProyecto:=gvr.FCDropDownList("DdlSubProyecto").SelectedValue.ToEntero, CvePersonal:=gvr.DataKey("CvePersonal").ToEntero, ImporteMX:=Importe * TC - Importe, ImporteME:=Importe, TipoCambio:=TC) Then
MsgError = "Ocurrió un error al registrar el asiento del ingreso."
End If
End If
End If
End If
End If
Next
If TxtAjuste.Text.ToDecimal <> 0 Then
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtAjuste.Text.ToDecimal, "", 44, TxtObservaciones.Text, Now, -1, -1, CveIE, CveProveedor:=-1, CveSubProyecto:=-1, CvePersonal:=-1, ImporteMX:=TxtAjuste.Text.ToDecimal, TipoCambio:=TC) Then
MsgError = "no se pudo insertar el detalle de la póliza2"
End If
End If
If CvePeriodo > 0 Then
If Not ObjNom.UpdatePagoNomina(CvePeriodo, CveIE, CvePrePoliza, UsuarioActual.CveEmpresa) Then
MsgError = "No se pudo actualizar el periodo de la nómina"
End If
'Generamos el Layout
'GeneraLayout()
End If
Else
MsgError = "No se pudo insertar la póliza"
End If
Else
MsgError = "No se insertó el encabezado"
End If
'If ChkContabilizar.Checked AndAlso UsuarioActual.Empresa.UsaContabilidad Then
' If Not ObjIE.UpdateIEPrePoliza(TxtFechaDocumento.Text.ToDate, NumPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0) Then
' MsgError = "Error al actualizar la poliza"
' End If
'End If
Catch ex As Exception
MsgError = "Error"
End Try
If MsgError = "" Then
If ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, -1) Then
If ObjMov.ValorPolizaDescuadre > 0 Then
' MsgError = ObjMov.MensajePolizaDescuadre
GuardaLogAD($"PolizaCheque/Guardar Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
End If
Else
MsgError = "No se pudo validar la prepoliza de cuadre."
End If
End If
'El movimiento 2 es el de Pago
If UsuarioActual.Empresa.Funcionalidad(200) = "1" And MsgError = "" Then
If idCuentaContabilizacion > 0 Then
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa) Then
'Alert(alertaContabilizacion, ModExtensiones.TipoMensaje.MsgInformacion)
IDPoliza = ObjMov.ContaIdPoliza
Else
MsgError = "Error al contabilizar"
Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
End If
Else
Alert("No se puede contabilizar la Prepoliza debido a que una o mas cuentas son inválidas", TipoMensaje.MsgError)
End If
End If
If MsgError = "" Then
ObjIE.Commit()
'If Conta IsNot Nothing Then Conta.Commit()
If filemove <> "" Then
filemove.FilesMove(CveIE.ToString, String.Format("{0}IE", UsuarioActual.Empresa.Ruta), ConcatenarDirectorioBase:=False)
End If
GeneraChequePDF(CveIE, UsuarioActual.Empresa, IDPoliza)
UPPDocumento.Update()
TxtFolio.Text = ""
TxtObservaciones.Text = ""
GvMov.DataBind()
DdlCuenta.SelectedValue = "-1"
TxtFechaDocumento.Text = ""
TxtImporte.Text = ""
TxtPagueseA.Text = ""
TxtObservaciones.Text = ""
Alert($"El Movimiento se guardo correctamente <br><br> <a href=""/Bancos/IE.aspx?CveIE={CveIE}"" target=""_blank"">Movimiento</a><br/><a href=""/Contabilidad/RegPoliza.aspx?IdPoliza={ObjMov.ContaIdPoliza}"" target=""_blank"">{If(ObjMov.ContaIdPoliza > 0, "Ver Póliza", "")}</a>", TipoMensaje.MsgInformacion, "window.location.reload();")
Else
Alert(MsgError.ToString, TipoMensaje.MsgError)
ObjIE.RollBack()
'If Conta IsNot Nothing Then Conta.RollBack()
End If
Else
Alert("Debe de llevar un importe", TipoMensaje.MsgAdvertencia)
'If Conta IsNot Nothing Then Conta.RollBack()
End If
Else
'If Conta IsNot Nothing Then Conta.RollBack()
End If
ObjIE.Dispose()
ObjMov.Dispose()
ObjNom.Dispose()
'If Conta IsNot Nothing Then Conta.Dispose()
Else
Alert("La suma de los movimientos no son iguales", TipoMensaje.MsgAdvertencia)
End If
End Sub
'' -------------------------------------- codigo para generar la poliza del cheque
'If pIDPoliza > 0 Then
'Dim ObjPoliza As New ClsContPAQi(UsuarioActual.Empresa)
' If ObjPoliza.GetPoliza(pIDPoliza, -1, -1, -1, -1) Then
' dtMovs = ObjPoliza.DtResultados
' End If
' ObjPoliza.Dispose()
' ''Movimientos Póliza
' If dtMovs IsNot Nothing Then
'Dim TotalAbonos, TotalCargos As Double
' TotalAbonos = 0 : TotalCargos = 0
' For Each Row As DataRow In dtMovs.Rows
''Cantidad
''If Row("AplicaParaConcepto").ToString.ToEntero > 0 Then
' Hoja.Range("B" & CeldaF & ": B" & CeldaF).Value = Row("CuentaFormato").ToString
''Unidad
''If Row("AplicaParaConcepto").ToString.ToEntero > 0 Then
' Hoja.Range("C" & CeldaF & ":C" & CeldaF).Value = Row("Nombre").ToString
''Concepto y Descripción
' Hoja.Range("F" & CeldaF & ":F" & CeldaF).Value = If(Row("Cargo").ToString.ToDouble > 0, Row("Cargo").ToString.ToDouble.FormatoNumero, "")
''P Unitario
''Morro el precio unitario si va a ir?
' Hoja.Range("G" & CeldaF & ":G" & CeldaF).Value = If(Row("Abono").ToString.ToDouble > 0, Row("Abono").ToString.ToDouble.FormatoNumero, "")
' TotalCargos += Row("Cargo").ToString.ToDouble
' TotalAbonos += Row("Abono").ToString.ToDouble
' If dtMovs.Rows.Count > 1 AndAlso CeldaF - CeldaI < dtMovs.Rows.Count - 1 Then
' CeldaF = CeldaF + 1
' Libro.Application.Run("AddRow", (CeldaF - 1).ToString, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
' missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing)
' Libro.Save()
' Libro.Application.DisplayAlerts = False
' Libro.Application.ScreenUpdating = False
' End If
' Next
'Dim AddedRow As Integer = CeldaF - CeldaI
' Hoja.Range("F" & (50 + AddedRow).ToString & ":F" & (50 + AddedRow).ToString).Value = TotalCargos.FormatoNumero
' Hoja.Range("G" & (50 + AddedRow).ToString & ":G" & (50 + AddedRow).ToString).Value = TotalAbonos.FormatoNumero
' Hoja.Range("C" & (52 + AddedRow).ToString & ":C" & (52 + AddedRow).ToString).Value = UsuarioRegistro
''Hoja.Range("E" & (13 + AddedRow).ToString & ":E" & (13 + AddedRow).ToString).Value = LblAmortizacion.Text.Trim.ToDouble(TC).FormatoNumero
''Hoja.Range("E" & (14 + AddedRow).ToString & ":E" & (14 + AddedRow).ToString).Value = TxtSubTotal2.Text.Trim.ToDouble(TC).FormatoNumero
''Hoja.Range("E" & (15 + AddedRow).ToString & ":E" & (15 + AddedRow).ToString).Value = TxtIVA.Text.Trim.ToDouble(TC).FormatoNumero
' End If
' End If
'Protected Sub LnkAgregar_Click(sender As Object, e As EventArgs) Handles LnkAgregar.Click
' If HdnCveCuenta.Value.ToEntero = 0 Then
' Alert("Seleccione una cuenta contable")
' Exit Sub
' End If
' If TxtCargoImporte.Text = "" AndAlso TxtAbonoImporte.Text = "" Then
' Alert("Ingrese un importe.")
' Exit Sub
' End If
' If HdnCveCuenta.Value.ToEntero > 0 AndAlso (TxtCargoImporte.Text.ToDouble > 0 Or TxtAbonoImporte.Text.ToDouble > 0) Then
' Dim Cuenta As String = ""
' Dim CodigoCuenta As String = ""
' If DdlCuentaContable.SelectedValue.ToEntero > 0 Then 'DtCuentasContables
' Dim drr As DataRow = DtCuentasContables.FiltroPrimero("Id=" & DdlCuentaContable.SelectedValue)
' If drr IsNot Nothing Then
' CodigoCuenta = drr("CuentaFormato").ToString()
' Cuenta = drr("Nombre").ToString()
' End If
' End If
' Dim dr As DataRow = DtMovimientos.NewRow
' dr("IdCuenta") = HdnCveCuenta.Value.ToEntero
' dr("CodigoCuenta") = CodigoCuenta
' dr("Cuenta") = Cuenta 'TxtCuentaContable.Text
' dr("Referencia") = TxtReferencia.Text
' dr("Concepto") = TxtConceptoContable.Text
' dr("Cargo") = TxtCargoImporte.Text.ToDouble
' dr("Abono") = TxtAbonoImporte.Text.ToDouble
' DtMovimientos.Rows.Add(dr)
' TxtTotalAbonos.Text = DtMovimientos.SUM("Abono").FormatoNumero
' TxtTotalCargos.Text = DtMovimientos.SUM("Cargo").FormatoNumero
' 'ArregloMovs.Add(Mov)
' GvMov.DataSource = DtMovimientos
' GvMov.DataBind()
' 'saco de la póliza el importe del cheque, que coincida la cuenta contable con la bancaria
' If DdlCuenta.SelectedValue.ToEntero > 0 Then
' Dim drr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero("CveCuenta=" & DdlCuenta.SelectedValue)
' If drr IsNot Nothing Then
' TxtImporte.Text = (DtMovimientos.SUM("Abono", "IdCuenta =" & drr("IdCtaContable").ToString) - DtMovimientos.SUM("Cargo", "IdCuenta =" & drr("IdCtaContable").ToString)).ToString.FormatoNumero
' UPPDocumento.Update()
' End If
' End If
' HdnCveCuenta.Value = "0"
' DdlCuentaContable.SelectedValue = "0"
' TxtReferencia.Text = ""
' TxtConceptoContable.Text = ""
' TxtCargoImporte.Text = ""
' TxtAbonoImporte.Text = ""
' End If
'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
If DdlCuenta.SelectedValue.ToEntero > 0 Then
Dim drr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta=" & DdlCuenta.SelectedValue)
If drr IsNot Nothing Then
TxtImporte.Text = DtMovimientos.SUM("Abono", "IdCuenta =" & drr("IdCtaContable").ToString).ToString
UPPDocumento.Update()
End If
End If
End Sub
Private Function IdCuentaBancos(CveCuenta As Integer) As Integer
Dim Retorno As Integer = 0
'saco de la póliza el importe del cheque, que coincida la cuenta contable con la bancaria
If CveCuenta > 0 Then
Dim drr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta=" & CveCuenta)
If drr IsNot Nothing Then
Retorno = drr("IdCtaContable").ToString.ToEntero
End If
End If
Return Retorno
End Function
End Class