// GET: Role/Create
        public ActionResult Create()
        {
            RolesBLL defRole = new RolesBLL();

            defRole.RoleID = 0;
            return(View(defRole));
        }
        private bool Validar()
        {
            bool paso = true;
            errorProvider1.Clear();

            if (DescripciontextBox.Text == string.Empty)
            {
                errorProvider1.SetError(DescripciontextBox, "El campo Descripcion no puede estar vacío");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (RolesBLL.ExisteDescripcion(DescripciontextBox.Text, (int)idnumericUpDown.Value))
            {
                errorProvider1.SetError(DescripciontextBox, "Este Rol ya existe");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (PermisocomboBox.Text == string.Empty)
            {
                errorProvider1.SetError(PermisocomboBox, "Debe seleccionar un Id");
                PermisocomboBox.Focus();
                paso = false;
            }
            if (this.Detalles.Count == 0)
            {
                errorProvider1.SetError(DetalledataGridView, "Debe agregar un Permiso");
                PermisocomboBox.Focus();
                paso = false;
            }

            return paso;
        }
        protected void ListViewUsers_ItemEditing(object sender, ListViewEditEventArgs e)
        {
            ListViewUsers.EditIndex = e.NewEditIndex;
            PopulateListViewUsers();

            if (this.ListViewUsers.EditIndex != -1)
            {
                Panel         validationMsg           = (Panel)this.ListViewUsers.Items[this.ListViewUsers.EditIndex].FindControl("editNameContainerIsValid");
                UpdatePanel   updatePanel             = (UpdatePanel)this.ListViewUsers.Items[this.ListViewUsers.EditIndex].FindControl("UpdatePanelEdit");
                TextBox       TextBoxUserNameEdit     = (TextBox)updatePanel.FindControl("TextBoxUsernameEdit");
                CheckBoxList  CheckBoxListRolesOfUser = (CheckBoxList)updatePanel.FindControl("CheckBoxListRolesOfUser");
                Literal       ListeralApplicationName = (Literal)updatePanel.FindControl("LiteralAppNameEdit");
                List <String> userRolesList           = RolesBLL.GetRolesForUserByApplication(ListeralApplicationName.Text, TextBoxUserNameEdit.Text);
                List <String> applicationRolesList    = RolesBLL.GetRolesByApplication(ListeralApplicationName.Text);

                validationMsg.Visible = false;

                foreach (string applicationRole in applicationRolesList)
                {
                    System.Web.UI.WebControls.ListItem listItem = new System.Web.UI.WebControls.ListItem(applicationRole, "", true);

                    foreach (string userRole in userRolesList)
                    {
                        if (applicationRole == userRole)
                        {
                            listItem.Selected = true;
                        }
                    }

                    CheckBoxListRolesOfUser.Items.Add(listItem);
                }
            }
        }
        //Este es el evento de boton guardar y sirve para almacenar o modificar los datos de los roles que se registren
        private void GuardarRolButton_Click(object sender, EventArgs e)
        {
            Roles roles;
            bool  paso = false;

            if (!Validar())
            {
                return;
            }
            roles = LlenaClase();

            //Determinar si es guardar o modificar
            if (RolIdNumericUpDown.Value != 0)
            {
                paso = RolesBLL.Guardar(roles);
                MessageBox.Show("El rol ha sido guardado con exito");
            }
            else
            {
                if (!ExisteEnBaseDeDatos())
                {
                    MessageBox.Show("No se puede modificar un usuario que no existe", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = RolesBLL.Modificar(roles);
            }
        }
Example #5
0
        //Esta funcion sirve para verificar que no falte ningun campo obligatorio por llenar
        private bool Validar()
        {
            bool paso = true;

            if (DescripcionTextBox.Text == "")
            {
                RolErrorProvider.SetError(DescripcionTextBox, "Campo obligatorio");
                DescripcionTextBox.Focus();
                paso = false;
            }
            if (RolesBLL.ExisteRol(DescripcionTextBox.Text))
            {
                RolErrorProvider.SetError(DescripcionTextBox, "rol existente");
                DescripcionTextBox.Focus();
                paso = false;
            }
            if (this.Detalle.Count == 0)
            {
                RolErrorProvider.SetError(RolDetalleDataGridView, "Favor de agregar un permiso");
                PermisoIdComboBox.Focus();
                paso = false;
            }

            return(paso);
        }
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            Roles rol;
            bool  paso = false;

            if (!Validar())
            {
                return;
            }

            rol = LlenaClase();

            paso = RolesBLL.Guardar(rol);

            if (paso)
            {
                Limpiar();
                MessageBox.Show("se guardo exitosamente!", "exito",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("no se guardo exitosamente", "Fallo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #7
0
 public rUsuario()
 {
     InitializeComponent();
     RolComboBox.DataSource    = RolesBLL.GetRoles();
     RolComboBox.DisplayMember = "DescripcionRol";
     RolComboBox.ValueMember   = "RolID";
 }
Example #8
0
        //
        // GET: /Admin/Role/

        public ActionResult Index(int pid = 0)
        {
            try
            {
                int       take         = 10;
                int       skip         = take * pid;
                RoleModal objRoleModal = new RoleModal();
                objRoleModal.PageID  = pid;
                objRoleModal.Current = pid + 1;

                var rolelist = new RolesBLL {
                }.GetAllRoles(skip, take);
                if (rolelist != null)
                {
                    double count = Convert.ToDouble(new RolesBLL {
                    }.GetPageCount());
                    var res      = count / take;
                    objRoleModal.Pagecount = (int)Math.Ceiling(res);
                    objRoleModal.Roleslist = rolelist;
                }
                CustomMethods.ValidateRoles("Role");
                return(View(objRoleModal));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Example #9
0
        private void EliminarButton_Click(object sender, EventArgs e)
        {
            MyErrorProvider.Clear();
            int id;

            int.TryParse(RolIdNumericUpDown.Text, out id);

            if (RolIdNumericUpDown.Value == 0)
            {
                MessageBox.Show("Debes agregar un Id valido para poder eliminar un Rol", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (ExisteEnLaBaseDeDatos())
            {
                if (MessageBox.Show("Deseas eliminar este Rol?", "Elije una opcion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (RolesBLL.Eliminar(id))
                    {
                        MessageBox.Show("Rol eliminado!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Limpiar();
                    }
                    else
                    {
                        MyErrorProvider.SetError(RolIdNumericUpDown, "Agrega un Id Valido! Este no existe.");
                    }
                }
            }
            else
            {
                MessageBox.Show("Este Rol no existe en la base de datos, prueba a eliminar otro.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            Roles roles;

            if (!Validar())
            {
                return;
            }

            roles = LlenaClase();

            var paso = RolesBLL.Guardar(roles);

            if (paso)
            {
                Limpiar();
                MessageBox.Show("El rol ha sido guardado", "Exito",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("El rol no ha sido guardado", "Fallo",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private bool Validar()
        {
            bool paso = true;

            if (DescripciontextBox.Text == string.Empty)
            {
                ErrorProvider.SetError(DescripciontextBox, "Este Campo no puede estar vacio");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (RolesBLL.ExisteDescripcion(DescripciontextBox.Text, (int)IdnumericUpDown.Value))
            {
                ErrorProvider.SetError(DescripciontextBox, "Esta Descripcion ya existe");
                DescripciontextBox.Focus();
                paso = false;
            }
            if (PermisocomboBox.Text == string.Empty)
            {
                ErrorProvider.SetError(PermisocomboBox, "Debe seleccionar un Permiso Id");
                PermisocomboBox.Focus();
                paso = false;
            }
            if (this.Detalle.Count == 0)
            {
                ErrorProvider.SetError(DetallesdataGridView, "Debe agregar un Permiso");
                DetallesdataGridView.Focus();
                paso = false;
            }

            return(paso);
        }
Example #12
0
        private bool Validar()
        {
            bool paso = true;

            if (DescripciontextBox.Text == string.Empty)
            {
                ErroreserrorProvider.SetError(DescripciontextBox, "Este campo no puede quedar vacio");
                DescripciontextBox.Focus();
                paso = false;
            }

            if (RolesBLL.ExisteDescripcion(DescripciontextBox.Text))
            {
                ErroreserrorProvider.SetError(DescripciontextBox, "Esta descripcion ya existe en la base de datos");
                DescripciontextBox.Focus();
                paso = false;
            }

            if (PermisoscomboBox.Text == string.Empty)
            {
                ErroreserrorProvider.SetError(PermisoscomboBox, "Debe seleccion un Id");
                PermisoscomboBox.Focus();
                paso = false;
            }

            if (this.Detalle.Count == 0)
            {
                ErroreserrorProvider.SetError(DetalledataGridView, "Es necesario agregar un permis");
                DetalledataGridView.Focus();
                paso = false;
            }

            return(paso);
        }
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            Roles rol;
            bool  paso = false;

            if (!Validar())
            {
                return;
            }

            rol = LlenarClase();

            paso = RolesBLL.Guardar(rol);

            if (!ExisteEnLaBaseDeDatos())
            {
                Limpiar();
                MessageBox.Show("Usuario guardado correctamente", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                Limpiar();
                MessageBox.Show("Usuario modificado correctamente", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #14
0
        private bool ExisteEnBaseDeDatos()
        {
            var roles = new Roles();

            roles = RolesBLL.Buscar((int)RolIdNumericUpDown.Value);
            return(roles != null);
        }
Example #15
0
        private void Guardarbutton_Click(object sender, EventArgs e)
        {
            bool  paso = false;
            Roles roles;

            if (!Validar())
            {
                return;
            }
            roles = LLenaClase();

            if (IdNumericUpDown.Value == 0)
            {
                paso = RolesBLL.Guardar(roles);
            }
            else
            {
                if (!ExisteEnLaBaseDeDatos())
                {
                    MessageBox.Show("No se puede modificar un rol que no existe", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                paso = RolesBLL.Modificar(roles);
            }

            if (paso)
            {
                Limpiar();
                MessageBox.Show("Guardado!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("No se pudo guardar", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        protected void DropDownApplicationNewUser_SelectedIndexChanged(object sender, EventArgs e)
        {
            //string applicationName = this.DropDownApplicationNewUser.SelectedValue;
            string applicationName = this.DropDownApplicationNewUser.SelectedItem.Text;

            this.CheckBoxListApplicationRoles.DataSource = RolesBLL.GetRolesByApplication(applicationName);
            this.CheckBoxListApplicationRoles.DataBind();
        }
        /// <summary>
        /// 获取菜单列表
        /// </summary>
        /// <param name="user">用户对象</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public IEnumerable <Roles> GetList(string where, string orderBy, int pageIndex, int pageSize)
        {
            RolesBLL bll         = new RolesBLL();
            string   decodeWhere = Common.Base64ToString(where);
            string   newWhere    = Common.Where2Query <Roles>(decodeWhere);
            var      list        = bll.GetList(newWhere, orderBy, pageIndex, pageSize);

            return(list);
        }
        public bool IsPermission(dynamic obj)
        {
            string   r   = obj.r;
            string   c   = obj.c;
            string   a   = obj.a;
            RolesBLL bll = new RolesBLL();

            return(bll.IsPermission(r, c, a));
        }
Example #19
0
        /// <summary>
        /// 查询所有的角色
        /// </summary>
        /// <returns></returns>
        public ActionResult GetRoleAll()
        {
            List <Roles> list   = RolesBLL.GetAll();
            var          listed = from s in list select new {
                s.RoleID,
                s.RoleName,
                s.RoleDesc
            };

            return(Json(listed));
        }
 private void EliminarButton_Click(object sender, EventArgs e)
 {
     if (RolesBLL.Eliminar((int)IdRolesNumericUpDown.Value))
     {
         Limpiar();
     }
     else
     {
         MessageBox.Show("No pudo ser eliminado", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #21
0
 private void EliminarButton_Click(object sender, EventArgs e)
 {
     if (RolesBLL.Eliminar((int)RolesIdNumericUpDown.Value))
     {
         Limpiar();
         MessageBox.Show("Transaccione exitosa!", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("No pudo ser eliminado", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #22
0
        public JsonResult ChangeStatusUserType(int id)
        {
            bool Result = false;
            bool changestatus = new RolesBLL {
            }.ChangeStatus(id);

            if (changestatus)
            {
                Result = true;
            }
            return(Json(Result));
        }
        private void BuscarButton_Click(object sender, EventArgs e)
        {
            Roles roles = RolesBLL.Buscar((int)IdRolesNumericUpDown.Value);

            if (roles != null)
            {
                LlenarCampos(roles);
            }
            else
            {
                MessageBox.Show("Usuario No existe.", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 获取角色
        /// </summary>
        /// <returns></returns>
        public string GetRoles()
        {
            StringBuilder sb = new StringBuilder();
            //string[] userRoles = UserData.Roles;
            //int maxRole = userRoles.Min();

            List <Roles> listMenu = new RolesBLL().GetList().ToList();

            sb.Append("[");
            LoopRole(listMenu, listMenu.FindAll(p => p.ParentId == 0 || p.ParentId == null), sb);
            sb.Append("]");
            return(sb.ToString());
        }
        protected void ButtonInsertRole_Click(object sender, EventArgs e)
        {
            bool   isRoleCreated   = false;
            string applicationName = this.DropDownApplicationsInsertRole.SelectedValue;
            string roleName        = this.TextBoxRoleName.Text;

            isRoleCreated = RolesBLL.CreateRoleForApplication(applicationName, roleName);
            if (isRoleCreated)
            {
                Utility.Clear(this.UpdatePanelInsertNewRole.Controls);
                Utility.ShowMessageAfterPOST(Page, Utility.GetStatusMessage(StatusMessages.SuccessfullInsertNewRole));
                PopulateGridViewApplicationsRoles();
            }
        }
Example #26
0
        private void Eliminarbutton_Click(object sender, EventArgs e)
        {
            int id;

            int.TryParse(IDnumericUpDown.Text, out id);
            Limpiar();
            if (RolesBLL.Eliminar(id))
            {
                MessageBox.Show("Rol eliminado correctamente", "Proceso exitoso", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                ErroreserrorProvider.SetError(IDnumericUpDown, "ID no existe en la base de datos");
            }
        }
        //Este es el evento del boton eliminar y sirve para eliminar los datos correspondiente al id ingresado
        private void EliminarRolButton_Click(object sender, EventArgs e)
        {
            RolErrorProvider.Clear();
            int id;

            int.TryParse(RolIdNumericUpDown.Text, out id);
            Limpiar();
            if (RolesBLL.Eliminar(id))
            {
                MessageBox.Show("Eliminado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                RolErrorProvider.SetError(RolIdNumericUpDown, "No se puede eliminar un usuario que no existe");
            }
        }
        private bool LLenaCampos(int id)
        {
            Roles roles = RolesBLL.Buscar(id);

            if (roles != null)
            {
                RolIdNumericUpDown.Value     = roles.RolId;
                DescripcionTextBox.Text      = roles.Descripcion;
                CreacionDateTimePicker.Value = roles.FechaCreacion;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #29
0
        private void EliminarButton_Click(object sender, EventArgs e)
        {
            int id = (int)RolIdNumericUpDown.Value;

            RolErrorProvider.Clear();

            if (RolesBLL.Eliminar(id))
            {
                MessageBox.Show("El rol ha sido eliminado", "Eliminar", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Limpiar();
            }
            else
            {
                RolErrorProvider.SetError(RolIdNumericUpDown, "Este Id no existe");
            }
        }
Example #30
0
        private void BuscarButton_Click(object sender, EventArgs e)
        {
            Roles roles = new Roles();
            int   id    = (int)RolIdNumericUpDown.Value;

            Limpiar();
            roles = RolesBLL.Buscar(id);
            if (roles != null)
            {
                LLenaCampos(roles);
            }
            else
            {
                MessageBox.Show("Rol no encontrado", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }