Option Explicit On Option Strict On Imports System.Data Imports System.Linq Imports Extensiones Partial Class CatClasificaciones Inherits ClsPaginas #Region " PROPIEDADES " Private Property DtCuentasContables As Data.DataTable Get Return CType(ViewState("DtCuentasContables"), DataTable) End Get Set(value As Data.DataTable) ViewState("DtCuentasContables") = value End Set End Property Public Property DtCuentas As DataTable Get Return CType((ViewState("DtCuentas")), DataTable) End Get Set(value As DataTable) ViewState("DtCuentas") = value End Set End Property Private Property CveCuentaGastoActual As Integer Get Return CType(ViewState("CveCuentaGastoActual"), Integer) End Get Set(value As Integer) ViewState("CveCuentaGastoActual") = value End Set End Property Private Property CargaGastos As Boolean Get Return CType(ViewState("CargaGastos"), Boolean) End Get Set(value As Boolean) ViewState("CargaGastos") = value End Set End Property Private Property CveCuentaIngresoActual As Integer Get Return CType(ViewState("CveCuentaIngresoActual"), Integer) End Get Set(value As Integer) ViewState("CveCuentaIngresoActual") = value End Set End Property Private Property CargaIngresos As Boolean Get Return CType(ViewState("CargaIngresos"), Boolean) End Get Set(value As Boolean) ViewState("CargaIngresos") = value End Set End Property Private Property CveCuentaCostoActual As Integer Get Return CType(ViewState("CveCuentaCostoActual"), Integer) End Get Set(value As Integer) ViewState("CveCuentaCostoActual") = value End Set End Property Private Property CargaCostos As Boolean Get Return CType(ViewState("CargaCostos"), Boolean) End Get Set(value As Boolean) ViewState("CargaCostos") = 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 CargaGastos = True CargaCostos = True CargaIngresos = True DtCuentasContables = Nothing CargaDdlSATPS() CargaDDLs() DdlCategoriaFiltro.DataSource = GlobalDTGralCategorias(UsuarioActual.CveEmpresa) DdlCategoriaFiltro.Items.Insert(0, New ListItem("Todos", "-1")) DdlCategoriaFiltro.DataBind() DdlCategoria.DataSource = GlobalDTGralCategorias(UsuarioActual.CveEmpresa) DdlCategoria.DataBind() '' 16/03/2018 - se mueve validacion de la culumna a Personaliza Columna If UsuarioActual.CveEmpresa.Contiene(80, 72) Then DivRequiereSerieLote.Visible = True 'GvDatos.Columns(5).Visible = True TDReqSerie.Visible = True Else DivRequiereSerieLote.Visible = False 'GvDatos.Columns(5).Visible = False TDReqSerie.Visible = False End If UpModalClasif.Update() If UsuarioActual.Empresa.TipoContabilizacion = 1 Then ''COMENTADO DF 30 JUNIO 2017 'Dim Cuenta As New ClsContPAQi(UsuarioActual.Empresa) 'If Cuenta.GetCuentas(-1, "-1", 1, 20000) Then ' DtCuentas = Cuenta.DtResultados 'End If 'Cuenta.Dispose() Else If UsuarioActual.Empresa.TipoContabilidad = 2 Then DivCuentaIngresos.Visible = False DivCuentaCostos.Visible = False DivCuentaGasto.Visible = False GvDatos.Columns(1).Visible = False GvDatos.Columns(2).Visible = False GvDatos.Columns(3).Visible = False 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")) CargaDatos() If UsuarioActual.Empresa.Funcionalidad(531) = "1" Then ' Funcionalidad Es Distribuidor DivEsAcumulador.Visible = True End If End If End Sub Public Sub CargaDatos() Dim ObjClasificaciones As New ClsClasificaciones If ObjClasificaciones.GetClasificaciones() Then ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros($"(Codigo IS NULL OR Codigo = '') AND CveEmpresa = {UsuarioActual.CveEmpresa} AND (CveCategoria = {DdlCategoriaFiltro.SelectedValue.ToEntero} OR {DdlCategoriaFiltro.SelectedValue.ToEntero} = -1) AND (UsoClasificacion = {DdlTipoClasificacion.SelectedValue.ToEntero} OR {DdlTipoClasificacion.SelectedValue.ToEntero} = -1 ) AND (Estado = {DdlEstatus.SelectedValue.ToEntero} OR {DdlEstatus.SelectedValue.ToEntero} = -1)") Else Me.GvDatos.DataSource = Nothing End If ObjClasificaciones.Dispose() CargaGrid() End Sub 'Public Sub CargaGlobal() ' Dim ObjClasificaciones As New ClsClasificaciones ' If ObjClasificaciones.GetClasificaciones(UsuarioActual.CveEmpresa) Then ' ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros($"(Codigo IS NULL OR Codigo = '') AND CveEmpresa = {UsuarioActual.CveEmpresa} AND (CveCategoria = {DdlCategoriaFiltro.SelectedValue.ToEntero} OR {DdlCategoriaFiltro.SelectedValue.ToEntero} = -1) AND (UsoClasificacion = {DdlTipoClasificacion.SelectedValue.ToEntero} OR {DdlTipoClasificacion.SelectedValue.ToEntero} = -1 ) AND (Estado = {DdlEstatus.SelectedValue.ToEntero} OR {DdlEstatus.SelectedValue.ToEntero} = -1)") ' GlobalDTClasificaciones(UsuarioActual.CveEmpresa) = Nothing ' Else ' Me.GvDatos.DataSource = Nothing ' Alert("Ocurrió un error al cargar las clasificaciones. Por favor vuelva a intentar.", TipoMensaje.MsgError) ' End If ' ObjClasificaciones.Dispose() 'End Sub Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click Dim ObjClasificaciones As New ClsClasificaciones Dim RequireSerieLote As Integer = If(ChkRequiereSerieLote.Checked, 1, 0) If HdnModalidadClasificacion.Value = "A" Then If ObjClasificaciones.AddClasificaciones(TxtClasificacion.Text.Trim, "", DdlCuentaGasto.SelectedValue.ToEntero, DdlCuentaGasto.SelectedItem.Text, DdlCuentaCostos.SelectedValue.ToEntero, DdlCuentaCostos.SelectedItem.Text, DdlCuentaIngresos.SelectedValue.ToEntero, DdlCuentaIngresos.SelectedItem.Text, DdlCategoria.SelectedValue.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, RequiereSerieLote:=RequireSerieLote, UsoClasificacion:=DdlUsoClasificacion.SelectedValue.ToEntero, CveSATPS:=DdlSATPS.SelectedValue.ToEntero, RequiereAFCompra:=ChkRequiereAFCompra.Checked, RequiereAFInsumo:=ChkRequiereAFInsumo.Checked, RequierePersonal:=ChkRequierePersonal.Checked, EsAcumulador:=ChkEsAcumulador.Checked, TopVentas:=ChkTopVentas.Checked, TopCompras:=ChkTopCompras.Checked, PrecioBaseCosto:=TxtPrecioBaseCosto.Text.ToDecimal) Then ViewState("DTClasificaciones") = ObjClasificaciones.DtResultados.FiltraParametros($"(Codigo IS NULL OR Codigo = '') AND CveEmpresa = {UsuarioActual.CveEmpresa} AND (CveCategoria = {DdlCategoriaFiltro.SelectedValue.ToEntero} OR {DdlCategoriaFiltro.SelectedValue.ToEntero} = -1) AND (UsoClasificacion = {DdlTipoClasificacion.SelectedValue.ToEntero} OR {DdlTipoClasificacion.SelectedValue.ToEntero} = -1 ) AND (Estado = {DdlEstatus.SelectedValue.ToEntero} OR {DdlEstatus.SelectedValue.ToEntero} = -1)") TxtClasificacion.Text = "" TxtPrecioBaseCosto.Text = "" DdlCuentaGasto.SelectedValueExist("0") DdlCuentaCostos.SelectedValueExist("0") DdlCuentaIngresos.SelectedValueExist("0") RegistraScript(String.Format("$('#{0}').modal('hide');", "ModalClasificaciones")) Alert("La nueva Clasificación se guardó correctamente.", TipoMensaje.MsgInformacion) End If ElseIf HdnModalidadClasificacion.Value = "U" Then Dim Clasificacion As String = TxtClasificacion.Text Dim Estatus As Boolean = ChkEstatus.Checked Dim CveClasificacion As Integer = HdnIDClasificacion.Value.ToEntero Dim DdlGasto As DropDownList = DdlCuentaGasto Dim DdlCosto As DropDownList = DdlCuentaCostos Dim DdlIngresos As DropDownList = DdlCuentaIngresos If ObjClasificaciones.UpdateClasificacion(Clasificacion, "", DdlGasto.SelectedValue.ToEntero, DdlGasto.SelectedItem.Text, DdlCosto.SelectedValue.ToEntero, DdlCosto.SelectedItem.Text, DdlIngresos.SelectedValue.ToEntero, DdlIngresos.SelectedItem.Text, Estatus, False, DdlCategoria.SelectedValue.ToEntero, UsuarioActual.CveUsuario, CveClasificacion, RequiereSerieLote:=RequireSerieLote, UsoClasificacion:=DdlUsoClasificacion.SelectedValue.ToEntero, CveSATPS:=DdlSATPS.SelectedValue.ToEntero, RequiereAFCompra:=ChkRequiereAFCompra.Checked, RequiereAFInsumo:=ChkRequiereAFInsumo.Checked, RequierePersonal:=ChkRequierePersonal.Checked, EsAcumulador:=ChkEsAcumulador.Checked, TopVentas:=ChkTopVentas.Checked, TopCompras:=ChkTopCompras.Checked, PrecioBaseCosto:=TxtPrecioBaseCosto.Text.ToDecimal) Then RegistraScript(String.Format("$('#{0}').modal('hide');", "ModalClasificaciones")) Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion) Else Alert("Ocurrió un error al actualizar la clasificación. Por favor vuelva a intentar.", TipoMensaje.MsgError) End If End If GlobalDTClasificaciones(UsuarioActual.CveEmpresa) = Nothing ObjClasificaciones.Dispose() CargaDatos() UpDatos.Update() UpModalClasif.Update() End Sub Private Sub CargaCuentasContables(Optional IdCuentaPadre As Integer = -1) If UsuarioActual.Empresa.TipoContabilidad = 1 Then DdlCuentaGasto.DataValueField = "CveCuenta" DdlCuentaGasto.DataTextField = "Cuenta" Dim ObjContabilidad As New ClsContabilidad If ObjContabilidad.GetCuentas(-1, "-1", 1, UsuarioActual.CveEmpresa) Then DtCuentasContables = ObjContabilidad.DtResultados 'Cuenta, CtaCodigo DtCuentasContables.Columns("CtaCodigo").ColumnName = "Cuenta" End If ObjContabilidad.Dispose() ElseIf UsuarioActual.Empresa.TipoContabilizacion = 1 Then Dim ObjEmpresa As New ClsSisEmpresas Dim Empresa As Empresa = Nothing If ObjEmpresa.GetEmpresas(UsuarioActual.CveEmpresa, "-1", "-1", "-1", "-1") Then Empresa = ObjEmpresa.Empresa Dim ObjContabilidad As New ClsContPAQi(Empresa) If ObjContabilidad.GetCuentas(-1, "-1", 1, 20000) Then DtCuentasContables = ObjContabilidad.DtResultados End If ObjContabilidad.Dispose() End If ObjEmpresa.Dispose() End If End Sub Protected Sub BtnCargarCuentas_Click(sender As Object, e As EventArgs) Handles BtnCargarCuentas.Click Select Case HdnCuenta.Value Case "1" If DdlCuentaGasto.Attributes("onclick") <> "" And DtCuentasContables Is Nothing Then CargaCuentasContables(If(UsuarioActual.Empresa.Funcionalidad(216).ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(216).ToEntero, -1)) DdlCuentaGasto.Items.Clear() : DdlCuentaGasto.Items.Add(New ListItem("-", "-1")) DdlCuentaGasto.DataSource = DtCuentasContables : DdlCuentaGasto.DataBind() DdlCuentaGasto.AutoPostBack = False : DdlCuentaGasto.Attributes.Remove("onclick") : DdlCuentaGasto.CssClass &= " select2me" : UpModalClasif.Update() DdlCuentaGasto.SelectedValueExist(CveCuentaGastoActual) Case "2" If DdlCuentaCostos.Attributes("onclick") <> "" And DtCuentasContables Is Nothing Then CargaCuentasContables(If(UsuarioActual.Empresa.Funcionalidad(216).ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(216).ToEntero, -1)) DdlCuentaCostos.Items.Clear() : DdlCuentaCostos.Items.Add(New ListItem("-", "-1")) DdlCuentaCostos.DataSource = DtCuentasContables : DdlCuentaCostos.DataBind() DdlCuentaCostos.AutoPostBack = False : DdlCuentaCostos.Attributes.Remove("onclick") : DdlCuentaCostos.CssClass &= " select2me" : UpModalClasif.Update() DdlCuentaCostos.SelectedValueExist(CveCuentaCostoActual) Case "3" If DdlCuentaIngresos.Attributes("onclick") <> "" And DtCuentasContables Is Nothing Then CargaCuentasContables(If(UsuarioActual.Empresa.Funcionalidad(216).ToEntero > 0, UsuarioActual.Empresa.Funcionalidad(216).ToEntero, -1)) DdlCuentaIngresos.Items.Clear() : DdlCuentaIngresos.Items.Add(New ListItem("-", "-1")) DdlCuentaIngresos.DataSource = DtCuentasContables : DdlCuentaIngresos.DataBind() DdlCuentaIngresos.AutoPostBack = False : DdlCuentaIngresos.Attributes.Remove("onclick") : DdlCuentaIngresos.CssClass &= " select2me" : UpModalClasif.Update() DdlCuentaIngresos.SelectedValueExist(CveCuentaIngresoActual) End Select End Sub Public Sub CargaDDLs() If UsuarioActual.Empresa.UsaContabilidad Then DdlCuentaGasto.AutoPostBack = True DdlCuentaCostos.AutoPostBack = True DdlCuentaIngresos.AutoPostBack = True DdlCuentaGasto.Attributes.Add("onclick", "CargaCuentas(1);") DdlCuentaCostos.Attributes.Add("onclick", "CargaCuentas(2);") DdlCuentaIngresos.Attributes.Add("onclick", "CargaCuentas(3);") UpModal.Update() End If End Sub Public Sub CargaDdlSATPS() DdlSATPS.setEsWebService(True) DdlSATPS.Attributes.Add("data-metodo", "getpssat") End Sub #Region "G V D A T O S" Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound If e.Row.RowType = DataControlRowType.Header Then e.Row.Cells(5).Text = "