Imports System.Data Imports System.Linq Imports Extensiones Partial Class Contabilidad2_CatCuentasAsignaciones Inherits ClsPaginas Private Property CveConceptoAsignacion() As Integer 'Guardamos el ID de registro para saber cual registro Editar Get Return If(IsNothing(ViewState("CveConceptoAsignacion")), -1, CInt(ViewState("CveConceptoAsignacion"))) End Get Set ViewState("CveConceptoAsignacion") = Value End Set End Property Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then CargaDatosModal() End If End Sub Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) CargaDatosSistema() End Sub Private Sub CargaDatos() Dim ObjConta As New ClsContabilidad If ObjConta.GetCuentasAsignaciones(UsuarioActual.CveEmpresa) Then GvDatos.DataSource = ObjConta.DtResultados End If ObjConta.Dispose() GvDatos.DataBind() End Sub Private Sub CargaDatosSistema() Dim ObjConta As New ClsContabilidad If ObjConta.GetCuentasAsignacionesSistema(UsuarioActual.CveEmpresa, DdlTipo.SelectedValue.ToEntero, DdlOpcion.SelectedValue.ToEntero) Then GvDatos.DataSource = ObjConta.DtResultados End If If ObjConta.GetCuentasGlobales(UsuarioActual.CveEmpresa) Then GvGlobal.DataSource = ObjConta.DtResultados End If ObjConta.Dispose() GvDatos.DataBind() GvGlobal.DataBind() UpDatos.Update() End Sub Private Sub CargaDatosModal() DdlConceptoNomina.DataSource = GlobalDTNomConceptos(UsuarioActual.CveEmpresa) DdlConceptoNomina.DataBind() Dim ObjConta As New ClsContabilidad If ObjConta.GetConta_ConceptosContables() Then DdlCconceptosContables.DataSource = ObjConta.DtResultados DdlConceptoGlobal.DataSource = ObjConta.DtResultados.FiltraParametros("EsCuentaUnica = false AND EsSistema = True AND EsGlobal = True") End If If ObjConta.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then DdlCuenta.DataSource = ObjConta.DtResultados DdlCuentaGlobal.DataSource = ObjConta.DtResultados End If ObjConta.Dispose() DdlProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa) DdlClientes.setEsWebService(True) DdlPersonal.setEsWebService(True) DdlClasificacion.DataSource = GlobalDTClasificaciones(UsuarioActual.CveEmpresa) DdlAlmacen.DataSource = GlobalDTAlmacen(UsuarioActual.CveEmpresa) DdlActivoFijo.DataSource = GlobalDTActivoFijos(UsuarioActual.CveEmpresa) Dim ObjBancos As New ClsBancos If ObjBancos.GetBancosCuentas(-1, CveEmpresa:=UsuarioActual.CveEmpresa) Then DdlCuentaBancaria.DataSource = ObjBancos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa) End If ObjBancos.Dispose() DdlCuentaBancaria.DataBind() DdlCconceptosContables.DataBind() DdlConceptoGlobal.DataBind() DdlCuenta.DataBind() DdlCuentaGlobal.DataBind() DdlProveedor.DataBind() 'DdlPersonal.DataBind() DdlClasificacion.DataBind() DdlAlmacen.DataBind() DdlCuentaBancaria.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlConceptoNomina.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlCconceptosContables.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlCuenta.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlProveedor.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlClasificacion.Items.Insert(0, New ListItem("Seleccione", "-1")) DdlAlmacen.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub Protected Sub ActualizaModulo(sender As Object, e As EventArgs) LimpiarDatos() Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim Dr As DataRow = GlobalDTContaConceptosContables(GvRow.DataKey("CveConceptoContable").ToEntero).FiltroPrimero("") Dim CveConceptoContable As Integer = GvRow.DataKey("CveConceptoContable").ToString.ToEntero HdnCveCuentaAsignacion.Value = GvRow.DataKey("CveCuentaAsignacion").ToString If Dr IsNot Nothing Then CveConceptoAsignacion = GvRow.DataKey("CveCuentaAsignacion").ToEntero DdlCconceptosContables.SelectedValueExist(GvRow.DataKey("CveConceptoContable")) DdlCuenta.SelectedValueExist(GvRow.DataKey("CveCuenta")) DdlConceptoNomina.SelectedValueExist(GvRow.DataKey("CveConceptoNomina").ToEntero) DdlProveedor.SelectedValueExist(GvRow.DataKey("CveProveedor")) DdlClasificacion.SelectedValueExist(GvRow.DataKey("CveClasificacion")) DdlAlmacen.SelectedValueExist(GvRow.DataKey("CveAlmacen")) TxtIdCuentaContable.Text = GvRow.DataKey("IdCuenta") TxtPorcentajeIVA.Text = GvRow.DataKey("PorcentajeIVA") DdlCuentaBancaria.SelectedValueExist(GvRow.DataKey("CveBancoCuenta")) Dim CveCliente As Integer = GvRow.DataKey("CveCliente").ToEntero Dim CvePersonal As Integer = GvRow.DataKey("CvePersonal").ToEntero If Dr("AplicaCliente").ToString = "True" Then divCliente.Visible = True If CveCliente > 0 Then DdlClientes.setEsWebService(False) Dim ObjCliente As New ClsClientes If ObjCliente.GetClientes(-1, "-1", "-1", "-1", "-1", "-1", "-1", -1, UsuarioActual.CveEmpresa) Then DdlClientes.ddl.DataSource = ObjCliente.DtResultados End If DdlClientes.ddl.DataBind() DdlClientes.ddl.SelectedValue = CveCliente End If End If If Dr("AplicaProveedor").ToString = "True" Then divProveedor.Visible = True End If If Dr("AplicaPersonal").ToString = "True" Then divPersonal.Visible = True If CvePersonal > 0 Then DdlPersonal.setEsWebService(False) Dim ObjPersonal As New ClsRH If ObjPersonal.GetPersonal(-1, "-1", "-1", "-1", "-1", -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, UsuarioActual.CveEmpresa) Then DdlPersonal.ddl.DataSource = ObjPersonal.DtResultados End If DdlPersonal.ddl.DataBind() DdlPersonal.ddl.SelectedValueExist(CvePersonal) End If End If If Dr("AplicaImpuesto").ToString = "True" Then divPorcentajeIVA.Visible = True End If If Dr("AplicaClasificacion").ToString = "True" Then divClasificacion.Visible = True End If If Dr("AplicaBancos").ToString = "True" Then divBancos.Visible = True End If If Dr("AplicaAlmacen").ToString = "True" Then divAlmacen.Visible = True End If If Dr("AplicaActivoFijo").ToString = "True" Then divActivoFijo.Visible = True End If If Dr("AplicaNomina").ToString = "True" Then divConceptoNomina.Visible = True End If LbAgregar.Text = "Actualizar" UpModalModulos.Update() RegistraScript("$('#ModalCat').modal();") End If End Sub Protected Sub EliminarRow(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim ObjConta As New ClsContabilidad If ObjConta.RemoveCuentasAsignaciones(GvRow.DataKey("CveCuentaAsignacion").ToEntero) Then Alert("se elimino correctamente") End If CargaDatosSistema() UpDatos.Update() ObjConta.Dispose() End Sub Protected Sub BtnAgregarGlobal_Click(sender As Object, e As EventArgs) Handles BtnAgregarGlobal.Click UppModalGlobal.Update() RegistraScript("$('#ModalGlobal').modal();") End Sub Protected Sub EliminarRowGlobal(sender As Object, e As EventArgs) Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) Dim ObjConta As New ClsContabilidad If ObjConta.RemoveCuentasGlobales(GvRow.DataKey("CveConceptoContable").ToEntero, GvRow.DataKey("CveEmpresa").ToEntero) Then Alert("se elimino correctamente") End If CargaDatosSistema() UpDatos.Update() ObjConta.Dispose() End Sub Protected Sub BtnAgregarAsignacion_Click(sender As Object, e As EventArgs) Handles BtnAgregarAsignacion.Click LimpiarDatos() LbAgregar.Text = "Agregar" UpModalModulos.Update() RegistraScript("$('#ModalCat').modal();") End Sub Private Sub LimpiarDatos() CveConceptoAsignacion = -1 DdlCconceptosContables.SelectedValue = -1 DdlCuenta.SelectedValue = -1 DdlProveedor.SelectedValue = -1 DdlClasificacion.SelectedValue = -1 DdlAlmacen.SelectedValue = -1 DdlConceptoNomina.SelectedValue = -1 DdlCuentaBancaria.SelectedValueExist("-1") TxtIdCuentaContable.Text = "" TxtPorcentajeIVA.Text = "" DdlClientes.ddl.DataSource = "" DdlClientes.ddl.DataBind() DdlClientes.setEsWebService(True) DdlPersonal.ddl.DataSource = "" DdlPersonal.ddl.DataBind() DdlPersonal.setEsWebService(True) End Sub Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click Dim ObjConta As New ClsContabilidad Dim ErrorString As String = "" If HdnCveCuentaAsignacion.Value.ToEntero <= 0 Then If Not ObjConta.AddCuentasAsignaciones(DdlCconceptosContables.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, DdlCuenta.SelectedValue.ToEntero, TxtIdCuentaContable.Text.ToEntero, DdlProveedor.SelectedValue.ToEntero, DdlClientes.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero, DdlClasificacion.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, TxtPorcentajeIVA.Text.ToDecimal, CveBancoCuenta:=DdlCuentaBancaria.SelectedValue.ToEntero(), CveConceptoNomina:=DdlConceptoNomina.SelectedValue.ToEntero()) Then ErrorString = "Error al agregar" End If ElseIf HdnCveCuentaAsignacion.Value.ToEntero > 0 Then If Not ObjConta.UpdateCuentasAsignaciones(CveConceptoAsignacion, DdlCconceptosContables.SelectedValue.ToEntero, DdlCuenta.SelectedValue.ToEntero, TxtIdCuentaContable.Text.ToEntero, DdlProveedor.SelectedValue.ToEntero, DdlClientes.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero, DdlClasificacion.SelectedValue.ToEntero, DdlAlmacen.SelectedValue.ToEntero, TxtPorcentajeIVA.Text.ToDecimal, CveBancoCuenta:=DdlCuentaBancaria.SelectedValue.ToEntero(), CveConceptoNomina:=DdlConceptoNomina.SelectedValue.ToEntero()) Then ErrorString = "Error al actualizar" End If End If ObjConta.Dispose() If Not ChkSeguirRegistrando.Checked Then RegistraScript("$('#ModalCat').modal('hide');") If ErrorString.Length > 0 Then Alert(ErrorString) Else Alert("Agregado correctamente") End If CargaDatosSistema() UpDatos.Update() End Sub Protected Sub LBAgregaGlobal_Click(sender As Object, e As EventArgs) Dim ErrorString As String = "" Dim ObjConta As New ClsContabilidad If Not ObjConta.AddCuentasGlobales(DdlConceptoGlobal.SelectedValue.ToEntero, DdlCuentaGlobal.SelectedValue.ToEntero, DdlTipoGlobal.SelectedValue.ToEntero, UsuarioActual.CveEmpresa) Then ErrorString = "Error al agregar" End If ObjConta.Dispose() If ErrorString.Length > 0 Then Alert(ErrorString) Else Alert("Agregado correctamente") End If CargaDatosSistema() UpDatos.Update() End Sub End Class