Transaccionalidad para la creacion de nuevas cuentas
This commit is contained in:
@@ -402,7 +402,7 @@ Partial Class Contabilidad2_CatCuentas
|
||||
'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
|
||||
'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
|
||||
|
||||
@@ -426,6 +426,7 @@ Partial Class Contabilidad2_CatCuentas
|
||||
Dim DigAgrup As Integer
|
||||
Dim CveAgrupadorSat As Integer
|
||||
Dim NomIdioma As String
|
||||
Dim TieneError As Boolean = False
|
||||
If DdlAgrupadorSAT.SelectedValue.ToEntero > 0 Then
|
||||
|
||||
If CveConceptoContable > 0 Then
|
||||
@@ -437,7 +438,7 @@ Partial Class Contabilidad2_CatCuentas
|
||||
PorcentajeIVA = TxtPorcentaje.ToEntero / 100
|
||||
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))
|
||||
@@ -456,13 +457,12 @@ Partial Class Contabilidad2_CatCuentas
|
||||
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,
|
||||
If Not ObjConta.UpdateCuenta(IDSelected.ToEntero, NombreCuenta, TipoCuenta, CuentaMayor, CveMoneda,
|
||||
DigAgrup, CveAgrupadorSat, NomIdioma) Then
|
||||
ObjConta.RollBack()
|
||||
ObjConta.Dispose()
|
||||
@@ -496,7 +496,7 @@ Partial Class Contabilidad2_CatCuentas
|
||||
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
|
||||
@@ -507,53 +507,66 @@ Partial Class Contabilidad2_CatCuentas
|
||||
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
|
||||
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)
|
||||
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
|
||||
|
||||
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)
|
||||
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("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
|
||||
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
|
||||
|
||||
Else
|
||||
TieneError = True
|
||||
ObjConta.RollBack()
|
||||
Alert("Ocurrio un error al crear la cuenta", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
If Not TieneError Then
|
||||
ObjConta.Commit()
|
||||
LimpiarCampos()
|
||||
updatos.Update()
|
||||
Alert("La cuenta se guardo correctamente")
|
||||
|
||||
Alert("La cuenta se guardo correctamente", TipoMensaje.MsgInformacion)
|
||||
End If
|
||||
ObjConta.Dispose()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user