1682 lines
72 KiB
VB.net
1682 lines
72 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.Web.Services
|
|
Imports System.IO
|
|
|
|
|
|
Partial Class Bancos_IE
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
|
|
'Configuración
|
|
Private Property CveIE As Integer
|
|
Get
|
|
Return ViewState("CveIE").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 CveProveedor As Integer
|
|
Get
|
|
Return ViewState("CveProveedor").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProveedor") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CvePersonal As Integer
|
|
Get
|
|
Return ViewState("CvePersonal").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePersonal") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveCliente As Integer
|
|
Get
|
|
Return ViewState("CveCliente").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCliente") = 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 Opcion As String
|
|
Get
|
|
Return ViewState("Opcion").ToString
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Opcion") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property IDCtaContable As Integer
|
|
Get
|
|
Return ViewState("IDCtaContable").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IDCtaContable") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property IDCtaBeneficiario As Integer
|
|
Get
|
|
Return ViewState("IDCtaBeneficiario").ToString.ToEntero
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("IDCtaBeneficiario") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property EmpresaPrueba As Boolean
|
|
Get
|
|
Return CBool(ViewState("EmpresaPrueba"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("EmpresaPrueba") = value
|
|
End Set
|
|
End Property
|
|
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
|
|
If UsuarioActual.CveUsuario = 1425 Then
|
|
EmpresaPrueba = True
|
|
End If
|
|
|
|
IDCtaBeneficiario = 0
|
|
IDCtaContable = 0
|
|
DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True
|
|
TxtImporte.Attributes.Add("onblur", "upIE(this);")
|
|
Calendario.StartDate = Now.AddMonths(-1)
|
|
' rbPagueseA.Attributes.Add("onchange", "upPagueseA(this);")
|
|
'If UsuarioActual.CveRol = 1 Then
|
|
'rbPagueseAFuncionarioEmpleado.Visible = True : lblPagueseAFuncionarioEmpleado.Visible = True : rbPagueseAProveedor.Visible = True : lblPagueseAProveedor.Visible = True
|
|
|
|
If UsuarioActual.CveEmpresa = 66 Then trNotificar.Visible = True
|
|
|
|
'Guarda el modo actual de la pagina
|
|
Opcion = If(Request("Opcion") IsNot Nothing, Request("Opcion").ToString, "-1")
|
|
|
|
Session("FileUpload") = ""
|
|
TRCveIE.Visible = False
|
|
CveProveedor = -1
|
|
CveCompra = -1
|
|
CvePersonal = -1
|
|
|
|
CargaTipoTransaccion()
|
|
CargaMoneda()
|
|
CargaCuenta()
|
|
|
|
|
|
'If UsuarioActual.CveRol = 1 AndAlso UsuarioActual.Empresa.UsaAC Then BtnSimplificarAC.Visible = True
|
|
'CargaEstatusIE()
|
|
|
|
|
|
ViewState("Orden") = ""
|
|
ViewState("OTipo") = "Tipo DESC"
|
|
ViewState("OTipoReferencia") = "TipoReferencia DESC"
|
|
ViewState("OEstado") = "Estado DESC"
|
|
ViewState("OFechaIng") = "FechaIng DESC"
|
|
ViewState("OUsuario") = "Usuario DESC"
|
|
|
|
Dim ObjIE As New ClsBancos
|
|
'Carga Estatus IE
|
|
If ObjIE.GetBancos_EstatusIE() Then
|
|
DdlEstatusIE.DataSource = ObjIE.DtResultados
|
|
DdlEstatusIE.DataBind()
|
|
End If
|
|
ObjIE.Dispose()
|
|
|
|
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSCREDITO") Then
|
|
LblPagueseA.Text = ""
|
|
LblPagueseA.Visible = False
|
|
Dim Dt As DataTable = Nothing
|
|
Dim Banc As New ClsBancos
|
|
Dim CveCredito As Integer = -1
|
|
Dim CveCreditoDetalle As Integer = -1
|
|
CveCredito = IfNull(Request("CveCredito"), "-1").ToString.ToEntero
|
|
CveCreditoDetalle = IfNull(Request("CveCreditoDetalle"), "-1").ToString.ToEntero
|
|
LtlTitulo.Text = "Pago de Créditos"
|
|
|
|
If Banc.GetCreditos(CveCredito, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
Dt = Banc.DtResultados
|
|
|
|
End If
|
|
|
|
Banc.Dispose()
|
|
PnlFyE.Visible = False
|
|
|
|
PnlCredito.Visible = True
|
|
|
|
DdlFinanciera.DataSource = Dt.FiltraParametros("", DistinctColumns:={"CveProveedor", "Proveedor"}, Orderby:="Proveedor")
|
|
DdlFinanciera.DataBind()
|
|
|
|
If DdlFinanciera.SelectedValue.ToEntero > 0 Then
|
|
DdlCredito.DataSource = Dt.FiltraParametros(String.Format("CveProveedor = {0} AND EstatusNum in (1,2,101,102)", DdlFinanciera.SelectedValue), DistinctColumns:={"CveCredito", "ReferenciaCredito"}, Orderby:="ReferenciaCredito")
|
|
DdlCredito.DataBind()
|
|
End If
|
|
DdlCredito.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
If CveCredito > 0 Then
|
|
'le asigno el valor
|
|
DdlCredito.SelectedValue = CveCredito.ToString
|
|
If CveCreditoDetalle > 0 Then
|
|
CargaCreditosDetalle()
|
|
DdlCreditoDetalle.SelectedValue = CveCreditoDetalle.ToString
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
TxtImporte.Attributes.Add("onkeyup", String.Format("FncImporteCuenta(this)"))
|
|
|
|
|
|
If Request("CveIE") IsNot Nothing AndAlso IsNumeric(Request("CveIE")) AndAlso Request("CveIE").ToEntero > 0 Then
|
|
ViewState("CveIE") = Request("CveIE")
|
|
'Configuración de Modalidad Update
|
|
TxtFolio.Enabled = False
|
|
TxtFechaDocumento.Enabled = False
|
|
Calendario.Enabled = False
|
|
TxtPagueseA.Enabled = False
|
|
TxtImporte.Enabled = False
|
|
TxtImporteLetra.Enabled = False
|
|
DdlMoneda.Enabled = False
|
|
TxtTipoCambio.Enabled = False
|
|
DdlCuenta.Enabled = False
|
|
'DdlTipo.Enabled = False
|
|
DdlTipoTransaccion.Enabled = False
|
|
TxtObservaciones.Enabled = False
|
|
ChkAplicaImpuestos.Enabled = False
|
|
ChkAbonoCuenta.Enabled = False
|
|
DivPegarImagen.Visible = False
|
|
|
|
|
|
CargaDatos()
|
|
|
|
BtnGuardar.Visible = False
|
|
LtlTitulo.Text = "Consulta del Ingreso/Egreso:"
|
|
ImgAddObs.Attributes.Add("onclick", "javascript:PosicionaObjeto(this.id,'DivEventoBitacora',null,-250,-250); $('#DivEventoBitacora').show(1000); ")
|
|
HlEvento.Visible = True
|
|
HlEvento.NavigateUrl = "/OI/PopUpAgenda.aspx?CveTipoEvento=2&CveIE=" & CveIE & "&TB_iframe=true&height=370&width=600;"
|
|
Else
|
|
'Configuración de Modalidad Insert
|
|
ImgAddObs.Visible = False
|
|
CveIE = -1
|
|
TxtFechaDocumento.Text = Now.ToShortDateString
|
|
End If
|
|
|
|
|
|
End If
|
|
End Sub
|
|
|
|
|
|
|
|
#Region " CARGA DATOS "
|
|
Private Sub CargaDatos()
|
|
Dim ObjIE As New ClsBancos()
|
|
|
|
If ObjIE.GetBancosIE(CveIE, UsuarioActual.CveEmpresa) Then
|
|
If ObjIE.DtResultados.Rows.Count > 0 Then
|
|
|
|
If UsuarioActual.TienePermisoProceso(99) Then
|
|
BtnActualizar.Visible = True
|
|
TxtFechaDocumento.Enabled = True
|
|
Calendario.Enabled = True
|
|
End If
|
|
|
|
If ObjIE.CveEstatusNotificacion > 0 Then
|
|
trNotificacion.Visible = True
|
|
LtNotificacion.Text = If(ObjIE.CveEstatusNotificacion = 1, "Notificado", String.Format("Entregado el {0} - {1}", ObjIE.FechaEntrega, ObjIE.ObservacionEntrega))
|
|
End If
|
|
|
|
'Pestaña Datos Generales
|
|
TxtCveIE.Text = ObjIE.CveIE.ToString
|
|
RBL.Visible = False
|
|
HplBuscar.Visible = False
|
|
RegistraScript("if($get('imgBuscarProveedor')) $get('imgBuscarProveedor').style.display='none';")
|
|
'DdlBanco.SelectedValue = ObjIE.CveBanco.ToString
|
|
|
|
DdlTipoTransaccion.SelectedValue = ObjIE.CveTipoTransaccion.ToString
|
|
|
|
|
|
DdlCuenta.SelectedValue = ObjIE.CveCuenta.ToString
|
|
DdlCuenta.Visible = False
|
|
|
|
LblCuenta.Text = ObjIE.BancoNumCuentaMoneda
|
|
|
|
TxtFechaDocumento.Text = ObjIE.FechaDocumento.ToShortDateString
|
|
TxtFolio.Text = ObjIE.Folio
|
|
TxtPagueseA.Text = ObjIE.PagueseA
|
|
LblBeneficiario.Text = ObjIE.PagueseA
|
|
TxtImporte.Text = ObjIE.Importe.FormatoNumero
|
|
TxtImporteLetra.Text = ObjIE.Importe.Texto2Letras(ObjIE.CveMoneda)
|
|
DdlMoneda.SelectedValue = ObjIE.CveMoneda.ToString
|
|
If ObjIE.TipoCambio > 0 Then
|
|
TrTipoCambio.Visible = True
|
|
Else
|
|
TrTipoCambio.Visible = False
|
|
End If
|
|
TxtTipoCambio.Text = ObjIE.TipoCambio.ToString
|
|
TxtObservaciones.Text = ObjIE.Observaciones
|
|
If Year(ObjIE.FechaAplicado) > 1 Then TxtFechaAplicado.Text = ObjIE.FechaAplicado.ToShortDateString
|
|
|
|
ChkAbonoCuenta.Checked = ObjIE.EsAbonoEnCuenta
|
|
ChkAplicaImpuestos.Checked = ObjIE.AplicaImpuestos
|
|
ChkImpreso.Checked = ObjIE.FueImpreso
|
|
ChkConciliado.Checked = ObjIE.FueConciliado
|
|
DdlEstatusIE.SelectedValue = ObjIE.CveEstatusIE.ToString
|
|
DdlEstatusIE.Visible = False
|
|
LblEstatusIE.Visible = True
|
|
LblEstatusIE.Text = ObjIE.EstatusIE.ToString
|
|
|
|
'saco el tipo de transaccion
|
|
Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", ObjIE.CveTipoTransaccion)) 'Egs o Ing
|
|
If dr IsNot Nothing Then
|
|
If dr("Tipo").ToString = "Egs" Then
|
|
LblPagueseA.Text = "Beneficiario"
|
|
Else
|
|
LblPagueseA.Text = "Pagador"
|
|
End If
|
|
|
|
End If
|
|
|
|
IDPoliza = ObjIE.IDPoliza
|
|
IDCtaContable = ObjIE.IdCtaContable
|
|
|
|
If ObjIE.IDPoliza > 0 Then
|
|
|
|
If UsuarioActual.TienePermisoProceso(107) Then BtnDescontabilizar.Visible = True
|
|
|
|
HplIrPoliza.Visible = True
|
|
HplIrPoliza.NavigateUrl = String.Format("/Contabilidad/RegPoliza.aspx?IdPoliza={0}", ObjIE.IDPoliza)
|
|
'ImgEliminarMovimiento.OnClientClick = "return confirm('Esta seguro de eliminar el documento y su póliza?');"
|
|
LnkEliminar.OnClientClick = "return confirm('¿Está seguro de eliminar el documento y su póliza?');"
|
|
Else
|
|
BtnDescontabilizar.Visible = False
|
|
HplIrPoliza.Visible = False
|
|
End If
|
|
|
|
'ImgImprimir.Visible = True
|
|
LblRegistroFecha.Text = ObjIE.FechaIng.ToShortDateString
|
|
LblRegistroUsuario.Text = ObjIE.Usuario
|
|
|
|
Select Case ObjIE.CveEstatusIE
|
|
Case 1
|
|
If Not ObjIE.FueConciliado Then
|
|
'If UsuarioActual.TienePermisoProceso(85) Then ImgCancelarMovimiento.Visible = True
|
|
If UsuarioActual.TienePermisoProceso(85) Then LnkCancelar.Visible = True
|
|
|
|
'If UsuarioActual.TienePermisoProceso(80) Then ImgEliminarMovimiento.Visible = True
|
|
If UsuarioActual.TienePermisoProceso(80) Then LnkEliminar.Visible = True
|
|
|
|
End If
|
|
If ObjIE.CveTipoTransaccion.Contiene(1, 2, 8, 9) Then ' si es cheque emitido y transferencia y layout
|
|
'ImgImprimir.Visible = True
|
|
LnkImprimir.Visible = True
|
|
End If
|
|
Case 2
|
|
LblEstatus.Text = ObjIE.EstatusIE
|
|
LblEstatus.ForeColor = Drawing.Color.Red
|
|
|
|
'FALTA AFECTAR POLIZA NEGATIVA
|
|
'If UsuarioActual.TienePermisoProceso(136) Then LnkEliminar.Visible = True
|
|
End Select
|
|
|
|
'Mostramos seccion cargar comprobante si no tiene estatus cancelado
|
|
If ObjIE.CveEstatusIE <> 2 Then
|
|
DivCargaComprobante.Visible = True
|
|
If ObjIE.Comprobante <> "" Then
|
|
TdNotaComprobante.Visible = True
|
|
End If
|
|
End If
|
|
|
|
If ObjIE.Comprobante <> "" Then
|
|
HplComprobante.Visible = True
|
|
HplComprobante.NavigateUrl = String.Format("/Empresas/{0}/IE/{1}", UsuarioActual.CveEmpresa, ObjIE.Comprobante)
|
|
End If
|
|
|
|
'HplListadoProveedores.NavigateUrl = String.Format("/Bancos/Reportes.aspx?Opcion=ImprimeMov&CveIE={0}", ObjIE.CveIE)
|
|
HplListaProveedores.NavigateUrl = String.Format("/Bancos/Reportes.aspx?Opcion=ImprimeMov&CveIE={0}", ObjIE.CveIE)
|
|
|
|
CargaEventoBitacora()
|
|
|
|
'Carga Cuenta Deposito o activa para seleccionar una
|
|
If ObjIE.CuentaDepositado <> "" Then
|
|
TrCuentaDepositado.Visible = True
|
|
LitDepositado.Text = ObjIE.CuentaDepositado
|
|
Else
|
|
|
|
If DdlTipoTransaccion.SelectedValue = "9" Then
|
|
|
|
Dim Dep As New ClsGenerales
|
|
If Dep.GetCuentasDepositos(CveProveedor:=ObjIE.CveProveedor) Then
|
|
DdlCuentaDeposito.DataSource = Dep.DtResultados
|
|
If Dep.DtResultados.Rows.Count > 0 Then
|
|
trCuentaDeposito.Visible = True
|
|
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
'ElseIf Dep.DtResultados.Rows.Count = 1 Then
|
|
' TrCuentaDepositado.Visible = True
|
|
' LitTextoDepositado.Text = "Cuenta Depósito"
|
|
' LitDepositado.Text = Dep.DtResultados.Rows(0)("CuentaDeposito").ToString
|
|
'End If
|
|
End If
|
|
Dep.Dispose()
|
|
DdlCuentaDeposito.DataBind()
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
If ObjIE.GetBancosIEMovimientos(CveIE, UsuarioActual.CveEmpresa) Then
|
|
GvM.DataSource = ObjIE.DtResultados
|
|
GvM.DataBind()
|
|
End If
|
|
|
|
Else
|
|
Alert("El Documento solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
|
BtnGuardar.Enabled = False
|
|
End If
|
|
End If
|
|
|
|
ObjIE.Dispose()
|
|
|
|
End Sub
|
|
|
|
|
|
#Region " CARGA PROVEEDOR "
|
|
Protected Sub BtnBuscarProveedor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBuscarProveedor.Click
|
|
HdnCvePersonal.Value = "-1"
|
|
ViewState("CveProveedor") = HdnCveProveedor.Value.ToEntero
|
|
ViewState("CvePersonal") = -1
|
|
CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1")
|
|
|
|
If Opcion = "DEV" Then
|
|
CargaIE()
|
|
End If
|
|
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", UsuarioActual.CveEmpresa) Then
|
|
If ObjProveedor.DtResultados.Rows.Count > 0 Then
|
|
TxtPagueseA.Text = ObjProveedor.RazonSocial
|
|
TxtNotificarA.Text = ObjProveedor.NotificarA.Trim
|
|
|
|
HdnProvPorIVA.Value = ObjProveedor.IVA.ToString
|
|
HdnProvPorRetIVA.Value = ObjProveedor.RetIVA.ToString
|
|
HdnProvPorRetISR.Value = ObjProveedor.RetISR.ToString
|
|
|
|
Select Case RBL.SelectedValue
|
|
Case "P" : IDCtaBeneficiario = ObjProveedor.IdCtaContAnticipos
|
|
Case "DD" : IDCtaBeneficiario = ObjProveedor.IdCtaContDeudor
|
|
Case "AC" : IDCtaBeneficiario = ObjProveedor.IdCtaContAcreedor
|
|
Case "DP" : IDCtaBeneficiario = ObjProveedor.IdCtaContDocsXPagar
|
|
Case Else
|
|
IDCtaBeneficiario = ObjProveedor.IdCtaContProveedores
|
|
End Select
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
If IDCtaBeneficiario = 0 Then
|
|
Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
BtnGuardar.Enabled = False
|
|
Else
|
|
BtnGuardar.Enabled = True
|
|
End If
|
|
UpGuardar.Update()
|
|
End If
|
|
|
|
CargaCuentasDepositos()
|
|
|
|
Else
|
|
Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ObjProveedor.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region " CARGA CLIENTE "
|
|
|
|
Private Sub BtnBuscarCliente_Click(sender As Object, e As EventArgs) Handles BtnBuscarCliente.Click
|
|
HdnCveProveedor.Value = "-1"
|
|
HdnCvePersonal.Value = "-1"
|
|
ViewState("CveCliente") = HdnCveCliente.Value.ToEntero
|
|
ViewState("CveProveedor") = -1
|
|
ViewState("CvePersonal") = -1
|
|
CargaCliente(HdnCveCliente.Value.ToEntero)
|
|
End Sub
|
|
|
|
|
|
Private Sub CargaCliente(ByVal CveCliente As Integer)
|
|
Dim ObjCliente As New ClsClientes
|
|
|
|
If ObjCliente.GetClientes(CveCliente, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa, -1) Then
|
|
If ObjCliente.DtResultados.Rows.Count > 0 Then
|
|
TxtPagueseA.Text = String.Format("{0}", ObjCliente.Nombre) ' ObjPersonal.NombreCompleto
|
|
|
|
HdnProvPorIVA.Value = "0" 'ObjProveedor.IVA.ToString
|
|
HdnProvPorRetIVA.Value = "0" 'ObjProveedor.RetIVA.ToString
|
|
HdnProvPorRetISR.Value = "0" 'ObjProveedor.RetISR.ToString
|
|
IDCtaBeneficiario = ObjCliente.IdCtaContAnticipos
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
If IDCtaBeneficiario = 0 Then
|
|
Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
BtnGuardar.Enabled = False
|
|
Else
|
|
BtnGuardar.Enabled = True
|
|
End If
|
|
UpGuardar.Update()
|
|
End If
|
|
|
|
Else
|
|
Alert("El Cliente solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ObjCliente.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " CARGA PERSONAL "
|
|
Protected Sub BtnBuscarPersonal_Click(sender As Object, e As EventArgs) Handles BtnBuscarPersonal.Click
|
|
HdnCveProveedor.Value = "-1"
|
|
ViewState("CvePersonal") = HdnCvePersonal.Value.ToEntero
|
|
ViewState("CveProveedor") = -1
|
|
CargaPersonal(HdnCvePersonal.Value.ToEntero)
|
|
|
|
If Opcion = "DEV" Then
|
|
CargaIE()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaPersonal(ByVal CvePersonal As Integer)
|
|
Dim ObjPersonal As New ClsRH
|
|
|
|
If ObjPersonal.GetPersonal(CvePersonal, UsuarioActual.CveEmpresa) Then
|
|
If ObjPersonal.DtResultados.Rows.Count > 0 Then
|
|
TxtPagueseA.Text = String.Format("{0} {1} {2}", ObjPersonal.Nombres, ObjPersonal.APaterno, ObjPersonal.AMaterno) ' ObjPersonal.NombreCompleto
|
|
|
|
HdnProvPorIVA.Value = "0" 'ObjProveedor.IVA.ToString
|
|
HdnProvPorRetIVA.Value = "0" 'ObjProveedor.RetIVA.ToString
|
|
HdnProvPorRetISR.Value = "0" 'ObjProveedor.RetISR.ToString
|
|
IDCtaBeneficiario = ObjPersonal.IdCtaContPersonal
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
If IDCtaBeneficiario = 0 Then
|
|
Alert("El Beneficiario no tiene cuenta contable vinculada. Por favor rectifique y vuelva a intentar.", TipoMensaje.MsgAdvertencia)
|
|
BtnGuardar.Enabled = False
|
|
Else
|
|
BtnGuardar.Enabled = True
|
|
End If
|
|
UpGuardar.Update()
|
|
End If
|
|
|
|
CargaCuentasDepositos()
|
|
Else
|
|
Alert("El Personal solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ObjPersonal.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA CUENTAS DEPOSITOS "
|
|
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
|
|
If dr IsNot Nothing Then
|
|
HdnTipoTransaccion.Value = dr("Tipo").ToString
|
|
End If
|
|
Select Case valor
|
|
Case 1
|
|
LblPagueseA.Text = "Páguese a"
|
|
Case 2
|
|
LblPagueseA.Text = "Beneficiario"
|
|
End Select
|
|
|
|
If HdnTipoTransaccion.Value = "Egs" Then
|
|
CargaCuentasDepositos()
|
|
Else
|
|
|
|
End If
|
|
|
|
End Sub
|
|
Private Sub CargaCuentasDepositos()
|
|
DdlCuentaDeposito.Items.Clear()
|
|
If DdlTipoTransaccion.SelectedValue = "2" Then
|
|
trCuentaDeposito.Visible = False
|
|
If CvePersonal > 0 Or CveProveedor > 0 Then
|
|
Dim Dep As New ClsGenerales
|
|
If Dep.GetCuentasDepositos(CveProveedor:=CveProveedor, CvePersonal:=CvePersonal) Then
|
|
DdlCuentaDeposito.DataSource = Dep.DtResultados
|
|
If Dep.DtResultados.Rows.Count > 1 Then
|
|
trCuentaDeposito.Visible = True
|
|
DdlCuentaDeposito.Items.Insert(0, New ListItem("Seleccione una cuenta", "-1"))
|
|
ElseIf Dep.DtResultados.Rows.Count = 1 Then
|
|
TrCuentaDepositado.Visible = True
|
|
LitTextoDepositado.Text = "Cuenta Depósito"
|
|
LitDepositado.Text = Dep.DtResultados.Rows(0)("CuentaDeposito").ToString
|
|
End If
|
|
End If
|
|
Dep.Dispose()
|
|
|
|
DdlCuentaDeposito.DataBind()
|
|
End If
|
|
Else
|
|
trCuentaDeposito.Visible = False
|
|
DdlCuentaDeposito.Items.Clear()
|
|
End If
|
|
UpDatos.Update()
|
|
|
|
End Sub
|
|
Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
|
|
|
|
'si solo es de egreso el movimiento debe de generar el siguiente folio.
|
|
|
|
If HdnTipoTransaccion.Value = "Egs" Then
|
|
Dim Folio As Long
|
|
Dim Banco As New ClsBancos
|
|
Folio = Banco.GetNextFolio(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero)
|
|
Banco.Dispose()
|
|
TxtFolio.Text = Folio.ToString
|
|
Else
|
|
TxtFolio.Text = ""
|
|
End If
|
|
|
|
|
|
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
|
|
If dr IsNot Nothing Then
|
|
DdlMoneda.SelectedValue = dr("CveMoneda").ToString
|
|
IDCtaContable = dr("IdCtaContable").ToString.ToEntero
|
|
End If
|
|
|
|
If trIEDevolucion.Visible Then
|
|
CargaIE()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CARGA CREDITOS - DETALLE "
|
|
|
|
Protected Sub DdlFinanciera_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlFinanciera.SelectedIndexChanged
|
|
CargaCreditos(DdlFinanciera.SelectedValue.ToEntero)
|
|
End Sub
|
|
|
|
Private Sub CargaCreditos(CveProveedor As Integer)
|
|
If CveProveedor < 1 Then Exit Sub
|
|
|
|
Dim Cred As New ClsBancos
|
|
Dim dt As DataTable = Nothing
|
|
|
|
If Cred.GetCreditos(-1, -1, -1, CveProveedor, -1, UsuarioActual.CveEmpresa) Then
|
|
TxtPagueseA.Text = Cred.Proveedor
|
|
CveProveedor = Cred.CveProveedor
|
|
DdlCredito.DataSource = Cred.DtResultados.FiltraParametros(String.Format("CveProveedor = {0} AND EstatusNum in (1,2,101,102)", DdlFinanciera.SelectedValue), DistinctColumns:={"CveCredito", "ReferenciaCredito"}, Orderby:="ReferenciaCredito")
|
|
DdlCredito.DataBind()
|
|
DdlCredito.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
|
|
End If
|
|
|
|
Cred.Dispose()
|
|
|
|
DdlCreditoDetalle.Items.Clear()
|
|
DdlCreditoDetalle.DataSource = Nothing
|
|
DdlCreditoDetalle.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub DdlCredito_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCredito.SelectedIndexChanged
|
|
CargaCreditosDetalle()
|
|
End Sub
|
|
|
|
Private Sub CargaCreditosDetalle()
|
|
Dim Cred As New ClsBancos
|
|
Dim dt As DataTable = Nothing
|
|
|
|
If DdlCredito.SelectedValue.ToEntero > 0 AndAlso Cred.GetCreditos(DdlCredito.SelectedValue.ToEntero, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then
|
|
TxtPagueseA.Text = Cred.Proveedor
|
|
CveProveedor = Cred.CveProveedor
|
|
HdnCveTipoCredito.Value = Cred.CveTipoCredito.ToString
|
|
If Cred.GetCreditosDetalle(DdlCredito.SelectedValue.ToEntero, -1) Then
|
|
|
|
dt = Cred.DtResultados.FiltraParametros("Estatus IN (1,101,102)")
|
|
TxtImporte.Text = dt.Rows(0)("Mensualidad").ToString.FormatoNumero()
|
|
HdnImporteCredito.Value = dt.Rows(0)("Mensualidad").ToString
|
|
RegistraScript(String.Format("$get('TxtImporte').value = '{0}';", dt.Rows(0)("Mensualidad").ToString.FormatoNumero()))
|
|
|
|
End If
|
|
End If
|
|
|
|
Cred.Dispose()
|
|
|
|
DdlCreditoDetalle.DataSource = dt
|
|
DdlCreditoDetalle.DataBind()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#End Region
|
|
|
|
|
|
#Region "PESTAÑA INFORMACION GENERAL DE BANCO IE"
|
|
|
|
Private Sub CargaCuenta()
|
|
|
|
DdlCuenta.Items.Clear()
|
|
Dim dt As DataTable = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltraParametros("CveTipoCuenta <> 1") ' quito las cajas chicas
|
|
'If CveMoneda > 0 Then
|
|
' dt = dt.FiltraParametros(String.Format("CveMoneda = {0}", CveMoneda))
|
|
|
|
'End If
|
|
DdlCuenta.DataSource = dt
|
|
DdlCuenta.DataBind()
|
|
DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaTipoTransaccion()
|
|
Dim dt As DataTable
|
|
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("EGSSINFACT", "EGSCREDITO") Then
|
|
dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Egs'")
|
|
LtlTitulo.Text = "Egreso Por Comprobar"
|
|
|
|
ElseIf Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString.Contiene("DEV") Then
|
|
dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing'")
|
|
LtlTitulo.Text = "Devolución"
|
|
LblPagueseA.Text = "Recibido de:"
|
|
|
|
DivPegarImagen.Visible = False
|
|
ElseIf Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "ANTC" Then
|
|
dt = GlobalDTTipoTransacciones.FiltraParametros("Tipo='Ing'")
|
|
LtlTitulo.Text = "Anticipo de Cliente"
|
|
LblPagueseA.Text = "Recibido de:"
|
|
DivPegarImagen.Visible = True
|
|
RBL.Items.Remove(RBL.Items.FindByValue("P")) : RBL.Items.Remove(RBL.Items.FindByValue("FE")) : RBL.Items.Remove(RBL.Items.FindByValue("DD")) : RBL.Items.Remove(RBL.Items.FindByValue("AC")) : RBL.Items.Remove(RBL.Items.FindByValue("DP"))
|
|
Else
|
|
dt = GlobalDTTipoTransacciones
|
|
End If
|
|
|
|
DdlTipoTransaccion.DataSource = dt
|
|
DdlTipoTransaccion.DataBind()
|
|
DdlTipoTransaccion.Items.Insert(0, New ListItem("Seleccione Tipo Movimiento", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaMoneda()
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
End Sub
|
|
|
|
'Private Sub CargaEstatusIE()
|
|
' DdlEstatusIE.DataSource = GlobalDTEstatusIE
|
|
' DdlEstatusIE.DataBind()
|
|
'End Sub
|
|
|
|
'Protected Sub DdlBanco_SelectedIndexChanged1(sender As Object, e As System.EventArgs) Handles DdlBanco.SelectedIndexChanged
|
|
' CargaCuenta()
|
|
'End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
#Region " GUARDAR - ACTUALIZAR "
|
|
|
|
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
|
|
If DdlEstatusIE.SelectedValue = "2" AndAlso TxtImporte.Text.ToDouble > 0 Then
|
|
Alert("Un movimiento Cancelado debe tener importe = 0", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlEstatusIE.SelectedValue <> "2" AndAlso TxtImporte.Text.ToDouble <= 0 Then
|
|
Alert("Debe ingresar un importe", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
'cuando sea activo es requerido proveedor o personal
|
|
If DdlEstatusIE.SelectedValue = "1" AndAlso (CveProveedor <= 0 And CvePersonal <= 0) AndAlso HdnTipoTransaccion.Value = "Egs" Then
|
|
Alert("Debe de seleccionar un Proveedor o un Funcionario Empleado", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
If DdlEstatusIE.SelectedValue = "1" AndAlso TxtPagueseA.Text.Trim = "" Then
|
|
Alert("Ingrese Beneficiario", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim ObjIE As New ClsBancos()
|
|
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
|
Dim ObjComp As New ClsCompras(ObjIE.IniciaTransacSQL)
|
|
|
|
Dim MsgError As String = ""
|
|
Dim CveConceptoContable As Integer = 30
|
|
Dim CveConceptoCompra As Integer = 10
|
|
Dim CveCreditoDetalle As Integer = -1
|
|
Dim CIF As Double = 0
|
|
Dim CvePlantillaPoliza As Integer = 2
|
|
Dim CvePrePoliza As Integer = 0
|
|
|
|
If CveIE = -1 Then
|
|
|
|
Dim CveCuentaDeposito As Integer = 0
|
|
|
|
If DdlCuentaDeposito.Items.Count > 0 Then
|
|
CveCuentaDeposito = DdlCuentaDeposito.SelectedValue.ToEntero
|
|
End If
|
|
|
|
'Cuando es Egreso sin factura, se registra una compra tipo anticipo
|
|
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "EGSCREDITO" Then
|
|
|
|
CveConceptoCompra = 48 'Anticipo Acreedores
|
|
CveConceptoContable = 30 'Bancos
|
|
CveCreditoDetalle = DdlCreditoDetalle.SelectedValue.ToEntero
|
|
|
|
Dim Estatus As Integer = 2
|
|
If HdnCveTipoCredito.Value = "1" Then
|
|
Estatus = 103
|
|
'cuando es crediproveedores es, pago a documentos por pagar
|
|
CveConceptoCompra = 57
|
|
End If
|
|
ObjIE.UpdateCreditosDetalle(Estatus, CveCreditoDetalle)
|
|
|
|
If HdnImporteCredito.Value.ToDouble > 0 AndAlso TxtImporte.Text.ToDouble > HdnImporteCredito.Value.ToDouble Then
|
|
CIF = TxtImporte.Text.ToDouble - HdnImporteCredito.Value.ToDouble
|
|
Else
|
|
CIF = 0
|
|
End If
|
|
CvePlantillaPoliza = 5
|
|
|
|
|
|
End If
|
|
|
|
|
|
'Cuando es Egreso sin factura, se registra una compra tipo anticipo
|
|
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "EGSSINFACT" Then
|
|
|
|
Select Case RBL.SelectedValue
|
|
Case "P" 'Proveedores
|
|
If CveProveedor > 0 Then
|
|
CveConceptoCompra = 10 'Anticipo a proveedor
|
|
CveConceptoContable = 30 'Pago a Proveedor
|
|
CvePlantillaPoliza = 3
|
|
End If
|
|
|
|
Case "DD" ' Deudores Diversos
|
|
If CveProveedor > 0 Then
|
|
CveConceptoCompra = 43 'Prestamo a deudor diverso
|
|
CveConceptoContable = 30 'Bancos
|
|
'limpio el iva
|
|
HdnProvPorIVA.Value = "0"
|
|
CvePlantillaPoliza = 6
|
|
End If
|
|
Case "AC" ' Acreedores Diversos
|
|
If CveProveedor > 0 Then
|
|
CveConceptoCompra = 42 'Prestamo a acreedor diverso
|
|
CveConceptoContable = 30 'Bancos
|
|
'limpio el iva
|
|
HdnProvPorIVA.Value = "0"
|
|
CvePlantillaPoliza = 21
|
|
End If
|
|
Case "DP" ' Documentos por pagar
|
|
If CveProveedor > 0 Then
|
|
CveConceptoCompra = 50 'Anticipo doc por pagar
|
|
CveConceptoContable = 30 'Bancos
|
|
'limpio el iva
|
|
HdnProvPorIVA.Value = "0"
|
|
CvePlantillaPoliza = 22
|
|
End If
|
|
End Select
|
|
|
|
|
|
End If
|
|
|
|
'OBTIENE COMPROBANTE!!
|
|
Dim TipoComprobante = -1
|
|
Dim Comprobante As String = ""
|
|
'OBTIENE COMPROBANTE DE CARGAR ARCHIVO - COMPROBANTE TIPO 1
|
|
If Session("FileUpload").ToString <> String.Empty AndAlso Session("FileUpload").ToString <> "" Then
|
|
Comprobante = Session("FileUpload").ToString.Split("."c)(1)
|
|
TipoComprobante = 1
|
|
End If
|
|
|
|
'OBTIENE COMPROBANTE DE IMAGEN - COMPROBANTE TIPO 2
|
|
|
|
If HdnImagen.Value <> "" Then
|
|
'ejemplo: data:image/png;base64,
|
|
Dim ext As Integer = HdnImagen.Value.IndexOf(";"c)
|
|
Comprobante = HdnImagen.Value.Substring(5, ext - 5)
|
|
If Comprobante.Contains("image/") Then Comprobante = Comprobante.Replace("image/", "")
|
|
TipoComprobante = 2
|
|
End If
|
|
|
|
|
|
If CvePersonal > 0 Then
|
|
CveConceptoCompra = 28 'Prestamo Personal
|
|
CveConceptoContable = 30 'Banco
|
|
CvePlantillaPoliza = 8
|
|
End If
|
|
|
|
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "DEV" Then
|
|
If CvePersonal > 0 Then
|
|
CveConceptoCompra = 29 'Comprobacion Personal
|
|
CveConceptoContable = 30 'Bancos
|
|
CvePlantillaPoliza = 9
|
|
ElseIf CveProveedor > 0 Then
|
|
CveConceptoCompra = 21 'Pago a Proveedor/CAncelacion Anticipos
|
|
CveConceptoContable = 30 'Bancos
|
|
CvePlantillaPoliza = 7
|
|
End If
|
|
End If
|
|
|
|
If Request("Opcion") IsNot Nothing AndAlso Request("Opcion").ToString = "ANTC" Then
|
|
If CveCliente > 0 Then
|
|
CveConceptoCompra = 3 'Anticipo Clientes
|
|
CveConceptoContable = 30 'Bancos
|
|
CvePlantillaPoliza = 12
|
|
|
|
End If
|
|
End If
|
|
|
|
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Banc", CvePlantillaPoliza, TxtImporte.Text.Trim.ToDouble, TxtImporte.Text.Trim.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtFechaDocumento.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
'valida prepoliza
|
|
If CvePrePoliza > 0 Then
|
|
|
|
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, TxtImporte.Text.Trim.ToDouble, DdlMoneda.SelectedValue.ToEntero,
|
|
TxtTipoCambio.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, TxtNotificarA.Text.Trim, ChkAbonoCuenta.Checked, ChkAplicaImpuestos.Checked, -1, CvePrePoliza, Comprobante, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveCuentaDeposito:=CveCuentaDeposito, CveEstatusIE:=DdlEstatusIE.SelectedValue.ToString.ToEntero)
|
|
|
|
|
|
If CveIE > 0 Then
|
|
|
|
'GUARDA COMPROBANTE
|
|
If TipoComprobante > 0 Then
|
|
String.Format("{0}IE/", UsuarioActual.Empresa.Ruta).DirectoryExistsCreate()
|
|
|
|
If TipoComprobante = 2 AndAlso HdnImagen.Value <> "" Then
|
|
Dim ext As Integer = HdnImagen.Value.IndexOf(","c) + 1
|
|
|
|
'If Not Directory.Exists(String.Format("{0}IE/", UsuarioActual.Empresa.Ruta)) Then Directory.CreateDirectory(String.Format("{0}IE/", UsuarioActual.Empresa.Ruta))
|
|
|
|
Dim msf As New MemoryStream(Convert.FromBase64String(HdnImagen.Value.Substring(ext)))
|
|
Dim stem As Stream = New FileStream(String.Format("{0}IE\{1}.{2}", UsuarioActual.Empresa.Ruta, CveIE, Comprobante), FileMode.Create)
|
|
msf.WriteTo(stem)
|
|
msf.Close()
|
|
stem.Close()
|
|
ElseIf TipoComprobante = 1 AndAlso Comprobante <> "" Then
|
|
Dim DirectorioGuardar = String.Format("{0}IE", UsuarioActual.Empresa.Ruta)
|
|
Dim ArchivoTemporal = String.Format("{0}Temp\{2}", UsuarioActual.Empresa.Ruta, Session("FileUpload").ToString)
|
|
|
|
File.Move(ArchivoTemporal, String.Format("{0}\{1}.{2}", DirectorioGuardar, CveIE, Comprobante))
|
|
End If
|
|
End If
|
|
|
|
|
|
|
|
|
|
'MOVIMIENTOS DE LA CONTA PARA AFECTAR SALDO
|
|
If Not Opcion.Contiene("DEV", "ANTC") AndAlso MsgError = "" Then
|
|
|
|
'MOVIMIENTOS EGRESOS
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDouble, TxtObservaciones.Text, CveConceptoContable, TxtObservaciones.Text, Now, 0, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle) Then
|
|
Dim IVA As Double = 0 ' TxtImporte.Text.ToDouble * HdnProvPorIVA.Value.ToDouble
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDouble - IVA - CIF, TxtObservaciones.Text, CveConceptoCompra, TxtObservaciones.Text, Now, 0, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle) Then
|
|
If IVA > 0 AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, IVA, TxtObservaciones.Text, 19, TxtObservaciones.Text, Now, 0, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle) Then
|
|
MsgError = "Detalle"
|
|
End If
|
|
'intereses pagados
|
|
If CIF > 0 AndAlso Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, CIF, TxtObservaciones.Text, 46, TxtObservaciones.Text, Now, 0, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle) Then
|
|
MsgError = "Detalle"
|
|
End If
|
|
Else
|
|
MsgError = "no se pudo insertar el detalle de la póliza2"
|
|
End If
|
|
Else
|
|
MsgError = "no se pudo insertar el detalle de la póliza"
|
|
End If
|
|
|
|
|
|
'MOVIMIENTOS INGRESOS - DEVOLUCIONES
|
|
ElseIf Opcion.Contiene("DEV", "ANTC") AndAlso MsgError = "" Then
|
|
|
|
'If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDouble, TxtObservaciones.Text, CveConceptoContable, TxtObservaciones.Text, Now, 0, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCliente:=CveCliente, CveCreditoDetalle:=CveCreditoDetalle) Then
|
|
' If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDouble, TxtObservaciones.Text, CveConceptoCompra, TxtObservaciones.Text, Now, 0, -1, If(CveProveedor > 0, DdlIEDevolucion.SelectedValue.ToEntero, CveIE), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCliente:=CveCliente, CveCreditoDetalle:=CveCreditoDetalle) Then
|
|
' MsgError = "no se pudo insertar el detalle de la póliza 2"
|
|
' End If
|
|
'Else
|
|
' MsgError = "no se pudo insertar el detalle de la póliza"
|
|
'End If
|
|
If EmpresaPrueba Then
|
|
Dim CvePlantilaPoliza = 12
|
|
Dim tipoCambio As Decimal
|
|
|
|
If DdlMoneda.SelectedValue.ToString.ToEntero = 2 Then
|
|
tipoCambio = GlobalTipoCambio(Now).ToString.ToDecimal
|
|
Else
|
|
tipoCambio = 1
|
|
End If
|
|
|
|
If ObjMov.GetPlantillaConceptos(UsuarioActual.CveEmpresa, CvePlantilaPoliza) Then
|
|
For Each Row As DataRow In ObjMov.DtResultados.Rows
|
|
|
|
Dim ConceptoContable = Row("CveConcepto").ToString.ToEntero
|
|
Dim TipoMovimiento As Boolean = If(Row("TipoMovto").ToString = "True", True, False)
|
|
Dim importeMovimiento As Decimal
|
|
Dim FechaMovimiento As Date = TxtFechaDocumento.Text.ToDate
|
|
Dim IdCtaContablePP As Integer
|
|
Dim importeMX As Decimal
|
|
|
|
Select Case ConceptoContable
|
|
|
|
Case 3
|
|
importeMovimiento = TxtImporte.Text.ToDecimal
|
|
importeMX = importeMovimiento * tipoCambio
|
|
IdCtaContablePP = IDCtaBeneficiario
|
|
|
|
Case 30
|
|
importeMovimiento = TxtImporte.Text.ToDecimal
|
|
importeMX = importeMovimiento * tipoCambio
|
|
IdCtaContablePP = IDCtaContable
|
|
|
|
End Select
|
|
|
|
If importeMovimiento <> 0 Then
|
|
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovimiento, TxtImporte.Text.ToDouble, "", ConceptoContable, TxtObservaciones.Text, FechaMovimiento, IdCtaContablePP, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCliente:=CveCliente, CveCreditoDetalle:=CveCreditoDetalle, ImporteMX:=importeMX) Then
|
|
MsgError = "no se pudo insertar el detalle de la póliza"
|
|
End If
|
|
End If
|
|
|
|
Next
|
|
|
|
End If
|
|
|
|
Else 'EMpresa Prueba
|
|
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, False, TxtImporte.Text.ToDouble, TxtObservaciones.Text, CveConceptoContable, TxtObservaciones.Text, Now, 0, -1, CveIE, CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle) Then
|
|
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, True, TxtImporte.Text.ToDouble, TxtObservaciones.Text, CveConceptoCompra, TxtObservaciones.Text, Now, 0, -1, If(CveProveedor > 0, DdlIEDevolucion.SelectedValue.ToEntero, CveIE), CveCompra:=CveCompra, CveProveedor:=CveProveedor, CvePersonal:=CvePersonal, CveCreditoDetalle:=CveCreditoDetalle) Then
|
|
MsgError = "no se pudo insertar el detalle de la póliza 2"
|
|
End If
|
|
Else
|
|
MsgError = "no se pudo insertar el detalle de la póliza"
|
|
End If
|
|
|
|
End If 'Empresa Prueba
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
|
If UsuarioActual.Empresa.UsaAC Then
|
|
Dim ConceptoRenglon, Referencia As String
|
|
Dim FolioPoliza As Integer
|
|
Dim Fecha As Date = TxtFechaDocumento.Text.ToDate
|
|
Dim TipoChq As String = ""
|
|
Dim Total As Double = TxtImporte.Text.ToDouble
|
|
|
|
Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Conta.IniciaTransacSQL()
|
|
|
|
If DdlTipoTransaccion.SelectedValue = "1" Then TipoChq = "CHQ"
|
|
ConceptoRenglon = String.Format("Anticipo {0}", TxtPagueseA.Text.Trim)
|
|
|
|
IDPoliza = Conta.AddPoliza(123456, 2, ConceptoRenglon, Total, Total, UsuarioActual.CveUsuario, Fecha, TxtFolio.Text, TipoChq)
|
|
|
|
If IDPoliza > 0 Then
|
|
FolioPoliza = Conta.Folio
|
|
Referencia = TxtFolio.Text
|
|
ConceptoRenglon = String.Format("Anticipo {0} {1}", TxtPagueseA.Text.Trim, TxtObservaciones.Text)
|
|
|
|
Total = TxtImporte.Text.ToDouble
|
|
|
|
If Not Conta.AddMovimiento(123456, IDPoliza, IDCtaContable, True, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then MsgError = "No se insertó el movimiento"
|
|
|
|
If Not Conta.AddMovimiento(123456, IDPoliza, IDCtaBeneficiario, False, Total, Referencia, ConceptoRenglon, 0, Fecha, "") Then MsgError = "No se insertó el movimiento"
|
|
|
|
Else
|
|
MsgError = "No se insertó el encabezado"
|
|
End If
|
|
|
|
If MsgError = "" Then
|
|
Conta.Commit()
|
|
|
|
Conta.AjustaPoliza(IDPoliza)
|
|
'actualizar la conta del IE
|
|
ObjIE.UpdateIEPrePoliza(Fecha, FolioPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0)
|
|
|
|
Else
|
|
Conta.RollBack()
|
|
IDPoliza = 0
|
|
End If
|
|
|
|
Conta.Dispose()
|
|
|
|
End If
|
|
|
|
Else
|
|
MsgError = "No se insertó el encabezado"
|
|
End If
|
|
Else
|
|
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
'Else
|
|
' MsgError = "Error al guardar"
|
|
'End If
|
|
|
|
Else
|
|
'If ObjIE.UpdateBancos_IE(DdlTipo.SelectedItem.ToString, DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, TxtImporte.Text.Trim.ToDouble, DdlMoneda.SelectedValue.ToEntero, TxtTipoCambio.Text.Trim.ToDouble, TxtObservaciones.Text.Trim, ChkEsAbonoEnCuenta.Checked, ChkAplicaImpuestos.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
Alert("El Documento se guardó correctamente.--------------Aun no Actualiza", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/IE.aspx"";")
|
|
'End If
|
|
' 'CargaDatos()
|
|
' UpDatos.Update()
|
|
' Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
'End If
|
|
End If
|
|
|
|
If MsgError = "" Then
|
|
Alert("El Documento se guardó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/IE.aspx"";")
|
|
ObjIE.Commit()
|
|
GeneraChequePDF(CveIE, UsuarioActual.Empresa)
|
|
Else
|
|
ObjIE.RollBack()
|
|
End If
|
|
|
|
ObjIE.Dispose()
|
|
ObjMov.Dispose()
|
|
If ObjComp IsNot Nothing Then ObjComp.Dispose()
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnActualizar_Click(sender As Object, e As EventArgs) Handles BtnActualizar.Click
|
|
Dim IE As New ClsBancos
|
|
|
|
If IE.UpdateBancos_IE(TxtFechaDocumento.Text.ToDate, Nothing, CveIE) Then
|
|
Alert("La Actualización del documento se realizó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
IE.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub ImgUpdateCuentaDeposito_Click(sender As Object, e As ImageClickEventArgs)
|
|
Dim IE As New ClsBancos
|
|
|
|
If IE.UpdateBancos_IECuentaDeposito(DdlCuentaDeposito.SelectedValue.ToEntero, CveIE) Then
|
|
Alert("Se vinculó con exito la cuenta deposito", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrió un error al vincular la cuenta deposito al IE", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
IE.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " ELIMINAR/CANCELAR - MOVIMIENTO "
|
|
|
|
Protected Sub BtnCancelarIE_Click(sender As Object, e As EventArgs)
|
|
RegistraScript("$('#DivCancelarIE').modal('hide');")
|
|
CancelarIE()
|
|
End Sub
|
|
|
|
Private Sub CancelarIE()
|
|
|
|
If Not IsDate(TxtFechaCancelacion.Text.ToDate) Then
|
|
Alert("El campo fecha cancelación es incorrecto. Por favor verifique y vuelva a intentar")
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim Banc As New ClsBancos
|
|
Banc.IniciaTransacSQL()
|
|
Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjAC.IniciaTransacSQL()
|
|
|
|
Dim ErrorCancelar = False
|
|
Dim IdPolizaNueva = -1
|
|
Dim FolioPolizaNueva = -1
|
|
|
|
If IDPoliza > 0 Then
|
|
Dim dt As DataTable
|
|
If ObjAC.GetPoliza(IDPoliza, -1, -1, -1, -1) AndAlso ObjAC.DtResultados.Rows.Count > 0 Then
|
|
dt = ObjAC.DtResultados
|
|
|
|
' MES ANTERIOR, MOVIMIENTOS CONTRARIOS (NEGATIVOS)
|
|
If dt.Rows(0)("FechaPol").ToString.ToDate.Month < TxtFechaCancelacion.Text.ToDate.Month Or dt.Rows(0)("FechaPol").ToString.ToDate.Year < TxtFechaCancelacion.Text.ToDate.Year Then
|
|
IdPolizaNueva = ObjAC.AddPoliza(123456, dt.Rows(0)("CodigoTipoPoliza").ToString.ToEntero, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), 0, 0, UsuarioActual.CveUsuario, TxtFechaCancelacion.Text.ToDate)
|
|
|
|
If IdPolizaNueva > 0 Then
|
|
FolioPolizaNueva = ObjAC.Folio
|
|
|
|
'CREA POLIZA NEGATIVA
|
|
For Each dr As DataRow In dt.Rows
|
|
If Not ObjAC.AddMovimiento(123, IdPolizaNueva, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "True", dr("Importe").ToString.ToDecimal * -1, dr("Referencia").ToString, String.Format("Cancelacion: {0}", dt.Rows(0)("Concepto").ToString), dr("IdSegNeg").ToString.ToEntero, TxtFechaCancelacion.Text.ToDate, "") Then
|
|
ErrorCancelar = True : Exit For
|
|
End If
|
|
Next
|
|
|
|
'AJUSTA POLIZA
|
|
If Not ErrorCancelar Then
|
|
If Not ObjAC.AjustaPoliza(IdPolizaNueva) Then
|
|
ErrorCancelar = True
|
|
End If
|
|
End If
|
|
|
|
'CANCELA IE
|
|
If Not ErrorCancelar Then
|
|
If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, True, IdPolizaNueva) Then
|
|
ErrorCancelar = True
|
|
End If
|
|
End If
|
|
|
|
Else
|
|
ErrorCancelar = True
|
|
End If
|
|
|
|
Else
|
|
|
|
'LIMPIA POLIZA PONIENDO IMPORTE EN CEROS
|
|
For Each dr As DataRow In dt.Rows
|
|
If Not ObjAC.UpdateMovimiento(dr("Id").ToString.ToEntero, dr("IdCuenta").ToString.ToEntero, dr("TipoMovto").ToString = "1", 0, dr("Referencia").ToString, dr("Concepto").ToString, dr("IdSegNeg").ToString.ToEntero, dr("Fecha").ToString.ToDate) Then
|
|
ErrorCancelar = True : Exit For
|
|
End If
|
|
Next
|
|
|
|
'AJUSTA POLIZA
|
|
If Not ErrorCancelar Then
|
|
If Not ObjAC.AjustaPoliza(IDPoliza) Then
|
|
ErrorCancelar = True
|
|
End If
|
|
End If
|
|
|
|
'CANCELA IE
|
|
If Not ErrorCancelar Then
|
|
If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva) Then
|
|
ErrorCancelar = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
End If
|
|
Else
|
|
|
|
If TxtFechaDocumento.Text.ToDate.Month < TxtFechaCancelacion.Text.ToDate.Month Or TxtFechaDocumento.Text.ToDate.Year < TxtFechaCancelacion.Text.ToDate.Year Then
|
|
'CANCELA IE MES ANTERIOR
|
|
If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva) Then
|
|
ErrorCancelar = True
|
|
End If
|
|
Else
|
|
'CANCELA IE MES ACTUAL
|
|
If Not Banc.CancelarBancos_IE(UsuarioActual.CveUsuario, CveIE, False, IdPolizaNueva) Then
|
|
ErrorCancelar = True
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
If Not ErrorCancelar Then
|
|
ObjAC.Commit()
|
|
Banc.Commit()
|
|
Dim Msg As New StringBuilder
|
|
Msg.Append("El movimiento bancario quedó cancelado exitosamente.")
|
|
|
|
If IdPolizaNueva > 0 Then Msg.AppendFormat("<br/><br/><a class=""Texto"" target='_blank' href=""/Contabilidad/RegPoliza.aspx?IdPoliza={0}"">Ver Póliza de cancelación</a>", IdPolizaNueva)
|
|
Alert(Msg.ToString, TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/RepIE.aspx""")
|
|
Else
|
|
ObjAC.RollBack()
|
|
Banc.RollBack()
|
|
Alert("El movimiento bancario no se pudo cancelar. Por favor vuelva a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjAC.Dispose()
|
|
Banc.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub LnkEliminar_Click(sender As Object, e As EventArgs) Handles LnkEliminar.Click
|
|
Dim ObjAC As ClsContPAQi = Nothing
|
|
Dim Banc As New ClsBancos
|
|
Banc.IniciaTransacSQL()
|
|
|
|
Dim ErrorCompra = False
|
|
|
|
If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IDPoliza > 0 Then
|
|
ObjAC = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjAC.IniciaTransacSQL()
|
|
If Not ObjAC.RemovePoliza(IDPoliza) Then
|
|
ErrorCompra = True
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorCompra Then
|
|
If Not Banc.EliminarBancos_IE(UsuarioActual.CveUsuario, CveIE) Then
|
|
ErrorCompra = True
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorCompra Then
|
|
Alert("El documento bancario quedó eliminado.", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/RepIE.aspx""")
|
|
If ObjAC IsNot Nothing Then ObjAC.Commit()
|
|
Banc.Commit()
|
|
Else
|
|
Alert("El documento no ha sido eliminado.", TipoMensaje.MsgAdvertencia)
|
|
If ObjAC IsNot Nothing Then ObjAC.RollBack()
|
|
Banc.RollBack()
|
|
End If
|
|
|
|
If ObjAC IsNot Nothing Then ObjAC.Dispose()
|
|
Banc.Dispose()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
|
|
Protected Sub DdlMoneda_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlMoneda.SelectedIndexChanged
|
|
If DdlMoneda.SelectedValue.ToEntero > 1 Then
|
|
TrTipoCambio.Visible = True
|
|
Else
|
|
TrTipoCambio.Visible = False
|
|
End If
|
|
End Sub
|
|
|
|
<WebMethod()> <Script.Services.ScriptMethodAttribute()>
|
|
Public Shared Function wsImporteLetra(ByVal contextKey As System.String, ByVal tCveMoneda As Integer) As System.String
|
|
Dim Retorno As String = ""
|
|
|
|
If contextKey.ToDouble >= 0 Then
|
|
Retorno = String.Format("---{0}---", contextKey.ToDouble.Texto2Letras(tCveMoneda))
|
|
End If
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
Protected Sub RBL_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RBL.SelectedIndexChanged
|
|
If RBL.SelectedValue = "FE" Then
|
|
HplBuscar.NavigateUrl = "/RH/PopUpBuscarPersonal.aspx?EsThickbox=S&Opt=Fact&TB_iframe=true&height=500&width=800"
|
|
ElseIf RBL.SelectedValue = "DD" Then
|
|
HplBuscar.NavigateUrl = "/Compras/PopUpBuscarProveedor.aspx?EsThickbox=S&Opt=Fact&Txt=Deudores&TB_iframe=true&height=500&width=800"
|
|
ElseIf RBL.SelectedValue = "C" Then
|
|
HplBuscar.NavigateUrl = "/Ventas/PopUpBuscarClientes.aspx?EsThickbox=S&Opt=Fact&TB_iframe=true&height=500&width=800"
|
|
Else
|
|
HplBuscar.NavigateUrl = "/Compras/PopUpBuscarProveedor.aspx?EsThickbox=S&Opt=Fact&TB_iframe=true&height=500&width=800"
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
#Region " IMPRIMIR "
|
|
'Protected Sub ImgImprimir_Click(sender As Object, e As EventArgs) Handles ImgImprimir.Click
|
|
' GeneraChequePDF(CveIE, UsuarioActual.Empresa)
|
|
'End Sub
|
|
Protected Sub LnkImprimir_Click(sender As Object, e As EventArgs) Handles LnkImprimir.Click
|
|
GeneraChequePDF(CveIE, UsuarioActual.Empresa)
|
|
End Sub
|
|
Protected Sub BtnImprimir_Click(sender As Object, e As EventArgs) Handles BtnImprimir.Click
|
|
If CveIE > 0 Then GeneraChequePDF(CveIE, UsuarioActual.Empresa)
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
#Region "E V E N T O - B I T A C O R A"
|
|
Protected Sub GVEventoBitacora_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvEB.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(200)
|
|
e.Row.Cells(1).Width = Unit.Pixel(200)
|
|
e.Row.Cells(2).Width = Unit.Pixel(100)
|
|
e.Row.Cells(3).Width = Unit.Pixel(500)
|
|
End If
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Left
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnGuardarEventoBitacora_Click(sender As Object, e As EventArgs) Handles BtnGuardarEventoBitacora.Click
|
|
|
|
Dim ObjEventoBitacora As New ClsOIEventos
|
|
If ObjEventoBitacora.AddEventoBitacora(TxtEventoDescripcion.Text.Trim, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados
|
|
TxtEventoDescripcion.Text = ""
|
|
Alert("La bitácora/observación se guardó correctamente", TipoMensaje.MsgInformacion)
|
|
End If
|
|
ObjEventoBitacora.Dispose()
|
|
GvEB.DataBind()
|
|
|
|
UPEventoBitacora.Update()
|
|
CargaEventoBitacora()
|
|
End Sub
|
|
Private Sub CargaEventoBitacora()
|
|
|
|
Dim ObjEventoBitacora As New ClsOIEventos()
|
|
If ObjEventoBitacora.GetAgendaBitacora(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CveIE:=CveIE) Then
|
|
'GVEventoBitacora.DataSource = ObjEventoBitacora.DtResultados
|
|
GvEB.DataSource = ObjEventoBitacora.DtResultados.FiltraParametros("CveTipoEvento = 6 OR CveTipoEvento = 2")
|
|
Else
|
|
GvEB.DataSource = Nothing
|
|
End If
|
|
GvEB.DataBind()
|
|
End Sub
|
|
#End Region
|
|
|
|
|
|
'#Region " SIMPLIFICAR - AC "
|
|
' Protected Sub BtnSimplificarAC_Click(sender As Object, e As EventArgs) Handles BtnSimplificarAC.Click
|
|
' If UsuarioActual.Empresa.UsaAC Then
|
|
|
|
|
|
' Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
' Conta.IniciaTransacSQL()
|
|
' Dim Total As Double = TxtImporte.Text.ToDouble
|
|
' Dim FolioPoliza As String
|
|
' Dim TieneError As Boolean = False
|
|
|
|
' If IDPoliza > 0 Then
|
|
' FolioPoliza = Conta.Folio.ToString
|
|
' Dim ConceptoRenglon As String
|
|
|
|
' 'NECESITO SACAR LAS PARTIDAS DE CADA PRESUPUESTO DE LAS FACTURAS PARA AFECTARLAS CON EL PAGO
|
|
' Dim dtAC As New DataTable
|
|
' dtAC.Columns.Add("PorcentajePago", Type.GetType("System.Double"))
|
|
' Dim PorcentajePago As Double = 1
|
|
' 'Dim ComprasAC As New ClsCompras
|
|
|
|
|
|
' Dim Mov As New ClsContabilidad
|
|
' Dim dtMovs As DataTable = Nothing
|
|
|
|
' If Mov.GetPrePolizasDetalle(-1, CveIE) Then
|
|
' dtMovs = Mov.DtResultados.FiltraParametros("CveConceptoContable IN (17)")
|
|
' End If
|
|
' Mov.Dispose()
|
|
|
|
' Dim Comp As New ClsCompras
|
|
|
|
' Conta.RemoveAllMovimientos(IDPoliza)
|
|
|
|
' For Each drr As DataRow In dtMovs.Rows
|
|
|
|
|
|
' 'obtengo su poliza para ver que presupuestos afecto
|
|
' ' If gvr.DataKey("Original").ToDouble > 0 Then PorcentajePago = gvr.FCTextBox("TxtAbonar").Text.ToDouble / gvr.DataKey("Original").ToDouble Else PorcentajePago = 1
|
|
|
|
' If Comp.GetPresupuestosCompras(drr("CveCompra").ToString.ToEntero) Then
|
|
' dtAC.Merge(Comp.DtResultados)
|
|
|
|
' For Each dr As DataRow In Comp.DtResultados.Rows
|
|
' Total = dr("TotalPresupuesto").ToString.ToDouble * PorcentajePago
|
|
|
|
' If Total > 0 Then
|
|
|
|
|
|
|
|
' ConceptoRenglon = String.Format("GE {0} Fact:{1}", TxtPagueseA.Text.Trim, dr("SerieFolio"))
|
|
' If Conta.AddMovimiento(123456, IDPoliza, dr("IdCuentaEjercido").ToString.ToEntero, False, Total, TxtFolio.Text, ConceptoRenglon, 0, TxtFechaDocumento.Text.ToDate, "") Then
|
|
' 'actualizo el idcuenta del presupuesto
|
|
' If Not Conta.AddMovimiento(123456, IDPoliza, dr("IdCuentaDevengado").ToString.ToEntero, True, Total, TxtFolio.Text, ConceptoRenglon, 0, TxtFechaDocumento.Text.ToDate, "") Then
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
|
|
' Else
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
|
|
|
|
' 'PAGADO
|
|
' ConceptoRenglon = String.Format("GP {0} Fact:{1}", TxtPagueseA.Text.Trim, dr("SerieFolio"))
|
|
' If Conta.AddMovimiento(123456, IDPoliza, dr("IdCuentaPagado").ToString.ToEntero, False, Total, TxtFolio.Text, ConceptoRenglon, 0, TxtFechaDocumento.Text.ToDate, "") Then
|
|
' 'actualizo el idcuenta del presupuesto
|
|
' If Not Conta.AddMovimiento(123456, IDPoliza, dr("IdCuentaEjercido").ToString.ToEntero, True, Total, TxtFolio.Text, ConceptoRenglon, 0, TxtFechaDocumento.Text.ToDate, "") Then
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
' Else
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
|
|
|
|
' 'obtengo el la cuenta del proveedor
|
|
' 'Dim CtaProveedor As Integer
|
|
|
|
' 'If drr("CveProveedor").ToString.ToEntero > 0 Then
|
|
' ' Dim ObjProveedor As New ClsCompProveedores()
|
|
|
|
' ' If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, drr("CveProveedor").ToString.ToEntero, "-1", "-1", "-1", "-1", "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
|
|
' ' If ObjProveedor.DtResultados.Rows.Count > 0 Then
|
|
|
|
' ' CtaProveedor = ObjProveedor.IdCtaContProveedores
|
|
' ' Else
|
|
' ' Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
' ' End If
|
|
' ' End If
|
|
' ' ObjProveedor.Dispose()
|
|
|
|
' 'End If
|
|
|
|
' 'AFECTAR MATRIZ EGRESOS
|
|
|
|
' If Conta.AddMovimiento(123456, IDPoliza, dr("IdCtaContProveedores").ToString.ToEntero, False, Total, TxtFolio.Text, ConceptoRenglon, 0, TxtFechaDocumento.Text.ToDate, "") Then
|
|
|
|
' Else
|
|
' TieneError = True
|
|
' Exit For
|
|
' End If
|
|
|
|
' End If
|
|
' Next
|
|
|
|
' End If
|
|
' Next
|
|
|
|
' 'registro de movimiento de banco, a nivel total
|
|
' ConceptoRenglon = String.Format("GP {0} {1}", TxtPagueseA.Text.Trim, TxtObservaciones.Text)
|
|
' Total = TxtImporte.Text.ToDouble
|
|
' 'actualizo el idcuenta del presupuesto
|
|
' If Not Conta.AddMovimiento(123456, IDPoliza, IDCtaContable, True, Total, TxtFolio.Text, ConceptoRenglon, 0, TxtFechaDocumento.Text.ToDate, "") Then
|
|
' TieneError = True
|
|
|
|
' End If
|
|
|
|
|
|
' Else
|
|
' TieneError = True
|
|
' End If
|
|
' If Not TieneError Then
|
|
|
|
' Conta.AjustaPoliza(IDPoliza)
|
|
' Conta.Commit()
|
|
|
|
' Else
|
|
' Conta.RollBack()
|
|
|
|
' End If
|
|
' Conta.Dispose()
|
|
|
|
|
|
' End If
|
|
' End Sub
|
|
'#End Region
|
|
|
|
|
|
#Region " C O N T A B I L I D A D DESASOCIAR POLIZA "
|
|
Protected Sub BtnDescontabilizar_Click(sender As Object, e As EventArgs)
|
|
Dim ObjConta As New ClsContabilidad
|
|
Dim Movimientos = ObjConta.GetMovimientosPoliza(IDPoliza, UsuarioActual.CveEmpresa)
|
|
|
|
'Verifica que solo exista 1 compra asociada
|
|
If Movimientos = 1 Then
|
|
EliminaPoliza()
|
|
Else
|
|
RegistraScript("ConfirmEliminarPoliza();")
|
|
End If
|
|
|
|
ObjConta.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub BtnEliminarPoliza_Click(sender As Object, e As EventArgs)
|
|
EliminaPoliza()
|
|
End Sub
|
|
|
|
Private Sub EliminaPoliza()
|
|
Dim ObjAC As New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjAC.IniciaTransacSQL()
|
|
Dim ObjConta As New ClsContabilidad
|
|
ObjConta.IniciaTransacSQL()
|
|
|
|
Dim ErrorCompra = False
|
|
|
|
'Elimina la poliza
|
|
If (UsuarioActual.Empresa.UsaAC Or UsuarioActual.Empresa.UsaContabilidad) AndAlso IDPoliza > 0 Then
|
|
If Not ObjAC.RemovePoliza(IDPoliza) Then
|
|
ErrorCompra = True
|
|
End If
|
|
End If
|
|
|
|
'Desasocia la poliza
|
|
If Not ErrorCompra Then
|
|
If Not ObjConta.DesasociarPoliza(IDPoliza, UsuarioActual.CveEmpresa) Then
|
|
ErrorCompra = True
|
|
End If
|
|
End If
|
|
|
|
If Not ErrorCompra Then
|
|
Alert("La poliza ha sido desvinculada y eliminada con exito.", TipoMensaje.MsgInformacion)
|
|
ObjAC.Commit()
|
|
ObjConta.Commit()
|
|
Else
|
|
Alert("Ocurrió un error al desvincular y/o eliminar la poliza. Por favor intente de nuevo ", TipoMensaje.MsgError)
|
|
ObjAC.RollBack()
|
|
ObjConta.RollBack()
|
|
End If
|
|
|
|
ObjAC.Dispose()
|
|
ObjConta.Dispose()
|
|
|
|
If Not ErrorCompra Then
|
|
CargaDatos()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " CARGAR - COMPROBANTE "
|
|
Protected Sub BtnConfirmaComprobante_Click(sender As Object, e As EventArgs)
|
|
Dim DirectorioGuardar = String.Format("{0}Empresas\{1}\IE", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa)
|
|
Dim ArchivoTemporal = String.Format("{0}Empresas\{1}\Temp\{2}", ModExtensiones.DirectorioBaseEmpresas, UsuarioActual.CveEmpresa, Session("FileUpload").ToString)
|
|
|
|
If Session("FileUpload").ToString <> String.Empty AndAlso File.Exists(ArchivoTemporal) Then
|
|
Dim Extension As String = Path.GetExtension(ArchivoTemporal)
|
|
|
|
Dim ObjIE As New ClsBancos
|
|
ObjIE.IniciaTransacSQL()
|
|
Dim TieneError = False
|
|
|
|
If ObjIE.UpdateComprobanteIE(Extension.Replace("."c, ""), CveIE) Then
|
|
If Not Directory.Exists(DirectorioGuardar) Then Directory.CreateDirectory(DirectorioGuardar)
|
|
|
|
'Si ya existe el archivo lo eliminamos, para evitar error
|
|
If File.Exists(String.Format("{0}\{1}{2}", DirectorioGuardar, CveIE, Extension)) Then
|
|
File.Delete(String.Format("{0}\{1}{2}", DirectorioGuardar, CveIE, Extension))
|
|
End If
|
|
|
|
File.Move(ArchivoTemporal, String.Format("{0}\{1}{2}", DirectorioGuardar, CveIE, Extension))
|
|
|
|
If Not File.Exists(String.Format("{0}\{1}{2}", DirectorioGuardar, CveIE, Extension)) Then
|
|
TieneError = True
|
|
End If
|
|
Else
|
|
TieneError = True
|
|
End If
|
|
|
|
If Not TieneError Then
|
|
ObjIE.Commit()
|
|
Alert("El Comprobante se guardo exitosamente.", TipoMensaje.MsgInformacion)
|
|
|
|
If HplComprobante.Visible = False Then
|
|
HplComprobante.Visible = True
|
|
HplComprobante.NavigateUrl = String.Format("/Empresas/{0}/IE/{1}{2}", UsuarioActual.CveEmpresa, CveIE, Extension)
|
|
UpDatos.Update()
|
|
End If
|
|
Else
|
|
ObjIE.RollBack()
|
|
Alert("Ocurrió un error al guardar el comprobante. Por favor vuelta a intentar.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
Session("FileUpload") = ""
|
|
ObjIE.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
|
|
#Region " DEVOLUCIONES "
|
|
|
|
Private Sub CargaIE()
|
|
Dim ObjMov As New ClsMovimientos
|
|
Dim DtIEDevolucion As DataTable = Nothing
|
|
|
|
If HdnCveProveedor.Value.ToEntero > 0 Or HdnCvePersonal.Value.ToEntero > 0 Then
|
|
trIEDevolucion.Visible = True
|
|
|
|
If ObjMov.GetEgresosSinComprobar("-1", "-1", HdnCveProveedor.Value.ToEntero, HdnCvePersonal.Value.ToEntero, -1, -1, -1, DdlMoneda.SelectedValue.ToEntero, -1, UsuarioActual.CveEmpresa) Then
|
|
DtIEDevolucion = ObjMov.DtResultados.FiltraParametros("CveIE > 0 AND Saldo > 0 ")
|
|
Else
|
|
Alert("Ocurrió un error al cargar los Egresos del Proveedor seleccionado. Por favor vuelva a intetar.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
End If
|
|
ObjMov.Dispose()
|
|
|
|
'CARGAMOS LOS IE EN EL DLL
|
|
DdlIEDevolucion.Items.Clear()
|
|
DdlIEDevolucion.DataSource = DtIEDevolucion
|
|
DdlIEDevolucion.DataBind()
|
|
DdlIEDevolucion.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
UpIEDevolucion.Update()
|
|
|
|
End Sub
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
End Class |