Files
SIG/Bancos/PopIECompras.aspx.vb

1861 lines
79 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports Extensiones
Partial Class Bancos_PopIECompras
Inherits ClsPaginas
#Region "Propiedades"
Private Property DtDeudores As DataTable
Get
Return CType(ViewState("DtDeudores"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtDeudores") = value
End Set
End Property
Private Property DtAcreedores As DataTable
Get
Return CType(ViewState("DtAcreedores"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtAcreedores") = value
End Set
End Property
Private Property DtDeudoresDetalle As DataTable
Get
Return CType(ViewState("DtDeudoresDetalle"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtDeudoresDetalle") = value
End Set
End Property
'Configuración
Private Property CveIE As Integer
Get
Return IfNull(ViewState("CveIE"), "0").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveIE") = value
End Set
End Property
Private Property CveCompra As Integer
Get
Return ViewState("CveCompra").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveCompra") = value
End Set
End Property
Private Property CveTipoConcepto As Integer
Get
Return ViewState("CveTipoConcepto").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveTipoConcepto") = value
End Set
End Property
Private Property IdPoliza As Integer
Get
Return ViewState("IdPoliza").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdPoliza") = value
End Set
End Property
Private Property FechaCompra As Date
Get
Return ViewState("FechaCompra").ToString.ToDate
End Get
Set(value As Date)
ViewState("FechaCompra") = value
End Set
End Property
Private Property CveProveedor As Integer
Get
Return ViewState("CveProveedor").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveProveedor") = value
End Set
End Property
Private ReadOnly Property CtaProveedor As Integer
Get
Return ViewState("CtaProveedor").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CtaProveedorDeudores As Integer
Get
Return ViewState("CtaProveedorDeudores").ToString.ToEntero
End Get
End Property
Private ReadOnly Property CtaProveedorAcreedores As Integer
Get
Return ViewState("CtaProveedorAcreedores").ToString.ToEntero
End Get
End Property
Private Property IdCuentaBancaria As Integer
Get
Return ViewState("IdCuentaBancaria").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdCuentaBancaria") = value
End Set
End Property
Private Property IdCuentaBancariaComplementaria As Integer
Get
Return ViewState("IdCuentaBancariaComplementaria").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdCuentaBancariaComplementaria") = value
End Set
End Property
Private ReadOnly Property IdCtaContMonedaExtranjera As Integer
Get
Return ViewState("IdCtaContMonedaExtranjera").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContComplementaria As Integer
Get
Return ViewState("IdCtaContComplementaria").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaProveedorExtranjera As Integer
Get
Return ViewState("IdCtaProveedorExtranjera").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetIVA As Integer
Get
Return ViewState("IdCtaContRetIVA").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetISR As Integer
Get
Return ViewState("IdCtaContRetISR").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetIVAAcreditable As Integer
Get
Return ViewState("IdCtaContRetIVAAcreditable").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContRetISRAcreditable As Integer
Get
Return ViewState("IdCtaContRetISRAcreditable").ToString.ToEntero
End Get
End Property
Private Property CveMoneda As Integer
Get
Return ViewState("CveMoneda").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMoneda") = value
End Set
End Property
Private Property TipoTransaccion As String
Get
Return ViewState("TipoTransaccion").ToString
End Get
Set(value As String)
ViewState("TipoTransaccion") = value
End Set
End Property
Private Property SaldoVenta As Decimal
Get
Return ViewState("SaldoVenta").ToString.ToDecimal
End Get
Set(value As Decimal)
ViewState("SaldoVenta") = value
End Set
End Property
Private Property MovimientoPagar As IEMovimiento
Get
Return CType(ViewState("MovimientoPagar"), IEMovimiento)
End Get
Set(value As IEMovimiento)
ViewState("MovimientoPagar") = value
End Set
End Property
Private Property CompraActual As Compra
Get
Return CType(ViewState("CompraActual"), Compra)
End Get
Set(value As Compra)
ViewState("CompraActual") = value
End Set
End Property
Private Property ArrIE As ArrayList
Get
Return CType(ViewState("ArrIE"), ArrayList)
End Get
Set(value As ArrayList)
ViewState("ArrIE") = value
End Set
End Property
Private Property ArrIEFuncionariosEmpleados As ArrayList
Get
Return CType(ViewState("ArrIEFuncionariosEmpleados"), ArrayList)
End Get
Set(value As ArrayList)
ViewState("ArrIEFuncionariosEmpleados") = value
End Set
End Property
Private Property DTFuncionarioEmpleado As DataTable
Get
Return CType(ViewState("DTFuncionarioEmpleado"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTFuncionarioEmpleado") = value
End Set
End Property
Private Property NombreProveedor As String
Get
Return ViewState("NombreProveedor").ToString
End Get
Set(value As String)
ViewState("NombreProveedor") = value
End Set
End Property
Private Property SerieFolio As String
Get
Return ViewState("SerieFolio").ToString
End Get
Set(value As String)
ViewState("SerieFolio") = value
End Set
End Property
Private Property CveMonedaCompra As Integer
Get
Return ViewState("CveMonedaVenta").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMonedaVenta") = value
End Set
End Property
Private Property TipoCambioOriginal As Decimal
Get
Return ViewState("TipoCambioOriginal").ToString.ToDecimal
End Get
Set(value As Decimal)
ViewState("TipoCambioOriginal") = value
End Set
End Property
<Serializable>
Public Class Anticipos
Public Property CveIE As Integer
Public Property Importe As Decimal
Public Property CvePersonal As Integer
End Class
<Serializable>
Public Class IEMovimiento
Public Property SubTotal As Decimal
Public Property IVA As Decimal
Public Property IVADeducible As Decimal
Public Property IVANoDeducible As Decimal
Public Property RetIVA As Decimal
Public Property RetISR As Decimal
Public Property Total As Decimal
Public Property Saldo As Decimal
Public Property IEPS As Decimal
Public Property ConceptoRetIVA As Integer
Public Property ConceptoRetISR As Integer
Public Property PorcentajeIVA As Decimal
Public Property IVAPorPagar As Decimal
End Class
Private Property CveMonedaFiltros As Integer
Get
Return ViewState("CveMonedaFiltros").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("CveMonedaFiltros") = value
End Set
End Property
Private Property RFCProveedor As String
Get
Return ViewState("RFCProveedor").ToString
End Get
Set(value As String)
ViewState("RFCProveedor") = value
End Set
End Property
Private Property IdCuentaCliente As Integer
Get
Return ViewState("IdCuentaCliente").ToString.ToEntero
End Get
Set(value As Integer)
ViewState("IdCuentaCliente") = value
End Set
End Property
Private ReadOnly Property IdCtaContRetIVACliente As Integer
Get
Return ViewState("IdCtaContRetIVACliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContComplementariaCliente As Integer
Get
Return ViewState("IdCtaContComplementariaCliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property IdCtaContMonedaExtranjeraCliente As Integer
Get
Return ViewState("IdCtaContMonedaExtranjeraCliente").ToString.ToEntero
End Get
End Property
Private ReadOnly Property NombreCliente As String
Get
Return ViewState("NombreCliente").ToString
End Get
End Property
Private Property NotificarA As String
Get
If ViewState("NotificarA") Is Nothing Then
Return ""
Else
Return ViewState("NotificarA").ToString
End If
End Get
Set(value As String)
ViewState("NotificarA") = value
End Set
End Property
Private Property CveSubProyecto As Integer
Get
If ViewState("CveSubProyecto") Is Nothing Then
Return -1
Else
Return ViewState("CveSubProyecto").ToString.ToEntero
End If
End Get
Set(value As Integer)
ViewState("CveSubProyecto") = value
End Set
End Property
Private Property EsImportacion As Boolean
Get
If ViewState("EsImportacion") Is Nothing Then
Return False
Else
Return CBool(ViewState("EsImportacion"))
End If
End Get
Set(value As Boolean)
ViewState("EsImportacion") = value
End Set
End Property
Private Property DtCheques As DataTable
Get
If ViewState("DtCheques") Is Nothing Then
ViewState("DtCheques") = New DataTable
End If
Return CType(ViewState("DtCheques"), DataTable)
End Get
Set(value As DataTable)
ViewState("DtCheques") = value
End Set
End Property
#End Region
Private Sub Bancos_PopIECompras_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
If Not UsuarioActual.Empresa.UsaAC Then
ViewState("IdCtaContMonedaExtranjera") = 0
ViewState("IdCtaContComplementaria") = 0
ViewState("IdCtaContRetIVA") = 0
ViewState("IdCtaContRetISR") = 0
ViewState("IdCuentaBancaria") = 0
ViewState("IdCuentaBancariaComplementaria") = 0
ViewState("IdCtaAnticipo") = 0
ViewState("CtaProveedorDeudores") = 0
ViewState("CtaProveedorAcreedores") = 0
ViewState("CveCuentaProveedorDeudores") = 0
ViewState("NombreProveedor") = ""
End If
CType(Me.Master, BaseMasterPage).EsPopup = True
CType(Me.Master, BaseMasterPage).PopupWidth = 750
RegistraScript("$get('tdContenido').style.height='350px'")
CveProveedor = -1
CveCompra = -1
CveTipoConcepto = 1
IdPoliza = -1
CveMoneda = 0
TipoTransaccion = "Egs"
MovimientoPagar = Nothing
ArrIE = New ArrayList()
ArrIEFuncionariosEmpleados = New ArrayList()
RFCProveedor = ""
TxtFechaDocumento.Text = Now.ToShortDateString
If Request("CveProveedor") IsNot Nothing Then
HdnCveProveedor.Value = Request("CveProveedor").ToString
CveProveedor = Request("CveProveedor").ToString.ToEntero
End If
If Request("CveCompra") IsNot Nothing AndAlso IsNumeric(Request("CveCompra")) AndAlso Request("CveCompra").ToEntero > 0 Then
CveCompra = Request("CveCompra").ToEntero
CargaCompra(CveCompra)
End If
If UsuarioActual.CveEmpresa.Contiene(4, 7, 11, 12, 72, 80) Then
rowComisiones.Visible = True
End If
'SI USUARIO USA AMORTIZACIÓN CONTABLE
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaAC Then
Dim AC As New ClsAC
If AC.GetPresupuestoIngresos(-1, -1, True, UsuarioActual.CveEmpresa) Then
DdlFuenteRecaudacion.DataSource = AC.DtResultados()
DdlFuenteRecaudacion.DataBind()
ViewState("DTFuenteRecaudacion") = AC.DtResultados()
End If
TrFR.Visible = True
AC.Dispose()
End If
CargaTipoTransaccion(TipoTransaccion)
CargaCuentas()
Dim ObjVentas As New ClsVentas
If ObjVentas.GetVentas(UsuarioActual.CveEmpresa, "-1", "-1", -1, "-1", -1, -1, -1, -1, "-1", "-1", "-1", ClienteRFC:=RFCProveedor, CveUsuarioConsulta:=UsuarioActual.CveUsuario) Then
RBLContado.Items(4).Enabled = True
End If
ObjVentas.Dispose()
If CveMoneda = 2 Then
ChkPagarPesos.Visible = True
TxtTipoCambio.Text = GlobalTipoCambio(Now).FormatoNumero(4)
Else
ChkPagarDolares.Visible = True
TxtTipoCambio.Text = GlobalTipoCambio(Now).FormatoNumero(4)
End If
UpDatos.Update()
End If
End Sub
#Region "C A M B I A R P A N E L"
Private Sub RBLContado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBLContado.SelectedIndexChanged
Select Case RBLContado.SelectedValue
Case "1" ' Bancos
PanelBancos.Visible = True
PanelFyE.Visible = False
PanelIngresos.Visible = False
PanelDeudores.Visible = False
PanelAcreedores.Visible = False
PanelVentas.Visible = False
TxtImporte.Text = SaldoVenta.FormatoNumero
Case "2" ' F y E
PanelBancos.Visible = False
PanelFyE.Visible = True
PanelIngresos.Visible = False
PanelDeudores.Visible = False
PanelAcreedores.Visible = False
PanelVentas.Visible = False
CargaFuncionariosEmpleados()
TxtImporte.Text = SaldoVenta.FormatoNumero
Case "3" 'Ingresos x Comprobar
PanelBancos.Visible = False
PanelFyE.Visible = False
PanelIngresos.Visible = True
PanelDeudores.Visible = False
PanelAcreedores.Visible = False
PanelVentas.Visible = False
CargaOtrosIngresos(CveMoneda)
TxtImporte.Text = "0.00"
Case "4" 'Deudores
PanelBancos.Visible = False
PanelFyE.Visible = False
PanelIngresos.Visible = False
PanelDeudores.Visible = True
PanelAcreedores.Visible = False
PanelVentas.Visible = False
CargaDeudores(CveMoneda)
TxtImporte.Text = "0.00"
Case "5" ' Acreedores
PanelBancos.Visible = False
PanelFyE.Visible = False
PanelIngresos.Visible = False
PanelDeudores.Visible = False
PanelAcreedores.Visible = True
PanelVentas.Visible = False
CargaAcreedores(CveMoneda)
Case "6" 'Ventas
PanelBancos.Visible = False
PanelFyE.Visible = False
PanelIngresos.Visible = False
PanelDeudores.Visible = False
PanelAcreedores.Visible = False
PanelVentas.Visible = True
CargaVentas(CveMoneda)
TxtImporte.Text = "0.00"
End Select
End Sub
#End Region
#Region "C A R G A R I N F O R M A C I O N"
Private Sub CargaCompra(pCveCompra As Integer)
Dim ObjCompra As New ClsCompras()
If ObjCompra.GetCompras(pCveCompra, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa) Then
If ObjCompra.DtResultados IsNot Nothing AndAlso ObjCompra.DtResultados.Rows.Count > 0 Then
Dim dr As DataRow = ObjCompra.DtResultados.Rows(0)
If UsuarioActual.Empresa.Funcionalidad(306) = "1" And dr("AplicaNotaCredito").ToString = "True" Then
BtnGuardar.Enabled = False
LbNANota.Visible = True
End If
'Datos Generales de la Compra
FechaCompra = dr("Fecha").ToString.ToDate
Dim Validada As Boolean = False
If Not UsuarioActual.Empresa.Funcionalidad(529) = "1" Then
'verificacion doble, si no la han cancelado, ya tiene una validaci[on para que llegue aqui
Dim Valida As New ClsValidaCFDi(dr("UUID").ToString(), dr("RFC").ToString, UsuarioActual.Empresa.RFC, dr("Total").ToString.ToDecimal)
If Valida.EsValida > 0 Then
If Valida.EsValida = 2 Then
Validada = False
'Dim ObjDatos As New ClsCompras
'If ObjDatos.UpdateEstatus(Valida.EsValida, gvr.DataKey("CveFactura").ToEntero) Then
'End If
'ObjDatos.Dispose()
BtnGuardar.Enabled = False
If UsuarioActual.Empresa.UsaAC Then
RegistraScript("if (confirm('La factura está cancelada ante el SAT., ¿Desea eliminar la compra?')) { $get('BtnEliminarCompra').click();}")
Else
Alert("La factura está cancelada ante el SAT.", TipoMensaje.MsgError)
End If
Else
Validada = True
End If
Else
'no se pudo validar, pero ya tuvo la primera vuelta de validacion
Validada = True
End If
Valida.Dispose()
Else
Validada = True
End If
'CargaProveedor
CveProveedor = dr("CveProveedor").ToString.ToEntero
HdnCveProveedor.Value = CveProveedor.ToString
CargaProveedor(CveProveedor, "-1")
CveMoneda = dr("CveMoneda").ToString.ToEntero
CveTipoConcepto = dr("CveTipoConcepto").ToString.ToEntero
CveMonedaCompra = dr("CveMoneda").ToString.ToEntero
CveMonedaFiltros = dr("CveMoneda").ToString.ToEntero
SerieFolio = dr("SerieFolio").ToString
TipoCambioOriginal = dr("TipoCambioOriginal").ToString.ToDecimal
NombreProveedor = dr("RazonSocial").ToString 'GlobalDTCompProveedores(UsuarioActual.CveEmpresa).FiltroPrimeroValor("RazonSocial", String.Format("CveProveedor = {0}", CveProveedor))
CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero
LtlTitulo.Text = "Cuentas por Pagar"
LtlTipo2.Text = "Folio"
LtlTipo3.Text = "Fecha"
LtlFechaVenta.Text = dr("Fecha").ToString.ToDate.ToShortDateString()
LtlFolio.Text = dr("SerieFolio").ToString
LtlSaldo.Text = If(CveMoneda = 1, $"{dr("Saldo").ToString.FormatoNumero}{" MXN"}", $"{dr("Saldo").ToString.FormatoNumero}{" USD"}")
'Configuración de Modalidad Update
MovimientoPagar = New IEMovimiento
MovimientoPagar.SubTotal = dr("SubTotal").ToString.ToDecimal
MovimientoPagar.IVA = dr("IVA").ToString.ToDecimal
MovimientoPagar.IVADeducible = dr("IVADeducible").ToString.ToDecimal.RoundSQL
MovimientoPagar.IVANoDeducible = dr("IVANoDeducible").ToString.ToDecimal.RoundSQL
MovimientoPagar.RetIVA = dr("RetIVA").ToString.ToDecimal
MovimientoPagar.RetISR = dr("RetISR").ToString.ToDecimal
MovimientoPagar.Total = dr("Total").ToString.ToDecimal
MovimientoPagar.Saldo = dr("Saldo").ToString.ToDecimal
MovimientoPagar.IEPS = dr("IEPS").ToString.ToDecimal
MovimientoPagar.ConceptoRetIVA = dr("CveRetIVAConcepto").ToString.ToEntero
MovimientoPagar.ConceptoRetISR = dr("CveRetISRConcepto").ToString.ToEntero
MovimientoPagar.PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal
MovimientoPagar.IVAPorPagar = dr("IVAPorPagar").ToString.ToDecimal
CompraActual = New Compra
CompraActual.CveCompra = CveCompra
CompraActual.CveTipoConceptoProveedor = dr("CveTipoConcepto").ToString.ToEntero
CompraActual.CveProveedor = dr("CveProveedor").ToString.ToEntero
CompraActual.CveMoneda = dr("CveMoneda").ToString.ToEntero
CompraActual.Fecha = dr("Fecha").ToString.ToDate
CompraActual.SerieFolio = dr("SerieFolio").ToString
CompraActual.ProveedorNombre = TxtPagueseA.Text
CompraActual.TC = dr("TipoCambio").ToString.ToDecimal
CompraActual.Total = dr("Total").ToString.ToDecimal
CompraActual.IVA = dr("IVA").ToString.ToDecimal
CompraActual.IVADeducible = dr("IVADeducible").ToString.ToDecimal.RoundSQL
CompraActual.IVANoDeducible = dr("IVANoDeducible").ToString.ToDecimal.RoundSQL
CompraActual.IEPS = dr("IEPS").ToString.ToDecimal
CompraActual.RetIVA = dr("RetIVA").ToString.ToDecimal
CompraActual.RetISR = dr("RetISR").ToString.ToDecimal
CompraActual.CveConceptoRetISR = dr("CveRetIVAConcepto").ToString.ToEntero
CompraActual.CveConceptoRetIVA = dr("CveRetISRConcepto").ToString.ToEntero
CompraActual.PorcentajeIVA = dr("PorcentajeIVA").ToString.ToDecimal
CompraActual.UsuarioActual = UsuarioActual
CompraActual.CveSubProyecto = dr("CveSubProyecto").ToString.ToEntero
CompraActual.IdCtaContableProv = CtaProveedor
CompraActual.IdCtaContableProvComplementaria = IdCtaProveedorExtranjera
CompraActual.EsImportacion = CBool(dr("EsImportacion"))
If Validada Then
TxtFolio.Enabled = True
TxtFechaDocumento.Enabled = True
Calendario.Enabled = True
TxtPagueseA.Enabled = False
TxtImporte.Enabled = True
DdlCuenta.Enabled = True
DdlTipoTransaccion.Enabled = True
TxtObservaciones.Enabled = True
BtnGuardar.Visible = True
'RVImporte.Enabled = True
'RVImporte.Enabled = True
'RVImporte.MaximumValue = dr("Saldo").ToString.ToDecimal.ToString.FormatoNumero
TxtImporte.Text = dr("Saldo").ToString.ToDecimal.FormatoNumero
SaldoVenta = dr("Saldo").ToString.ToDecimal
EsImportacion = CBool(dr("EsImportacion"))
End If
End If
End If
ObjCompra.Dispose()
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
RFCProveedor = ObjProveedor.RFC
'Conta ContPAQ
ViewState("CtaProveedor") = ObjProveedor.IdCtaContProveedores
ViewState("CtaProveedorDeudores") = ObjProveedor.IdCtaContDeudor
ViewState("CtaProveedorAcreedores") = ObjProveedor.IdCtaContAcreedor
ViewState("IdCtaContRetISR") = ObjProveedor.IdCtaContRetISR
ViewState("IdCtaContRetISRAcreditable") = ObjProveedor.IdCtaContRetISRAcreditable
ViewState("IdCtaContRetIVA") = ObjProveedor.IdCtaContRetIVA
ViewState("IdCtaContRetIVAAcreditable") = ObjProveedor.IdCtaContRetIVAAcreditable
ViewState("IdCtaProveedorExtranjera") = ObjProveedor.IdCtaContProveedoresExtranjera
ViewState("IdCtaContComplementaria") = ObjProveedor.IdCtaContProveedoresComplementaria
Else
Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
End If
End If
ObjProveedor.Dispose()
End Sub
Private Sub CargaTipoTransaccion(Optional Tipo As String = "Egs")
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros(String.Format("Tipo = '{0}'", Tipo))
DdlTipoTransaccion.DataBind()
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
End Sub
Private Sub CargaCuentas()
DdlCuenta.Items.Clear()
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
'dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda))
If ChkPagarPesos.Checked Then
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 1))
RegistraScript("CambiaPesosDolares();")
ElseIf ChkPagarDolares.Checked Then
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", 2))
RegistraScript("CambiaDolaresPesos();")
Else
If CveMoneda > 0 Then
dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda))
End If
End If
DdlCuenta.DataSource = dt
DdlCuenta.DataBind()
DdlCuenta.Items.Insert(0, New ListItem("Seleccione cuenta", "-1"))
End Sub
Private Sub CargaGridTarjetas()
Dim ObjCreditos As New ClsBancos
ObjCreditos.GetTarjetasCreditos(DdlCuenta.SelectedValue.ToEntero)
DdlTarjeta.Items.Clear()
DdlTarjeta.DataSource = ObjCreditos.DtResultados
DdlTarjeta.DataBind()
DdlTarjeta.Items.Insert(0, New ListItem("Seleccione", "-1"))
ObjCreditos.Dispose()
DivTarjeta.Visible = True
End Sub
Protected Sub CargaFuncionariosEmpleados()
If CveCompra > 0 Then
Dim objGastosXComprobar As New ClsMovimientos
If objGastosXComprobar.GetEgresosSinComprobarPersonal(UsuarioActual.CveEmpresa) Then
'TRATAR DE HACERLO CON LINQ
DTFuncionarioEmpleado = New DataTable
DTFuncionarioEmpleado.Columns.Add("CvePersonal", GetType(Integer))
DTFuncionarioEmpleado.Columns.Add("NombreCompleto", GetType(String))
DTFuncionarioEmpleado.Columns.Add("CveIE", GetType(String))
For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros($"CvePersonal > 0 AND CveMoneda = {CveMoneda}", "NombreCompleto").Rows
Dim RowFE As DataRow = Nothing
RowFE = DTFuncionarioEmpleado.NewRow()
RowFE("CvePersonal") = Row("CvePersonal").ToString.ToEntero
RowFE("NombreCompleto") = String.Format("{0} - ${1}", Row("NombreCompleto").ToString.Trim, Row("Saldo").ToString.FormatoNumero(2))
RowFE("CveIE") = Row("CveIE").ToString
DTFuncionarioEmpleado.Rows.Add(RowFE)
Next
DdlFuncionarioEmpleado.DataSource = DTFuncionarioEmpleado
DdlFuncionarioEmpleado.DataBind()
DdlFuncionarioEmpleado.Items.Insert(0, New ListItem("Seleccione", "-1"))
End If
objGastosXComprobar.Dispose()
End If
End Sub
Protected Sub CargaOtrosIngresos(Optional CveMoneda As Integer = 1)
Dim IngresosXcomprobar As New ClsMovimientos
DdlIngreso.Items.Clear()
If IngresosXcomprobar.GetIngresosSaldos(-1, UsuarioActual.CveEmpresa) Then
DtDeudores = IngresosXcomprobar.DtResultados.FiltraParametros($"CveCliente > 0 AND Saldo > 0 AND CveMoneda = {CveMoneda}")
DdlIngreso.DataSource = DtDeudores
DdlIngreso.DataBind()
DdlIngreso.Items.Insert(0, New ListItem("Seleccione Ingreso", "-1"))
UpDatos.Update()
CambieIngreso()
End If
IngresosXcomprobar.Dispose()
End Sub
Protected Sub CargaDeudores(Optional CveMoneda As Integer = 1)
Dim Deudores As New ClsMovimientos
DdlDeudor.Items.Clear()
If CveCompra > 0 Then
If Deudores.GetDeudoresSaldos2(-1, UsuarioActual.CveEmpresa) Then
DtDeudores = Deudores.DtResultados.FiltraParametros($"CveProveedor > 0 AND Saldo > 0 AND CveMoneda = {CveMoneda}")
DdlDeudor.DataSource = DtDeudores
DdlDeudor.DataBind()
DdlDeudor.Items.Insert(0, New ListItem("Seleccione Deudor", "-1"))
UpDatos.Update()
CambieDeudor()
End If
End If
Deudores.Dispose()
End Sub
Protected Sub CargaAcreedores(Optional CveMoneda As Integer = 1)
Dim ObjMov As New ClsMovimientos
If ObjMov.GetAcreedoresSaldos(-1, UsuarioActual.CveEmpresa) Then
DtAcreedores = ObjMov.DtResultados.FiltraParametros($"CveProveedor > 0 AND CveMoneda = {CveMoneda}")
DdlAcreedor.DataSource = DtAcreedores
DdlAcreedor.DataBind()
DdlAcreedor.Items.Insert(0, New ListItem("Seleccione Acreedor", "-1"))
UpDatos.Update()
CambieAcreedor()
End If
ObjMov.Dispose()
End Sub
Protected Sub CargaVentas(Optional CveMoneda As Integer = 1)
Dim ObjMovtos As New ClsMovimientos
Dim dtc As DataTable = GlobalDTCliente(UsuarioActual.CveEmpresa).FiltraParametros(String.Format("RFC = '{0}'", RFCProveedor))
If dtc IsNot Nothing AndAlso dtc.Rows.Count = 1 Then
Dim CveCliente As Integer = dtc.Rows(0)("CveCliente").ToString.ToEntero
ViewState("IdCuentaCliente") = dtc.Rows(0)("IdCtaContClientes")
ViewState("IdCtaContRetIVACliente") = dtc.Rows(0)("IdCtaContRetIVA")
ViewState("IdCtaContRetISRCliente") = dtc.Rows(0)("IdCtaContRetISR")
ViewState("IdCtaContComplementariaCliente") = dtc.Rows(0)("IdCtaContComplementaria")
ViewState("IdCtaContMonedaExtranjeraCliente") = dtc.Rows(0)("IdCtaContMonedaExtranjera")
ViewState("NombreCliente") = dtc.Rows(0)("Nombre")
If ObjMovtos.GetCxCClienteDetalle(CveCliente, "-1", "-1", -1, -1, UsuarioActual.CveEmpresa, -1) Then
GvVentas.DataSource = ObjMovtos.DtResultados.FiltraParametros($" Saldo > 0 AND CveVenta > 0 AND CveMoneda = {CveMoneda}")
End If
End If
ObjMovtos.Dispose()
GvVentas.DataBind()
UpDatos.Update()
End Sub
Private Sub CambieIngreso()
Dim stringDeudor As String = DdlIngreso.SelectedItem.ToString
Dim SaldoD As Decimal = stringDeudor.Substring(stringDeudor.IndexOf("$") + 1, stringDeudor.Length - (stringDeudor.IndexOf("$") + 1)).ToDecimal
If DdlIngreso.SelectedValue.ToEntero > 0 Then
Dim Deudores As New ClsMovimientos
If Deudores.GetIngresosSaldosDetalle(DdlIngreso.SelectedValue.ToEntero, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then
DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveCliente > 0 AND Saldo > 0")
GvIngresos.DataSource = DtDeudoresDetalle
GvIngresos.DataBind()
End If
Deudores.Dispose()
Else
GvIngresos.DataSource = Nothing
GvIngresos.DataBind()
End If
UpIngresos.Update()
End Sub
Private Sub CambieDeudor()
Dim stringDeudor As String = DdlDeudor.SelectedItem.ToString
Dim SaldoD As Decimal = stringDeudor.Substring(stringDeudor.IndexOf("$") + 1, stringDeudor.Length - (stringDeudor.IndexOf("$") + 1)).ToDecimal
If DdlDeudor.SelectedValue.ToEntero > 0 Then
Dim Deudores As New ClsMovimientos
Dim OpcionSaldo As Integer = 1
If Deudores.GetDeudoresSaldosDetalle(DdlDeudor.SelectedValue.ToEntero, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then
DtDeudoresDetalle = Deudores.DtResultados.FiltraParametros("CveProveedor > 0 AND Saldo > 0")
GvDeudores.DataSource = DtDeudoresDetalle
GvDeudores.DataBind()
End If
Deudores.Dispose()
Else
GvDeudores.DataSource = Nothing
GvDeudores.DataBind()
End If
UpDeudores.Update()
End Sub
Private Sub CambieAcreedor()
If DdlAcreedor.SelectedValue.ToEntero > 0 Then
Dim dr As DataRow
dr = DtAcreedores.FiltroPrimero(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue))
If dr IsNot Nothing Then
Dim tSaldo As Decimal = dr("Saldo").ToString.ToDecimal
'si el saldo es mayor de la compra poner el valor de la compra sino el valor del saldo
TxtImporte.Text = If(tSaldo > TxtTotal.Text.ToDecimal, TxtTotal.Text, tSaldo.ToString).FormatoNumero
Dim ObjMov As New ClsMovimientos
If ObjMov.GetAcreedoresSaldosDetalles(-1, CveMonedaFiltros, UsuarioActual.CveEmpresa) Then
GvAcreedores.DataSource = ObjMov.DtResultados.FiltraParametros(String.Format("CveProveedor = {0}", DdlAcreedor.SelectedValue))
GvAcreedores.DataBind()
End If
ObjMov.Dispose()
End If
Else
GvAcreedores.DataSource = Nothing
GvAcreedores.DataBind()
End If
UpAcreedores.Update()
End Sub
Private Sub CargaCuentasDepositos()
DdlCuentaDeposito.Items.Clear()
If DdlTipoTransaccion.SelectedValue.Contiene("2", "9", "17") Then ' transferencias y layout
trCuentaDeposito.Visible = False
Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor)
If dtc IsNot Nothing Then
If DdlTipoTransaccion.SelectedValue = "9" Then
DdlCuentaDeposito.DataSource = dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'")
If dtc.FiltraParametros("EstatusPagoElectronico = 'True' AND Estatus ='True'").Rows.Count > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
Else
BtnGuardar.Enabled = False
Alert("El Beneficiario no tiene una cuenta activa en BBVA, dela de alta o seleccione otro método de pago", TipoMensaje.MsgAdvertencia)
End If
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
ElseIf DdlTipoTransaccion.SelectedValue = "17" Then
If dtc.Rows.Count > 0 Then
DdlCuentaDeposito.DataSource = dtc
trCuentaDeposito.Visible = True
BtnGuardar.ToolTip = ""
Else
BtnGuardar.Enabled = False
BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
End If
UpGuardar.Update()
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
Else
DdlCuentaDeposito.DataSource = dtc.FiltraParametros("Estatus ='True'")
If dtc.Rows.Count > 0 Then
trCuentaDeposito.Visible = True
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
End If
End If
Else
If DdlTipoTransaccion.SelectedValue.Contiene("9", "17") Then
BtnGuardar.Enabled = False
BtnGuardar.ToolTip = "El proveedor no tiene cuentas deposito"
Else
trCuentaDeposito.Visible = True
BtnGuardar.Enabled = True
BtnGuardar.ToolTip = ""
End If
UpGuardar.Update()
End If
DdlCuentaDeposito.DataBind()
Else
trCuentaDeposito.Visible = False
DdlCuentaDeposito.Items.Clear()
'TrReferenciaCIE.Visible = False
End If
UpCuentaDeposito.Update()
End Sub
#End Region
#Region "DDL'S CHANGED"
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
Select Case valor
Case 1
LblPagueseA.Text = "Páguese a"
Case 2
LblPagueseA.Text = "Beneficiario"
End Select
CargaCuentas()
CargaCuentasDepositos()
UpDatos.Update()
End Sub
Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
Dim Folio As Long
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta = " & DdlCuenta.SelectedValue)
Dim TCveMoneda = -1
If dr IsNot Nothing Then
If ChkPagarPesos.Checked Then
CveMoneda = 1
RegistraScript("CambiaPesosDolares();")
Else
CveMoneda = dr("CveMoneda").ToString.ToEntero
RegistraScript("CambiaDolaresPesos();")
End If
IdCuentaBancaria = dr("IdCtaContable").ToString.ToEntero
IdCuentaBancariaComplementaria = dr("IdCtaContableComplementaria").ToString.ToEntero
If dr("UsaTarjeta").ToString = "True" Then
CargaGridTarjetas()
Else
DivTarjeta.Visible = False
End If
End If
If UsuarioActual.Empresa.Funcionalidad(505) <> "1" Then
Dim Banco As New ClsBancos
Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero)
TxtFolio.Text = Folio.ToString
Banco.Dispose()
End If
End Sub
Private Sub DdlOtrosPagos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlOtrosPagos.SelectedIndexChanged
Dim EsOtrosEgresos As Boolean = (DdlOtrosPagos.SelectedValue.Equals("2"))
rowComision.Visible = EsOtrosEgresos
rowTotal.Visible = EsOtrosEgresos
TxtComision.Text = "0.00"
TxtTotal.Text = TxtImporte.Text
End Sub
Protected Sub DdlFuncionarioEmpleado_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFuncionarioEmpleado.SelectedIndexChanged
ArrIEFuncionariosEmpleados = New ArrayList()
ArrIE = New ArrayList()
DtCheques = New DataTable
'Dim objGastosXComprobar As New ClsMovimientos
Dim CvePersonal As Integer = DdlFuncionarioEmpleado.SelectedValue.ToEntero
'If objGastosXComprobar.GetEgresosSinComprobarPersonal(UsuarioActual.CveEmpresa) Then
'For Each Row As DataRow In objGastosXComprobar.DtResultados.FiltraParametros("CvePersonal > 0 AND FechaDocumento IS NOT NULL").Rows
' ArrIE.Add(New Anticipos With {.CveIE = Row("CveIE").ToString.ToEntero, .Importe = Row("Saldo").ToString.ToDecimal, .CvePersonal = Row("CvePersonal").ToString.ToEntero})
'Next
Dim ObjMovtos As New ClsMovimientos
RowCheque.Visible = True
ObjMovtos.GetEgresosSinComprobarPersonalDetalle(DdlFuncionarioEmpleado.SelectedValue.ToEntero, UsuarioActual.CveEmpresa)
DtCheques = ObjMovtos.DtResultados.FiltraParametros("CveIE > 0", "FechaDocumento, FolioFecha")
'Limpia Ddl Cheques
DDlCheques.Items.Clear()
If DtCheques.Rows.Count > 0 Then
DDlCheques.DataSource = DtCheques
End If
ObjMovtos.Dispose()
DDlCheques.DataBind()
'EstaAsociadoAPersonal = True
DDlCheques_SelectedIndexChanged(DDlCheques, EventArgs.Empty)
UpDatos.Update()
'End If
End Sub
Protected Sub DDlCheques_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DDlCheques.SelectedIndexChanged
'Dim saldo As Double = DtCheques.Rows(DDlCheques.SelectedIndex)("Saldo").ToString.ToDecimal
Dim saldo As Double = DtCheques.Rows(DDlCheques.SelectedIndex)("Saldo").ToString.ToDecimal
'TxtDocumentoImporteFE.Text = If(saldo < TxtTotal.Text.ToDouble, saldo.FormatoNumero, TxtTotal.Text)
'lblSaldoFE.Text = saldo.FormatoNumero
If CveCompra > 0 Then
'Dim tSaldo As Decimal = DdlFuncionarioEmpleado.SelectedItem.Text.Split(CChar("-"))(1).ToDecimal
If saldo < MovimientoPagar.Saldo Then
TxtImporte.Text = saldo.FormatoNumero()
Else
TxtImporte.Text = MovimientoPagar.Saldo.FormatoNumero()
End If
End If
UpDatos.Update()
End Sub
Private Sub DdlIngreso_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlIngreso.SelectedIndexChanged
CambieIngreso()
End Sub
Private Sub DdlDeudor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlDeudor.SelectedIndexChanged
CambieDeudor()
End Sub
Private Sub DdlAcreedor_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlAcreedor.SelectedIndexChanged
CambieAcreedor()
End Sub
#End Region
#Region "CHK TIPO CAMBIO"
#Region "PAGAR CON PESOS"
Protected Sub ChkPagarPesos_CheckedChanged(sender As Object, e As EventArgs)
If ChkPagarPesos.Checked Then
DivTipoCambio.Visible = True
CargaCuentas()
CargaOtrosIngresos(1)
CargaDeudores(1)
CargaAcreedores(1)
CargaVentas(1)
CveMonedaFiltros = 1
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
GvIngresos.Columns(5).Visible = True
GvIngresos.Columns(6).Visible = True
GvDeudores.Columns(5).Visible = True
GvDeudores.Columns(6).Visible = True
'RVImporte.Enabled = False
' RVImporte.MaximumValue = "0.00"
CVImporteDolares.Enabled = True
Else
DivTipoCambio.Visible = False
CargaCuentas()
CargaOtrosIngresos(2)
CargaDeudores(2)
CargaAcreedores(2)
CargaVentas(2)
CveMonedaFiltros = 2
TxtFechaDocumento.Attributes.Remove("onchange")
GvIngresos.Columns(5).Visible = False
GvIngresos.Columns(6).Visible = False
GvDeudores.Columns(5).Visible = False
GvDeudores.Columns(6).Visible = False
'RVImporte.Enabled = True
'RVImporte.MaximumValue = LtlSaldo.Text.ToDecimal.ToString
CVImporteDolares.Enabled = False
CVImportePesos.Enabled = False
End If
UpDatos.Update()
RegistraScript("CambiaPesosDolares();")
End Sub
Protected Sub CVImporteDolares_ServerValidate(source As Object, args As ServerValidateEventArgs)
If args.Value.ToString.Substring(0, args.Value.Length - 3).ToDecimal <= LtlSaldo.Text.Substring(0, LtlSaldo.Text.Length - 3).ToDecimal Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
#End Region
#Region "PAGAR CON DOLARES"
Protected Sub ChkPagarDolares_CheckedChanged(sender As Object, e As EventArgs)
If ChkPagarDolares.Checked Then
DivTipoCambio.Visible = True
CargaCuentas()
CargaOtrosIngresos(2)
CargaDeudores(2)
CargaAcreedores(2)
CargaVentas(2)
CveMonedaFiltros = 2
TxtFechaDocumento.Attributes.Add("onchange", "CambiaTC(this);")
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
GvIngresos.Columns(5).Visible = True
GvIngresos.Columns(6).Visible = True
GvDeudores.Columns(5).Visible = True
GvDeudores.Columns(6).Visible = True
'RVImporte.Enabled = False
'RVImporte.MaximumValue = "0.00"
CVImportePesos.Enabled = True
Else
DivTipoCambio.Visible = False
CargaCuentas()
CargaOtrosIngresos(1)
CargaDeudores(1)
CargaAcreedores(1)
CargaVentas(1)
CveMonedaFiltros = 1
TxtFechaDocumento.Attributes.Remove("onchange")
GvIngresos.Columns(5).Visible = False
GvIngresos.Columns(6).Visible = False
GvDeudores.Columns(5).Visible = False
GvDeudores.Columns(6).Visible = False
' RVImporte.Enabled = True
'RVImporte.MaximumValue = LtlSaldo.Text.ToDecimal.ToString
CVImporteDolares.Enabled = False
CVImportePesos.Enabled = False
End If
UpDatos.Update()
RegistraScript("CambiaDolaresPesos();")
End Sub
Protected Sub CVImportePesos_ServerValidate(source As Object, args As ServerValidateEventArgs)
If args.Value.ToString.Substring(0, args.Value.Length - 3).ToDecimal <= LtlSaldo.Text.Substring(0, LtlSaldo.Text.Length - 3).ToDecimal Then
args.IsValid = True
Else
args.IsValid = False
End If
End Sub
#End Region
Protected Sub BtnCambiaTipoMoneda_Click(sender As Object, e As EventArgs)
CambiaTipoMoneda()
End Sub
Private Sub CambiaTipoMoneda()
If ChkPagarPesos.Visible Then
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
RegistraScript("CambiaPesosDolares();")
End If
If ChkPagarDolares.Visible Then
TxtTipoCambio.Text = GlobalTipoCambio(TxtFechaDocumento.Text.ToDate).FormatoNumero(4)
RegistraScript("CambiaDolaresPesos();")
End If
UpDatos.Update()
End Sub
#End Region
#Region "GV ROW DATA BOUND"
Private Sub GvIngresos_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvIngresos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim total As Decimal
Dim saldo As Decimal
saldo = e.Row.DataKey("Saldo").ToDecimal
total = SaldoVenta
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
Private Sub GvDeudores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvDeudores.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim total As Decimal
Dim saldo As Decimal
saldo = e.Row.DataKey("Saldo").ToDecimal
total = SaldoVenta
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
Private Sub GvAcreedores_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvAcreedores.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim total As Decimal
Dim saldo As Decimal
saldo = e.Row.DataKey("Saldo").ToDecimal
total = SaldoVenta
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
Private Sub GvVentas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvVentas.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim total As Decimal
Dim saldo As Decimal
saldo = e.Row.DataKey("Saldo").ToDecimal
total = SaldoVenta
e.Row.FCCheckBox("Chk").Attributes.Add("onclick", String.Format("ClickDeudorChk(this, ""{0}"", ""{1}"", ""{2}"")", e.Row.FCTextBox("TxtSaldoDeudor").ClientID, total, saldo))
e.Row.FCTextBox("TxtSaldoDeudor").Attributes.Add("onKeyUp", "AjustaTextboxDeudores();")
e.Row.FCTextBox("LbTipoMoneda").Text = If(e.Row.DataKey("CveMoneda").ToString.ToEntero = 1, "USD", " MXN")
Dim rv As RangeValidator = CType(e.Row.FindControl("RVSaldoDeudor"), RangeValidator)
End If
End Sub
#End Region
#Region "G U A R D A R"
Private Sub BtnGuardar_Click(sender As Object, e As EventArgs) Handles BtnGuardar.Click
Dim FechaFactura As Date = FechaCompra
Dim FechaDocumentoPago As Date = TxtFechaDocumento.Text.ToDate
Dim AnioFactura As Integer = FechaFactura.Year
Dim MesFactura As Integer = FechaFactura.Month
Dim AnioDocumento As Integer = FechaDocumentoPago.Year
Dim MesDocumento As Integer = FechaDocumentoPago.Month
If AnioFactura > AnioDocumento Then
Alert($"El mes de la fecha de compra no puede ser mayor al mes de la la fecha de pago <br/> Fecha de compra: { FechaCompra.ToString("dd/MM/yyyy") }", TipoMensaje.MsgAdvertencia)
Exit Sub
ElseIf AnioFactura = AnioDocumento And MesFactura > MesDocumento Then
Alert($"El mes de la fecha de compra no puede ser mayor al mes de la la fecha de pago <br/> Fecha de compra: { FechaCompra.ToString("dd/MM/yyyy") }", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
'VALIDACION PARA LOS IMPORTES CUANDO SE QUIERE PAGAR EN DIFERENTE MONEDA
If Not Page.IsValid Then
Exit Sub
End If
Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero)
If dtc IsNot Nothing Then
Dim Row = dtc.FiltroPrimero("")
If Row IsNot Nothing AndAlso Row("Estatus").ToString = "False" Then
Alert("La cuenta depósito del proveedor esta inactiva.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
End If
Dim ImportePagado As Decimal = TxtImporte.Text.ToDecimal
If ImportePagado <= 0 Then
Alert("Debe ingresar un importe.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim MsgError As String = ""
Dim CveProveedor2 As Integer = CveProveedor
Dim Fecha As Date = TxtFechaDocumento.Text.Trim.ToDate
Dim ObjIE As New ClsBancos()
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
Dim CvePlantillaPoliza As Integer = 2
Dim ConceptoPoliza As String = String.Format("{0} {1}", NombreProveedor, SerieFolio)
Dim CveCuentaDeposito As Integer = If(DdlCuentaDeposito.Items.Count > 0, DdlCuentaDeposito.SelectedValue.ToEntero, 0)
Dim FechaDocumento = FechaCompra
'Saca moneda en que se va a pagar segun metodo de pago
Select Case RBLContado.SelectedValue
Case "1" ' Banco
If DdlCuenta.SelectedValue.ToEntero > 0 Then
CveMoneda = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimeroValor("CveMoneda", $"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveCuenta = {DdlCuenta.SelectedValue.ToEntero}").ToEntero
End If
Case "2", "3", "4", "5", "6" 'FyE, Ingresos, Deudores, Acreedores
If ChkPagarDolares.Checked Then
CveMoneda = 2
ElseIf ChkPagarPesos.Checked Then
CveMoneda = 1
End If
End Select
'cuando es pago con ventas, debe de ser de Diario
Dim CveTipoPoliza As Integer = ObjMov.ObtenerTipoPoliza(DdlTipoTransaccion.SelectedValue, "-1", UsuarioActual.CveEmpresa)
If RBLContado.SelectedValue = "6" Then CveTipoPoliza = 3
Dim CvePrePoliza As Integer = ObjMov.AddPrePolizas("Bancos/PopIECompras", CvePlantillaPoliza, ImportePagado, ImportePagado, CveMoneda, Fecha, ConceptoPoliza, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveTipoPoliza:=CveTipoPoliza)
Dim Pago As New CompraPago
Pago.Fecha = TxtFechaDocumento.Text.ToDate
Pago.CveMonedaPago = CveMoneda
ImportePagado = TxtImporte.Text.Trim.ToDecimal
'Tipos de cambio
If Pago.CveMonedaPago = 1 AndAlso CompraActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en Pesos
Pago.TCPago = TxtTipoCambio.Text.ToDecimal
Pago.TCCambioMoneda = 1 / TxtTipoCambio.Text.ToDecimal
ElseIf Pago.CveMonedaPago = 2 AndAlso CompraActual.CveMoneda = 2 Then 'Si la venta viene en Dolares y se va a pagar en DOLARES
Pago.TCPago = TxtTipoCambio.Text.ToDecimal
ElseIf Pago.CveMonedaPago = 2 AndAlso CompraActual.CveMoneda = 1 Then 'Si la venta viene en pesos y se va a pagar en DOLARES
Pago.TCPago = TxtTipoCambio.Text.ToDecimal
Pago.TCCambioMoneda = TxtTipoCambio.Text.ToDecimal
End If
If ChkPagarPesos.Checked Then Pago.TCCambioMoneda = 1 / TxtTipoCambio.Text.ToDecimal
If ChkPagarDolares.Checked Then Pago.TCCambioMoneda = TxtTipoCambio.Text.ToDecimal
If TxtComision.Text.ToDecimal <> 0 Then Pago.OtroGastoIngreso = TxtComision.Text.ToDecimal Else Pago.OtroGastoIngreso = 0
Select Case RBLContado.SelectedValue
Case "1" ' Bancos
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, Fecha, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImportePagado, CveMoneda, 15.55, TxtObservaciones.Text.Trim, "", True, True, -1, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaTarjeta:=If(DivTarjeta.Visible, DdlTarjeta.SelectedValue.ToEntero, -1), CveCuentaDeposito:=CveCuentaDeposito, Referencia:=If(TxtReferenciaCIE.Visible, TxtReferenciaCIE.Text, "-1"), ConceptoCIE:=If(TxtConceptoCIE.Text.Trim.Length > 0, TxtConceptoCIE.Text, "-1"))
If Not CveIE > 0 Then
MsgError = "Ocurrio un Error al registrarse el movimiento bancario."
End If
'Importe de pago
Pago.ImportePago = ImportePagado
Pago.CveIE = CveIE
If MsgError = "" AndAlso AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjMov) Then
MsgError = "No se pudo insertar la póliza"
End If
'AGREGO PREPOLIZA BANCOS
Dim IdCuenta As Integer = 0
Dim UsaComplementariaBancos As Boolean = Not UsuarioActual.CveEmpresa.Contiene(7, 11, 122, 145, 13, 83)
Dim ConceptoMovimiento As String = $"{TxtPagueseA.Text.Trim} - {TxtObservaciones.Text} {If(Pago.TCPago > 1, $" TC:{Pago.TCPago}", "")}"
Dim Referencia As String = TxtFolio.Text.Trim
Dim tImporteMN As Decimal = TxtImporte.Text.ToDecimal
Pago.ImportePago = tImporteMN
If DivTarjeta.Visible AndAlso DdlTarjeta.SelectedValue.ToEntero > 0 Then
Dim ObjCreditos As New ClsBancos
ObjCreditos.GetTarjetasCreditos(DdlCuenta.SelectedValue.ToEntero, DdlTarjeta.SelectedValue.ToEntero)
If ObjCreditos.DtResultados.Rows.Count > 0 AndAlso (ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjeta").ToString.ToEntero > 0) Then
IdCuenta = ObjCreditos.DtResultados.Rows(0)("IdCtaContableTarjeta").ToString.ToEntero
End If
Dim Importe42 As Decimal = Pago.ImportePago + Pago.OtroGastoIngreso
tImporteMN = If(Pago.CveMonedaPago = 2, If(DivTipoCambio.Visible, Importe42 / TxtTipoCambio.Text.ToDecimal * Pago.TCPago, Importe42 * Pago.TCPago), Importe42)
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Importe42, tImporteMN, 42, Referencia, ConceptoMovimiento, IdCuenta, CveIE:=CveIE, CveProveedor:=CveProveedor, TipoCambio:=Pago.TCPago, CveSubProyecto:=CveSubProyecto) Then
MsgError = "No se pudo insertar la póliza"
End If
Else
Dim ImporteME As Decimal = 0
If Pago.CveMonedaPago = 2 Then ImporteME = Pago.ImportePago
If Not UsaComplementariaBancos And Pago.CveMonedaPago = 2 Then
ImporteME = tImporteMN
tImporteMN = (tImporteMN * Pago.TCPago).RoundSQL
End If
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, tImporteMN, 30, Referencia, ConceptoMovimiento, IdCuenta, CveIE:=CveIE, CveProveedor:=CveProveedor, TipoCambio:=Pago.TCPago, CveSubProyecto:=CveSubProyecto, ImporteME:=ImporteME) Then
MsgError = "No se pudo insertar la póliza"
End If
If Pago.CveMonedaPago = 2 AndAlso UsaComplementariaBancos Then
If MsgError = "" AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, (Pago.ImportePago * Pago.TCPago - Pago.ImportePago).RoundSQL, 204, Referencia, ConceptoMovimiento, IdCuentaBancariaComplementaria, CveIE:=CveIE, CveProveedor:=CveProveedor, ImporteME:=Pago.ImportePago, TipoCambio:=Pago.TCPago, CveSubProyecto:=CveSubProyecto) Then
MsgError = "No se pudo insertar la póliza"
End If
End If
End If
Case "2" 'FyE
CveIE = DDlCheques.SelectedValue.ToEntero
If Not CveIE > 0 Then
Alert("No se encontro movimientos bancarios de personal", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Dim saldo As Decimal = DtCheques.Rows(DDlCheques.SelectedIndex)("Saldo").ToString.ToDecimal
If TxtImporte.Text.ToDecimal > saldo Then
Alert("El importe no debe de superar el saldo del cheque seleccionado.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
Pago.ImportePago = ImportePagado
Pago.CveIE = CveIE
Pago.TipoPago = "Per"
Pago.CvePersonal = DdlFuncionarioEmpleado.SelectedValue.ToEntero
If AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjMov) Then
MsgError = "No se pudo insertar la póliza"
End If
'AGREGO PREPOLIZA FyE
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, Pago.ImportePago, TxtObservaciones.Text, 29, TxtObservaciones.Text, TxtFechaDocumento.Text.ToDate, -1, -1, CvePersonal:=Pago.CvePersonal, CveIE:=CveIE, ImporteMX:=Pago.ImportePago) Then
MsgError = "Error al registrar detalle de concepto bancario"
End If
Case "3" 'Ingresos X Comprobar
ImportePagado = TxtImporte.Text.Trim.ToDecimal
Pago.ImportePago = ImportePagado
For Each rw As GridViewRow In GvIngresos.Rows
If rw.FCCheckBox("Chk").Checked Then
CveIE = rw.DataKey("CveIE").ToEntero
Pago.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero
Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal
If ChkPagarPesos.Checked Then Pago.TCCambioMoneda = 1 / rw.DataKey("TipoCambio").ToDecimal
If ChkPagarDolares.Checked Then Pago.TCCambioMoneda = rw.DataKey("TipoCambio").ToDecimal
If AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjMov) Then
MsgError = "No se pudo insertar la póliza"
Else
Exit For
End If
End If
Next
Case "4" 'Deudores Diversos
'verifica que se halla selccionado algun acreedor
If DdlDeudor.SelectedValue.ToEntero <= 0 Then
Alert("Debe especificar el deudor.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
For Each rw As GridViewRow In GvDeudores.Rows
If rw.FCCheckBox("Chk").Checked AndAlso rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal <> 0 Then
Pago.CveIE = rw.DataKey("CveIE").ToEntero
Pago.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero
Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal
Pago.CveProveedor = DdlDeudor.SelectedValue.ToEntero
Pago.TipoPago = "DD"
If AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjMov) Then
MsgError = "No se pudo insertar la póliza"
Else
Exit For
End If
End If
Next
Case "5" 'Acreedores Diversos
'verifica que se halla selccionado algun acreedor
If DdlAcreedor.SelectedValue.ToEntero <= 0 Then
Alert("Debe especificar el Acreedor.", TipoMensaje.MsgAdvertencia)
Exit Sub
End If
For Each rw As GridViewRow In GvAcreedores.Rows
If rw.FCCheckBox("Chk").Checked AndAlso rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal <> 0 Then
Dim TCC As Decimal = 1
Pago = New CompraPago
If ChkPagarPesos.Checked Then Pago.TCCambioMoneda = 1 / TxtTipoCambio.Text.ToDecimal
If ChkPagarDolares.Checked Then Pago.TCCambioMoneda = TxtTipoCambio.Text.ToDecimal
Pago.CveIE = rw.DataKey("CveIE").ToEntero
Pago.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero
Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
Pago.TCPago = TxtTipoCambio.Text.ToDecimal
Pago.CveProveedor = DdlAcreedor.SelectedValue.ToEntero
Pago.TipoPago = "Egsc"
If AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjMov) Then
MsgError = "No se pudo insertar la póliza"
Else
Exit For
End If
End If
Next
Case "6" 'Ventas
For Each rw As GridViewRow In GvVentas.Rows
If rw.FCCheckBox("Chk").Checked AndAlso rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal <> 0 Then
Pago.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero
Pago.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
Pago.TCPago = rw.DataKey("TipoCambio").ToDecimal
Pago.CveProveedor = DdlAcreedor.SelectedValue.ToEntero
Pago.CveVentaRelacionada = rw.DataKey("CveVenta").ToEntero
Pago.TipoPago = "Venta"
If AplicaPrePolizaPagoCompra(CompraActual, Pago, CvePrePoliza, ObjMov) Then
MsgError = "No se pudo insertar la póliza"
End If
If MsgError = "" Then
Dim VentaActual As New Venta(UsuarioActual) With {.CveVenta = rw.DataKey("CveVenta").ToEntero, .ClienteNombre = NombreCliente, .SerieFolio = rw.DataKey("SerieFolio"), .CveCliente = rw.DataKey("CveCliente").ToEntero, .IVA = rw.DataKey("IVA").ToDecimal, .IEPS = rw.DataKey("IEPS").ToDecimal, .RetIVA = rw.DataKey("RetIVA").ToDecimal, .RetISR = rw.DataKey("RetISR").ToDecimal, .Total = rw.DataKey("Total").ToDecimal, .PorcentajeIVA = rw.DataKey("PorcentajeIVA").ToDecimal, .CveSubProyecto = rw.DataKey("CveSubProyecto").ToEntero, .CveMoneda = rw.DataKey("CveMoneda").ToEntero}
Dim PagoVenta As New VentaPago
PagoVenta.CveMonedaPago = rw.DataKey("CveMoneda").ToEntero
PagoVenta.ImportePago = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
PagoVenta.ImportePagoVenta = rw.FCTextBox("TxtSaldoDeudor").Text.ToDecimal
PagoVenta.TCPago = rw.DataKey("TipoCambio").ToDecimal
PagoVenta.CveCompraRelacionada = CompraActual.CveCompra
PagoVenta.TipoPago = "Venta"
If AplicaPrePolizaPagoVenta(VentaActual, PagoVenta, CvePrePoliza, ObjMov) Then
MsgError = "No se pudo insertar la póliza"
End If
Else
Exit For
End If
End If
Next
Case Else
ImportePagado = 0
End Select
Dim ObjConta As ClsContPAQi = Nothing
If MsgError = "" AndAlso ObjMov.ValidacionPrePolizaCuadre(CvePrePoliza, 5) Then
If ObjMov.ValorPolizaDescuadre > 0 Then
MsgError = ObjMov.MensajePolizaDescuadre
GuardaLogAD($"Bancos/PopIECompras | Error:{ObjMov.MensajePolizaDescuadre} Diferencia:{ObjMov.ValorDiferencia} | CvePrePoliza:{CvePrePoliza}", "LogPrePolizas")
Else
If UsuarioActual.Empresa.Funcionalidad(200) = "1" AndAlso MsgError = "" Then
If UsuarioActual.Empresa.TipoContabilidad = 2 AndAlso UsuarioActual.Empresa.UsaContabilidad Then
ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
ObjConta.IniciaTransacSQL()
End If
If ObjMov.ContabilizarPrePoliza(CvePrePoliza, UsuarioActual.CveUsuario, UsuarioActual.Empresa, ObjConta:=ObjConta) Then
IdPoliza = ObjMov.ContaIdPoliza
Else
Alert("Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico", TipoMensaje.MsgError)
MsgError = "Ocurrio un error al contabilizar, pongase en contacto con Soporte Técnico"
End If
End If
End If
End If
If MsgError = "" Then
ObjIE.Commit()
If ObjConta IsNot Nothing Then ObjConta.Commit()
Dim StrMsg As New StringBuilder
StrMsg.Append("El Documento se guardó correctamente.<br/>")
If TipoTransaccion = "Egs" AndAlso CveIE > 0 Then GeneraChequePDF(CveIE, UsuarioActual.Empresa)
If UsuarioActual.Empresa.TipoContabilidad = 1 Then
StrMsg.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}"">Ver Póliza</a>", CvePrePoliza)
Else
If IdPoliza > 0 Then
StrMsg.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza</a>", IdPoliza)
End If
End If
If RBLContado.SelectedValue.ToEntero = 6 And ChkEmitirComplementoPago.Checked Then GeneraTimbre(CvePrePoliza) Else Alert(StrMsg.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();")
EnviarCorreoNotificacion(CveIE, NotificarA, "", UsuarioActual, False)
Else
ObjIE.RollBack()
If ObjConta IsNot Nothing Then ObjConta.RollBack()
Alert(MsgError, TipoMensaje.MsgError)
End If
ObjIE.Dispose()
ObjMov.Dispose()
End Sub
#End Region
#Region "ENVIAR CORREO NOTIFICACION DE PAGO"
Private Sub EnviarCorreoNotificacion(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario, MostarAlert As Boolean)
Try
Dim Hilo As New Threading.Thread(Sub() EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar))
'Dim Hilo As New Threading.Thread( EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar))
Hilo.Start()
If MostarAlert Then
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
End If
Catch ex As Exception
If MostarAlert Then
Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError)
End If
End Try
End Sub
Private Sub EnviarCorreoNotifiMandaCorreocacionHilo(CveIENotificar As Integer, CorreoNotificarA As String, CopiaPara As String, UsuarioActualNotificar As Usuario)
Try
Dim ObjBancos As New ClsBancos()
If ObjBancos.NotificacionPago(CveIENotificar, CorreoNotificarA, CopiaPara, UsuarioActualNotificar) Then
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
Else
Alert("No se pudo enviar el correo electrónico.", TipoMensaje.MsgError)
End If
ObjBancos.Dispose()
Catch ex As Exception
GuardaLog("Error al enviar notificación de pago PopIECompras --> " & ex.StackTrace.ToString)
End Try
End Sub
#End Region
#Region "COMPLEMENTO DE PAGO"
Private Sub GeneraTimbre(CvePrePoliza As Integer)
Dim Str As New StringBuilder
Dim Banco As New ClsBancos
Banco.IniciaTransacSQL()
If Banco.GeneraTimbrePago(CveIE, -1, UsuarioActual, CvePrePoliza:=CvePrePoliza) Then
If Banco.Mensaje = "" Then
Banco.Commit()
PDFReciboDePagos(-1, -1, Banco.CveComplementoPago, False)
Str.AppendFormat("Folio: <b>{0}</b> &nbsp;", Banco.ComplementoSerieFolio)
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">XML &nbsp;<i class=""fa fa-file""></i></i></a>&nbsp;&nbsp;", Encripta(String.Format("OP=CompP&EXT=xml&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
Str.AppendFormat("<a class=""texto"" style='color:#337ab7' href=""/Compras/PopUpVerFactura.aspx?P={0}"" target=""_blank"">PDF &nbsp;<i class=""fa fa-ad-pdf""></i></i></i></a>&nbsp;", Encripta(String.Format("OP=CompP&EXT=pdf&SerieFolio={0}&CveComplementoPago={1}", Banco.ComplementoSerieFolio, Banco.CveComplementoPago)))
'Str.AppendFormat("<a style='color:#337ab7' target='_blank' href='./IE.aspx?CveIE={0}'>{1}</a> &nbsp; {2}<br>", CveIE, SerieFolio, NombreProveedor)
MandaCorreo(Banco.ComplementoSerieFolio, Banco.CobranzaCorreo)
End If
Else
Str.AppendFormat("No se genero complemento del Folio {0} por el siguiente motivo: {1}", SerieFolio, Banco.Mensaje)
Banco.RollBack()
End If
Banco.Dispose()
Alert(Str.ToString, TipoMensaje.MsgInformacion, "self.parent.tb_remove();self.parent.location.reload();")
End Sub
Private Sub MandaCorreo(NombreArchivo As String, Correo As String, Optional ConAlerta As Boolean = True)
If Not DdlTipoTransaccion.SelectedValue.ToEntero.Contiene(9, 17) Then
Try
Dim Msg As String = ""
If NombreArchivo <> "-1" Then '
Dim ObjMail As New ClsSisMail()
Dim RutaXML As String = String.Format("{0}\XML\Pag\{1}.xml", UsuarioActual.Empresa.Ruta, NombreArchivo)
Dim RutaPDF As String = String.Format("{0}\PDF\Pag\{1}.pdf", UsuarioActual.Empresa.Ruta, NombreArchivo)
Dim Cuerpo As String = "Se hace entrega del comprobante de pago"
Dim Asunto As String = "Entrega de comprobante de pago"
If IO.File.Exists(RutaPDF) AndAlso IO.File.Exists(RutaXML) Then
Dim LSRutasMail As New List(Of ClsSisMail.ArchivoMail)
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaPDF})
LSRutasMail.Add(New ClsSisMail.ArchivoMail With {.Ruta = RutaXML})
If ObjMail.SendMail(UsuarioActual.Empresa, Correo, Asunto, Cuerpo, "", LSRutasMail) Then
If ConAlerta Then
RegistraScript("$('#ModalDivMail').modal('hide');")
Alert("El correo se envió correctamente", TipoMensaje.MsgInformacion)
End If
Else
Msg = "No se pudo enviar el correo electrónico."
End If
Else
Msg = "No se pudo adjuntar el correo electrónico."
End If
End If
If ConAlerta AndAlso Msg <> "" Then
Alert(Msg, TipoMensaje.MsgError)
End If
Catch ex As Exception
OnError("Ocurrió error al mandar MAIL", ex)
End Try
End If
End Sub
#End Region
Protected Sub DdlCuentaDeposito_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim dtc As DataTable = GlobalDTProveedoresCuentas(UsuarioActual.CveEmpresa, CveProveedor:=CveProveedor, CveCuentaDeposito:=DdlCuentaDeposito.SelectedValue.ToEntero)
If dtc IsNot Nothing AndAlso dtc.Rows.Count = 1 Then
If dtc.Rows(0)("TieneCIE").ToString.ToEntero = 1 Then
TrReferenciaCIE.Visible = True
TxtReferenciaCIE.Text = dtc.Rows(0)("Referencia").ToString
TxtConceptoCIE.Text = dtc.Rows(0)("ConceptoCIE").ToString
'OriReferenciaCIE = dtc.Rows(0)("Referencia").ToString
'OriConceptoCIE = dtc.Rows(0)("ConceptoCIE").ToString
Else
TrReferenciaCIE.Visible = False
End If
If Boolean.Parse(dtc.Rows(0)("EstatusPagoElectronicoGrupos").ToString) = True AndAlso dtc.Rows(0)("CveSATBanco").ToString.ToEntero <= 0 Then
Alert("Es necesario establecer el banco de la cuenta deposito", TipoMensaje.MsgAdvertencia)
BtnGuardar.Enabled = False
Else
BtnGuardar.Enabled = True
End If
Else
TrReferenciaCIE.Visible = False
End If
UpCuentaDeposito.Update()
UpGuardar.Update()
End Sub
Private Sub RVTxtFechaDocumento_Init(sender As Object, e As EventArgs) Handles RVTxtFechaDocumento.Init
RVTxtFechaDocumento.MaximumValue = DateTime.Now.ToShortDateString
Calendario.EndDate = DateTime.Now
End Sub
Protected Sub CVTxtImporte_ServerValidate(source As Object, args As ServerValidateEventArgs)
Dim Saldo As Decimal = LtlSaldo.Text.Replace("USD", "").Replace("MXN", "").Replace(",", "").ToDecimal
Dim ImportePagado As Decimal = TxtImporte.Text.ToDecimal
If ChkPagarPesos.Checked Then
Dim TC As Decimal = TxtTipoCambio.Text.ToDecimal
Dim PagoEnDollares As Decimal = (ImportePagado / TC).RoundSQL()
If PagoEnDollares <= Saldo Then
args.IsValid = True
Else
args.IsValid = False
End If
Else
If ImportePagado <= Saldo Then
args.IsValid = True
Else
args.IsValid = False
End If
End If
End Sub
End Class