260 lines
12 KiB
VB.net
260 lines
12 KiB
VB.net
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
|
|
TxtComision.Attributes.Add("onKeyUp", "txtSuma(event);")
|
|
TxtDescuento.Attributes.Add("onKeyUp", "txtSumaDescuento(event);")
|
|
|
|
CargaCuentas()
|
|
ChkFaltante.Attributes.Add("onclick", "CheckFaltante(this);")
|
|
ChkDescuento.Attributes.Add("onclick", "CheckDescuento(this);")
|
|
|
|
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"))
|
|
|
|
DdlSubProyectoDeposito.DataSource = DdlSubProyectos.DataSource
|
|
DdlSubProyectoDeposito.DataBind()
|
|
DdlSubProyectos.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlSubProyectoDescuento.DataSource = DdlSubProyectos.DataSource
|
|
DdlSubProyectoDescuento.DataBind()
|
|
DdlSubProyectos.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa, UsoClasificacion:=2)
|
|
DdlClasificacion.DataBind()
|
|
DdlSubProyectos.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
|
|
DdlClasificacionDescuento.DataSource = DdlClasificacion.DataSource
|
|
DdlClasificacionDescuento.DataBind()
|
|
DdlSubProyectos.Items.Insert(0, New ListItem("Seleccione", "-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 = "0.00"
|
|
TxtComision.text = ""
|
|
divLabelTotal.Visible = True
|
|
End Sub
|
|
|
|
Private Sub BtnDepositar_Click(sender As Object, e As EventArgs) Handles BtnDepositar.Click
|
|
|
|
Dim TotalImporte As Decimal = 0
|
|
Dim TotalImportePrePoliza As Decimal
|
|
Dim Comision As Decimal = TxtComision.Text.ToDecimal
|
|
Dim Descuento As Decimal = TxtDescuento.Text.ToDecimal
|
|
|
|
|
|
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 depósito", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
|
|
TotalImportePrePoliza = TotalImporte
|
|
If Comision <> 0 Then
|
|
TotalImporte = TotalImporte + Comision + Descuento
|
|
'Comision = -(Comision) ' se inverte el valor, va cargada
|
|
'Descuento = -(Descuento) ' se inverte el valor, va cargada
|
|
If DdlSubProyectoDeposito.SelectedValue.ToEntero = -1 Or DdlClasificacion.SelectedValue.ToEntero = -1 Then
|
|
Alert("Debes Seleccionar un Subproyecto y una Clasificación", TipoMensaje.MsgAdvertencia)
|
|
Exit Sub
|
|
End If
|
|
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("")
|
|
Dim CveSubProyecto As Integer = -1
|
|
Dim CveSubProyectoDescuento As Integer = -1
|
|
Dim CveClasificacion As Integer = -1
|
|
Dim CveClasificacionDescuento As Integer = -1
|
|
Dim documentos As String = "Los Depósitos se realizaron exitósamente<br/><br/>"
|
|
Dim imprimirFolios As String = ""
|
|
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, TotalImportePrePoliza, TotalImportePrePoliza, CveMoneda, Fecha, "Depósito Bancario", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
'Entrada a bancos
|
|
FolioIE = ObjBancos.GetNextFolio(DdlCuentaDeposito.SelectedValue.ToEntero, 13)
|
|
If Not FolioIE > 0 Then
|
|
OcurrioError = True
|
|
End If
|
|
CveIEOrigen = ObjBancos.AddBancos_IE(DdlCuentaDeposito.SelectedValue.ToEntero, 13, Fecha, FolioIE.ToString, "Depósito Bancario", TotalImporte, CveMoneda, 1, "Depósito Bancario", "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
documentos += String.Format("<a href='/Bancos/IE.aspx?CveIE={0}' target='_blank' class='Texto'>Depósito: {1}</a>     <br/> ", CveIEOrigen, FolioIE)
|
|
|
|
|
|
If ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, False, TotalImporte, "Depósito Bancario", 30, "Depósito Bancario", Fecha, IdCuentaBancariaOrigen, -1, CveClasificacion:=CveClasificacion, CveSubProyecto:=CveSubProyecto, CveIE:=CveIEOrigen, ImporteMX:=TotalImporte * TipoCambio, CveCuenta:=CveCuentaBancariaOrigen) Then
|
|
|
|
If ChkFaltante.Checked Then
|
|
CveSubProyecto = DdlSubProyectoDeposito.SelectedValue.ToEntero
|
|
CveClasificacion = DdlClasificacion.SelectedValue.ToEntero
|
|
|
|
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, True, Comision, DdlClasificacion.SelectedItem.Text, 51, DdlClasificacion.SelectedItem.Text, Fecha, IdCuentaBancariaOrigen, -1, CveClasificacion:=CveClasificacion, CveSubProyecto:=CveSubProyecto, ImporteMX:=Comision * TipoCambio, CveCuenta:=CveCuentaBancariaOrigen) Then
|
|
OcurrioError = True
|
|
End If
|
|
End If
|
|
|
|
If ChkDescuento.Checked Then
|
|
CveSubProyectoDescuento = DdlSubProyectoDescuento.SelectedValue.ToEntero
|
|
CveClasificacionDescuento = DdlClasificacionDescuento.SelectedValue.ToEntero
|
|
|
|
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, False, Descuento, DdlClasificacionDescuento.SelectedItem.Text, 51, DdlClasificacionDescuento.SelectedItem.Text, Fecha, IdCuentaBancariaOrigen, -1, CveClasificacion:=CveClasificacionDescuento, CveSubProyecto:=CveSubProyecto, ImporteMX:=Comision * TipoCambio, CveCuenta:=CveCuentaBancariaOrigen) Then
|
|
OcurrioError = True
|
|
End If
|
|
End If
|
|
Else
|
|
OcurrioError = True
|
|
End If
|
|
|
|
For Each Gvr As GridViewRow In GvFacturas.Rows
|
|
|
|
If Gvr.FCCheckBox("ChkFactura").Checked Then
|
|
'Datos de las Nuevas PrePolizas
|
|
'Entrada a Bancos
|
|
|
|
Dim Importe As Decimal = Gvr.DataKey("Importe").ToDecimal
|
|
Dim SerieFolio As String = Gvr.DataKey("SerieFolio").ToString
|
|
|
|
'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
|
|
|
|
FolioIE = ObjBancos.GetNextFolio(DdlCajaChica.SelectedValue.ToEntero, 2)
|
|
If Not FolioIE > 0 Then
|
|
OcurrioError = True
|
|
End If
|
|
CveIEDestino = ObjBancos.AddBancos_IE(DdlCajaChica.SelectedValue.ToEntero, 2, Fecha, FolioIE.ToString, String.Format("Depósito Bancario: {0}", SerieFolio), Importe, CveMoneda, 1, "Depósito Bancario", "", False, False, -1, NuevaCvePrePoliza, "-1", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
|
|
|
|
If Not ObjContabilidad.AddPrePolizasDetalle(NuevaCvePrePoliza, True, Importe, SerieFolio, 30, String.Format("Depósito Bancario: {0}", SerieFolio), Fecha, IdCuentaBancariaDestino, -1, CveClasificacion:=CveClasificacion, CveSubProyecto:=CveSubProyecto, CveIE:=CveIEDestino, ImporteMX:=Importe * TipoCambio, CveCuenta:=CveCuentaBancariaDestino) Then
|
|
OcurrioError = True
|
|
End If
|
|
|
|
'Asignamos la cuenta Deposito
|
|
If Not ObjBancos.UpdateBancos_IECuentaDeposito(CveIEDestino, CveIE) Then
|
|
OcurrioError = True
|
|
End If
|
|
Dim StrEncript As String = Encripta($"OP=DC&CveIE={CveIEDestino}&CuentaCaja={DdlCajaChica.SelectedItem.Text}&CuentaDepo={DdlCuentaDeposito.SelectedItem.Text}")
|
|
|
|
'documentos += String.Format("<a class=""Texto"" target='_blank' href=""/Compras/PopUpVerFactura.aspx?P={0}"">Imprimir {1}</a> <br/><br/> ", StrEncript, SerieFolio)
|
|
End If
|
|
|
|
Next
|
|
|
|
|
|
If OcurrioError Then
|
|
ObjContabilidad.RollBack()
|
|
Alert("Ocurrio un error al realizar los depositos", TipoMensaje.MsgError)
|
|
Else
|
|
ObjContabilidad.Commit()
|
|
CargaDatos()
|
|
|
|
documentos += String.Format("<a class=""Texto"" target='_blank' href=""/Contabilidad/RegPrePolizas.aspx?CvePrePoliza={0}"">Prepóliza</a> <br/><br/> ", NuevaCvePrePoliza)
|
|
|
|
Alert(documentos.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 |