Пример #1
0
        protected void rpRoleList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Add")
            {
                if (e.Item.ItemType == ListItemType.Header)
                {
                    TextBox txtRoleNameAdd = e.Item.FindControl("txtRoleNameAdd") as TextBox;

                    Role role = new Role()
                    {
                        Role_Name = txtRoleNameAdd.Text,
                        IsActive  = true
                    };

                    RoleDAL dal = new RoleDAL();
                    dal.AddRole(role);
                    dal.Save();
                }
            }
            else if (e.CommandName == "Delete")
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    HiddenField hfId = e.Item.FindControl("hfId") as HiddenField;
                    RoleDAL     dal  = new RoleDAL();
                    dal.DeleteRole(int.Parse(hfId.Value));
                }
            }
            Utility.BindDataToRepeater(rpRoleList, GetRoleList());
            SetFocus(source);
            Response.Redirect("AccessControlManagement.aspx?tabno=2");
        }
Пример #2
0
        /// <summary>
        /// Delete a role
        /// </summary>
        /// <param name="roleName">Name of role that you want to delete.</param>
        /// <returns>Return the number of rows affected or return -1 if occur exception.</returns>
        public void DeleteRole(String roleName)
        {
            Role deleteRole = GetRole(roleName);
            int  result     = RD.DeleteRole(deleteRole.Role_Name);

            if (result == -1)
            {
                throw new Exception("An error occurred while executing this operation.");
            }
        }
Пример #3
0
        public bool DeleteRole(RoleBE role)
        {
            RoleDAL roleDAL = new RoleDAL();

            if (roleDAL.DeleteRole(role))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// To Delete Role
        /// </summary>
        /// <param name="roleID"></param>
        /// <returns></returns>
        public string DeleteRole(int roleID)
        {
            RoleDAL objRoleDAL = new RoleDAL();

            return(objRoleDAL.DeleteRole(roleID));
        }
Пример #5
0
 public int DeleteRole(int RoleID)
 {
     return(rdal.DeleteRole(RoleID));
 }
Пример #6
0
 public IEnumerable <SalonAPI.Models.RoleDAL.tblRoles> Delete_Role(int RoleId)
 {
     return(objRole.DeleteRole(RoleId));
 }
Пример #7
0
        public void RoleDALMenu()
        {
            while (true)
            {
                System.Console.WriteLine("Welcome in Role");
                System.Console.WriteLine("c - Create");
                System.Console.WriteLine("r - read one");
                System.Console.WriteLine("rall - read all");
                System.Console.WriteLine("u - update");
                System.Console.WriteLine("d - delete");
                System.Console.WriteLine("else - exit");

                string a = System.Console.ReadLine();



                switch (a)
                {
                case "c":
                    System.Console.WriteLine("Input RoleName:");
                    role = dal.CreateRole(new RoleDTO {
                        RoleName = System.Console.ReadLine()
                    });
                    System.Console.WriteLine("You add the: Id - " + role.RoleId + " Name - " + role.RoleName);
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "r":
                    System.Console.Write("Choose Id: ");
                    role = dal.GetRoleById(System.Convert.ToInt32(System.Console.ReadLine()));
                    System.Console.WriteLine("You read the: Id - " + role.RoleId + " Name - " + role.RoleName);
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "rall":
                    List <RoleDTO> categories = dal.GetAllRole();
                    for (int i = 0; i < role.Count; i++)
                    {
                        System.Console.WriteLine("Id - " + role[i].RoleId + " Name - " + role[i].RoleName);
                    }
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "u":
                    System.Console.WriteLine("Update Name:");
                    role = dal.UpdateRole(new RoleDTO {
                        RoleName = System.Console.ReadLine()
                    });
                    System.Console.WriteLine("You add the: Id - " + role.RoleId + " Name - " + role.RoleName);
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "d":
                    System.Console.WriteLine("Choose Id:");
                    dal.DeleteRole(System.Convert.ToInt32(System.Console.ReadLine()));
                    System.Console.WriteLine("Delete successful");
                    System.Console.WriteLine("Press any key");
                    System.Console.WriteLine("");
                    System.Console.WriteLine("");
                    System.Console.ReadKey();
                    break;

                case "else":
                    break;
                }
            }
        }
Пример #8
0
 /// <summary>
 /// 删除单个角色信息
 /// </summary>
 /// <param name="roleId"></param>
 ///  <param name="delType">0 ---logic   1= real</param>
 /// <returns></returns>
 public bool DeleteRoleLogic(int roleId)
 {
     return(roleDAL.DeleteRole(roleId, 0));
 }