677 lines
30 KiB
VB.net
677 lines
30 KiB
VB.net
Imports System.Data
|
|
Imports Extensiones
|
|
|
|
Partial Class Contabilidad2_CatCuentas
|
|
Inherits ClsPaginas
|
|
|
|
#Region "Propiedades"
|
|
|
|
Private Property DtDatos As DataTable
|
|
Get
|
|
Return CType(ViewState("DtDatos"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtDatos") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property DtConceptosconta As DataTable
|
|
Get
|
|
Return CType(ViewState("DtConceptosconta"), DataTable)
|
|
End Get
|
|
Set(value As DataTable)
|
|
ViewState("DtConceptosconta") = value
|
|
End Set
|
|
End Property
|
|
Private Property IDSelected As Integer
|
|
Get
|
|
Return ViewState("idsel").ToString.ToEntero()
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("idsel") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CvePadre As Integer
|
|
Get
|
|
Return ViewState("CvePadre").ToString.ToEntero()
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CvePadre") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property Afectable As Boolean
|
|
Get
|
|
Return ViewState("Afectable").ToString
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("Afectable") = value
|
|
End Set
|
|
End Property
|
|
#Region "Contabilidadnew"
|
|
Private Property CveProveedor As Integer
|
|
Get
|
|
Return ViewState("CveProveedor").ToString.ToEntero()
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveProveedor") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveCliente As Integer
|
|
Get
|
|
Return ViewState("CveCliente").ToString.ToEntero()
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveCliente") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveClasificacion As Integer
|
|
Get
|
|
Return ViewState("CveClasificacion").ToString.ToEntero()
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveClasificacion") = value
|
|
End Set
|
|
End Property
|
|
|
|
Private Property CveBancoCuenta As Integer
|
|
Get
|
|
Return ViewState("CveBancoCuenta").ToString.ToEntero()
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveBancoCuenta") = value
|
|
End Set
|
|
End Property
|
|
Private Property CveAlmacen As Integer
|
|
Get
|
|
Return ViewState("CveAlmacen").ToString.ToEntero()
|
|
End Get
|
|
Set(value As Integer)
|
|
ViewState("CveAlmacen") = value
|
|
End Set
|
|
End Property
|
|
#End Region
|
|
#End Region
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
'inicio()
|
|
'RegistraScript("$('#Tsubcuenta').mask('00000-0000-0000-00000');")
|
|
' If UsuarioActual.Empresa.UsaContabilidad Then
|
|
DdlAlmacen.DataSource = GlobalDTAlmacenUsuarios(UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa)
|
|
DdlAlmacen.DataBind()
|
|
DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
CargaMonedas()
|
|
CargaAgrupadorSAT()
|
|
CargaDatos()
|
|
Using objconta As New ClsContabilidad
|
|
objconta.GetConta_ConceptosContables(1)
|
|
DtConceptosconta = objconta.DtResultados
|
|
End Using
|
|
Using ObjBancos As New ClsBancos
|
|
If ObjBancos.GetBancosCuentas(-1) Then
|
|
ddlBancos.DataSource = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
ddlBancos.DataBind()
|
|
ddlBancos.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End If
|
|
End Using
|
|
|
|
|
|
DdlConcepto.DataSource = DtConceptosconta
|
|
DdlConcepto.DataBind()
|
|
DdlConcepto.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
'Else
|
|
' Alert("Este módulo requiere el uso de Contabilidad.", TipoMensaje.MsgAdvertencia)
|
|
' MEECuenta.Enabled = False
|
|
'End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub CargaMonedas()
|
|
|
|
DdlMoneda.DataSource = GlobalDTMonedas
|
|
DdlMoneda.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaAgrupadorSAT()
|
|
|
|
Dim ObjConta As New ClsContabilidad
|
|
|
|
If ObjConta.GetAgrupadoresSAT() Then
|
|
DdlAgrupadorSAT.DataSource = ObjConta.DtResultados
|
|
End If
|
|
|
|
ObjConta.Dispose()
|
|
DdlAgrupadorSAT.DataBind()
|
|
DdlAgrupadorSAT.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaDatos()
|
|
'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim ObjConta As New ClsContabilidad
|
|
|
|
|
|
If ObjConta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
DtDatos = ObjConta.DtResultados
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
'para obtener la mascara, tomo el primer dato y reemplazo los numeros por cero
|
|
Dim Mascara As String = "####-####-###"
|
|
If DtDatos IsNot Nothing AndAlso DtDatos.Rows.Count > 0 Then
|
|
Mascara = DtDatos.Rows(0)("Codigo").ToString.Replace("1", "0").Replace("2", "0").Replace("3", "0").Replace("4", "0").Replace("5", "0").Replace("6", "0").Replace("7", "0").Replace("8", "0").Replace("9", "0")
|
|
End If
|
|
|
|
MEECuenta.Mask = Mascara.Replace("0", "9")
|
|
MEECuenta.AutoComplete = True
|
|
MEECuenta.AutoCompleteValue = Mascara
|
|
|
|
ArbolCuentas.DataSource = DtDatos
|
|
ArbolCuentas.nivel = "CtaInicial"
|
|
ArbolCuentas.nodoid = "CveCuenta"
|
|
ArbolCuentas.padre = "CvePadre"
|
|
ArbolCuentas.titulo = "CtaCodigo"
|
|
ArbolCuentas.DataBind()
|
|
|
|
|
|
End Sub
|
|
|
|
'Private Function getNodosHijos(nodo As Integer) As DataTable
|
|
' Return DtDatos.FiltraParametros(String.Format("IdPadre = {0}", nodo))
|
|
'End Function
|
|
Private Function getNodospadreHijos(nodo As Integer) As DataTable
|
|
Return DtDatos.FiltraParametros(String.Format("CveCuenta = {0}", nodo))
|
|
End Function
|
|
Protected Sub agregar_Click(sender As Object, e As EventArgs) Handles ArbolCuentas.addclick
|
|
LimpiarCampos()
|
|
Dim dt As New DataTable
|
|
|
|
'IDSelected = HdnID.Value.ToEntero() "ul" + itempadre.Cve;
|
|
Dim obj As ADServerControl.DragableItem = DirectCast(sender, ADServerControl.DragableItem)
|
|
IDSelected = obj.Cve
|
|
'obj.FindControl(String.Format("ul{0}", obj.Cve))
|
|
'obj.Controls.Add(New TextBox())
|
|
dt = getNodospadreHijos(IDSelected)
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
Dim dr As DataRow = dt.Rows(0)
|
|
'TxtCuenta.Text = Trim(dr("CuentaFormato").ToString.Replace("-", "").ToString)
|
|
'Tcuenta.Text = Trim(dr("CuentaFormato").ToString.Replace("-", "").ToString)
|
|
Tsubcuenta.Text = dr("CuentaFormato").ToString()
|
|
DTcuenta.SelectedValue = dr("Tipo").ToString()
|
|
DcuentaMayor.SelectedValue = dr("CtaMayor").ToString
|
|
LblSubCuenta.Text = dr("Nombre").ToString
|
|
Afectable = dr("Afectable").ToString
|
|
CvePadre = dr("CvePadre").ToString.ToEntero
|
|
End If
|
|
|
|
If Afectable Then
|
|
RegistraScript(String.Format("Afectable({0});", nuevacuenta.ClientID))
|
|
Alert("Se va crear una subcuenta en una cuenta afectable", TipoMensaje.MsgAdvertencia)
|
|
Else
|
|
RegistraScript("NoAfectable();")
|
|
|
|
End If
|
|
TxtCuenta.Enabled = True
|
|
|
|
'Tcuenta.Enabled = True
|
|
nuevacuenta.Visible = True
|
|
updatos.Visible = True
|
|
updatos.Update()
|
|
|
|
End Sub
|
|
Private Sub limpiavalorescontables()
|
|
|
|
|
|
DdlConcepto.SelectedValueExist(-1)
|
|
onconceptochange()
|
|
CveProveedor = -1
|
|
DdlProveedores.SelectedText = ""
|
|
DdlProveedores.SelectedValue = CveProveedor
|
|
CveCliente = -1
|
|
DdlClientesWS.SelectedText = ""
|
|
DdlClientesWS.SelectedValue = CveCliente
|
|
Dim PorcentajeImpuesto As Decimal = -1
|
|
DdlClasificacion.SelectedValueExist(PorcentajeImpuesto)
|
|
CveClasificacion = -1
|
|
DdlClasificacion.SelectedValueExist(CveClasificacion)
|
|
CveBancoCuenta = -1
|
|
CveAlmacen = -1
|
|
DdlAlmacen.SelectedValueExist(CveAlmacen)
|
|
End Sub
|
|
Protected Sub editar_Click(sender As Object, e As EventArgs) Handles ArbolCuentas.editclick
|
|
LimpiarCampos()
|
|
limpiavalorescontables()
|
|
Dim dt As DataTable
|
|
Dim obj As ADServerControl.DragableItem = DirectCast(sender, ADServerControl.DragableItem)
|
|
IDSelected = obj.Cve
|
|
dt = getNodospadreHijos(IDSelected)
|
|
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
|
|
Dim dr As DataRow = dt.Rows(0)
|
|
TxtCuenta.Text = dr("CuentaFormato").ToString.Replace("-", "").ToString
|
|
'Tcuenta.Text = dr("CuentaFormato").ToString.Replace("-", "").ToString
|
|
Tnombre.Text = dr("Nombre").ToString()
|
|
DTcuenta.SelectedValue = dr("Tipo").ToString()
|
|
DcuentaMayor.SelectedValue = dr("CtaMayor").ToString
|
|
DdlMoneda.SelectedValue = dr("CveMoneda").ToString
|
|
Using objconta As New ClsContabilidad
|
|
objconta.GetConta_CuentasDataContabilidad(IDSelected, UsuarioActual.CveEmpresa)
|
|
If objconta.DtResultados.Rows.Count > 0 Then
|
|
Dim rowcc As DataRow = objconta.DtResultados.Rows(0)
|
|
DdlConcepto.SelectedValue = -1
|
|
DdlConcepto.SelectedValueExist(rowcc("CveConceptoAdmin").ToString().ToEntero())
|
|
onconceptochange()
|
|
CveProveedor = rowcc("CveProveedor").ToString().ToEntero()
|
|
DdlProveedores.SelectedText = rowcc("Proveedor").ToString().ToEntero()
|
|
DdlProveedores.SelectedValue = CveProveedor
|
|
CveCliente = rowcc("CveCliente").ToString().ToEntero()
|
|
DdlClientesWS.SelectedText = rowcc("Cliente").ToString().ToEntero()
|
|
DdlClientesWS.SelectedValue = CveCliente
|
|
Dim PorcentajeImpuesto As Decimal = rowcc("PorcentajeImpuesto").ToString().ToDecimal() * 100
|
|
TxtPorcentaje.Text = (PorcentajeImpuesto)
|
|
CveClasificacion = rowcc("CveClasificacion").ToString().ToEntero()
|
|
DdlClasificacion.SelectedValueExist(CveClasificacion)
|
|
CveBancoCuenta = rowcc("CveBancoCuenta").ToString().ToEntero()
|
|
ddlBancos.SelectedValue = -1
|
|
ddlBancos.SelectedValueExist(CveBancoCuenta)
|
|
CveAlmacen = rowcc("CveAlmacen").ToString().ToEntero()
|
|
DdlAlmacen.SelectedValue = -1
|
|
DdlAlmacen.SelectedValueExist(CveAlmacen)
|
|
End If
|
|
|
|
End Using
|
|
|
|
If dr("CveAgrupadorSAT").ToString.ToEntero = 0 Then
|
|
DdlAgrupadorSAT.SelectedValue = -1
|
|
Else
|
|
DdlAgrupadorSAT.SelectedValueExist(dr("CveAgrupadorSAT").ToString)
|
|
End If
|
|
|
|
|
|
TxtDigAgrup.Text = dr("DigAgrup").ToString
|
|
TxtNomIngles.Text = dr("NomIdioma").ToString
|
|
|
|
Dim Hijos As Integer = DtDatos.FiltraParametros(String.Format("CvePadre = {0}", IDSelected)).Rows.Count
|
|
|
|
If Hijos = 0 Then BtnEliminar.Visible = True
|
|
|
|
dt = getNodospadreHijos(dr("CvePadre").ToString.ToEntero)
|
|
If dt.Rows.Count > 0 Then
|
|
Dim drt As DataRow = dt.Rows(0)
|
|
Tsubcuenta.Text = drt("Codigo").ToString
|
|
LblSubCuenta.Text = drt("Nombre").ToString
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
Guardar.Visible = True
|
|
updatos.Visible = True
|
|
updatos.Update()
|
|
|
|
End Sub
|
|
|
|
Protected Sub Guardar_Click(sender As Object, e As EventArgs) Handles Guardar.Click
|
|
|
|
If Tnombre.Text.Trim = "" Then Alert("Ingrese nombre de la cuenta", TipoMensaje.MsgError) : Exit Sub
|
|
|
|
'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim ObjConta As New ClsContabilidad
|
|
|
|
Dim CveConceptoAdmin As Integer = DdlConcepto.SelectedValue.ToEntero()
|
|
Dim CveProveedor As Integer = DdlProveedores.SelectedValue.ToEntero()
|
|
Dim CveCliente As Integer = DdlClientesWS.SelectedValue.ToEntero()
|
|
Dim CveClasificacion As Integer = DdlClasificacion.SelectedValue.ToEntero()
|
|
Dim PorcentajeImpuesto As Decimal = TxtPorcentaje.Text.ToDecimal() / 100
|
|
Dim CveBancoCuenta As Integer = ddlBancos.SelectedValue.ToEntero
|
|
Dim CveAlmacen As Integer = DdlAlmacen.SelectedValue.ToEntero()
|
|
|
|
If DdlAgrupadorSAT.SelectedValue.ToEntero > 0 Then
|
|
If ObjConta.UpdateCuenta(IDSelected.ToEntero, Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, DdlMoneda.SelectedValue.ToEntero,
|
|
TxtDigAgrup.Text.ToString.ToEntero, DdlAgrupadorSAT.SelectedValue.ToEntero, TxtNomIngles.Text.ToString, CveConceptoAdmin:=CveConceptoAdmin,
|
|
CveProveedor:=CveProveedor, CveCliente:=CveCliente, CveClasificacion:=CveClasificacion, PorcentajeImpuesto:=PorcentajeImpuesto,
|
|
CveBancoCuenta:=CveBancoCuenta, CveAlmacen:=CveAlmacen) Then
|
|
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
|
Dim ObjContaEmpresa As New ClsContPAQi(UsuarioActual.Empresa)
|
|
If Not ObjContaEmpresa.UpdateCuenta(IDSelected.ToEntero, Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero,
|
|
DdlMoneda.SelectedValue.ToEntero, DdlAgrupadorSAT.SelectedValue.ToEntero, SubCuentaDe:=Tsubcuenta.Text.Trim) > 0 Then
|
|
ObjContaEmpresa.Dispose()
|
|
ObjConta.Dispose()
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
|
|
Dim codigo As String = DtDatos.FiltroPrimeroValor("Codigo", $"CveCuenta={IDSelected}")
|
|
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
|
|
|
Using ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa)
|
|
|
|
If ObjConta2.GetCuentas(-1, "-1", -1) Then
|
|
Dim Id As Integer = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"Codigo='{codigo}'").ToEntero
|
|
Dim IdAgrupador As Integer
|
|
|
|
If ObjConta2.GetAgrupadoresSAT() Then
|
|
IdAgrupador = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"CodigoNombre='{DdlAgrupadorSAT.SelectedItem.Text}'").ToEntero
|
|
End If
|
|
If Id > 0 Then
|
|
If ObjConta2.UpdateCuenta(Id, Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, DdlMoneda.SelectedValue.ToEntero, IdAgrupador, SubCuentaDe:=Tsubcuenta.Text.Trim) > 0 Then
|
|
End If
|
|
End If
|
|
End If
|
|
End Using
|
|
End If
|
|
|
|
Dim customerRow As Data.DataRow
|
|
customerRow = DtDatos.Select(String.Format("CveCuenta = {0}", IDSelected))(0)
|
|
customerRow("Nombre") = Tnombre.Text
|
|
DtDatos.AcceptChanges()
|
|
|
|
CargaDatos()
|
|
ArbolCuentas.DataSource = DtDatos
|
|
|
|
Dim item As CheckBox = DirectCast(ArbolCuentas.FindControl(String.Format("chk{0}", IDSelected)), CheckBox)
|
|
item.Text = String.Format("{0} - {1}", customerRow("CuentaFormato").ToString, Tnombre.Text)
|
|
'updatos.Visible = False
|
|
'Guardar.Visible = False
|
|
LimpiarCampos()
|
|
'RegistraScript("$get('BtnCambiaAgrupadorSAT').click();")
|
|
updatos.Update()
|
|
|
|
Alert("La cuenta se guardo correctamente")
|
|
|
|
End If
|
|
Else
|
|
Alert("Es necesario agregar el campo 'Agrupador SAT'", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
|
|
ObjConta.Dispose()
|
|
|
|
End Sub
|
|
Protected Sub nuevacuenta_Click(sender As Object, e As EventArgs) Handles nuevacuenta.Click
|
|
|
|
If Tnombre.Text.Trim = "" Then Alert("Ingrese nombre de la cuenta", TipoMensaje.MsgError) : Exit Sub
|
|
|
|
If TxtCuenta.Text.Trim = "" Then Alert("Ingrese la cuenta", TipoMensaje.MsgError) : Exit Sub
|
|
'If Tcuenta.Text.Trim = "" Then Alert("Ingrese la cuenta", TipoMensaje.MsgError) : Exit Sub
|
|
|
|
|
|
'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim ObjConta As New ClsContabilidad
|
|
Dim CuentaEfectivo As Integer = 0
|
|
Dim Afectable As Integer = 1 'If(DcuentaMayor.SelectedValue <> 2, 0, 1) ' cuando sea tipo 2, va a ser afectable
|
|
Tcuenta.Text.Replace("-", "")
|
|
Dim idnew As Integer = 0
|
|
|
|
Dim CveConceptoContable As Integer = DdlConcepto.SelectedValue.ToEntero()
|
|
Dim row As DataRow = Nothing
|
|
Dim CveTipoSaldo As Integer = 0
|
|
Dim PorcentajeIVA As Decimal = -1
|
|
Dim drt As DataRow
|
|
Dim CveConceptoAdmin As Integer
|
|
Dim CveProveedor As Integer
|
|
Dim CveCliente As Integer
|
|
Dim CveClasificacion As Integer
|
|
Dim PorcentajeImpuesto As Decimal
|
|
Dim CveBancoCuenta As Integer
|
|
'Dim CveAlmacen As Integer = -1
|
|
'Dim CvePersonal As Integer = -1
|
|
Dim NombreCuenta As String
|
|
Dim TipoCuenta As String
|
|
Dim CuentaMayor As Integer
|
|
Dim CveMoneda As Integer
|
|
Dim DigAgrup As Integer
|
|
Dim CveAgrupadorSat As Integer
|
|
Dim NomIdioma As String
|
|
If DdlAgrupadorSAT.SelectedValue.ToEntero > 0 Then
|
|
|
|
If CveConceptoContable > 0 Then
|
|
row = DtConceptosconta.FiltroPrimero(String.Format("CveConceptoContable={0}", CveConceptoContable))
|
|
CveTipoSaldo = row("CveTipoSaldo").ToString.ToEntero()
|
|
End If
|
|
If Not IsNothing(row) Then
|
|
If CveTipoSaldo = 3 Then
|
|
PorcentajeIVA = TxtPorcentaje.ToEntero / 100
|
|
End If
|
|
End If
|
|
|
|
If Afectable Then
|
|
If ObjConta.GetCuentas(IDSelected, "-1", -1, UsuarioActual.CveEmpresa) Then
|
|
drt = ObjConta.DtResultados.FiltroPrimero(String.Format("CveCuenta={0}", IDSelected))
|
|
CveConceptoAdmin = IIf(drt("CveConceptoAdmin").ToString.ToEntero = 0, -1, drt("CveConceptoAdmin").ToString.ToEntero)
|
|
CveProveedor = IIf(drt("CveProveedor").ToString.ToEntero = 0, -1, drt("CveProveedor").ToString.ToEntero)
|
|
CveCliente = IIf(drt("CveCliente").ToString.ToEntero = 0, -1, drt("CveCliente").ToString.ToEntero)
|
|
CveClasificacion = IIf(drt("CveClasificacion").ToString.ToEntero = 0, -1, drt("CveClasificacion").ToString.ToEntero)
|
|
PorcentajeImpuesto = IIf(drt("PorcentajeImpuesto").ToString.ToEntero = 0, -1, drt("PorcentajeImpuesto").ToString.ToEntero)
|
|
CveBancoCuenta = IIf(drt("CveBancoCuenta").ToString.ToEntero = 0, -1, drt("CveBancoCuenta").ToString.ToEntero)
|
|
'CveAlmacen = IIf(drt("CveAlmacen").ToString.ToEntero = 0, -1, drt("CveAlmacen").ToString.ToEntero)
|
|
'CvePersonal = IIf(drt("CvePersonal").ToString.ToEntero = 0, -1, drt("CvePersonal").ToString.ToEntero)
|
|
NombreCuenta = IIf(drt("Nombre").ToString = "", "", drt("Nombre").ToString.ToEntero)
|
|
TipoCuenta = IIf(drt("Tipo").ToString = "", "", drt("Tipo").ToString.ToEntero)
|
|
CuentaMayor = IIf(drt("CtaMayor").ToString.ToEntero = 0, 0, drt("CtaMayor").ToString.ToEntero)
|
|
CveMoneda = IIf(drt("CveMoneda").ToString.ToEntero = -1, -1, drt("CveMoneda").ToString.ToEntero)
|
|
DigAgrup = IIf(drt("DigAgrup").ToString.ToEntero = -1, -1, drt("DigAgrup").ToString.ToEntero)
|
|
CveAgrupadorSat = IIf(drt("CveAgrupadorSAT").ToString.ToEntero = 0, -1, drt("CveAgrupadorSAT").ToString.ToEntero)
|
|
NomIdioma = IIf(drt("NomIdioma").ToString = "", "", drt("NomIdioma").ToString.ToEntero)
|
|
|
|
idnew = ObjConta.AddCuenta(CvePadre, TxtCuenta.Text.Replace("-", ""), Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero,
|
|
DdlMoneda.SelectedValue.ToEntero, TxtDigAgrup.Text.ToEntero, DdlAgrupadorSAT.SelectedValue.ToEntero, TxtNomIngles.Text.ToString, CveConceptoAdmin:=CveConceptoAdmin, CveProveedor:=CveProveedor, CveCliente:=CveCliente,
|
|
CveClasificacion:=CveClasificacion, PorcentajeImpuesto:=PorcentajeImpuesto, CveBancoCuenta:=CveBancoCuenta)
|
|
If idnew > 0 Then
|
|
If Not ObjConta.UpdateTraspasoPrepoliza(UsuarioActual.CveEmpresa, IDSelected, idnew) Then
|
|
If ObjConta.UpdateCuenta(IDSelected.ToEntero, NombreCuenta, TipoCuenta, CuentaMayor, CveMoneda,
|
|
DigAgrup, CveAgrupadorSat, NomIdioma) Then
|
|
ObjConta.RollBack()
|
|
ObjConta.Dispose()
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Else
|
|
idnew = ObjConta.AddCuenta(IDSelected, TxtCuenta.Text.Replace("-", ""), Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero,
|
|
DdlMoneda.SelectedValue.ToEntero, TxtDigAgrup.Text.ToEntero, DdlAgrupadorSAT.SelectedValue.ToEntero, TxtNomIngles.Text.ToString, PorcentajeImpuesto:=PorcentajeIVA)
|
|
End If
|
|
|
|
Else
|
|
Alert("Es necesario agregar el campo 'Agrupador SAT'", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
If idnew > 0 Then
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
|
Dim ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim codigoPadre As String = DtDatos.FiltroPrimeroValor("Codigo", $"CveCuenta={IDSelected}") 'Tsubcuenta.Text
|
|
If ObjConta2.GetCuentas(-1, "-1", -1) Then
|
|
Dim IdPadre As Integer = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"Codigo='{codigoPadre}'").ToEntero
|
|
Dim IdAgrupador As Integer
|
|
|
|
If ObjConta2.GetAgrupadoresSAT() Then
|
|
IdAgrupador = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"CodigoNombre='{DdlAgrupadorSAT.SelectedItem.Text}'").ToEntero
|
|
End If
|
|
|
|
|
|
codigoPadre = DtDatos.FiltroPrimeroValor("Codigo", $"CveCuenta={IDSelected}") 'Tsubcuenta.Text
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
|
ObjConta2 = New ClsContPAQi(UsuarioActual.Empresa)
|
|
|
|
If ObjConta2.GetCuentas(-1, "-1", -1) Then
|
|
IdPadre = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"Codigo='{codigoPadre}'").ToEntero
|
|
If ObjConta2.GetAgrupadoresSAT() Then
|
|
IdAgrupador = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"CodigoNombre='{DdlAgrupadorSAT.SelectedItem.Text}'").ToEntero
|
|
End If
|
|
|
|
If IdPadre > 0 Then
|
|
Dim idnew2 As Integer = ObjConta2.AddCuenta(TxtCuenta.Text.Replace("-", ""), Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, CuentaEfectivo, DdlMoneda.SelectedValue.ToEntero, TxtDigAgrup.Text.ToEntero, TxtNomIngles.Text.Trim, Afectable, IdPadre, IdAgrupador)
|
|
|
|
If idnew2 > 0 Then
|
|
If ObjConta.UpdateCuentaCompaq(idnew, idnew2, UsuarioActual.CveEmpresa) Then
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
ObjConta2.Dispose()
|
|
End If
|
|
|
|
Dim dr As DataRow = DtDatos.NewRow
|
|
dr("CveCuenta") = idnew
|
|
dr("CuentaFormato") = TxtCuenta.Text
|
|
'dr("CuentaFormato") = Tcuenta.Text
|
|
dr("Nombre") = Tnombre.Text
|
|
dr("CtaCodigo") = String.Format("{0} - {1}", TxtCuenta.Text, Tnombre.Text)
|
|
'dr("CtaCodigo") = String.Format("{0} - {1}", Tcuenta.Text, Tnombre.Text)
|
|
dr("Tipo") = DTcuenta.SelectedValue.ToString
|
|
dr("CtaMayor") = DcuentaMayor.SelectedValue.ToString
|
|
dr("CvePadre") = IDSelected
|
|
dr("Codigo") = Tnombre.Text
|
|
dr("CveMoneda") = DdlMoneda.SelectedValue.ToEntero
|
|
dr("DigAgrup") = TxtDigAgrup.Text.Trim.ToEntero
|
|
dr("NomIdioma") = TxtNomIngles.Text.Trim
|
|
DtDatos.Rows.Add(dr)
|
|
ArbolCuentas.DataSource = DtDatos
|
|
'.Attributes.Add("data-hijos","0");
|
|
Dim item As ADServerControl.DragableItem = DirectCast(ArbolCuentas.FindControl(String.Format("{0}", IDSelected)), ADServerControl.DragableItem)
|
|
item.Attributes.Item("data-hijos") = item.Attributes.Item("data-hijos").ToEntero + 1
|
|
Dim objul As ADServerControl.DragableUL = DirectCast(ArbolCuentas.FindControl(String.Format("ul{0}", IDSelected)), ADServerControl.DragableUL)
|
|
If (IsNothing(objul)) Then
|
|
objul = New ADServerControl.DragableUL
|
|
objul.ID = String.Format("ul{0}", item.Cve)
|
|
item.Controls.Add(objul)
|
|
End If
|
|
ArbolCuentas.additem(objul, idnew, IDSelected, String.Format("{0} - {1}", TxtCuenta.Text, Tnombre.Text))
|
|
|
|
|
|
CargaDatos()
|
|
|
|
End If
|
|
If ObjConta2 IsNot Nothing Then ObjConta2.Dispose()
|
|
|
|
End If
|
|
LimpiarCampos()
|
|
updatos.Update()
|
|
Alert("La cuenta se guardo correctamente")
|
|
|
|
End If
|
|
ObjConta.Dispose()
|
|
|
|
|
|
|
|
End Sub
|
|
Private Sub LimpiarCampos()
|
|
TxtCuenta.Text = ""
|
|
'Tcuenta.Text = ""
|
|
Tnombre.Text = ""
|
|
DTcuenta.SelectedValue = "-1"
|
|
DcuentaMayor.SelectedValue = "-1"
|
|
DdlAgrupadorSAT.SelectedValue = "-1"
|
|
Tsubcuenta.Text = ""
|
|
TxtDigAgrup.Text = ""
|
|
Guardar.Visible = False
|
|
nuevacuenta.Visible = False
|
|
TxtCuenta.Enabled = False
|
|
'Tcuenta.Enabled = False
|
|
BtnEliminar.Visible = False
|
|
End Sub
|
|
|
|
Protected Sub borrar_Click(sender As Object, e As EventArgs) Handles borrar.Click
|
|
|
|
End Sub
|
|
|
|
Protected Sub BtnEliminar_Click(sender As Object, e As EventArgs) Handles BtnEliminar.Click
|
|
'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
|
Dim ObjConta As New ClsContabilidad
|
|
'ObjConta.IniciaTransacSQL()
|
|
|
|
If ObjConta.RemoveCuenta(IDSelected.ToEntero) Then
|
|
' ObjConta.Commit()
|
|
|
|
Dim customerRow As Data.DataRow
|
|
customerRow = DtDatos.Select(String.Format("CveCuenta = {0}", IDSelected))(0)
|
|
customerRow("CvePadre") = "-5"
|
|
DtDatos.AcceptChanges()
|
|
|
|
ArbolCuentas.DataSource = DtDatos
|
|
Dim item As ADServerControl.DragableItem = DirectCast(ArbolCuentas.FindControl(String.Format("{0}", IDSelected)), ADServerControl.DragableItem)
|
|
Dim padre As ADServerControl.DragableItem = DirectCast(ArbolCuentas.FindControl(String.Format("{0}", item.CvePadre)), ADServerControl.DragableItem)
|
|
padre.Attributes.Item("data-hijos") = padre.Attributes.Item("data-hijos").ToEntero - 1
|
|
ArbolCuentas.Controls.Remove(item)
|
|
RegistraScript(String.Format("$('#{0}').click();", editar.ClientID))
|
|
|
|
LimpiarCampos()
|
|
upcuentas.Update()
|
|
Alert("La Cuenta ha sido eliminada", TipoMensaje.MsgInformacion)
|
|
|
|
Dim codigo As String = DtDatos.FiltroPrimeroValor("Codigo", $"CveCuenta={IDSelected}")
|
|
|
|
If UsuarioActual.Empresa.TipoContabilidad = 2 Then
|
|
Dim ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa)
|
|
If ObjConta2.GetCuentas(-1, "-1", -1) Then
|
|
Dim Id As Integer = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"Codigo='{codigo}'").ToEntero
|
|
|
|
If Id > 0 Then
|
|
If ObjConta2.RemoveCuenta(Id) Then
|
|
End If
|
|
End If
|
|
End If
|
|
ObjConta2.Dispose()
|
|
|
|
End If
|
|
|
|
Else
|
|
Alert("La Cuenta no pudo ser eliminada", TipoMensaje.MsgError)
|
|
' ObjConta.RollBack()
|
|
End If
|
|
|
|
ObjConta.Dispose()
|
|
|
|
End Sub
|
|
'Protected Sub BtnCambiaAgrupadorSAT_Click(sender As Object, e As EventArgs)
|
|
' CargaAgrupadorSAT()
|
|
'End Sub
|
|
Protected Sub DdlConcepto_SelectedIndexChanged(sender As Object, e As EventArgs)
|
|
onconceptochange()
|
|
End Sub
|
|
Private Sub onconceptochange(Optional CveCuenta As Integer = -1)
|
|
PnlOpcion1.Visible = False
|
|
pnlOpcion2.Visible = False
|
|
pnlOpcion3.Visible = False
|
|
pnlOpcion4.Visible = False
|
|
pnlOpcion5.Visible = False
|
|
pnlOpcion6.Visible = False
|
|
Dim CveConceptoContable As Integer = DdlConcepto.SelectedValue.ToEntero()
|
|
Dim row As DataRow = Nothing
|
|
Dim CveTipoSaldo As Integer = 0
|
|
Dim CveParejaContable As Integer = 0
|
|
If CveConceptoContable > 0 Then
|
|
row = DtConceptosconta.FiltroPrimero(String.Format("CveConceptoContable={0}", CveConceptoContable))
|
|
CveTipoSaldo = row("CveTipoSaldo").ToString.ToEntero()
|
|
CveParejaContable = row("CveParejaContable").ToString().ToEntero()
|
|
End If
|
|
If Not IsNothing(row) Then
|
|
Select Case CveTipoSaldo
|
|
Case 1
|
|
PnlOpcion1.Visible = True
|
|
Case 2
|
|
pnlOpcion2.Visible = True
|
|
Case 3
|
|
pnlOpcion2.Visible = True
|
|
pnlOpcion3.Visible = True
|
|
'If DdlClasificacion.Items.Count < 2 Then
|
|
DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa)
|
|
DdlClasificacion.DataBind()
|
|
'End If
|
|
Case 4
|
|
pnlOpcion4.Visible = True
|
|
Case 5
|
|
pnlOpcion5.Visible = True
|
|
|
|
Case 6
|
|
pnlOpcion6.Visible = True
|
|
|
|
End Select
|
|
End If
|
|
End Sub
|
|
|
|
End Class |