Exemple #1
0
        private void GenerarSubMenu(System.Web.UI.WebControls.MenuItem itemPadre, DsOpcion ds, DataRow[] subMenu)
        {
            try
            {
                foreach (DataRow dr in subMenu)
                {
                    System.Web.UI.WebControls.MenuItem itemHijo = new System.Web.UI.WebControls.MenuItem();
                    itemHijo.Text  = dr["Titulo"].ToString();
                    itemHijo.Value = dr["OpcionID"].ToString();

                    if (ds.Datos.Select("OpcionPadreID = '" + dr["OpcionID"] + "'", "OrdenVisual").Length > 0)
                    {
                        GenerarSubMenu(itemHijo, ds, ds.Datos.Select("OpcionPadreID = '" + dr["OpcionID"] + "'", "OrdenVisual"));
                    }
                    else
                    {
                        if (!dr["Url"].ToString().Equals(""))
                        {
                            itemHijo.NavigateUrl = dr["Url"].ToString();
                        }
                        else
                        {
                            itemHijo.Selected = false;
                        }
                    }

                    itemPadre.ChildItems.Add(itemHijo);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemple #2
0
        /* Método que obtiene todas las opciones / subopciones asignadas a un usuario determinado. */
        //public DsOpcion GetOpcionesMenuByUsuarioID(int usuarioID, bool esReporte)
        //{
        //    DsOpcion ds = new DsOpcion();
        //    SqlParameter pUsuarioID = new SqlParameter("@UsuarioID", Utiles.BaseDatos.IntToSql(usuarioID));
        //    SqlParameter pEsReporte = new SqlParameter("@EsReporte", (esReporte));

        //    Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "OpcionesMenuByUsuarioID", pUsuarioID, pEsReporte);
        //    return ds;
        //}

        /* Método que obtiene todas las opciones / subopciones asignadas a un usuario determinado. */
        public DsOpcion GetOpcionesMenuByUsuarioID(int usuarioID, bool esReporte)
        {
            DsOpcion ds      = new DsOpcion();
            DsOpcion dsResul = new DsOpcion();
            //SqlParameter pUsuarioID = new SqlParameter("@UsuarioID", Utiles.BaseDatos.IntToSql(usuarioID));
            SqlParameter pEsReporte = new SqlParameter("@EsReporte", (esReporte));

            if (CacheDataManager.GetCacheValue(SisPack.CacheObjetos.OpcionesMenu.ToString()) == null)
            {
                Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "OpcionesMenuByUsuarioID", pEsReporte);
                CacheDataManager.SetCacheValue(SisPack.CacheObjetos.OpcionesMenu.ToString(), ds);
            }
            else
            {
                ds = (DsOpcion)CacheDataManager.GetCacheValue(SisPack.CacheObjetos.OpcionesMenu.ToString());
            }

            DsOpcion.DatosRow[] dr = (DsOpcion.DatosRow[])ds.Datos.Select("UsuarioID =" + usuarioID, "Descripcion");
            foreach (DsOpcion.DatosRow copyRow in dr)
            {
                dsResul.Datos.ImportRow(copyRow);
            }

            dr = null;
            return(dsResul);
        }
        // Método que obtiene todas las opciones de todos los perfiles del usuario
        public DsOpcion GetOpciones()
        {
            DsOpcion     ds         = new DsOpcion();
            SqlParameter pUsuarioID = new SqlParameter("@UsuarioID", Utiles.BaseDatos.IntToSql(this.UsuarioID));

            Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "OpcionesByUsuarioSEL", pUsuarioID);
            return(ds);
        }
Exemple #4
0
        public DsOpcion GetOpcionesPadres(int perfilID)
        {
            DsOpcion     ds        = new DsOpcion();
            SqlParameter pPerfilID = new SqlParameter("@PerfilID", Utiles.BaseDatos.IntToSql(perfilID));

            Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "OpcionesPadresSEL", pPerfilID);
            return(ds);
        }
        public override global::System.Data.DataSet Clone()
        {
            DsOpcion cln = ((DsOpcion)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Exemple #6
0
        private void GenerarMenu(int usuarioID)
        {
            try
            {
                this.mSisPack.Items.Clear();

                /* Obtenemos todo el menú habilitado para el usuario de la sesión. */
                IOpcion opcion = OpcionFactory.GetOpcion();
                opcion.EsAccion = false;

                /*Obtenemos la variable que indica si es Servidor de Reportes o Produccion*/
                string permiteReportes = System.Configuration.ConfigurationManager.AppSettings["Server"];
                bool   esReporte       = permiteReportes == "R" ? true : false;// Convert.ToBoolean(permiteReportes);

                DsOpcion ds = opcion.GetOpcionesMenuByUsuarioID(usuarioID, esReporte);

                /* Creamos el nodo principal (raíz). */
                foreach (DataRow dr in ds.Datos.Select("OpcionPadreID IS NULL", "OrdenVisual"))
                {
                    /* Creamos un nodo padre. */
                    System.Web.UI.WebControls.MenuItem itemPadre = new System.Web.UI.WebControls.MenuItem();

                    itemPadre.Text  = dr["Titulo"].ToString();
                    itemPadre.Value = dr["OpcionID"].ToString();

                    if (ds.Datos.Select("OpcionPadreID = '" + dr["OpcionID"] + "'", "OrdenVisual").Length > 0)
                    {
                        /* Generar los subnodos recursivamente. */
                        GenerarSubMenu(itemPadre, ds, ds.Datos.Select("OpcionPadreID = '" + dr["OpcionID"] + "'", "OrdenVisual"));
                    }
                    else
                    {
                        /* Si tiene una Url seteada la colocamos al nodo. */
                        if (!dr["Url"].ToString().Equals(""))
                        {
                            itemPadre.NavigateUrl = dr["Url"].ToString();
                        }
                        else
                        {
                            itemPadre.Selected = false;
                        }
                    }

                    /* Agregamos el nodo padre(completo) al nodo raíz. */
                    this.mSisPack.Items.Add(itemPadre);
                }

                opcion = null;
                ds     = null;
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            DsOpcion ds = new DsOpcion();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Exemple #8
0
        public bool AsignarOpciones(ArrayList colOpciones)
        {
            // abro una conexion sql
            System.Data.SqlClient.SqlConnection conexion = new System.Data.SqlClient.SqlConnection();
            // defino una transaccion
            System.Data.SqlClient.SqlTransaction transaccion;
            conexion.ConnectionString = Config.ConnectionString;
            // abro la transaccion
            conexion.Open();
            // inicio la transaccion
            transaccion = conexion.BeginTransaction();

            try
            {
                // borro todas las opciones de ese perfil de la tabla OpcionPerfil
                Config.Conexion.EjecutarSinResultados(transaccion, "EliminarOpcionesPerfilDEL", this.PerfilID);

                // agrego cada opcion-perfil en la tabla OpcionPerfil
                foreach (String opcionID in colOpciones)
                {
                    Config.Conexion.EjecutarSinResultados(transaccion, "AsignarOpcionPerfilINS", opcionID, this.PerfilID);
                }

                /*SFE: Remuevo el cache de los usuarios.*/
                DsOpcion     ds = new DsOpcion();
                string       permiteReportes = System.Configuration.ConfigurationSettings.AppSettings["Server"];
                bool         esReporte       = permiteReportes == "R" ? true : false;// Convert.ToBoolean(permiteReportes);
                SqlParameter pEsReporte      = new SqlParameter("@EsReporte", (esReporte));
                Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "OpcionesMenuByUsuarioID", pEsReporte);
                CacheDataManager.RemoveCacheValue(SisPack.CacheObjetos.OpcionesMenu.ToString());
                CacheDataManager.SetCacheValue(SisPack.CacheObjetos.OpcionesMenu.ToString(), ds);

                //ds = new DsOperadorOpciones();
                //Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "UsuarioOpcionALL", pEsReporte);
                //CacheDataManager.SetCacheValue("UsuarioOpcionALL", ds);
                CacheDataManager.RemoveCacheValue("UsuarioOpcionALL");
            }
            catch (Exception ex)
            {
                transaccion.Rollback();
                throw new Exception(ex.Message, ex);
            }
            finally
            {
                transaccion.Commit();
                conexion.Close();
            }

            return(true);
        }
Exemple #9
0
        private void BuscarHijos(int perfilID, string opcionPadreID, squishyTREE.TreeNode n)
        {
            IOpcion opcion = OpcionFactory.GetOpcion();

            opcion.OpcionPadreID = opcionPadreID;
            DsOpcion ds = opcion.GetOpcionesByPerfilID(perfilID);

            int i = 2;

            foreach (DsOpcion.DatosRow dr in ds.Datos)
            {
                string key = "n" + i;
                // obtengo el nodo padre
                squishyTREE.TreeNode n1 = n.AddNode(dr.OpcionID, key);
                n1.AddTaggedValue("val1", dr.Descripcion);

                // busco los hijos de este padre
                this.BuscarHijos(perfilID, dr.OpcionID, n1);
                i++;
            }
        }
        private void buscarHijos(string opcionPadreID, squishyTREE.TreeNode n)
        {
            IOpcion  opcion = OpcionFactory.GetOpcion();
            DsOpcion ds     = opcion.GetOpcionesHijos(opcionPadreID, Utiles.Validaciones.obtieneEntero(this.txtPerfilID.Text));
            int      i      = 2;

            foreach (DsOpcion.DatosRow dr in ds.Datos)
            {
                string key = "n" + i;
                // obtengo el nodo padre
                squishyTREE.TreeNode n1 = n.AddNode(dr.OpcionID, key, true);
                n1.AddTaggedValue("val1", dr.Descripcion);
                if (dr.Asignado)
                {
                    n1.Check();
                }
                // busco los hijos de este padre
                buscarHijos(dr.OpcionID, n1);
                i++;
            }
        }
Exemple #11
0
        public bool Eliminar()
        {
            try
            {
                Config.Conexion.EjecutarSinResultados("UsuarioDEL", this.UsuarioID);

                /*SFE: Remuevo el cache de los usuarios.*/
                DsOpcion     ds = new DsOpcion();
                string       permiteReportes = System.Configuration.ConfigurationSettings.AppSettings["Server"];
                bool         esReporte       = permiteReportes == "R" ? true : false;// Convert.ToBoolean(permiteReportes);
                SqlParameter pEsReporte      = new SqlParameter("@EsReporte", (esReporte));
                Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "OpcionesMenuByUsuarioID", pEsReporte);
                CacheDataManager.RemoveCacheValue(SisPack.CacheObjetos.OpcionesMenu.ToString());
                CacheDataManager.SetCacheValue(SisPack.CacheObjetos.OpcionesMenu.ToString(), ds);

                CacheDataManager.RemoveCacheValue("UsuarioOpcionALL");
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (User.Identity.IsAuthenticated)
            {
                //this.SetCultura();
                string sOpcion = "asignarOpciones";
                Menu   oMenu   = (Menu)this.FindControl("Menu1");
                this.ValidarSeguridad(oMenu, sOpcion);
            }

            tvwMain.AddHeader("Descripción", "", typeof(string), "val1", "left");
            if (!this.IsPostBack)
            {
                this.txtPerfilID.Text = this.Request.QueryString["PerfilID"] == null ? null : this.Request.QueryString["PerfilID"];

                ObtenerPerfil();

                IOpcion  opcion = OpcionFactory.GetOpcion();
                DsOpcion ds     = opcion.GetOpcionesPadres(Utiles.Validaciones.obtieneEntero(this.txtPerfilID.Text));
                foreach (DsOpcion.DatosRow dr in ds.Datos)
                {
                    // obtengo el nodo padre
                    tvwMain.ForceInheritedChecks = true;
                    squishyTREE.TreeNode n1 = tvwMain.AddNode(dr.OpcionID, "n1", true);
                    n1.AddTaggedValue("val1", dr.Descripcion);

                    if (dr.Asignado)
                    {
                        n1.Check();
                    }

                    // busco los hijos de este padre
                    buscarHijos(dr.OpcionID, n1);
                }
            }
        }
Exemple #13
0
        private void BindGrid(int currentPage)
        {
            try
            {
                #region Consulta de permisos por perfil
                if (this.rbPermisosPorPerfil.Checked && !this.ddlPerfilPorCategoria.SelectedValue.Trim().Equals(""))
                {
                    /* Consultar si existe el perfil, dependiendo de los filtros ingresados. */
                    IPerfil perfil = PerfilFactory.GetPerfil();
                    perfil.PerfilID = this.ddlPerfilPorCategoria.SelectedValue.Trim().Equals("")?0: Convert.ToInt32(this.ddlPerfilPorCategoria.SelectedValue.Trim());
                    if (perfil.Consultar())
                    {
                        IOpcion opcion = OpcionFactory.GetOpcion();
                        opcion.OpcionPadreID = "";
                        DsOpcion ds = opcion.GetOpcionesByPerfilID(perfil.PerfilID);

                        tvwMain.Controls.Clear();

                        foreach (DsOpcion.DatosRow dr in ds.Datos)
                        {
                            // obtengo el nodo padre
                            squishyTREE.TreeNode n1 = tvwMain.AddNode(dr.OpcionID, "n1");
                            n1.AddTaggedValue("val1", dr.Descripcion);

                            // busco los hijos de este padre
                            this.BuscarHijos(perfil.PerfilID, dr.OpcionID, n1);
                        }
                    }
                    this.tvwMain.Visible     = true;
                    this.butImprimir.Visible = true;
                    tvwMain.ExpandAll();
                }
                else
                {
                    this.tvwMain.Visible     = false;
                    this.butImprimir.Visible = false;
                }
                #endregion

                #region Consulta de usuarios por perfil
                if (this.rbUsuariosPorPerfil.Checked && !this.ddlPerfilPorCategoria.SelectedValue.Trim().Equals(""))
                {
                    AdministrarGrillas.Configurar(dtgDatosUsuarios, "UsuarioID", this.CantidadOpciones);

                    IPerfil usuarios = PerfilFactory.GetPerfil();
                    usuarios.PerfilID = ddlPerfilPorCategoria.SelectedValue.Trim().Equals("")?0:Convert.ToInt32(ddlPerfilPorCategoria.SelectedValue.Trim());

                    DsUsuarios dsUsuarios = usuarios.GetUsuariosByPerfilID();
                    this.dtgDatosUsuarios.DataSource       = dsUsuarios;
                    this.dtgDatosUsuarios.CurrentPageIndex = currentPage;
                    this.dtgDatosUsuarios.DataBind();

                    usuarios   = null;
                    dsUsuarios = null;
                    this.dtgDatosUsuarios.Visible = true;
                }
                else
                {
                    this.dtgDatosUsuarios.Visible = false;
                }
                #endregion

                #region Consulta de perfiles por permiso
                if (this.rbPerfilesPorPermiso.Checked && !this.ddlPermiso.SelectedValue.Trim().Equals(""))
                {
                    AdministrarGrillas.Configurar(dtgDatosPerfiles, "PerfilID", this.CantidadOpciones);

                    IOpcion permiso = OpcionFactory.GetOpcion();
                    permiso.OpcionID = this.ddlPermiso.SelectedValue.Trim().Equals("")?"":this.ddlPermiso.SelectedValue.Trim();

                    DsPerfil dsPerfilesO = permiso.GetPerfilesByOpcionID();
                    this.dtgDatosPerfiles.DataSource       = dsPerfilesO;
                    this.dtgDatosUsuarios.CurrentPageIndex = currentPage;
                    this.dtgDatosPerfiles.DataBind();

                    permiso     = null;
                    dsPerfilesO = null;
                    this.dtgDatosPerfiles.Visible = true;
                }
                else
                {
                    this.dtgDatosPerfiles.Visible = false;
                }
                #endregion

                #region Consulta de perfiles por usuario
                if (this.rbPerfilesPorUsuario.Checked)
                {
                    AdministrarGrillas.Configurar(dtgDatosPerfiles, "PerfilID", this.CantidadOpciones);

                    IUsuarios perfiles = UsuariosFactory.GetUsuario();
                    perfiles.UsuarioID = cUsuario.UsuarioID.Trim().Equals("")?0:Convert.ToInt32(cUsuario.UsuarioID.Trim());

                    DsPerfil dsPerfiles = perfiles.GetPerfilesAsignadosByUsuarioID();
                    this.dtgDatosPerfiles.DataSource       = dsPerfiles;
                    this.dtgDatosUsuarios.CurrentPageIndex = currentPage;
                    this.dtgDatosPerfiles.DataBind();

                    perfiles   = null;
                    dsPerfiles = null;
                    this.dtgDatosPerfiles.Visible = true;
                }
                else if (!this.rbPerfilesPorPermiso.Checked)
                {
                    this.dtgDatosPerfiles.Visible = false;
                }
                #endregion

                Page.RegisterStartupScript("mostrar", "<script language='javascript'>VisualizarGrilla();\n</script>");
            }
            catch (Exception ex)
            {
                ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message);
            }
        }
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                DsOpcion ds = new DsOpcion();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "DatosDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }