-- unificación de módulos de Contabilidad a una sola carpeta. como principal ContaSIG

This commit is contained in:
2024-06-17 08:33:45 -07:00
parent 54ac9b836b
commit 9219751707
88 changed files with 17456 additions and 21235 deletions

View File

@@ -1,7 +1,8 @@
Imports System.Data
Imports Extensiones
Imports Microsoft.Reporting.WebForms
Partial Class Contabilidad_CatCuentas
Partial Class Contabilidad2_CatCuentas
Inherits ClsPaginas
#Region "Propiedades"
@@ -14,49 +15,127 @@ Partial Class Contabilidad_CatCuentas
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
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 CBool(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
If UsuarioActual.Empresa.TipoContabilizacion = 1 Then
Response.Redirect("/Contabilidad2/CatCuentas.aspx")
Exit Sub
End If
If UsuarioActual.Empresa.UsaContabilidad Then
CargaMonedas()
CargaAgrupadorSAT()
CargaDatos()
Else
Alert("Este módulo requiere el uso de Contabilidad.", TipoMensaje.MsgAdvertencia)
MEECuenta.Enabled = False
LnkPdf.Visible = False
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
End If
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()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.GetMonedas() Then
DdlMoneda.DataSource = ObjConta.DtResultados
End If
ObjConta.Dispose()
DdlMoneda.DataSource = GlobalDTMonedas
DdlMoneda.DataBind()
End Sub
Private Sub CargaAgrupadorSAT()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
Dim ObjConta As New ClsContabilidad
If ObjConta.GetAgrupadoresSAT() Then
DdlAgrupadorSAT.DataSource = ObjConta.DtResultados
@@ -66,40 +145,49 @@ Partial Class Contabilidad_CatCuentas
DdlAgrupadorSAT.DataBind()
DdlAgrupadorSAT.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
Private Sub CargaDatos()
Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
If ObjConta.GetCuentas(-1, "-1", -1) Then
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
'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 AndAlso DtDatos.FiltraParametros("CtaInicial>0").Rows.Count > 0 Then
Mascara = DtDatos.FiltraParametros("CtaInicial>0").Rows(0)("CuentaFormato").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
ObjConta.Dispose()
MEECuenta.Mask = Mascara.Replace("0", "9")
'para obtener la mascara, tomo el primer dato y reemplazo los numeros por cero
Dim Mascara As String = UsuarioActual.Empresa.ContaFormatoCuenta.Replace("X", "9") '"###-##-####"
'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 = "id"
ArbolCuentas.padre = "IdPadre"
ArbolCuentas.titulo = "CtaCodigo"
updatos.Update()
ObjConta.Dispose()
ArbolCuentas.nodoid = "CveCuenta"
ArbolCuentas.padre = "CvePadre"
ArbolCuentas.titulo = "CuentaFormatoNombre"
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("Id = {0}", nodo))
Return DtDatos.FiltraParametros(String.Format("CveCuenta = {0}", nodo))
End Function
Protected Sub agregar_Click(sender As Object, e As EventArgs) Handles ArbolCuentas.addclick
LimpiarCampos()
Tsubcuenta.Visible = True
DdlCuentaContable.Visible = False
Dim dt As New DataTable
'IDSelected = HdnID.Value.ToEntero() "ul" + itempadre.Cve;
Dim obj As ADServerControl.DragableItem = DirectCast(sender, ADServerControl.DragableItem)
IDSelected = obj.Cve
@@ -108,178 +196,453 @@ Partial Class Contabilidad_CatCuentas
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 = CBool(dr("Afectable").ToString)
CvePadre = dr("CvePadre").ToString.ToEntero
End If
Tcuenta.Enabled = True
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.ToString
CveCliente = -1
DdlClientesWS.SelectedText = ""
DdlClientesWS.SelectedValue = CveCliente.ToString
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()
CargaCuentasContables()
Tsubcuenta.Visible = False
DdlCuentaContable.Visible = True
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)
Tcuenta.Text = dr("CuentaFormato").ToString.Replace("-", "")
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.SelectedValueExist(dr("IdMoneda").ToString)
DdlMoneda.SelectedValue = If(dr("CveMoneda").ToString = "", "1", 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()
DdlProveedores.SelectedValue = CveProveedor.ToString
CveCliente = rowcc("CveCliente").ToString().ToEntero()
DdlClientesWS.SelectedText = rowcc("Cliente").ToString
DdlClientesWS.SelectedValue = CveCliente.ToString
Dim PorcentajeImpuesto As Decimal = rowcc("PorcentajeImpuesto").ToString().ToDecimal() * 100
TxtPorcentaje.Text = PorcentajeImpuesto.ToString
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)
DdlPersonal.SelectedValueExist(rowcc("CvePersonal").ToString().ToEntero())
End If
If dr("IdAgrupadorSAT").ToString.ToEntero = 0 Then
End Using
If dr("CveAgrupadorSAT").ToString.ToEntero = 0 Then
DdlAgrupadorSAT.SelectedValue = "-1"
Else
DdlAgrupadorSAT.SelectedValue = dr("IdAgrupadorSAT").ToString
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("IdPadre = {0}", IDSelected)).Rows.Count
Dim Hijos As Integer = DtDatos.FiltraParametros(String.Format("CvePadre = {0}", IDSelected)).Rows.Count
If Hijos = 0 Then BtnEliminar.Visible = True
dt = getNodospadreHijos(dr("IdPadre").ToString.ToEntero)
dt = getNodospadreHijos(dr("CvePadre").ToString.ToEntero)
If dt.Rows.Count > 0 Then
Dim drt As DataRow = dt.Rows(0)
Tsubcuenta.Text = drt("Codigo").ToString
DdlCuentaContable.SelectedValueExist(drt("CveCuenta").ToString)
LblSubCuenta.Text = drt("Nombre").ToString
HdnSubCuentaDe.Value = drt("Codigo").ToString
Guardar.OnClientClick = $"ValidaGuardar('{drt("Codigo").ToString}');"
Guardar.Attributes.Add("data-toggle", "confirmation")
Guardar.Attributes.Add("data-popout", "true")
Guardar.Attributes.Add("data-original-title", "confirmar")
Guardar.Attributes.Add("data-btn-ok-label", "Guardar")
Guardar.Attributes.Add("data-html", "true")
End If
End If
TxtCuenta.Enabled = True
Guardar.Visible = True
updatos.Visible = True
updatos.Update()
End Sub
Private Sub CargaCuentasContables()
DdlCuentaContable.ClearSelection()
DdlCuentaContable.Items.Clear()
DdlCuentaContable.SelectedValue = Nothing
Dim ObjConta As New ClsContabilidad
If ObjConta.GetCuentas(-1, "-1", -1, UsuarioActual.CveEmpresa) Then
DdlCuentaContable.DataSource = ObjConta.DtResultados
End If
ObjConta.Dispose()
DdlCuentaContable.DataBind()
DdlCuentaContable.Items.Insert(0, New ListItem("-", "-1"))
DdlCuentaContable.SelectedValueExist("-1")
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
If ObjConta.UpdateCuenta(IDSelected.ToEntero, Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, DdlMoneda.SelectedValue.ToEntero, DdlAgrupadorSAT.SelectedValue.ToEntero, SubCuentaDe:=Tsubcuenta.Text.Trim) > 0 Then
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, Codigo:=TxtCuenta.Text.Replace("-", ""), CvePadre:=DdlCuentaContable.SelectedValue.ToEntero) 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()
GlobalDTContaCuentasContables(UsuarioActual.CveEmpresa) = Nothing
Alert("La cuenta se guardo correctamente")
End If
Else
Alert("Es necesario agregar el campo 'Agrupador SAT'", TipoMensaje.MsgError)
End If
ObjConta.Dispose()
Dim customerRow As Data.DataRow
customerRow = DtDatos.Select(String.Format("Id = {0}", IDSelected))(0)
customerRow("Nombre") = Tnombre.Text
DtDatos.AcceptChanges()
CargaDatos()
ArbolCuentas.DataSource = DtDatos
ArbolCuentas.DataBind()
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()
updatos.Update()
Alert("La cuenta se guardo correctamente")
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 Tcuenta.Text.Trim = "" Then Alert("Ingrese 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 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
TxtCuenta.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
Dim TieneError As Boolean = False
If DdlAgrupadorSAT.SelectedValue.ToEntero > 0 Then
' [IPP] VIEJO | COMENTADO 9/MARZO/2018
'Dim Afectable As Integer = If(DcuentaMayor.SelectedValue <> 2, 0, 1) ' cuando sea tipo 2, va a ser afectable
Dim Afectable = 1
Dim idnew = ObjConta.AddCuenta(Tcuenta.Text.Replace("-", ""), Tnombre.Text, DTcuenta.SelectedValue.ToString, DcuentaMayor.SelectedValue.ToString.ToEntero, CuentaEfectivo, DdlMoneda.SelectedValue.ToEntero, TxtDigAgrup.Text.ToEntero, TxtNomIngles.Text.Trim, Afectable, IDSelected.ToEntero, DdlAgrupadorSAT.SelectedValue.ToEntero)
If idnew > 0 Then
Dim dr As DataRow = DtDatos.NewRow
dr("id") = idnew
dr("CuentaFormato") = Tcuenta.Text
dr("Nombre") = Tnombre.Text
dr("CtaCodigo") = String.Format("{0} - {1}", Tcuenta.Text, Tnombre.Text)
dr("Tipo") = DTcuenta.SelectedValue.ToString
dr("CtaMayor") = DcuentaMayor.SelectedValue.ToString
dr("IdPadre") = IDSelected
dr("Codigo") = Tnombre.Text
dr("IdMoneda") = 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).ToString
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)
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.Text.ToDecimal / 100D
End If
End If
ObjConta.IniciaTransacSQL()
If Afectable Then
If ObjConta.GetCuentas(IDSelected, "-1", -1, UsuarioActual.CveEmpresa) Then
drt = ObjConta.DtResultados.FiltroPrimero(String.Format("CveCuenta={0}", IDSelected))
CveConceptoAdmin = If(drt("CveConceptoAdmin").ToString.ToEntero = 0, -1, drt("CveConceptoAdmin").ToString.ToEntero)
CveProveedor = If(drt("CveProveedor").ToString.ToEntero = 0, -1, drt("CveProveedor").ToString.ToEntero)
CveCliente = If(drt("CveCliente").ToString.ToEntero = 0, -1, drt("CveCliente").ToString.ToEntero)
CveClasificacion = If(drt("CveClasificacion").ToString.ToEntero = 0, -1, drt("CveClasificacion").ToString.ToEntero)
PorcentajeImpuesto = If(drt("PorcentajeImpuesto").ToString.ToEntero = 0, -1, drt("PorcentajeImpuesto").ToString.ToEntero)
CveBancoCuenta = If(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 = If(drt("Nombre").ToString = "", "", drt("Nombre").ToString)
TipoCuenta = If(drt("Tipo").ToString = "", "", drt("Tipo").ToString)
CuentaMayor = If(drt("CtaMayor").ToString.ToEntero = 0, 0, drt("CtaMayor").ToString.ToEntero)
CveMoneda = If(drt("CveMoneda").ToString.ToEntero = -1, -1, drt("CveMoneda").ToString.ToEntero)
DigAgrup = If(drt("DigAgrup").ToString.ToEntero = -1, -1, drt("DigAgrup").ToString.ToEntero)
CveAgrupadorSat = If(drt("CveAgrupadorSAT").ToString.ToEntero = 0, -1, drt("CveAgrupadorSAT").ToString.ToEntero)
NomIdioma = If(drt("NomIdioma").ToString = "", "", drt("NomIdioma").ToString)
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 ObjConta.UpdateTraspasoPrepoliza(UsuarioActual.CveEmpresa, IDSelected, idnew) Then
If Not ObjConta.UpdateCuenta(IDSelected.ToEntero, NombreCuenta, TipoCuenta, CuentaMayor, CveMoneda,
DigAgrup, CveAgrupadorSat, NomIdioma) Then
TieneError = True
ObjConta.RollBack()
ObjConta.Dispose()
Exit Sub
End If
Else
Alert("El traspaso de movimientos en la cuenta tuvo un error.", TipoMensaje.MsgError)
TieneError = True
ObjConta.RollBack()
ObjConta.Dispose()
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
ArbolCuentas.additem(objul, idnew, IDSelected, String.Format("{0} - {1}", Tcuenta.Text, Tnombre.Text))
'updatos.Visible = False
'nuevacuenta.Visible = False
LimpiarCampos()
updatos.Update()
CargaDatos()
Alert("La cuenta se guardo correctamente")
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)
ObjConta2.IniciaTransacSQL()
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, 1, IdPadre, IdAgrupador)
If idnew2 > 0 Then
If Not ObjConta.UpdateCuentaCompaq(idnew, idnew2, UsuarioActual.CveEmpresa) Then
TieneError = True
ObjConta2.RollBack()
ObjConta.RollBack()
Alert("Ocurrio un error al vincultar la cuenta con SIG y Compaq", TipoMensaje.MsgError)
Else
ObjConta2.Commit()
End If
Else
TieneError = True
ObjConta2.RollBack()
Alert("Ocurrio un error al crear la cuenta en Compaq", TipoMensaje.MsgError)
End If
End If
End If
ObjConta2.Dispose()
End If
If Not TieneError Then
Dim dr As DataRow = DtDatos.NewRow
dr("CveCuenta") = idnew
dr("CuentaFormato") = TxtCuenta.Text
'dr("CuentaFormato") = Tcuenta.Text
dr("Nombre") = Tnombre.Text
dr("CuentaFormatoNombre") = String.Format("{0} - {1}", TxtCuenta.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).ToString
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))
End If
End If
If ObjConta2 IsNot Nothing Then ObjConta2.Dispose()
End If
Else
TieneError = True
ObjConta.RollBack()
Alert("Ocurrio un error al crear la cuenta", TipoMensaje.MsgError)
End If
If Not TieneError Then
ObjConta.Commit()
GlobalDTContaCuentasContables(UsuarioActual.CveEmpresa) = Nothing
CargaDatos()
LimpiarCampos()
updatos.Update()
Alert("La cuenta se guardo correctamente", TipoMensaje.MsgInformacion)
End If
ObjConta.Dispose()
End Sub
Private Sub LimpiarCampos()
Tcuenta.Text = ""
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
Tcuenta.Enabled = False
TxtCuenta.Enabled = False
'Tcuenta.Enabled = False
DdlCuentaContable.SelectedValueExist(-1)
DdlCuentaContable.Visible = False
Tsubcuenta.Visible = True
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)
ObjConta.IniciaTransacSQL()
'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("Id = {0}", IDSelected))(0)
customerRow("IdPadre") = "-5"
customerRow = DtDatos.Select(String.Format("CveCuenta = {0}", IDSelected))(0)
customerRow("CvePadre") = "-5"
DtDatos.AcceptChanges()
ArbolCuentas.DataSource = DtDatos
@@ -289,30 +652,98 @@ Partial Class Contabilidad_CatCuentas
ArbolCuentas.Controls.Remove(item)
RegistraScript(String.Format("$('#{0}').click();", editar.ClientID))
'getNodospadreHijos(IDSelected).Rows(0).Delete()
'RegistraScript(String.Format("$('li#{0}').remove();", IDSelected))
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
GlobalDTContaCuentasContables(UsuarioActual.CveEmpresa) = Nothing
Else
Alert("La Cuenta no pudo ser eliminada", TipoMensaje.MsgError)
ObjConta.RollBack()
' ObjConta.RollBack()
End If
ObjConta.Dispose()
End Sub
Private Sub LnkPdf_Click(sender As Object, e As EventArgs) Handles LnkPdf.Click
Dim Imagen As New System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png")
'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
Case 8
pnlOpcion8.Visible = True
DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
DdlPersonal.DataBind()
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
params.Add(New ReportParameter("FechaImpresion", NowADS().ToDateTime.ToShortDateString))
End Select
End If
End Sub
Protected Sub LnkImprimirExcel_Click(sender As Object, e As EventArgs)
Imprime("Excel")
End Sub
Private Sub Imprime(Formato As String)
If DtDatos IsNot Nothing Then
params.Add(New ReportParameter("LogoPath", If(Imagen.Exists, $"file://{Imagen.FullName}", "")))
Dim params As New List(Of ReportParameter)
params.Add(New ReportParameter("NombreEmpresa", UsuarioActual.Empresa.Empresa))
params.Add(New ReportParameter("UsuarioImprimio", UsuarioActual.Nombre))
ImprimirPDF("Empresas/Grales/Formatos/CatCuentas.rdlc", DtDatos.FiltraParametros("", "Orden ASC"), params, String.Format("Catalogo Cuentas-{0}", NowADS().ToDateTime.ToShortDateString))
ImprimirPDF("Empresas/Grales/Formatos/Cuentas.rdlc", DtDatos, params, "Cuentas", Formato)
Else
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia)
End If
End Sub
End Class