Commit inicial Ventas Productivo
This commit is contained in:
376
Contabilidad2/CatCuentas.aspx.vb
Normal file
376
Contabilidad2/CatCuentas.aspx.vb
Normal file
@@ -0,0 +1,376 @@
|
||||
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 IDSelected As Integer
|
||||
Get
|
||||
Return ViewState("idsel").ToString.ToEntero
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("idsel") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
#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
|
||||
CargaMonedas()
|
||||
CargaAgrupadorSAT()
|
||||
CargaDatos()
|
||||
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)
|
||||
Dim ObJConta As New ClsContabilidad
|
||||
|
||||
|
||||
If ObJConta.GetMonedas() Then
|
||||
DdlMoneda.DataSource = ObJConta.DtResultados
|
||||
End If
|
||||
ObJConta.Dispose()
|
||||
DdlMoneda.DataBind()
|
||||
End Sub
|
||||
|
||||
Private Sub CargaAgrupadorSAT()
|
||||
'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
Dim ObjConta As New ClsContabilidad
|
||||
|
||||
If ObjConta.GetAgrupadoresSAT(UsuarioActual.CveEmpresa) 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"
|
||||
|
||||
|
||||
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
|
||||
End If
|
||||
TxtCuenta.Enabled = True
|
||||
|
||||
'Tcuenta.Enabled = True
|
||||
nuevacuenta.Visible = True
|
||||
updatos.Visible = True
|
||||
updatos.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub editar_Click(sender As Object, e As EventArgs) Handles ArbolCuentas.editclick
|
||||
LimpiarCampos()
|
||||
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
|
||||
|
||||
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 ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
|
||||
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) Then
|
||||
|
||||
Dim codigo As String = DtDatos.FiltroPrimeroValor("Codigo", $"CveCuenta={IDSelected}")
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
ObjConta.Dispose()
|
||||
ObjConta2.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 ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
|
||||
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 = 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)
|
||||
|
||||
If idnew > 0 Then
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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))
|
||||
'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")
|
||||
End If
|
||||
|
||||
ObjConta.Dispose()
|
||||
ObjConta2.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
|
||||
Dim ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa)
|
||||
'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 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
|
||||
Else
|
||||
Alert("La Cuenta no pudo ser eliminada", TipoMensaje.MsgError)
|
||||
' ObjConta.RollBack()
|
||||
End If
|
||||
|
||||
ObjConta.Dispose()
|
||||
ObjConta2.Dispose()
|
||||
|
||||
End Sub
|
||||
'Protected Sub BtnCambiaAgrupadorSAT_Click(sender As Object, e As EventArgs)
|
||||
' CargaAgrupadorSAT()
|
||||
'End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user