示例#1
0
        internal bool UpgradeArchitectureToRemote(out Exception ex)
        {
            ex = null;
            int errCount = 0;

            try
            {
                Architecture      a     = this.CurrentArchitecture;
                List <Action>     atcs  = a.Acts;
                List <Department> deps  = a.Deps;
                List <Module>     mods  = a.Mods;
                List <Permission> perms = a.Pers;
                List <Role>       roles = a.Roles;
                List <UserGroup>  ugrps = a.Ugroups;
                List <User>       users = a.Users;
                ActionLogic.GetInstance().UpgradeList(atcs);
                DepartmentLogic.GetInstance().UpgradeList(deps);
                ModuleLogic.GetInstance().UpgradeList(mods);
                PermissionLogic.GetInstance().UpgradeList(perms);
                RoleLogic.GetInstance().UpgradeList(roles);
                UserGroupLogic.GetInstance().UpgradeList(ugrps);
                UserLogic.GetInstance().UpgradeList(users);
            }
            catch (Exception e)
            {
                errCount++;
                ex = e;
            }
            return(errCount == 0);
        }
示例#2
0
        private static Architecture GetRemoteArchitecture()
        {
            Architecture a = Architecture.Empty;

            a.Deps    = DepartmentLogic.GetInstance().GetAllDepartments();
            a.Ugroups = UserGroupLogic.GetInstance().GetAllUserGroups();
            a.Users   = UserLogic.GetInstance().GetAllUsers();
            a.Mods    = ModuleLogic.GetInstance().GetAllModules();
            a.Acts    = ActionLogic.GetInstance().GetAllActions();
            a.Pers    = PermissionLogic.GetInstance().GetAllPermissions();
            a.Roles   = RoleLogic.GetInstance().GetAllRoles();
            return(a);
        }
示例#3
0
        public static List <int> GetUserGroupIds(string ugroups, UserGroupLogic ul = null)
        {
            List <int> ugrps = new List <int>();

            string[] ids = ugroups.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (ul == null)
            {
                ul = UserGroupLogic.GetInstance();
            }
            foreach (string id in ids)
            {
                int I;
                if (int.TryParse(id, out I))
                {
                    ugrps.Add(I);
                }
            }
            return(ugrps);
        }
示例#4
0
 private void button22_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         UserGroup ug = new UserGroup();
         ug.ID     = data[comboBox1.SelectedIndex].ID;
         ug.Name   = textBox1.Text.Trim();
         ug.Remark = textBox2.Text;
         UserGroupLogic ul = UserGroupLogic.GetInstance();
         if (ul.ExistsNameOther(ug.Name, ug.ID))
         {
             if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
             {
                 if (ul.UpdateUserGroup(ug))
                 {
                     data[comboBox1.SelectedIndex].Name   = ug.Name;
                     data[comboBox1.SelectedIndex].Remark = ug.Remark;
                     RefreshInfo();
                     MessageBox.Show("修改成功!");
                 }
             }
             else
             {
                 textBox1.Focus();
                 textBox1.SelectAll();
             }
         }
         else
         {
             if (ul.UpdateUserGroup(ug))
             {
                 data[comboBox1.SelectedIndex].Name   = ug.Name;
                 data[comboBox1.SelectedIndex].Remark = ug.Remark;
                 RefreshInfo();
                 MessageBox.Show("修改成功!");
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要修改的项目!");
     }
 }
示例#5
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         if (MessageBox.Show("确定要删除该项目?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
         {
             UserGroup ug = data[comboBox1.SelectedIndex];
             if (UserGroupLogic.GetInstance().DeleteUserGroup(ug))
             {
                 data.RemoveAt(comboBox1.SelectedIndex);
                 RefreshInfo();
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的项目!");
     }
 }
示例#6
0
        public List <User> GetAllUsers()
        {
            List <User> users = new List <User>();
            string      sql   = "select * from TF_User";
            DataTable   dt    = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                DepartmentLogic dl = DepartmentLogic.GetInstance();
                RoleLogic       rl = RoleLogic.GetInstance();
                UserGroupLogic  ul = UserGroupLogic.GetInstance();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    User user = new User();
                    user.ID          = Convert.ToInt32(dt.Rows[i]["ID"]);
                    user.Username    = dt.Rows[i]["Username"].ToString();
                    user.Departments = Common.GetDepartments(dt.Rows[i]["Depart"].ToString(), dl);
                    user.Flag        = Convert.ToInt32(dt.Rows[i]["Flag"]);
                    if (dt.Rows[i]["Password"] != null && dt.Rows[i]["Password"] != DBNull.Value)
                    {
                        user.Password = dt.Rows[i]["Password"].ToString();
                    }
                    else
                    {
                        user.Password = "";
                    }
                    if (dt.Rows[i]["Roles"] != null && dt.Rows[i]["Roles"] != DBNull.Value)
                    {
                        user.Roles = Common.GetRoles(dt.Rows[i]["Roles"].ToString(), rl);
                    }
                    if (dt.Rows[i]["Usergroup"] != null && dt.Rows[i]["Usergroup"] != DBNull.Value)
                    {
                        user.Usergroups = Common.GetUserGroups(dt.Rows[i]["Usergroup"].ToString(), ul);
                    }
                    if (dt.Rows[i]["Remark"] != null && dt.Rows[i]["Remark"] != DBNull.Value)
                    {
                        user.Remark = dt.Rows[i]["Remark"].ToString();
                    }
                    users.Add(user);
                }
            }
            return(users);
        }
示例#7
0
        private void button11_Click(object sender, EventArgs e)
        {
            UserGroup ug = new UserGroup();

            ug.Name   = textBox1.Text.Trim();
            ug.Remark = textBox2.Text;
            UserGroupLogic ul = UserGroupLogic.GetInstance();

            if (ul.ExistsName(ug.Name))
            {
                if (MessageBox.Show("系统中已经存在该名称,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    int id = ul.AddUserGroup(ug);
                    if (id > 0)
                    {
                        ug.ID = id;
                        data.Add(ug);
                        RefreshInfo();
                        MessageBox.Show("添加成功!");
                    }
                }
                else
                {
                    textBox1.Focus();
                    textBox1.SelectAll();
                }
            }
            else
            {
                int id = ul.AddUserGroup(ug);
                if (id > 0)
                {
                    ug.ID = id;
                    data.Add(ug);
                    RefreshInfo();
                    MessageBox.Show("添加成功!");
                }
            }
        }