Commit inicial Ventas Productivo
This commit is contained in:
160
Bancos/DepositosCaja.aspx.vb
Normal file
160
Bancos/DepositosCaja.aspx.vb
Normal file
@@ -0,0 +1,160 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports Extensiones
|
||||
Imports System.Data
|
||||
Partial Class Bancos_DepositosCaja
|
||||
Inherits ClsPaginas
|
||||
|
||||
Private Property FacturasCheckadas As Integer
|
||||
Get
|
||||
Return ViewState("FacturasCheckadas").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("FacturasCheckadas") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not IsPostBack Then
|
||||
FacturasCheckadas = 0
|
||||
TxtFecha.Text = Now.ToShortDateString
|
||||
CargaCuentas()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCuentas()
|
||||
DdlCuentaDeposito.DataSource = GlobalDTBancosCuentas(-1).FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTipoCuenta <> 1", "", {"CveCuenta", "NumCuentaMoneda"})
|
||||
DdlCuentaDeposito.DataBind()
|
||||
|
||||
DdlCajaChica.DataSource = GlobalDTBancosCuentas(-1).FiltraParametros($"CveEmpresa = {UsuarioActual.CveEmpresa} AND CveTipoCuenta = 1", "", {"CveCuenta", "NumCuentaMoneda"})
|
||||
DdlCajaChica.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub BtnConsultar_Click(sender As Object, e As EventArgs) Handles BtnConsultar.Click
|
||||
CargaDatos()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjBancos As New ClsBancos
|
||||
Dim FechaI, FechaF As String
|
||||
FechaI = If(IsDate(txtFechaI.Text.Trim()), txtFechaI.Text.Trim(), "-1")
|
||||
FechaF = If(IsDate(txtFechaF.Text.Trim()), txtFechaF.Text.Trim(), "-1")
|
||||
|
||||
ObjBancos.GetPagosCajaChica(FechaI, FechaF, UsuarioActual.CveEmpresa, DdlCajaChica.SelectedValue.ToEntero)
|
||||
|
||||
GvFacturas.DataSource = ObjBancos.DtResultados
|
||||
ObjBancos.Dispose()
|
||||
|
||||
UpGvFacturas.Update()
|
||||
GvFacturas.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub BtnDepositar_Click(sender As Object, e As EventArgs) Handles BtnDepositar.Click
|
||||
|
||||
Dim TotalImporte As Decimal = 0
|
||||
For Each Gvr As GridViewRow In GvFacturas.Rows
|
||||
If Gvr.FCCheckBox("ChkFactura").Checked Then TotalImporte += Gvr.DataKey("Importe").ToDecimal
|
||||
Next
|
||||
|
||||
If TotalImporte = 0 Then
|
||||
Alert("Seleccion una factura para realizar el deposito", TipoMensaje.MsgAdvertencia)
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
||||
Dim OcurrioError As Boolean = False
|
||||
Dim ObjContabilidad As New ClsContabilidad()
|
||||
Dim ObjBancos As New ClsBancos(ObjContabilidad.IniciaTransacSQL())
|
||||
|
||||
Dim CveIEOrigen As Integer 'CajaChica
|
||||
Dim CveIEDestino As Integer 'Banco
|
||||
Dim NuevaCvePrePoliza As Integer
|
||||
Dim FolioIE As Long = -1
|
||||
Dim CveMoneda As Integer = 1
|
||||
Dim TipoCambio As Decimal = 1
|
||||
Dim Fecha As Date = TxtFecha.Text.ToDate
|
||||
Dim IdCuentaBancariaOrigen As Integer = 0
|
||||
Dim IdCuentaBancariaDestino As Integer = 0
|
||||
Dim CveCuentaBancariaOrigen As Integer = 0
|
||||
Dim CveCuentaBancariaDestino As Integer = 0
|
||||
Dim drOrigen As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero($"CveCuenta = {DdlCajaChica.SelectedValue}")
|
||||
Dim drDestino As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario).FiltroPrimero($"CveCuenta = {DdlCuentaDeposito.SelectedValue}")
|
||||
|
||||
If drOrigen IsNot Nothing Then
|
||||
CveMoneda = drOrigen("CveMoneda").ToString.ToEntero
|
||||
IdCuentaBancariaOrigen = drOrigen("IdCtaContable").ToString.ToEntero
|
||||
CveCuentaBancariaOrigen = drOrigen("IdCtaContableSIG").ToString.ToEntero
|
||||
End If
|
||||
|
||||
If drDestino IsNot Nothing Then
|
||||
CveMoneda = drDestino("CveMoneda").ToString.ToEntero
|
||||
IdCuentaBancariaDestino = drDestino("IdCtaContable").ToString.ToEntero
|
||||
CveCuentaBancariaDestino = drDestino("IdCtaContableSIG").ToString.ToEntero
|
||||
End If
|
||||
|
||||
NuevaCvePrePoliza = ObjContabilidad.AddPrePolizas("Vta", 13, TotalImporte, TotalImporte, CveMoneda, Fecha, "Depósito Bancario", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
'Salida de Caja Chica
|
||||
FolioIE = ObjBancos.GetNextFolio(DdlCajaChica.SelectedValue.ToEntero, 2)
|
||||
If Not FolioIE > 0 Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
CveIEOrigen = ObjBancos.AddBancos_IE(DdlCajaChica.SelectedValue.ToEntero, 2, Fecha, FolioIE.ToString, "Depósito Bancario", TotalImporte, CveMoneda, 1, "Depósito Bancario", "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
|
||||
'Entrada a Bancos
|
||||
FolioIE = ObjBancos.GetNextFolio(DdlCuentaDeposito.SelectedValue.ToEntero, 8)
|
||||
If Not FolioIE > 0 Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
CveIEDestino = ObjBancos.AddBancos_IE(DdlCuentaDeposito.SelectedValue.ToEntero, 8, Fecha, FolioIE.ToString, "Depósito Bancario", TotalImporte, CveMoneda, 1, "Depósito Bancario", "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
||||
|
||||
|
||||
For Each Gvr As GridViewRow In GvFacturas.Rows
|
||||
|
||||
If Gvr.FCCheckBox("ChkFactura").Checked Then
|
||||
'Datos de las Nuevas PrePolizas
|
||||
|
||||
Dim Importe As Double = Gvr.DataKey("Importe").ToDouble
|
||||
|
||||
'Datos de las Prepolizas A Cancelar
|
||||
Dim CveIE As Integer = Gvr.DataKey("CveIE").ToEntero
|
||||
Dim CveVenta As Integer = Gvr.DataKey("CveVenta").ToEntero
|
||||
Dim CvePrePoliza As Integer = Gvr.DataKey("CvePrePoliza").ToEntero
|
||||
|
||||
'Asignamos la cuenta Deposito
|
||||
If Not ObjBancos.UpdateBancos_IECuentaDeposito(CveIEDestino, CveIE) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
If ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, True, TotalImporte, "Depósito Bancario", 30, "Depósito Bancario", Fecha, IdCuentaBancariaOrigen, -1, CveIE:=CveIEOrigen, ImporteMX:=TotalImporte * TipoCambio, CveCuenta:=CveCuentaBancariaOrigen) Then
|
||||
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TotalImporte, "Depósito Bancario", 30, "Depósito Bancario", Fecha, IdCuentaBancariaDestino, -1, CveIE:=CveIEDestino, ImporteMX:=TotalImporte * TipoCambio, CveCuenta:=CveCuentaBancariaDestino) Then
|
||||
OcurrioError = True
|
||||
End If
|
||||
Else OcurrioError = True
|
||||
End If
|
||||
|
||||
If OcurrioError Then
|
||||
ObjContabilidad.RollBack()
|
||||
Alert("Ocurrio un error al realizar los depositos", TipoMensaje.MsgError)
|
||||
Else
|
||||
ObjContabilidad.Commit()
|
||||
CargaDatos()
|
||||
Dim SbMensaje As New StringBuilder()
|
||||
Dim StrEncript As String = Encripta($"OP=DC&CveIE={CveIEDestino}&CuentaCaja={DdlCajaChica.SelectedItem.Text}&CuentaDepo={DdlCuentaDeposito.SelectedItem.Text}")
|
||||
SbMensaje.Append("Los Depósitos se realizaron exitósamente<br/><br/>")
|
||||
SbMensaje.AppendFormat("<a href='/Bancos/IE.aspx?CveIE={0}' target='_blank' class='Texto'>Documento</a>     ", CveIEDestino)
|
||||
SbMensaje.AppendFormat("<a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir</a> ", StrEncript)
|
||||
Alert(SbMensaje.ToString)
|
||||
|
||||
End If
|
||||
|
||||
ObjContabilidad.Dispose()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user