diff --git a/Contabilidad2/CatCuentas.aspx.vb b/Contabilidad2/CatCuentas.aspx.vb index 40341986f..3b47bd41e 100644 --- a/Contabilidad2/CatCuentas.aspx.vb +++ b/Contabilidad2/CatCuentas.aspx.vb @@ -315,7 +315,7 @@ Partial Class Contabilidad2_CatCuentas Dim codigo As String = DtDatos.FiltroPrimeroValor("Codigo", $"CveCuenta={IDSelected}") - If UsuarioActual.Empresa.TipoContabilidad <> 1 Then + If UsuarioActual.Empresa.TipoContabilidad = 2 Then Using ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa) @@ -371,7 +371,7 @@ Partial Class Contabilidad2_CatCuentas 'Dim ObjConta As New ClsContPAQi(UsuarioActual.Empresa) Dim ObjConta As New ClsContabilidad - Dim ObjConta2 As New ClsContPAQi(UsuarioActual.Empresa) + Dim ObjConta2 As ClsContPAQi Dim CuentaEfectivo As Integer = 0 Dim Afectable As Integer = 1 'If(DcuentaMayor.SelectedValue <> 2, 0, 1) ' cuando sea tipo 2, va a ser afectable @@ -388,41 +388,45 @@ Partial Class Contabilidad2_CatCuentas 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 UsuarioActual.Empresa.TipoContabilidad = 2 Then + ObjConta2 = New ClsContPAQi(UsuarioActual.Empresa) - If ObjConta2.GetAgrupadoresSAT() Then - IdAgrupador = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"CodigoNombre='{DdlAgrupadorSAT.SelectedItem.Text}'").ToEntero - End If + If ObjConta2.GetCuentas(-1, "-1", -1) Then + Dim IdPadre As Integer = ObjConta2.DtResultados.FiltroPrimeroValor("Id", $"Codigo='{codigoPadre}'").ToEntero + Dim IdAgrupador As Integer - 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 + 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 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("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 + 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 @@ -444,7 +448,7 @@ Partial Class Contabilidad2_CatCuentas End If ObjConta.Dispose() - ObjConta2.Dispose() + If ObjConta2 IsNot Nothing Then ObjConta2.Dispose() End Sub Private Sub LimpiarCampos() TxtCuenta.Text = ""