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 txtFechaI.Text = Now.AddDays(-1).ToShortDateString txtFechaF.Text = Now.ToShortDateString CargaCuentas() End If End Sub Private Sub CargaCuentas() DdlCuentaDeposito.DataSource = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros(" CveTipoCuenta <> 1", "", {"CveCuenta", "NumCuentaMoneda"}) DdlCuentaDeposito.DataBind() DdlCajaChica.DataSource = GlobalDTBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros(" CveTipoCuenta = 1", "", {"CveCuenta", "NumCuentaMoneda"}) DdlCajaChica.DataBind() DdlSubProyectos.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa) DdlSubProyectos.DataBind() DdlSubProyectos.Items.Insert(0, New ListItem("Todos", "-1")) 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, DdlTipoPago.SelectedValue.ToEntero, CveSubProyecto:=DdlSubProyectos.SelectedValue.ToEntero) GvFacturas.DataSource = ObjBancos.DtResultados ObjBancos.Dispose() UpGvFacturas.Update() GvFacturas.DataBind() lblValorTotal.Text = "00.00" divLabelTotal.Visible = True 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, CveCuenta:=DdlCajaChica.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") Dim drDestino As DataRow = GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveCuenta:=DdlCuentaDeposito.SelectedValue.ToEntero, CveEmpresa:=UsuarioActual.CveEmpresa).FiltroPrimero("") 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

") SbMensaje.AppendFormat("Documento     ", CveIEDestino) SbMensaje.AppendFormat("Imprimir ", StrEncript) Alert(SbMensaje.ToString) End If ObjContabilidad.Dispose() End Sub Private Sub ObtenerTotalImporta() Dim Total As Double = 0 For Each Gvr As GridViewRow In GvFacturas.Rows If Gvr.FCCheckBox("ChkFactura").Checked Then Total += Gvr.DataKey("Importe").ToDouble End If Next lblValorTotal.Text = Total.ToString("N") UpGvFacturas.Update() End Sub Public Sub ChkFactura_Click(sender As Object, e As EventArgs) 'ObtenerTotalImporta() End Sub Protected Sub GvFacturas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvFacturas.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then e.Row.FCCheckBox("ChkFactura").Attributes.Add("onclick", String.Format("FnSuma(this,{0});", e.Row.DBCampo("Importe"))) End If End Sub End Class