예제 #1
0
 public static bool UpdateRoleModule(Role_Module role)
 {
     using (var cn = Database.GetDbConnection())
     {
         return(cn.Update <Role_Module>(role));
     }
 }
예제 #2
0
 public void Update(Role_Module model)
 {
     Execute(SqlUpdateCommand, model);
 }
예제 #3
0
 public void Insert(Role_Module model)
 {
     Execute(SqlInsertCommand, model);
 }
예제 #4
0
        private void InitDB()
        {
            #region 初始化部门
            Department depart = Department.GetOne("根组织");
            if (depart == null)
            {
                Department.Add(new Department
                {
                    Name     = "根组织",
                    ParentID = null,
                    Remark   = "不可删除",
                    SortID   = 0
                });
                depart = Department.GetOne("根组织");
            }
            #endregion
            #region 初始化管理员
            UserInfo user = UserInfo.GetOne("admin");
            if (user == null)
            {
                UserInfo.Add(new UserInfo
                {
                    Name             = "admin",
                    RoleID           = 1,
                    DepartmentID     = depart.ID,
                    Password         = CabinetUtility.Encryption.AESAlgorithm.Encrypto("admin"),
                    RealName         = "管理员",
                    CreateTime       = DateTime.Now,
                    Status           = 1,
                    LastPasswordTime = DateTime.Now
                });
            }
            #endregion

            #region 初始化权限
            if (Role_Module.Get(1).Count == 0)
            {
                List <Role_Module> roleList = new List <Role_Module>();
                for (int i = 1; i < 5; i++)
                {
                    for (int j = 0; j < 12; j++)
                    {
                        Role_Module role = new CabinetData.Entities.Role_Module();
                        role.RoleID       = i;
                        role.ModuleID     = j;
                        role.ModuleName   = Enum.GetName(typeof(ModuleEnum), j);
                        role.EnableAdd    = true;
                        role.EnableDelete = true;
                        role.EnableEdit   = true;
                        role.EnableView   = true;
                        roleList.Add(role);
                    }
                }
                Role_Module.Insert(roleList);
            }

            #endregion

            #region 新增字段
            UserInfo.AddColumn();
            #endregion
        }