protected void rbPadres_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         this.bMenu = new GestorDocumental.Controllers.MenuController();
         Models.Menu mP = new Models.Menu
         {
             IdMenu = int.Parse(this.rbPadres.SelectedValue)
         };
         this.chkHijos.DataSource     = this.bMenu.ObtenerHijos(mP);
         this.chkHijos.DataTextField  = "DescMenu";
         this.chkHijos.DataValueField = "IdMenu";
         this.chkHijos.DataBind();
         P_Roles r = new P_Roles
         {
             RolId = int.Parse(this.lstPerfil.SelectedValue)
         };
         this.ResaltarOpcionesMenu(this.bMenu.ObtenerHijosPerfil(r, mP));
         this.UpdatePanel2.Update();
     }
     catch (Exception exception)
     {
         this.lblError.Text = exception.Message;
         this.UpdatePanel3.Update();
     }
 }
        public string crearRol(string nombreRol)
        {
            try
            {
                P_Roles data = new P_Roles();
                data.DescRol = nombreRol;
                data.Activo  = true;

                GestorDocumentalEnt db = new GestorDocumentalEnt();
                db.P_Roles.AddObject(data);
                db.SaveChanges();

                //Generamos el log del proceso que acabamos de realizar.
                string mensajeLog = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
                mensajeLog = mensajeLog + "    Se ha creado el rol: " + nombreRol + " Usuario: " + ((Usuarios)Session["USUARIO_LOGUEADO"]).IdUsuario;
                escribirLog(mensajeLog);

                return("Correcto");
            }
            catch (Exception ex)
            {
                //Generamos el log del proceso que acabamos de realizar.
                string mensajeLog = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
                mensajeLog = mensajeLog + "    Error creando el Rol: " + ex.Message + " Usuario: " + ((Usuarios)Session["USUARIO_LOGUEADO"]).IdUsuario;
                escribirLog(mensajeLog);

                return("Incorrecto");
            }
        }
Beispiel #3
0
        public List <spObtenerMenuHijosPerfil_Result> ObtenerHijosPerfil(P_Roles R, Menu M)
        {
            List <spObtenerMenuHijosPerfil_Result> list2;

            try
            {
                list2 = this.gd.spObtenerMenuHijosPerfil(M.IdMenu, R.RolId).ToList();
            }
            catch (Exception exception)
            {
                LogRepository.registro("Error en MenuController metodo ObtenerHijosPerfil " + exception.Message + " stack trace " + exception.StackTrace);
                throw exception;
            }
            return(list2);
        }
