From c750a6951b087c8337b908dc4a1755697c38f51d Mon Sep 17 00:00:00 2001 From: rrene Date: Wed, 22 Nov 2023 09:28:50 -0700 Subject: [PATCH] =?UTF-8?q?--=20cambios=20de=20asignaci=C3=B3n=20de=20cuen?= =?UTF-8?q?tas,=20neuvo=20esquema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ventas/CatClasificaciones.aspx | 2 +- Ventas/CatClasificacionesDetalle.aspx | 8 +- Ventas/CatClasificacionesDetalle.aspx.vb | 160 +++++++++++++++-------- 3 files changed, 114 insertions(+), 56 deletions(-) diff --git a/Ventas/CatClasificaciones.aspx b/Ventas/CatClasificaciones.aspx index c1e894b28..2574ba124 100644 --- a/Ventas/CatClasificaciones.aspx +++ b/Ventas/CatClasificaciones.aspx @@ -101,7 +101,7 @@ - + diff --git a/Ventas/CatClasificacionesDetalle.aspx b/Ventas/CatClasificacionesDetalle.aspx index 83f4cb1f0..b85fdb71d 100644 --- a/Ventas/CatClasificacionesDetalle.aspx +++ b/Ventas/CatClasificacionesDetalle.aspx @@ -110,7 +110,7 @@ - + @@ -135,11 +135,11 @@ - + - + @@ -148,7 +148,7 @@ - + diff --git a/Ventas/CatClasificacionesDetalle.aspx.vb b/Ventas/CatClasificacionesDetalle.aspx.vb index e59d1ce2b..6be5b9dc7 100644 --- a/Ventas/CatClasificacionesDetalle.aspx.vb +++ b/Ventas/CatClasificacionesDetalle.aspx.vb @@ -40,32 +40,32 @@ Partial Class CatClasificacionesDetalle If CargaDatos() Then - If UsuarioActual.Empresa.TipoContabilidad = 2 Then - Dim Cuenta As New ClsContPAQi(UsuarioActual.Empresa) + 'If UsuarioActual.Empresa.TipoContabilidad = 2 Then + ' Dim Cuenta As New ClsContPAQi(UsuarioActual.Empresa) - If Cuenta.GetCuentas(-1, "-1", -1) Then - DtCuentas = Cuenta.DtResultados - End If - Cuenta.Dispose() - Try - DdlCuentaGasto.DataSource = DtCuentas : DdlCuentaGasto.DataBind() - Catch ex As Exception + ' If Cuenta.GetCuentas(-1, "-1", -1) Then + ' DtCuentas = Cuenta.DtResultados + ' End If + ' Cuenta.Dispose() + ' Try + ' DdlCuentaGasto.DataSource = DtCuentas : DdlCuentaGasto.DataBind() + ' Catch ex As Exception - End Try + ' End Try - Try - DdlCuentaCostos.DataSource = DtCuentas : DdlCuentaCostos.DataBind() - Catch ex As Exception + ' Try + ' DdlCuentaCostos.DataSource = DtCuentas : DdlCuentaCostos.DataBind() + ' Catch ex As Exception - End Try + ' End Try - Try - DdlCuentaIngresos.DataSource = DtCuentas : DdlCuentaIngresos.DataBind() - Catch ex As Exception + ' Try + ' DdlCuentaIngresos.DataSource = DtCuentas : DdlCuentaIngresos.DataBind() + ' Catch ex As Exception - End Try + ' End Try - End If + 'End If DdlCuentaGasto.Items.Insert(0, New ListItem("-", "-1")) DdlCuentaCostos.Items.Insert(0, New ListItem("-", "-1")) DdlCuentaIngresos.Items.Insert(0, New ListItem("-", "-1")) @@ -103,9 +103,9 @@ Partial Class CatClasificacionesDetalle If dr IsNot Nothing Then TxtClasificacion.Text = dr("Clasificacion").ToString LblClasificacion.Text = dr("Clasificacion").ToString - DdlCuentaGasto.SelectedValue = dr("IdCuentaGasto").ToString - DdlCuentaCostos.SelectedValue = dr("IdCuentaCostos").ToString - DdlCuentaIngresos.SelectedValue = dr("IdCuentaIngresos").ToString + 'DdlCuentaGasto.SelectedValue = dr("CveCuentaGasto").ToString + 'DdlCuentaCostos.SelectedValue = dr("IdCuentaCostos").ToString + 'DdlCuentaIngresos.SelectedValue = dr("IdCuentaIngresos").ToString DdlCategoria.DataSource = GlobalDTGralCategorias(UsuarioActual.CveEmpresa) DdlCategoria.DataBind() @@ -117,7 +117,6 @@ Partial Class CatClasificacionesDetalle If ObjClasificaciones.GetClasificacionesSubProyecto(CveClasificacion, UsuarioActual.CveEmpresa) Then ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados - Else Me.GvDatos.DataSource = Nothing End If @@ -159,34 +158,34 @@ Partial Class CatClasificacionesDetalle Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then - If e.Row.RowIndex = 0 Then - e.Row.Cells(0).Width = Unit.Pixel(150) - e.Row.Cells(1).Width = Unit.Pixel(150) - e.Row.Cells(2).Width = Unit.Pixel(220) - e.Row.Cells(3).Width = Unit.Pixel(220) + 'If e.Row.RowIndex = 0 Then + ' e.Row.Cells(0).Width = Unit.Pixel(150) + ' e.Row.Cells(1).Width = Unit.Pixel(150) + ' e.Row.Cells(2).Width = Unit.Pixel(220) + ' e.Row.Cells(3).Width = Unit.Pixel(220) - e.Row.Cells(4).Width = Unit.Pixel(60) - e.Row.Cells(5).Width = Unit.Pixel(61) - 'e.Row.Cells(7).Width = Unit.Pixel(50) - 'e.Row.Cells(8).Width = Unit.Pixel(50) - End If + ' e.Row.Cells(4).Width = Unit.Pixel(60) + ' e.Row.Cells(5).Width = Unit.Pixel(61) + ' 'e.Row.Cells(7).Width = Unit.Pixel(50) + ' 'e.Row.Cells(8).Width = Unit.Pixel(50) + 'End If If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then - e.Row.FCDropDownList("DdlCuentaGasto").DataSource = DtCuentas + e.Row.FCDropDownList("DdlCuentaGasto").DataSource = GlobalDTContaCuentasContables(UsuarioActual.CveEmpresa, Afectable:=1) e.Row.FCDropDownList("DdlCuentaGasto").DataBind() e.Row.FCDropDownList("DdlCuentaGasto").Items.Insert(0, New ListItem("-", "-1")) - e.Row.FCDropDownList("DdlCuentaGasto").SelectedValue = e.Row.DBCampo("IdCuentaGasto") + e.Row.FCDropDownList("DdlCuentaGasto").SelectedValue = e.Row.DBCampo("CveCuentaGasto") - e.Row.FCDropDownList("DdlCuentaCostos").DataSource = DtCuentas - e.Row.FCDropDownList("DdlCuentaCostos").DataBind() - e.Row.FCDropDownList("DdlCuentaCostos").Items.Insert(0, New ListItem("-", "-1")) - e.Row.FCDropDownList("DdlCuentaCostos").SelectedValue = e.Row.DBCampo("IdCuentaCostos") + 'e.Row.FCDropDownList("DdlCuentaCostos").DataSource = DtCuentas + 'e.Row.FCDropDownList("DdlCuentaCostos").DataBind() + 'e.Row.FCDropDownList("DdlCuentaCostos").Items.Insert(0, New ListItem("-", "-1")) + 'e.Row.FCDropDownList("DdlCuentaCostos").SelectedValue = e.Row.DBCampo("IdCuentaCostos") - e.Row.FCDropDownList("DdlCuentaIngresos").DataSource = DtCuentas - e.Row.FCDropDownList("DdlCuentaIngresos").DataBind() - e.Row.FCDropDownList("DdlCuentaIngresos").Items.Insert(0, New ListItem("-", "-1")) - e.Row.FCDropDownList("DdlCuentaIngresos").SelectedValue = e.Row.DBCampo("IdCuentaIngresos") + 'e.Row.FCDropDownList("DdlCuentaIngresos").DataSource = DtCuentas + 'e.Row.FCDropDownList("DdlCuentaIngresos").DataBind() + 'e.Row.FCDropDownList("DdlCuentaIngresos").Items.Insert(0, New ListItem("-", "-1")) + 'e.Row.FCDropDownList("DdlCuentaIngresos").SelectedValue = e.Row.DBCampo("IdCuentaIngresos") 'e.Row.FCDropDownList("DdlCuentaInventario").DataSource = DtCuentas 'e.Row.FCDropDownList("DdlCuentaInventario").DataBind() @@ -210,15 +209,27 @@ Partial Class CatClasificacionesDetalle End Sub Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting - Dim ObjClasificaciones As New ClsClasificaciones - If ObjClasificaciones.RemoveClasificacion(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then + 'Dim ObjClasificaciones As New ClsClasificaciones + 'If ObjClasificaciones.RemoveClasificacion(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then + ' GvDatos.EditIndex = -1 + ' ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + ' Alert("La Clasificación se eliminó correctamente.", TipoMensaje.MsgInformacion) + 'Else + ' Alert("Ocurrió un error al eliminar la clasificación. Por favor vuelva a intentar.", TipoMensaje.MsgError) + 'End If + 'CargaGlobal() + 'ObjClasificaciones.Dispose() + + Dim ObjClasificaciones As New ClsContabilidad + If ObjClasificaciones.RemoveCuentasAsignaciones(GvDatos.Rows(e.RowIndex).DataKey("CveCuentaAsignacionGasto").ToEntero) Then GvDatos.EditIndex = -1 - ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + CargaDatos() + 'ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) Alert("La Clasificación se eliminó correctamente.", TipoMensaje.MsgInformacion) Else Alert("Ocurrió un error al eliminar la clasificación. Por favor vuelva a intentar.", TipoMensaje.MsgError) End If - CargaGlobal() + ObjClasificaciones.Dispose() If ViewState("Orden").ToString() <> String.Empty Then @@ -227,7 +238,6 @@ Partial Class CatClasificacionesDetalle CargaGrid("") End If - End Sub Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit @@ -240,14 +250,14 @@ Partial Class CatClasificacionesDetalle End Sub Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating - Dim ObjClasificaciones As New ClsClasificaciones + 'Dim ObjClasificaciones As New ClsClasificaciones Dim CveSubProyecto As Integer = e.Keys("CveSubProyecto").ToString.ToEntero Dim tCveClasificacion As Integer = e.Keys("CveClasificacion").ToString.ToEntero Dim DdlGasto As DropDownList = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlCuentaGasto") - Dim DdlCostos As DropDownList = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlCuentaCostos") - Dim DdlIngresos As DropDownList = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlCuentaIngresos") + 'Dim DdlCostos As DropDownList = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlCuentaCostos") + 'Dim DdlIngresos As DropDownList = GvDatos.Rows(e.RowIndex).FCDropDownList("DdlCuentaIngresos") 'If ObjClasificaciones.UpdateClasificacionSubProyecto(tCveClasificacion, CveSubProyecto, DdlIngresos.SelectedValue.ToEntero, DdlIngresos.SelectedItem.Text) Then ' GvDatos.EditIndex = -1 @@ -256,6 +266,54 @@ Partial Class CatClasificacionesDetalle 'Else ' Alert("Ocurrió un error al actualizar la clasificación. Por favor vuelva a intentar.", TipoMensaje.MsgError) 'End If + Dim gvr As GridViewRow = GvDatos.Rows(e.RowIndex) + + + + Dim ObjClasificaciones As New ClsContabilidad + + If gvr.DataKey("CveCuentaAsignacionGasto").ToEntero = 0 Then + + If ObjClasificaciones.AddCuentasAsignaciones(6, UsuarioActual.CveEmpresa, + DdlGasto.SelectedValue.ToEntero, + CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero, + CveSubProyecto:=gvr.DataKey("CveSubProyecto").ToEntero) Then + GvDatos.EditIndex = -1 + CargaDatos() + 'ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + Alert("La Clasificación se registró correctamente.", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrió un error al registró la clasificación. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + Else + + If DdlGasto.SelectedValue.ToEntero > 0 Then + If ObjClasificaciones.UpdateCuentasAsignaciones(gvr.DataKey("CveCuentaAsignacionGasto").ToEntero, + CveConceptoContable:=6, + CveCuenta:=DdlGasto.SelectedValue.ToEntero, + CveClasificacion:=gvr.DataKey("CveClasificacion").ToEntero, + CveSubProyecto:=gvr.DataKey("CveSubProyecto").ToEntero) Then + GvDatos.EditIndex = -1 + CargaDatos() + 'ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + Alert("La Clasificación se actualizo correctamente.", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrió un error se actualizó la clasificación. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + Else + If ObjClasificaciones.RemoveCuentasAsignaciones(gvr.DataKey("CveCuentaAsignacionGasto").ToEntero) Then + GvDatos.EditIndex = -1 + CargaDatos() + 'ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) + Alert("La Clasificación se eliminó correctamente.", TipoMensaje.MsgInformacion) + Else + Alert("Ocurrió un error se eliminó la clasificación. Por favor vuelva a intentar.", TipoMensaje.MsgError) + End If + End If + + + End If + ObjClasificaciones.Dispose()