668 lines
28 KiB
VB.net
668 lines
28 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
Imports System.Linq
|
|
Imports System.Web.Services
|
|
|
|
|
|
Partial Class Bancos_OtrosIE
|
|
Inherits ClsPaginas
|
|
|
|
Private Shared missing As Object = System.Reflection.Missing.Value
|
|
Public Property ArregloMovs As ArrayList
|
|
Get
|
|
Return CType(ViewState("ArregloMovs"), ArrayList)
|
|
End Get
|
|
Set(value As ArrayList)
|
|
ViewState("ArregloMovs") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DTMovimientos As DataTable
|
|
Get
|
|
Return CType(ViewState("DTMovimientos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTMovimientos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property DTCuentasContables As DataTable
|
|
Get
|
|
Return CType(ViewState("DTCuentasContables"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DTCuentasContables") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property TipoPlantilla As Integer
|
|
Get
|
|
Return CType(ViewState("TipoPlantilla"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("TipoPlantilla") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property CveMoneda As Integer
|
|
Get
|
|
Return CType(ViewState("CveMoneda"), Integer)
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveMoneda") = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
|
|
If Not Page.IsPostBack Then
|
|
CveMoneda = 1
|
|
DirectCast(Master.FindControl("TSM"), ScriptManager).EnablePageMethods = True
|
|
|
|
Dim DT As DataTable = Nothing
|
|
If UsuarioActual.Empresa.UsaContabilidad Then
|
|
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
|
|
If ObjConta.GetCuentas(-1, "-1", 1) Then
|
|
DT = ObjConta.DtResultados
|
|
DTCuentasContables = ObjConta.DtResultados
|
|
Session("DTCuentas") = ObjConta.DtResultados
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
End If
|
|
|
|
TipoPlantilla = 0
|
|
If IfNull(Request("Tipo"), "").ToString = "Ing" Then
|
|
TipoPlantilla = 1
|
|
LtlEncabezado.Text = "Otros Ingresos"
|
|
TrPaguese.Visible = False
|
|
End If
|
|
|
|
ChkContabilizar.Attributes.Add("onclick", "javascript:showContent(this)")
|
|
CargaPlantillas(TipoPlantilla)
|
|
|
|
CargaTipoTransaccion(TipoPlantilla)
|
|
CargaCuenta()
|
|
|
|
'CREA TABLA TEMPORAL
|
|
ArregloMovs = New ArrayList
|
|
DTMovimientos = New DataTable("Movimientos")
|
|
Dim IDMov As DataColumn = DTMovimientos.Columns.Add("IdMov", Type.GetType("System.Int32")) : IDMov.AutoIncrement = True
|
|
With DTMovimientos.Columns
|
|
.Add("IdCuenta", Type.GetType("System.Int32"))
|
|
.Add("CodigoCuenta", Type.GetType("System.String"))
|
|
.Add("Cuenta", Type.GetType("System.String"))
|
|
.Add("Referencia", Type.GetType("System.String"))
|
|
.Add("Concepto", Type.GetType("System.String"))
|
|
.Add("Cargo", Type.GetType("System.Double"))
|
|
.Add("Abono", Type.GetType("System.Double"))
|
|
.Add("TipoMovto", Type.GetType("System.Int32"))
|
|
.Add("EsComodin", Type.GetType("System.Int32"))
|
|
.Add("CveConcepto", Type.GetType("System.Int32"))
|
|
End With
|
|
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaPlantillas(TipoPlantilla As Integer)
|
|
DdlPlantilla.DataSource = GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa, TipoPlantilla)
|
|
DdlPlantilla.DataBind()
|
|
DdlPlantilla.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaCuenta()
|
|
DdlCuenta.Items.Clear()
|
|
DdlCuenta.DataSource = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa)
|
|
DdlCuenta.DataBind()
|
|
DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaTipoTransaccion(TipoPlantilla As Integer)
|
|
DdlTipoTransaccion.DataSource = GlobalDTTipoTransacciones.FiltraParametros(String.Format("Tipo = '{0}' ", If(TipoPlantilla = 0, "Egs", "Ing")))
|
|
DdlTipoTransaccion.DataBind()
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoTransaccion_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoTransaccion.SelectedIndexChanged
|
|
CargaFolio()
|
|
End Sub
|
|
|
|
Private Sub CargaFolio()
|
|
If HdnTipoTransaccion.Value = "" Then CargaHdnTipoTransaccion()
|
|
If HdnTipoTransaccion.Value = "Egs" Then
|
|
If DdlTipoTransaccion.SelectedValue.ToEntero > 0 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
|
|
End If
|
|
|
|
Else
|
|
TxtFolio.Text = ""
|
|
End If
|
|
|
|
Dim dr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero(String.Format("CveCuenta={0}", DdlCuenta.SelectedValue))
|
|
If dr IsNot Nothing Then
|
|
CveMoneda = dr("CveMoneda").ToString.ToEntero
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaHdnTipoTransaccion()
|
|
Dim dr As DataRow = GlobalDTTipoTransacciones.FiltroPrimero(String.Format("CveTipoTransaccion = {0}", DdlTipoTransaccion.SelectedValue)) 'Egs o Ing
|
|
If dr IsNot Nothing Then
|
|
HdnTipoTransaccion.Value = dr("Tipo").ToString
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub DdlCuenta_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlCuenta.SelectedIndexChanged
|
|
CargaFolio()
|
|
End Sub
|
|
|
|
<WebMethodAttribute()> <Script.Services.ScriptMethodAttribute()> _
|
|
Public Shared Function wsGetCuentas(ByVal prefixText As String, ByVal count As Integer) As String()
|
|
Dim items As New List(Of String)(count)
|
|
Dim dbrows As DataRow()
|
|
|
|
dbrows = DirectCast(HttpContext.Current.Session("DTCuentas"), DataTable).Select(String.Format("nombre like '%{0}%'", prefixText))
|
|
|
|
For i As Integer = 0 To count - 1
|
|
If dbrows.Length > i Then
|
|
items.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dbrows(i)("Nombre").ToString, dbrows(i)("Id").ToString))
|
|
Else
|
|
Exit For
|
|
End If
|
|
Next
|
|
|
|
Return items.ToArray()
|
|
End Function
|
|
|
|
<WebMethodAttribute()> <Script.Services.ScriptMethodAttribute()> _
|
|
Public Shared Function wsGetNombreCuenta(ByVal contextKey As System.String) As System.String
|
|
Dim Retorno As String = ""
|
|
Dim dr As DataRow = DirectCast(HttpContext.Current.Session("DTCuentas"), DataTable).FiltroPrimero("Id = " & contextKey)
|
|
|
|
If dr IsNot Nothing Then
|
|
Retorno = dr("nombre").ToString
|
|
End If
|
|
|
|
Return Retorno
|
|
End Function
|
|
|
|
Protected Sub DdlPlantilla_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlPlantilla.SelectedIndexChanged
|
|
If DdlCuenta.SelectedValue.ToEntero <= 0 Then
|
|
Alert("Seleccione la Cuenta Bancaria", TipoMensaje.MsgAdvertencia)
|
|
DdlPlantilla.SelectedValue = "-1"
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim CvePlantilla As Integer = DdlPlantilla.SelectedValue.ToEntero
|
|
|
|
Dim DT As DataTable = GlobalDTContaPlantillasPolizasDetalle(CvePlantilla).FiltraParametros("", "Orden")
|
|
Dim Cuenta As String = ""
|
|
Dim IdCuenta As Integer = 0
|
|
Dim CodigoCuenta As String = ""
|
|
Dim EsComodin As Integer = 0
|
|
|
|
DTMovimientos.Clear()
|
|
|
|
For Each DRt As DataRow In DT.Rows
|
|
|
|
Cuenta = DRt("ConceptoContable").ToString
|
|
IdCuenta = 0
|
|
|
|
If DRt("IdCtaContable").ToString.ToEntero > 0 Then 'DTCuentasContables
|
|
Dim DRr As DataRow = DTCuentasContables.FiltroPrimero(String.Format("Id={0}", DRt("IdCtaContable").ToString))
|
|
|
|
If DRr IsNot Nothing Then
|
|
IdCuenta = DRt("IdCtaContable").ToString.ToEntero
|
|
CodigoCuenta = DRr("CuentaFormato").ToString()
|
|
End If
|
|
EsComodin = 0
|
|
Else
|
|
'SACO LA CLAVE DE LA CUENTA BANCARIA SELECCIONADO
|
|
If DdlCuenta.SelectedValue.ToEntero > 0 And DRt("CveConcepto").ToString = "30" Then 'DTCuentasContables
|
|
Dim DRr As DataRow = DTCuentasContables.FiltroPrimero(String.Format("Id={0}", IdCuentaBancos(DdlCuenta.SelectedValue.ToEntero)))
|
|
If DRr IsNot Nothing Then
|
|
IdCuenta = DRr("Id").ToString.ToEntero
|
|
CodigoCuenta = DRr("CuentaFormato").ToString()
|
|
EsComodin = 1
|
|
Else
|
|
Alert("La Cuenta Bancaria no se ha vinculado a la cuenta contable", TipoMensaje.MsgAdvertencia)
|
|
GvMov.DataBind()
|
|
UPMovs.Update()
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
End If
|
|
|
|
Dim DR As DataRow = DTMovimientos.NewRow
|
|
DR("IdCuenta") = IdCuenta
|
|
DR("CodigoCuenta") = CodigoCuenta
|
|
DR("Cuenta") = Cuenta
|
|
DR("Referencia") = ""
|
|
DR("Concepto") = TxtObservaciones.Text
|
|
DR("TipoMovto") = If(DRt("TipoMovto").ToString = "False", 0, 1)
|
|
DR("EsComodin") = EsComodin
|
|
DR("CveConcepto") = DRt("CveConcepto")
|
|
|
|
DTMovimientos.Rows.Add(DR)
|
|
Next
|
|
|
|
|
|
GvMov.DataSource = DTMovimientos
|
|
GvMov.DataBind()
|
|
UPMovs.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvMov_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvMov.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(110)
|
|
e.Row.Cells(1).Width = Unit.Pixel(200)
|
|
e.Row.Cells(2).Width = Unit.Pixel(120)
|
|
e.Row.Cells(3).Width = Unit.Pixel(303)
|
|
e.Row.Cells(4).Width = Unit.Pixel(72)
|
|
e.Row.Cells(5).Width = Unit.Pixel(72)
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(0).ToolTip = e.Row.DBCampo("IdCuenta")
|
|
If e.Row.DBCampo("TipoMovto") = "1" Then e.Row.FCTextBox("TxtAbono").Visible = True Else e.Row.FCTextBox("TxtCargo").Visible = True
|
|
|
|
'CUANDO SE MODIFICA EL IMPORTE DE LA CUENTA BANCARIA, QUE SE ACTUALICE EL IMPORTE DEL DOCUMENTO
|
|
If e.Row.DBCampo("EsComodin") = "1" Then
|
|
If e.Row.DBCampo("TipoMovto") = "1" Then
|
|
e.Row.FCTextBox("TxtAbono").Attributes.Add("onkeyup", "FncImporte('TxtImporte',this.id,2)")
|
|
e.Row.FCTextBox("TxtAbono").Text = TxtImporte.Text
|
|
Else
|
|
e.Row.FCTextBox("TxtCargo").Attributes.Add("onkeyup", "FncImporte('TxtImporte',this.id,2)")
|
|
e.Row.FCTextBox("TxtCargo").Text = TxtImporte.Text
|
|
End If
|
|
|
|
TxtImporte.Attributes.Add("onkeyup", String.Format("FncImporte(this.id,'{0}',1)", e.Row.FCTextBox(If(e.Row.DBCampo("TipoMovto") = "1", "TxtAbono", "TxtCargo")).ClientID))
|
|
|
|
UPPImporte.Update()
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnIEGuardar_Click(sender As Object, e As EventArgs) Handles BtnIEGuardar.Click
|
|
|
|
If TxtImporte.Text.ToDouble <= 0 Then
|
|
Alert("Debe de llevar un Importe", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim TotalCargos, TotalAbonos, ImporteDocumento As Double
|
|
TotalCargos = TxtImporte.Text.ToDouble
|
|
TotalAbonos = TxtImporte.Text.ToDouble
|
|
|
|
|
|
If ChkContabilizar.Checked Then
|
|
TotalCargos = 0
|
|
TotalAbonos = 0
|
|
For Each Gvr As GridViewRow In GvMov.Rows
|
|
TotalCargos += Gvr.FCTextBox("TxtCargo").Text.ToDouble
|
|
TotalAbonos += Gvr.FCTextBox("TxtAbono").Text.ToDouble
|
|
Next
|
|
|
|
If TotalCargos <> TotalAbonos Then
|
|
|
|
Alert("La suma de los movimientos no coinciden", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Dim ObjIE As New ClsBancos()
|
|
Dim ObjMov As New ClsContabilidad(ObjIE.IniciaTransacSQL)
|
|
Dim ObjConta As ClsContPAQi = Nothing
|
|
Dim IDPoliza As Integer = 0
|
|
Dim CveIE, NumPoliza As Integer
|
|
Dim MsgError As String = ""
|
|
Dim CvePrePoliza As Integer = 0
|
|
|
|
If ChkContabilizar.Checked AndAlso UsuarioActual.Empresa.UsaContabilidad Then
|
|
ObjConta = New ClsContPAQi(UsuarioActual.Empresa)
|
|
ObjConta.IniciaTransacSQL()
|
|
IDPoliza = ObjConta.AddPoliza(2, TxtObservaciones.Text, TotalCargos, TotalAbonos, UsuarioActual.CveUsuario, TxtFechaDocumento.Text.ToDate)
|
|
|
|
'INSERTO LA PÓLIZA
|
|
NumPoliza = ObjConta.Folio
|
|
|
|
If IDPoliza = 0 Then
|
|
MsgError = "No se pudo insertar la póliza contable."
|
|
End If
|
|
End If
|
|
|
|
If MsgError = "" Then
|
|
|
|
ImporteDocumento = TxtImporte.Text.ToDouble
|
|
|
|
If ImporteDocumento > 0 Then
|
|
|
|
|
|
|
|
Try
|
|
CvePrePoliza = ObjMov.AddPrePolizas("Banc", 12, TotalCargos, TotalAbonos, 1, TxtFechaDocumento.Text.ToDate, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
CveIE = ObjIE.AddBancos_IE(DdlCuenta.SelectedValue.ToEntero, DdlTipoTransaccion.SelectedValue.ToEntero, TxtFechaDocumento.Text.Trim.ToDate, TxtFolio.Text.Trim, TxtPagueseA.Text.Trim, ImporteDocumento, CveMoneda, 0.0, TxtObservaciones.Text.Trim, "", True, True, IDPoliza, CvePrePoliza, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
If CveIE > 0 Then
|
|
'inserto los movimientos de la conta para abonar al saldo
|
|
|
|
|
|
If CvePrePoliza > 0 Then
|
|
Dim Importe As Decimal = 0
|
|
Dim TipoMovto As Boolean = False
|
|
'INSERTO LAS COMPRAS QUE VOY A PAGAR
|
|
|
|
If ChkContabilizar.Checked Then
|
|
|
|
For Each gvr As GridViewRow In GvMov.Rows
|
|
If gvr.DataKey("TipoMovto").ToDouble > 0 Then
|
|
Importe = gvr.FCTextBox("TxtAbono").Text.ToDouble
|
|
TipoMovto = True
|
|
Else
|
|
Importe = gvr.FCTextBox("TxtCargo").Text.ToDouble
|
|
TipoMovto = False
|
|
End If
|
|
If ChkContabilizar.Checked AndAlso UsuarioActual.Empresa.UsaContabilidad Then
|
|
If Not ObjConta.AddMovimiento(IDPoliza, gvr.DataKey("IDCuenta").ToEntero, TipoMovto, Importe, gvr.FCLiteral("LtlReferencia").Text, gvr.FCTextBox("TxtConcepto").Text, 0, TxtFechaDocumento.Text.ToDate, "") Then
|
|
MsgError = "No se pudo insertar movimiento contable"
|
|
Exit For
|
|
End If
|
|
End If
|
|
|
|
If MsgError = "" Then
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, gvr.FCTextBox("TxtConcepto").Text, gvr.DataKey("CveConcepto").ToEntero, TxtObservaciones.Text, Now, 0, -1, CveIE,
|
|
CveProveedor:=HdnCveProveedor.Value.ToEntero, CvePersonal:=HdnCvePersonal.Value.ToEntero, CveCliente:=HdnCveCliente.Value.ToEntero, CveColectiva:=HdnCveBeneficiario.Value.ToEntero) Then
|
|
|
|
Else
|
|
MsgError = "No se pudo insertar el detalle de la póliza2"
|
|
End If
|
|
End If
|
|
Next
|
|
Else
|
|
|
|
Dim CveConcepto As Integer
|
|
|
|
If HdnCveProveedor.Value.ToEntero > 0 Then
|
|
CveConcepto = 10
|
|
ElseIf HdnCveCliente.Value.ToEntero > 0 Then
|
|
CveConcepto = 11
|
|
ElseIf HdnCvePersonal.Value.ToEntero > 0 Then
|
|
CveConcepto = 12
|
|
ElseIf HdnCveBeneficiario.Value.ToEntero > 0 Then
|
|
CveConcepto = 13
|
|
|
|
End If
|
|
|
|
If ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, "", 30, TxtObservaciones.Text, Now, 0, -1, CveIE, CveProveedor:=HdnCveProveedor.Value.ToEntero, CvePersonal:=HdnCvePersonal.Value.ToEntero, CveCliente:=HdnCveCliente.Value.ToEntero, CveColectiva:=HdnCveBeneficiario.Value.ToEntero) Then
|
|
If Not ObjMov.AddPrePolizasDetalle(CvePrePoliza, TipoMovto, Importe, "", CveConcepto, TxtObservaciones.Text, Now, 0, -1, CveIE, CveProveedor:=HdnCveProveedor.Value.ToEntero, CvePersonal:=HdnCvePersonal.Value.ToEntero, CveCliente:=HdnCveCliente.Value.ToEntero, CveColectiva:=HdnCveBeneficiario.Value.ToEntero) Then
|
|
|
|
End If
|
|
Else
|
|
MsgError = "No se pudo insertar el detalle de la póliza2"
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Else
|
|
MsgError = "No se pudo insertar la póliza"
|
|
End If
|
|
Else
|
|
MsgError = "No se insertó el encabezado"
|
|
End If
|
|
|
|
If ChkContabilizar.Checked AndAlso UsuarioActual.Empresa.UsaContabilidad Then
|
|
If Not ObjIE.UpdateIEPrePoliza(TxtFechaDocumento.Text.ToDate, NumPoliza.ToString, IDPoliza, CvePrePoliza, CveIE, 0) Then
|
|
MsgError = "Error al actualizar la Póliza"
|
|
End If
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
MsgError = "Error"
|
|
End Try
|
|
|
|
If MsgError = "" Then
|
|
ObjIE.Commit()
|
|
If ObjConta IsNot Nothing Then ObjConta.Commit()
|
|
|
|
GeneraChequePDF(CveIE, UsuarioActual.Empresa, IDPoliza)
|
|
|
|
UPPDocumento.Update()
|
|
|
|
TxtFolio.Text = ""
|
|
TxtObservaciones.Text = ""
|
|
GvMov.DataBind()
|
|
DdlCuenta.SelectedValue = "-1"
|
|
TxtFechaDocumento.Text = ""
|
|
TxtImporte.Text = ""
|
|
TxtPagueseA.Text = ""
|
|
TxtObservaciones.Text = ""
|
|
Else
|
|
ObjIE.RollBack()
|
|
If ObjConta IsNot Nothing Then ObjConta.RollBack()
|
|
End If
|
|
|
|
Else
|
|
Alert("Debe de llevar un Importe", TipoMensaje.MsgAdvertencia)
|
|
If ObjConta IsNot Nothing Then ObjConta.RollBack()
|
|
End If
|
|
Else
|
|
If ObjConta IsNot Nothing Then ObjConta.RollBack()
|
|
End If
|
|
|
|
ObjIE.Dispose()
|
|
ObjMov.Dispose()
|
|
If ObjConta IsNot Nothing Then ObjConta.Dispose()
|
|
|
|
|
|
End Sub
|
|
|
|
Protected Sub GvMov_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvMov.RowDeleting
|
|
Dim idMov As Integer = GvMov.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
Dim Rows As DataRow() = DTMovimientos.Select("IDMov = " & idMov)
|
|
If Rows.Count > 0 Then
|
|
DTMovimientos.Rows.Remove(Rows(0))
|
|
DTMovimientos.AcceptChanges()
|
|
End If
|
|
|
|
GvMov.DataSource = DTMovimientos
|
|
GvMov.DataBind()
|
|
|
|
'saco de la póliza el importe del cheque, que coincida la cuenta contable con la bancaria
|
|
If DdlCuenta.SelectedValue.ToEntero > 0 Then
|
|
Dim DR As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta=" & DdlCuenta.SelectedValue)
|
|
If DR IsNot Nothing Then
|
|
TxtImporte.Text = DTMovimientos.SUM("Abono", "IdCuenta =" & DR("IdCtaContable").ToString).ToString
|
|
UPPDocumento.Update()
|
|
End If
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function IdCuentaBancos(CveCuenta As Integer) As Integer
|
|
Dim Retorno As Integer = 0
|
|
'saco de la póliza el importe del cheque, que coincida la cuenta contable con la bancaria
|
|
If CveCuenta > 0 Then
|
|
Dim drr As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("CveCuenta=" & CveCuenta)
|
|
If drr IsNot Nothing Then
|
|
Retorno = drr("IdCtaContable").ToString.ToEntero
|
|
End If
|
|
End If
|
|
Return Retorno
|
|
End Function
|
|
|
|
Private Sub CargaCuentasDepositos(CveProveedor As Integer, CveCliente As Integer, CvePersonal As Integer, CveColectiva As Integer)
|
|
DdlCuentaDeposito.Items.Clear()
|
|
If DdlTipoTransaccion.SelectedValue = "2" Then
|
|
trCuentaDeposito.Visible = False
|
|
Dim Dep As New ClsGenerales
|
|
If Dep.GetCuentasDepositos(CveProveedor, CveCliente, CvePersonal, CveColectiva) 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"))
|
|
End If
|
|
End If
|
|
Dep.Dispose()
|
|
|
|
DdlCuentaDeposito.DataBind()
|
|
Else
|
|
trCuentaDeposito.Visible = False
|
|
DdlCuentaDeposito.Items.Clear()
|
|
End If
|
|
|
|
RecargaGlobalCuentasBancarias(CveProveedor)
|
|
'UpDatos.Update()
|
|
|
|
End Sub
|
|
|
|
#Region "Buscar"
|
|
|
|
Protected Sub BtnBuscarBeneficiario_Click(sender As Object, e As EventArgs) Handles BtnBuscarBeneficiario.Click
|
|
ViewState("CveColectiva") = HdnCveBeneficiario.Value.ToEntero
|
|
CargaColectiva(HdnCveBeneficiario.Value.ToEntero, DdlTipoBeneficiario.SelectedValue.ToEntero)
|
|
CargaCuentasDepositos(-1, -1, -1, HdnCveBeneficiario.Value.ToEntero)
|
|
End Sub
|
|
|
|
Protected Sub BtnBuscarProveedor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnBuscarProveedor.Click
|
|
ViewState("CveProveedor") = HdnCveProveedor.Value.ToEntero
|
|
ViewState("CvePersonal") = -1
|
|
CargaProveedor(HdnCveProveedor.Value.ToEntero, "-1")
|
|
CargaCuentasDepositos(HdnCveProveedor.Value.ToEntero, -1, -1, -1)
|
|
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
|
|
|
|
HdnProvPorIVA.Value = ObjProveedor.IVA.ToString
|
|
HdnProvPorRetIVA.Value = ObjProveedor.RetIVA.ToString
|
|
HdnProvPorRetISR.Value = ObjProveedor.RetISR.ToString
|
|
|
|
Else
|
|
Alert("El Proveedor solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ObjProveedor.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub BtnBuscarPersonal_Click(sender As Object, e As EventArgs) Handles BtnBuscarPersonal.Click
|
|
ViewState("CvePersonal") = HdnCvePersonal.Value.ToEntero
|
|
ViewState("CveProveedor") = -1
|
|
CargaPersonal(HdnCvePersonal.Value.ToEntero)
|
|
CargaCuentasDepositos(-1, -1, HdnCvePersonal.Value.ToEntero, -1)
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "Cargar"
|
|
|
|
Private Sub CargaClientes(Clave As Integer)
|
|
Dim ObjClientes As New ClsClientes
|
|
If ObjClientes.GetClientes(Clave, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
If ObjClientes.DtResultados.Rows.Count > 0 Then
|
|
TxtPagueseA.Text = ObjClientes.Nombre
|
|
Else
|
|
Alert("El Cliente no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ObjClientes.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaColectiva(ByVal CveColectiva As Integer, TipoBeneficiario As Integer)
|
|
Dim ObjColectiva As New ClsGenerales
|
|
|
|
If TipoBeneficiario = 3 Then 'CLIENTES
|
|
CargaClientes(CveColectiva)
|
|
End If
|
|
If TipoBeneficiario = 1 Then 'PROVEEDORES
|
|
CargaProveedor(CveColectiva)
|
|
End If
|
|
If TipoBeneficiario = 2 Then 'FUNCIONARIOS (PERSONAL)
|
|
CargaPersonal(CveColectiva)
|
|
End If
|
|
|
|
If TipoBeneficiario > 0 And TipoBeneficiario < 7 Then
|
|
If ObjColectiva.GetColectivas(CveColectiva, "-1", "-1", "-1", UsuarioActual.CveEmpresa) Then
|
|
If ObjColectiva.DtResultados.Rows.Count > 0 Then
|
|
TxtPagueseA.Text = ObjColectiva.Colectiva
|
|
Else
|
|
Alert("El Colectiva solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ObjColectiva.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaPersonal(Clave As Integer)
|
|
Dim ObjPersonal As New ClsRH
|
|
If ObjPersonal.GetPersonal(Clave, UsuarioActual.CveEmpresa) Then
|
|
If ObjPersonal.DtResultados.Rows.Count > 0 Then
|
|
TxtPagueseA.Text = ObjPersonal.NombreCompleto
|
|
Else
|
|
Alert("El Funcionario o Empleado solicitado no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ObjPersonal.Dispose()
|
|
End Sub
|
|
|
|
Private Sub CargaProveedor(Clave As Integer)
|
|
Dim ObjProveedor As New ClsCompProveedores
|
|
If ObjProveedor.GetProveedores(ClsCompProveedores.TipoConsulta.ParaUsoEnEmpresa, Clave, "-1", "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
If ObjProveedor.DtResultados.Rows.Count > 0 Then
|
|
TxtPagueseA.Text = ObjProveedor.RazonSocial
|
|
Else
|
|
Alert("El Proveedor no existe, por favor intente de nuevo.", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End If
|
|
ObjProveedor.Dispose()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Protected Sub RblTipoBeneficiario_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlTipoBeneficiario.SelectedIndexChanged
|
|
ImgEnable()
|
|
Select Case DdlTipoBeneficiario.SelectedValue
|
|
Case "1"
|
|
ImgBuscaProveedor.Visible = True
|
|
Case "2"
|
|
ImgBuscaPersonal.Visible = True
|
|
Case "3"
|
|
ImgBuscaCliente.Visible = True
|
|
Case "4", "5", "6", "7", "8", "9"
|
|
ImgBuscaBeneficiario.Visible = True
|
|
ImgBuscaBeneficiario.Attributes.Add("onclick", String.Format("javascript:AbrirVentana('/Bancos/PopUpBuscarColectiva.aspx?Tipo={0}',800,600,'PopUpBuscarColectiva');", DdlTipoBeneficiario.SelectedValue.ToEntero - 3))
|
|
End Select
|
|
|
|
End Sub
|
|
|
|
Private Sub ImgEnable()
|
|
ImgBuscaBeneficiario.Visible = False
|
|
ImgBuscaCliente.Visible = False
|
|
ImgBuscaProveedor.Visible = False
|
|
ImgBuscaPersonal.Visible = False
|
|
End Sub
|
|
|
|
Private Sub RecargaGlobalCuentasBancarias(CveProveedor As Integer, Optional ByVal CveCuenta As Integer = -1)
|
|
If CveProveedor > 0 Then
|
|
Dim ObjCuentasBancos As New ClsGenerales
|
|
|
|
If ObjCuentasBancos.GetCuentasDepositos() Then
|
|
GlobalDTProveedoresCuentas(-1, True) = ObjCuentasBancos.DtResultados
|
|
End If
|
|
ObjCuentasBancos.Dispose()
|
|
End If
|
|
End Sub
|
|
End Class
|
|
|