Beispiel #4
0
 public void borrarOpcionesMenu(P_Roles R, Menu M)
 {
     try
     {
         using (this.gd)
         {
             P_Roles entity = this.gd.P_Roles.SingleOrDefault <P_Roles>(x => x.RolId == R.RolId);
             this.gd.Menu.SingleOrDefault <Menu>(y => (y.IdMenu == M.IdMenu)).P_Roles.Remove(entity);
             this.gd.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogRepository.registro("Error en MenuController metodo borrarOpcionesMenu " + exception.Message + " stack trace " + exception.StackTrace);
         throw exception;
     }
 }
 protected void lstPerfil_SelectedIndexChanged(object sender, EventArgs e)
 {
     if ((this.lstPerfil.SelectedIndex > 0) && (this.rbPadres.SelectedIndex > -1))
     {
         this.bMenu = new GestorDocumental.Controllers.MenuController();
         Models.Menu mP = new Models.Menu
         {
             IdMenu = int.Parse(this.rbPadres.SelectedValue)
         };
         this.chkHijos.DataSource = this.bMenu.ObtenerHijos(mP);
         P_Roles r = new P_Roles
         {
             RolId = int.Parse(this.lstPerfil.SelectedValue)
         };
         this.ResaltarOpcionesMenu(bMenu.ObtenerHijosPerfil(r, mP));
         this.UpdatePanel2.Update();
     }
 }
 protected void gvRoles_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     try
     {
         this.bRoles = new GestorDocumental.Controllers.PerfilesController();
         P_Roles     r   = new P_Roles();
         GridViewRow row = this.gvRoles.Rows[e.RowIndex];
         r.DescRol = ((TextBox)row.Cells[1].Controls[1]).Text;
         r.RolId   = int.Parse(((Label)row.Cells[0].Controls[1]).Text);
         this.bRoles.InsetarRol(r);
         this.gvRoles.EditIndex = -1;
         this.cargarRoles();
     }
     catch (Exception exception)
     {
         this.lblerror.Text = exception.Message;
         this.UpdatePanel4.Update();
     }
 }
 protected void btnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         this.bRoles = new GestorDocumental.Controllers.PerfilesController();
         P_Roles r = new P_Roles
         {
             DescRol = this.txtDescPerfil.Text
         };
         this.bRoles.InsetarRol(r);
         this.cargarRoles();
         this.UpdatePanel3.Update();
     }
     catch (Exception exception)
     {
         this.lblerror.Text = exception.Message;
         this.UpdatePanel4.Update();
     }
 }
 protected void chkHijos_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         Models.Menu menu;
         P_Roles     roles;
         string      s        = string.Empty;
         string      str2     = string.Empty;
         string[]    strArray = base.Request.Form["__EVENTTARGET"].Split(new char[] { '$' });
         int         num      = int.Parse(strArray[strArray.Length - 1]);
         if (this.chkHijos.Items[num].Selected)
         {
             s = this.chkHijos.Items[num].Value;
         }
         else
         {
             str2 = this.chkHijos.Items[num].Value;
         }
         if (s != "")
         {
             menu        = new Models.Menu();
             roles       = new P_Roles();
             this.bMenu  = new GestorDocumental.Controllers.MenuController();
             menu.IdMenu = int.Parse(s);
             roles.RolId = int.Parse(this.lstPerfil.SelectedValue);
             this.bMenu.InsertarOpcionesMenu(roles, menu);
         }
         else
         {
             menu        = new Models.Menu();
             roles       = new P_Roles();
             this.bMenu  = new GestorDocumental.Controllers.MenuController();
             menu.IdMenu = int.Parse(str2);
             roles.RolId = int.Parse(this.lstPerfil.SelectedValue);
             this.bMenu.borrarOpcionesMenu(roles, menu);
         }
     }
     catch (Exception exception)
     {
         this.lblError.Text = exception.Message;
         this.UpdatePanel3.Update();
     }
 }
Beispiel #9
0
 public void InsertarOpcionesMenu(P_Roles R, Menu M)
 {
     try
     {
         using (this.gd)
         {
             P_Roles entity = this.gd.P_Roles.SingleOrDefault <P_Roles>(x => x.RolId == R.RolId);
             Menu    menu   = this.gd.Menu.SingleOrDefault <Menu>(y => y.IdMenu == M.IdMenu);
             menu.P_Roles.Add(entity);
             foreach (P_Roles roles2 in menu.P_Roles)
             {
                 this.gd.ObjectStateManager.ChangeObjectState(menu, EntityState.Unchanged);
             }
             this.gd.SaveChanges();
         }
     }
     catch (Exception exception)
     {
         LogRepository.registro("Error en MenuController metodo InsertarOpcionesMenu " + exception.Message + " stack trace " + exception.StackTrace);
         throw exception;
     }
 }
        public List <P_Roles> obtenerRolesUsuario()
        {
            List <P_Roles> list2;

            try
            {
                this.gd = new GestorDocumentalEnt();
                List <P_Roles> list = (from r in this.gd.P_Roles select r).ToList <P_Roles>();
                P_Roles        item = new P_Roles
                {
                    RolId   = 0,
                    DescRol = "Seleccione..."
                };
                list.Insert(0, item);
                list2 = list;
            }
            catch (Exception exception)
            {
                LogRepository.registro("Error en UsuariosController metodo obtenerRolesUsuario " + exception.Message);
                throw exception;
            }
            return(list2);
        }
 public void InsetarRol(P_Roles R)
 {
     try
     {
         using (this.gd = new GestorDocumentalEnt())
         {
             if (this.gd.P_Roles.Any <P_Roles>(O => O.RolId == R.RolId))
             {
                 this.gd.P_Roles.First <P_Roles>(i => (i.RolId == R.RolId)).DescRol = R.DescRol;
                 this.gd.SaveChanges();
             }
             else
             {
                 this.gd.AddToP_Roles(R);
                 this.gd.SaveChanges();
             }
         }
     }
     catch (Exception exception)
     {
         LogRepository.registro("Error en PerfilesController metodo InsetarRol " + exception.Message + " stack trace " + exception.StackTrace);
         throw exception;
     }
 }