Ejemplo n.º 1
0
        private void treeRoles_AfterSelect(object sender, TreeViewEventArgs e)
        {
            DDRole   role = new DDRole("RoleName", treeRoles.SelectedNode.Text.Trim());
            TreeNode tempTreeNode;

            for (int i = 0; i < treeModules.Nodes[0].Nodes.Count; i++)
            {
                tempTreeNode = treeModules.Nodes[0].Nodes[i];
                for (int j = 0; j < tempTreeNode.Nodes.Count; j++)
                {
                    DDModule module = new DDModule("ModuleName", tempTreeNode.Nodes[j].Text.Trim());
                    Query    query  = new Query(DDPermission.Schema);
                    query.AddWhere("RoleID", role.RoleID);
                    query.AddWhere("ModuleID", module.ModuleID);
                    DataTable dt = query.ExecuteDataSet().Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        tempTreeNode.Nodes[j].Checked = true;
                    }
                    else
                    {
                        tempTreeNode.Nodes[j].Checked = false;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int AmountLimit = 0;

            try
            {
                AmountLimit = Convert.ToInt32(tbxAmountLimit.Text);
                if (this.tbxRoleName.Text.Trim().Length > 0)
                {
                    DDRole role = new DDRole();
                    role.RoleName    = this.tbxRoleName.Text.Trim();
                    role.AmountLimit = AmountLimit;
                    role.Save();
                    InitRoles();
                }
                else
                {
                    MessageBox.Show("角色名不能为空!", "提示信息");
                }
            }
            catch
            {
                MessageBox.Show("请输入正确的金额!", "提示信息");
            }
        }
Ejemplo n.º 3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                DDRole role = new DDRole("RoleName", treeRoles.SelectedNode.Text.Trim());

                Query queryDel = new Query(DDPermission.Schema);
                queryDel.AddWhere("RoleID", role.RoleID);
                queryDel.QueryType = QueryType.Delete;
                queryDel.Execute();

                TreeNode tempTreeNode;
                for (int i = 0; i < treeModules.Nodes[0].Nodes.Count; i++)
                {
                    tempTreeNode = treeModules.Nodes[0].Nodes[i];
                    for (int j = 0; j < tempTreeNode.Nodes.Count; j++)
                    {
                        if (tempTreeNode.Nodes[j].Checked == true)
                        {
                            DDModule     module     = new DDModule("ModuleName", tempTreeNode.Nodes[j].Text.Trim());
                            DDPermission permission = new DDPermission();
                            permission.RoleID   = role.RoleID;
                            permission.ModuleID = module.ModuleID;
                            permission.Save();
                        }
                    }
                }
                MessageBox.Show("更新成功!", "提示信息");
            }
            catch
            {
                MessageBox.Show("更新失败,请检查数据库是否连接正确!", "提示信息");
            }
        }
Ejemplo n.º 4
0
        public void Insert(string RoleName)
        {
            DDRole item = new DDRole();

            item.RoleName = RoleName;


            item.Save(UserName);
        }
Ejemplo n.º 5
0
        public void Update(int RoleID, string RoleName)
        {
            DDRole item = new DDRole();

            item.MarkOld();
            item.IsLoaded = true;

            item.RoleID = RoleID;

            item.RoleName = RoleName;

            item.Save(UserName);
        }
Ejemplo n.º 6
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (this.tbxRoleName.Text.Trim().Length > 0)
     {
         DDRole role = new DDRole();
         role.RoleName = this.tbxRoleName.Text.Trim();
         role.Save();
         InitRoles();
     }
     else
     {
         MessageBox.Show("角色名不能为空!", "提示信息");
     }
 }
Ejemplo n.º 7
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (treeRoles.SelectedNode != null)
            {
                this.RoleNameRecord = treeRoles.SelectedNode.Text.Trim();
            }
            try
            {
                int    AmountLimit = Convert.ToInt32(tbxAmountLimit.Text);
                DDRole role        = new DDRole("RoleName", RoleNameRecord);
                role.AmountLimit = AmountLimit;
                role.RoleName    = tbxRoleName.Text;
                role.Save();

                Query queryDel = new Query(DDPermission.Schema);
                queryDel.AddWhere("RoleID", role.RoleID);
                queryDel.QueryType = QueryType.Delete;
                queryDel.Execute();

                TreeNode tempTreeNode;
                for (int i = 0; i < treeModules.Nodes[0].Nodes.Count; i++)
                {
                    tempTreeNode = treeModules.Nodes[0].Nodes[i];
                    for (int j = 0; j < tempTreeNode.Nodes.Count; j++)
                    {
                        if (tempTreeNode.Nodes[j].Checked == true)
                        {
                            DDModule     module     = new DDModule("ModuleName", tempTreeNode.Nodes[j].Text.Trim());
                            DDPermission permission = new DDPermission();
                            permission.RoleID   = role.RoleID;
                            permission.ModuleID = module.ModuleID;
                            permission.Save();
                        }
                    }
                }
                MessageBox.Show("更新成功!", "提示信息");
            }
            catch
            {
                MessageBox.Show("更新失败,请检查资金限额和数据库连接!", "提示信息");
            }
            InitRoles();
        }
Ejemplo n.º 8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DDRole role            = new DDRole("RoleName", treeRoles.SelectedNode.Text);
                Query  queryPermission = new Query(DDPermission.Schema);
                queryPermission.AddWhere("RoleID", role.RoleID);
                queryPermission.QueryType = QueryType.Delete;
                queryPermission.Execute();

                Query queryRole = new Query(DDRole.Schema);
                queryRole.AddWhere("RoleName", treeRoles.SelectedNode.Text);
                queryRole.QueryType = QueryType.Delete;
                queryRole.Execute();

                InitRoles();
            }
            catch
            {
                MessageBox.Show("请选择需要删除的角色!", "提示信息");
            }
        }
Ejemplo n.º 9
0
 public bool Destroy(object RoleID)
 {
     return(DDRole.Destroy(RoleID) == 1);
 }
Ejemplo n.º 10
0
 public bool Delete(object RoleID)
 {
     return(DDRole.Delete(RoleID) == 1);
 }