Commit inicial Ventas Productivo
This commit is contained in:
685
Bancos/CuentasBancariasDetalle.aspx.vb
Normal file
685
Bancos/CuentasBancariasDetalle.aspx.vb
Normal file
@@ -0,0 +1,685 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports Extensiones
|
||||
Imports System.Runtime.InteropServices
|
||||
Imports System.IO
|
||||
Imports System.Data
|
||||
|
||||
Partial Class Bancos_CuentasBancariasDetalle
|
||||
Inherits ClsPaginas
|
||||
|
||||
'Configuración
|
||||
#Region "P R O P I E D A D E S"
|
||||
Private ReadOnly Property CveCuenta As Integer
|
||||
Get
|
||||
Return ViewState("CveCuenta").ToString.ToEntero
|
||||
End Get
|
||||
End Property
|
||||
Private Property DTUsuarios As DataTable
|
||||
Get
|
||||
Return CType(ViewState("DTUsuarios"), DataTable)
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTUsuarios") = 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
|
||||
CargarTipoCuenta()
|
||||
CargarBanco()
|
||||
CargarMoneda()
|
||||
ViewState("DTUsuarios") = Nothing
|
||||
|
||||
DdlUsuarios.DataSource = GlobalDTUsuarios(CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros("", "Nombre")
|
||||
DdlUsuarios.DataBind()
|
||||
|
||||
|
||||
|
||||
If Request("CveCuenta") IsNot Nothing AndAlso IsNumeric(Request("CveCuenta")) AndAlso Request("CveCuenta").ToEntero > 0 Then
|
||||
ViewState("CveCuenta") = Request("CveCuenta")
|
||||
|
||||
|
||||
If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then
|
||||
trCuentaContable.Visible = True
|
||||
trCuentaContableComplementaria.Visible = True
|
||||
CargaCuentasContables()
|
||||
End If
|
||||
|
||||
CargaDatos()
|
||||
'Configuración de Modalidad Update
|
||||
BtnGuardar.Text = "Guardar Cambios"
|
||||
'LtlTitulo.Text = "Consulta del Banco:"
|
||||
CargaDatosUsuarios()
|
||||
InicializaConvenio()
|
||||
Else
|
||||
'Configuración de Modalidad Insert
|
||||
LblFecha.Text = Now.ToShortDateString()
|
||||
LtlTitulo.Text = "Agregar Nueva Cuenta Bancaria"
|
||||
ViewState("CveCuenta") = -1
|
||||
BtnEliminar.Visible = False
|
||||
CreaDTUsuarios()
|
||||
If UsuarioActual.Empresa.UsaContabilidad Or UsuarioActual.Empresa.UsaAC Then
|
||||
trCuentaContable.Visible = True
|
||||
trCuentaContableComplementaria.Visible = True
|
||||
CargaCuentasContables()
|
||||
End If
|
||||
'LbAgregarSucursal.Enabled = False
|
||||
End If
|
||||
ActivarRegistroAutomatico()
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
#Region " CARGA VALORES INICIALES "
|
||||
Private Sub SetValues()
|
||||
ViewState("Orden") = ""
|
||||
ViewState("OrdenUsuarios") = ""
|
||||
ViewState("OTipoCuenta") = "TipoCuenta DESC"
|
||||
ViewState("OEstatus") = "Estatus DESC"
|
||||
ViewState("OFecha") = "Fecha DESC"
|
||||
ViewState("OUsuario") = "Usuario DESC"
|
||||
End Sub
|
||||
|
||||
#Region "CARGA COMBOS"
|
||||
Private Sub CargarTipoCuenta()
|
||||
DdlTipoCuenta.DataSource = GlobalDTTipoCuenta
|
||||
DdlTipoCuenta.DataBind()
|
||||
End Sub
|
||||
Private Sub CargarBanco()
|
||||
DdlBanco.DataSource = GlobalDTBancos.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
DdlBanco.DataBind()
|
||||
|
||||
DdlBanco.Items.Add(New ListItem("Empresa", "0"))
|
||||
End Sub
|
||||
Private Sub CargarMoneda()
|
||||
DdlMoneda.DataSource = GlobalDTMonedas
|
||||
DdlMoneda.DataBind()
|
||||
End Sub
|
||||
Private Sub CargaCuentasContables()
|
||||
Dim IdPadre As Integer
|
||||
Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
|
||||
If DdlTipoCuenta.SelectedValue.ToEntero = 1 Then 'Caja Chica
|
||||
IdPadre = UsuarioActual.Empresa.Funcionalidad(218).ToEntero
|
||||
Else
|
||||
Dim tesstr = UsuarioActual.Empresa.Funcionalidad(209)
|
||||
IdPadre = UsuarioActual.Empresa.Funcionalidad(209).ToEntero
|
||||
End If
|
||||
|
||||
If IdPadre = 0 Then IdPadre = -1
|
||||
Dim dt As DataTable = Nothing
|
||||
If Conta.GetCuentasRecursiva(IdPadre, 1) Then
|
||||
dt = Conta.DtResultados
|
||||
End If
|
||||
|
||||
Conta.Dispose()
|
||||
DDlCuentaContable.DataSource = dt
|
||||
DDlCuentaContable.DataBind()
|
||||
DDlCuentaContable.Items.Insert(0, New ListItem("-", "-1"))
|
||||
DdlCuentaContableComplementaria.DataSource = dt
|
||||
DdlCuentaContableComplementaria.DataBind()
|
||||
DdlCuentaContableComplementaria.Items.Insert(0, New ListItem("-", "-1"))
|
||||
If dt IsNot Nothing Then dt.Dispose()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " CARGA DATOS "
|
||||
Private Sub CargaDatos()
|
||||
Dim ObjCuentasBancariasDetalle As New ClsBancos()
|
||||
If ObjCuentasBancariasDetalle.GetBancosCuentas(CveCuenta, UsuarioActual.CveEmpresa) Then
|
||||
If ObjCuentasBancariasDetalle.DtResultados.Rows.Count > 0 Then
|
||||
'Campos para Modificación
|
||||
If ObjCuentasBancariasDetalle.TipoCuenta.ToString = "Caja Chica" Then
|
||||
LtlTitulo.Text = " Caja Chica de "
|
||||
LtlBanco.Text = ObjCuentasBancariasDetalle.NumCuenta
|
||||
Else
|
||||
LtlTitulo.Text = "Consulta de Bancos: "
|
||||
LtlBanco.Text = ObjCuentasBancariasDetalle.Banco
|
||||
End If
|
||||
DdlBanco.SelectedValue = ObjCuentasBancariasDetalle.CveBanco.ToString
|
||||
TxtNumCuenta.Text = ObjCuentasBancariasDetalle.NumCuenta
|
||||
TxtCLABE.Text = ObjCuentasBancariasDetalle.CLABE
|
||||
DdlMoneda.SelectedValue = ObjCuentasBancariasDetalle.CveMoneda.ToString
|
||||
ChkEstatus.Checked = If((ObjCuentasBancariasDetalle.Estatus) = "Activo", True, False)
|
||||
LblFecha.Text = ObjCuentasBancariasDetalle.Fecha.ToShortDateString
|
||||
LblUsuario.Text = ObjCuentasBancariasDetalle.Usuario
|
||||
TxtConvenio.Text = ObjCuentasBancariasDetalle.ConvenioPagoElectronico.ToString
|
||||
ChkLayout.Checked = ObjCuentasBancariasDetalle.UsaLayout
|
||||
ChkUsaTarjeta.Checked = ObjCuentasBancariasDetalle.UsaTarjeta
|
||||
|
||||
ChkUsaTarjeta_CheckedChanged(Nothing, Nothing)
|
||||
|
||||
trFinicial.Visible = False
|
||||
trLimiteCredito.Visible = True
|
||||
TxtLimiteCredito.Text = ObjCuentasBancariasDetalle.LimiteCredito.ToString
|
||||
|
||||
DdlTipoCuenta.SelectedValue = ObjCuentasBancariasDetalle.CveTipoCuenta.ToString
|
||||
|
||||
DdlTipoCuenta_SelectedIndexChanged(DdlTipoCuenta, EventArgs.Empty)
|
||||
DDlCuentaContable.SelectedValueExist(ObjCuentasBancariasDetalle.IdCtaContable.ToString)
|
||||
DdlCuentaContableComplementaria.SelectedValueExist(ObjCuentasBancariasDetalle.IdCtaContableComplementaria.ToString)
|
||||
Else
|
||||
Alert("El Banco Solicitado no existe, por favor revise su búsqueda.", TipoMensaje.MsgAdvertencia)
|
||||
BtnGuardar.Enabled = False
|
||||
End If
|
||||
End If
|
||||
ObjCuentasBancariasDetalle.Dispose()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " GUARDAR "
|
||||
|
||||
Protected Sub BtnGuardar_Click(sender As Object, e As System.EventArgs) Handles BtnGuardar.Click
|
||||
Dim ObjCuentasBancariasDetalle As New ClsBancos()
|
||||
Dim ObjContaAC As ClsContPAQi = Nothing
|
||||
ObjCuentasBancariasDetalle.IniciaTransacSQL()
|
||||
|
||||
Dim ErrorUsuarios = False
|
||||
|
||||
If CveCuenta = -1 Then
|
||||
|
||||
If ObjCuentasBancariasDetalle.AddBancosCuentas(DdlBanco.SelectedValue.ToEntero, DdlTipoCuenta.SelectedValue.ToEntero, TxtNumCuenta.Text.Trim,
|
||||
TxtCLABE.Text.Trim, DdlMoneda.SelectedValue.ToEntero, 0, TxtFInicial.Text.Trim.ToEntero, 0, 0, TxtLimiteCredito.Text.Trim.ToDouble, DDlCuentaContable.SelectedValue.ToEntero,
|
||||
DdlCuentaContableComplementaria.SelectedValue.ToEntero, "", UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, If(ChkLayout.Checked, TxtConvenio.Text, ""), ChkLayout.Checked, ChkUsaTarjeta.Checked) Then
|
||||
ViewState("CveCuenta") = ObjCuentasBancariasDetalle.TCveCuenta
|
||||
Else
|
||||
ErrorUsuarios = True
|
||||
End If
|
||||
|
||||
If Not ErrorUsuarios Then
|
||||
For Each row As DataRow In DTUsuarios.Rows
|
||||
If Not ObjCuentasBancariasDetalle.AddBancosCuentasUsuarios(ObjCuentasBancariasDetalle.TCveCuenta, row("CveUsuario").ToString.ToEntero) Then
|
||||
ErrorUsuarios = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
If Not ErrorUsuarios Then
|
||||
If ObjCuentasBancariasDetalle.GetBancosCuentasUsuarios(-1) Then
|
||||
GlobalDTBancosCuentas(-1) = ObjCuentasBancariasDetalle.DtResultados
|
||||
Else
|
||||
ErrorUsuarios = True
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not ErrorUsuarios AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToEntero > 1 AndAlso UsuarioActual.Empresa.Funcionalidad(209).ToEntero > 0 Then
|
||||
ObjContaAC = New ClsContPAQi(UsuarioActual.Empresa)
|
||||
ObjContaAC.IniciaTransacSQL()
|
||||
ErrorUsuarios = GuardaCuentasContables(ObjContaAC, ObjCuentasBancariasDetalle)
|
||||
End If
|
||||
|
||||
Else
|
||||
If ObjCuentasBancariasDetalle.UpdateBancosCuentas(DdlBanco.SelectedValue.ToEntero, DdlTipoCuenta.SelectedValue.ToEntero, TxtNumCuenta.Text.Trim, TxtCLABE.Text.Trim, DdlMoneda.SelectedValue.ToEntero, 0, TxtFInicial.Text.Trim.ToEntero, 0, 0, TxtLimiteCredito.Text.Trim.ToDouble, DDlCuentaContable.SelectedValue.ToEntero, DdlCuentaContableComplementaria.SelectedValue.ToEntero, "", ChkEstatus.Checked, CveCuenta, TxtConvenio.Text, ChkLayout.Checked, ChkUsaTarjeta.Checked) Then
|
||||
'CargaDatos()
|
||||
If ObjCuentasBancariasDetalle.GetBancosCuentasUsuarios(-1) Then
|
||||
GlobalDTBancosCuentas(-1) = ObjCuentasBancariasDetalle.DtResultados
|
||||
Else
|
||||
ErrorUsuarios = True
|
||||
End If
|
||||
UpDatos.Update()
|
||||
Else
|
||||
ErrorUsuarios = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not ErrorUsuarios Then
|
||||
ObjCuentasBancariasDetalle.Commit()
|
||||
If ObjContaAC IsNot Nothing Then ObjContaAC.Commit()
|
||||
If UsuarioActual.Empresa.Funcionalidad(209).ToEntero > 0 AndAlso UsuarioActual.Empresa.Funcionalidad(200).ToEntero > 0 AndAlso DDlCuentaContable.SelectedValue.ToEntero < 1 Then
|
||||
BtnAgregaCuentaContable(BtnCuentaContable, Nothing)
|
||||
End If
|
||||
Alert(If(CveCuenta > 0, "Los cambios se guardaron correctamente.", "La cuenta se agregó correctamente."), TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/CuentasBancarias.aspx""")
|
||||
Else
|
||||
ObjCuentasBancariasDetalle.RollBack()
|
||||
If ObjContaAC IsNot Nothing Then ObjContaAC.RollBack()
|
||||
Alert("Ocurrio un error. Por favor intente nuevamente.", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
ObjCuentasBancariasDetalle.Dispose()
|
||||
If ObjContaAC IsNot Nothing Then ObjContaAC.Dispose()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " ELIMINAR "
|
||||
Protected Sub BtnEliminar_Click(sender As Object, e As System.EventArgs) Handles BtnEliminar.Click
|
||||
Dim ObjCuentasBancariasDetalle As New ClsBancos()
|
||||
ObjCuentasBancariasDetalle.IniciaTransacSQL()
|
||||
Dim TieneError = False
|
||||
|
||||
'Eliminar usuarios con acceso a la cuenta
|
||||
For Each row As DataRow In DTUsuarios.Rows
|
||||
If Not ObjCuentasBancariasDetalle.RemoveBancosCuentasUsuarios(CveCuenta, row("CveUsuario").ToString.ToEntero) Then
|
||||
TieneError = True
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
'Elimina cuenta
|
||||
If Not TieneError Then
|
||||
If Not ObjCuentasBancariasDetalle.RemoveBancosCuentas(CveCuenta) Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
ObjCuentasBancariasDetalle.Commit()
|
||||
Alert("La cuenta se Eliminó correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Bancos/CuentasBancarias.aspx""")
|
||||
Else
|
||||
ObjCuentasBancariasDetalle.RollBack()
|
||||
Alert("Ocurrió un error al eliminar la cuenta. Por favor vuelta a intentar.", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
ObjCuentasBancariasDetalle.Dispose()
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " TIPO CUENTA "
|
||||
Protected Sub DdlTipoCuenta_SelectedIndexChanged(sender As Object, e As EventArgs)
|
||||
If DdlTipoCuenta.SelectedValue.ToString.ToEntero >= 6 Then
|
||||
TxtFInicial.Visible = False
|
||||
LtFInicial.Visible = False
|
||||
trLimiteCredito.Visible = True
|
||||
LtLimiteCredito.Visible = True
|
||||
TxtLimiteCredito.Visible = True
|
||||
RFVLimiteCredito.Enabled = True
|
||||
VCELimiteCredito.Enabled = True
|
||||
Else
|
||||
TxtFInicial.Visible = True
|
||||
LtFInicial.Visible = True
|
||||
trLimiteCredito.Visible = False
|
||||
LtLimiteCredito.Visible = False
|
||||
TxtLimiteCredito.Visible = False
|
||||
RFVLimiteCredito.Enabled = False
|
||||
VCELimiteCredito.Enabled = False
|
||||
End If
|
||||
CargaCuentasContables()
|
||||
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " U S U A R I O S - C U E N T A S"
|
||||
Protected Sub LnkAgregar_Click(sender As Object, e As EventArgs) Handles LnkAgregar.Click
|
||||
Dim Obj As New ClsBancos
|
||||
Dim Row As DataRow
|
||||
|
||||
If CveCuenta > 0 Then
|
||||
If Obj.AddBancosCuentasUsuarios(CveCuenta, DdlUsuarios.SelectedValue.ToEntero) Then
|
||||
DTUsuarios = Obj.DtResultados
|
||||
GVU.DataSource = Obj.DtResultados
|
||||
If Obj.GetBancosCuentasUsuarios(-1) Then
|
||||
GlobalDTBancosCuentas(-1) = Obj.DtResultados
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
If DTUsuarios.FiltraParametros(String.Format("CveUsuario = {0}", DdlUsuarios.SelectedValue.ToString)).Rows.Count > 0 Then
|
||||
Alert("El usuario ya se encuntra con Acceso a la cuenta", TipoMensaje.MsgAdvertencia)
|
||||
Else
|
||||
Row = DTUsuarios.NewRow
|
||||
Row("CveCuenta") = DTUsuarios.Rows.Count + 1
|
||||
Row("CveUsuario") = DdlUsuarios.SelectedValue.ToEntero
|
||||
Row("Nombre") = DdlUsuarios.SelectedItem.Text.ToString
|
||||
DTUsuarios.Rows.Add(Row)
|
||||
End If
|
||||
GVU.DataSource = DTUsuarios
|
||||
End If
|
||||
CargaUsuariosDDL()
|
||||
Obj.Dispose()
|
||||
GVU.DataBind()
|
||||
End Sub
|
||||
Private Sub CargaDatosUsuarios()
|
||||
Dim ObjCuentasBancariasDetalle As New ClsBancos()
|
||||
If ObjCuentasBancariasDetalle.GetBancosCuentasUsuariosAcceso(CveCuenta) Then
|
||||
DTUsuarios = ObjCuentasBancariasDetalle.DtResultados
|
||||
GVU.DataSource = DTUsuarios
|
||||
End If
|
||||
|
||||
ObjCuentasBancariasDetalle.Dispose()
|
||||
GVU.DataBind()
|
||||
End Sub
|
||||
|
||||
Public Sub CargaUsuariosDDL()
|
||||
Dim sUsuarios As String = ""
|
||||
For Each row As DataRow In DTUsuarios.Rows
|
||||
sUsuarios = $"{sUsuarios} {row("CveUsuario").ToString},"
|
||||
Next
|
||||
If sUsuarios <> "" Then
|
||||
DdlUsuarios.DataSource = GlobalDTUsuarios(CveEmpresa:=UsuarioActual.CveEmpresa).FiltraParametros($"CveUsuario NOT IN ({sUsuarios.Substring(0, sUsuarios.Length - 1)})", "Nombre")
|
||||
DdlUsuarios.DataBind()
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub CreaDTUsuarios()
|
||||
DTUsuarios = New DataTable
|
||||
DTUsuarios.Columns.Add("CveCuenta", GetType(Integer)) ' Consecutivo en este caso
|
||||
DTUsuarios.Columns.Add("CveUsuario", GetType(Integer))
|
||||
DTUsuarios.Columns.Add("Nombre", GetType(String))
|
||||
End Sub
|
||||
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVU.RowDeleting
|
||||
Dim ObjBancos As New ClsBancos
|
||||
If CveCuenta > 0 Then
|
||||
If ObjBancos.RemoveBancosCuentasUsuarios(GVU.DataKeys(e.RowIndex)("CveCuenta").ToString.ToEntero, GVU.DataKeys(e.RowIndex)("CveUsuario").ToString.ToEntero) Then
|
||||
GVU.EditIndex = -1
|
||||
DTUsuarios = ObjBancos.DtResultados
|
||||
GVU.DataSource = ObjBancos.DtResultados
|
||||
If ObjBancos.GetBancosCuentasUsuarios(-1) Then
|
||||
GlobalDTBancosCuentas(-1) = ObjBancos.DtResultados
|
||||
End If
|
||||
Alert("El usuario se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
Else
|
||||
DTUsuarios.Rows.RemoveAt(e.RowIndex)
|
||||
GVU.DataSource = DTUsuarios
|
||||
End If
|
||||
GVU.DataBind()
|
||||
CargaUsuariosDDL()
|
||||
ObjBancos.Dispose()
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " AGREGAR CUENTAS CONTABLES"
|
||||
Private Sub ActivarRegistroAutomatico()
|
||||
|
||||
|
||||
'Cuenta Contable
|
||||
If DDlCuentaContable.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(209).ToEntero > 0 Then
|
||||
DDlCuentaContable.Width = 240
|
||||
BtnCuentaContable.Visible = True
|
||||
End If
|
||||
|
||||
'Cuenta Contable Complementaria
|
||||
If DdlCuentaContableComplementaria.SelectedValue.ToEntero <= 0 And UsuarioActual.Empresa.Funcionalidad(210).ToEntero > 0 Then
|
||||
DdlCuentaContableComplementaria.Width = 240
|
||||
BtnCuentaContableComplementaria.Visible = True
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnAgregaCuentaContable(ByVal sender As Object, ByVal e As EventArgs)
|
||||
Dim CuentaContable = DirectCast(sender, Button).CommandArgument.ToString
|
||||
Dim Button = DirectCast(sender, Button)
|
||||
|
||||
Select Case CuentaContable
|
||||
Case "CuentaContable"
|
||||
AgregarCuentaContable(Button, DDlCuentaContable)
|
||||
Case "CuentaContableComplementaria"
|
||||
AgregarCuentaContable(Button, DdlCuentaContableComplementaria)
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub AgregarCuentaContable(btn As Button, ddl As DropDownList)
|
||||
Dim IdCuentaContable As Integer = -1
|
||||
Dim CtaCodigo As String = ""
|
||||
Dim TieneError = False
|
||||
Dim IdCtaContable As Integer = -1, IdCtaContableComplementaria As Integer = -1
|
||||
Dim CtaContableCodigo As String = "-1", CtaComplementariaCodigo As String = "-1"
|
||||
Dim TipoCase = ""
|
||||
|
||||
Dim ObjContaAC As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
Dim ObjCuentasBancariasDetalle As New ClsBancos()
|
||||
ObjContaAC.IniciaTransacSQL()
|
||||
ObjCuentasBancariasDetalle.IniciaTransacSQL()
|
||||
|
||||
|
||||
Dim CuentaPadre = -1
|
||||
|
||||
TipoCase = btn.CommandArgument.ToString
|
||||
|
||||
Select Case TipoCase
|
||||
Case "CuentaContable"
|
||||
CuentaPadre = UsuarioActual.Empresa.Funcionalidad(209).ToEntero
|
||||
Case "CuentaContableComplementaria"
|
||||
CuentaPadre = UsuarioActual.Empresa.Funcionalidad(210).ToEntero
|
||||
End Select
|
||||
|
||||
'agrega cuenta
|
||||
IdCuentaContable = AgregaCuenta(ObjContaAC, CuentaPadre)
|
||||
|
||||
If IdCuentaContable > 0 Then
|
||||
|
||||
ObjContaAC.GetCuentas(IdCuentaContable, "-1", -1)
|
||||
Dim dt = ObjContaAC.DtResultados
|
||||
|
||||
If dt.Rows.Count = 1 Then
|
||||
|
||||
Dim row As DataRow = dt.Rows(0)
|
||||
CtaCodigo = CStr(row("CtaCodigo"))
|
||||
|
||||
Select Case TipoCase
|
||||
Case "CuentaContable"
|
||||
IdCtaContable = IdCuentaContable
|
||||
CtaContableCodigo = CtaCodigo
|
||||
Case "CuentaContableComplementaria"
|
||||
IdCtaContableComplementaria = IdCuentaContable
|
||||
CtaContableCodigo = CtaCodigo
|
||||
End Select
|
||||
|
||||
|
||||
If Not ObjCuentasBancariasDetalle.VincularCuentasContablesBancarias(IdCtaContable, IdCtaContableComplementaria, CveCuenta) Then
|
||||
TieneError = True
|
||||
End If
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
|
||||
|
||||
If Not TieneError Then
|
||||
Alert(String.Format("Se registo la Cuenta Contable: {0}", CtaCodigo, TipoMensaje.MsgInformacion))
|
||||
ddl.Items.Add(New ListItem(CtaCodigo, IdCuentaContable.ToString)) : ddl.SelectedValueExist(IdCuentaContable.ToString)
|
||||
btn.Visible = False
|
||||
ddl.Width = 330
|
||||
ObjCuentasBancariasDetalle.Commit()
|
||||
ObjContaAC.Commit()
|
||||
Else
|
||||
Alert("error", TipoMensaje.MsgError)
|
||||
ObjCuentasBancariasDetalle.RollBack()
|
||||
ObjContaAC.RollBack()
|
||||
End If
|
||||
|
||||
|
||||
ObjContaAC.Dispose()
|
||||
ObjCuentasBancariasDetalle.Dispose()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
Private Function AgregaCuenta(ObjContaAC As ClsContPAQi, CuentaPadre As Integer) As Integer
|
||||
Dim IdCuentaContable As Integer = -1
|
||||
Dim TieneError = False
|
||||
|
||||
IdCuentaContable = ObjContaAC.AddSiguienteCuentaHijo(CuentaPadre, TxtNumCuenta.Text.Trim)
|
||||
If IdCuentaContable > 0 Then
|
||||
|
||||
Else
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
If TieneError Then
|
||||
IdCuentaContable = -1
|
||||
End If
|
||||
|
||||
Return IdCuentaContable
|
||||
End Function
|
||||
|
||||
Private Function GuardaCuentasContables(ObjContaAC As ClsContPAQi, ObjCuentasBancariasDetalle As ClsBancos) As Boolean
|
||||
Dim TieneError = False
|
||||
Dim IdCuentaContable, IdCuentaContableComplementaria As Integer
|
||||
|
||||
'agrega cuenta 1
|
||||
If ChckCuentaContable.Checked Then
|
||||
IdCuentaContable = AgregaCuenta(ObjContaAC, UsuarioActual.Empresa.Funcionalidad(209).ToEntero)
|
||||
|
||||
If IdCuentaContable < 0 Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
'agrega cuenta 2
|
||||
If ChckCuentaContable.Checked Then
|
||||
IdCuentaContableComplementaria = AgregaCuenta(ObjContaAC, UsuarioActual.Empresa.Funcionalidad(210).ToEntero)
|
||||
|
||||
If IdCuentaContableComplementaria < 0 Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
'vincula ambos
|
||||
If Not TieneError Then
|
||||
If Not ObjCuentasBancariasDetalle.VincularCuentasContablesBancarias(IdCuentaContable, IdCuentaContableComplementaria, CveCuenta) Then
|
||||
TieneError = True
|
||||
End If
|
||||
End If
|
||||
|
||||
Return TieneError
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
|
||||
#Region " Convenio CIE "
|
||||
Private Sub InicializaConvenio()
|
||||
If ChkLayout.Checked Then
|
||||
TrConvenio.Visible = True
|
||||
Else
|
||||
TrConvenio.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub ChkLayout_CheckedChanged(sender As Object, e As EventArgs)
|
||||
InicializaConvenio()
|
||||
End Sub
|
||||
|
||||
Protected Sub ChkUsaTarjeta_CheckedChanged(sender As Object, e As EventArgs)
|
||||
If ChkUsaTarjeta.Checked AndAlso CveCuenta > 0 Then
|
||||
DivTarjeta.Visible = True
|
||||
CargaDatosTarjeta()
|
||||
Else
|
||||
DivTarjeta.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "D A T O S T A R J E TA - C R E D I T O"
|
||||
Private Sub LkbAgregarTarjera_Click(sender As Object, e As EventArgs) Handles LkbAgregarTarjera.Click
|
||||
Dim ObjTarjeta As New ClsBancos()
|
||||
Dim TieneError = False
|
||||
|
||||
If Not ObjTarjeta.AddTarjetaCredito(CveCuenta, TxtNumTarjeta.Text, TxtNombreResponsable.Text, TxtFechaVencimiento.Text.ToDate, UsuarioActual.CveUsuario) Then
|
||||
TieneError = True
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
Alert("Se guardo la tarjeta de credito correctamente", TipoMensaje.MsgInformacion)
|
||||
TxtNumTarjeta.Text = ""
|
||||
TxtNombreResponsable.Text = ""
|
||||
TxtFechaVencimiento.Text = ""
|
||||
CargaDatosTarjeta()
|
||||
Else
|
||||
Alert("Ocurrio un Error al Guardar la tarjeta de credito", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
ObjTarjeta.Dispose()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaDatosTarjeta()
|
||||
Dim ObjTarjeta As New ClsBancos()
|
||||
|
||||
If ObjTarjeta.GetTarjetaCredito(-1, CveCuenta, -1) Then
|
||||
GvTarjetas.DataSource = ObjTarjeta.DtResultados()
|
||||
Else
|
||||
GvTarjetas.DataSource = Nothing
|
||||
End If
|
||||
GvTarjetas.DataBind()
|
||||
ObjTarjeta.Dispose()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub GvTarjetas_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvTarjetas.RowEditing
|
||||
GvTarjetas.EditIndex = e.NewEditIndex
|
||||
CargaDatosTarjeta()
|
||||
End Sub
|
||||
|
||||
Private Sub GvTarjetas_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvTarjetas.RowCancelingEdit
|
||||
GvTarjetas.EditIndex = -1
|
||||
CargaDatosTarjeta()
|
||||
End Sub
|
||||
|
||||
Private Sub GvTarjetas_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvTarjetas.RowUpdating
|
||||
Dim ObjTarjeta As New ClsBancos()
|
||||
Dim TieneError = False
|
||||
|
||||
Dim CveCuentaTarjeta = GvTarjetas.Rows(e.RowIndex).DataKey("CveCuentaTarjeta").ToEntero
|
||||
Dim CveCuenta As Integer = GvTarjetas.Rows(e.RowIndex).DataKey("CveCuenta").ToEntero
|
||||
Dim Numero = DirectCast(GvTarjetas.Rows(e.RowIndex).FindControl("TxtNumeroEdit"), TextBox).Text.Trim
|
||||
Dim Responsable = DirectCast(GvTarjetas.Rows(e.RowIndex).FindControl("TxtResponsableEdit"), TextBox).Text.Trim
|
||||
Dim Vencimiento = DirectCast(GvTarjetas.Rows(e.RowIndex).FindControl("TxtFechaVencimientoEdit"), TextBox).Text.ToDate
|
||||
|
||||
If Not ObjTarjeta.UpdateTarjetaCredito(CveCuentaTarjeta, CveCuenta, Numero, Responsable, Vencimiento, UsuarioActual.CveUsuario) Then
|
||||
TieneError = True
|
||||
Else
|
||||
GvTarjetas.EditIndex = -1
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
||||
CargaDatosTarjeta()
|
||||
Else
|
||||
Alert("Error al actualizar los cambios.", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
ObjTarjeta.Dispose()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub GvTarjetas_RowDeleting(sender As Object, e As GridViewDeleteEventArgs) Handles GvTarjetas.RowDeleting
|
||||
Dim ObjTarjeta As New ClsBancos()
|
||||
Dim TieneError = False
|
||||
|
||||
Dim CveCuentaTarjeta = GvTarjetas.Rows(e.RowIndex).DataKey("CveCuentaTarjeta").ToEntero
|
||||
|
||||
If ObjTarjeta.RemoveTarjetaCredito(CveCuentaTarjeta, UsuarioActual.CveUsuario) Then
|
||||
CargaDatosTarjeta()
|
||||
Alert("Se eliminaron datos correctamente", TipoMensaje.MsgInformacion)
|
||||
Else
|
||||
Alert("Error al eliminar", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
ObjTarjeta.Dispose()
|
||||
UpDatos.Update()
|
||||
End Sub
|
||||
|
||||
Private Sub GvTarjetas_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvTarjetas.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
If e.Row.RowIndex = 0 Then
|
||||
e.Row.Cells(0).Width = Unit.Pixel(100)
|
||||
e.Row.Cells(1).Width = Unit.Pixel(100)
|
||||
e.Row.Cells(2).Width = Unit.Pixel(200)
|
||||
e.Row.Cells(3).Width = Unit.Pixel(20)
|
||||
e.Row.Cells(4).Width = Unit.Pixel(20)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user