コード例 #1
0
        /// <summary>
        /// 选中项发生更改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _RecordListView_SelectionChanged(object sender, EventArgs e)
        {
            if (this._RecordListView.SelectedObjects != null && this._RecordListView.SelectedObjects.Count > 0)
            {
                _SelUser = (KPS.Model.UserInfo) this._RecordListView.SelectedObjects[0];

                KPS.BLL.PermissionManager Pmanager = new BLL.PermissionManager();
                UserListPerms = Pmanager.GetModelList(string.Format("userName='******'", _SelUser.userName));

                ShowUserAuthMenu(UserListPerms, _SelUser);//显示用户权限菜单
            }
        }
コード例 #2
0
        /// <summary>
        /// 菜单初始化显示
        /// </summary>
        private void MenuInitShow()
        {
            LoginUserInfo _user = LoginManager.Instance.GetThisUserLoginInfo();//当前登录用户

            //if (!_user.IsAdministrator)
            //{
            #region 菜单禁用
            foreach (ToolStripItem _item in HeadInsertDataMenu.DropDownItems)
            {
                _item.Enabled = false;
            }
            foreach (ToolStripItem _item in HeadDataQueryMenu.DropDownItems)
            {
                _item.Enabled = false;
            }
            foreach (ToolStripItem _item in HeadTolMenu.DropDownItems)
            {
                _item.Enabled = false;
            }
            foreach (ToolStripItem _item in TolMenuData.DropDownItems)
            {
                _item.Enabled = false;
            }

            btnBuyInsert.Enabled           = false;
            btnBuyQuery.Enabled            = false;
            btnSellInsert.Enabled          = false;
            btnSellQuery.Enabled           = false;
            btnInventoryQuery.Enabled      = false;
            btnInventoryQueryTotal.Enabled = false;

            #endregion
            KPS.BLL.PermissionManager       Pmanager = new BLL.PermissionManager();
            List <KPS.Model.PermissionInfo> Authlist = Pmanager.GetModelList(string.Format("userName='******'", _user.LoginName));
            if (Authlist != null && Authlist.Count > 0)
            {
                foreach (KPS.Model.PermissionInfo _pinfo in Authlist)
                {
                    MenuEnableTrue(_pinfo);
                }
            }
            //}
        }
コード例 #3
0
        /// <summary>
        /// 保存权限
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (_SelUser != null)
            {
                //if (_SelUser.userName == "admin")
                //{
                //    MessageBox.Show("管理员权限不可设置!");
                //}
                //else
                //{
                List <Model.PermissionInfo> list = GetSelectNodesAuth();

                //1.删除原用户权限
                string strPIDList = "";
                if (UserListPerms != null && UserListPerms.Count > 0)
                {
                    foreach (KPS.Model.PermissionInfo _pinfo in UserListPerms)
                    {
                        strPIDList = strPIDList + _pinfo.permissionID + ",";
                    }
                    strPIDList = strPIDList.Substring(0, strPIDList.Length - 1);
                }
                KPS.BLL.PermissionManager pmanager = new BLL.PermissionManager();
                bool _bolstate = true;
                try
                {
                    if (strPIDList != "")
                    {
                        _bolstate = pmanager.DeleteList(strPIDList);
                    }

                    //2.重新添加用户权限
                    if (_bolstate)
                    {
                        foreach (KPS.Model.PermissionInfo _pinfo in list)
                        {
                            if (!pmanager.Add(_pinfo))
                            {
                                _bolstate = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                if (_bolstate)
                {
                    MessageBox.Show("保存成功!");
                }
                else
                {
                    MessageBox.Show("保存失败!");
                }

                //}
            }
            else
            {
                MessageBox.Show("您未选择任何用户!");
            }
        }
コード例 #4
0
        /// <summary>
        ///删除用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemDel_Click(object sender, EventArgs e)
        {
            UserInfo _ItemInfo = null;
            if (this._RecordListView.SelectedObjects != null && this._RecordListView.SelectedObjects.Count > 0)
            {
                _ItemInfo = (UserInfo)this._RecordListView.SelectedObjects[0];
            }
            else
            {
                MessageBox.Show("请选中项后再试!");
            }
            //if (_ItemInfo.userName == "admin")
            //{
            //    MessageBox.Show("管理员不可删除!");
            //    return;
            //}
            ConfirmFrm confirm = new ConfirmFrm("提示", string.Format("您确定需要删除用户 {0}?",_ItemInfo.userName), "确定", "取消", 3);
            if (confirm.ShowDialog() == DialogResult.OK)
            {
                PermissionManager manager = new PermissionManager();
                bool bolsucced = manager.DeleteItemByUserName(_ItemInfo.userName);

                //1.调用bll,从模块对应的权限列表中移除
                UserInfoManager usermanager = new UserInfoManager();
                bolsucced=usermanager.Delete(_ItemInfo.ID);
                if (bolsucced)
                {
                    RecordList.Remove(_ItemInfo);
                    //从用户权限列表中移除

                    //2.从列表中移除
                    this._RecordListView.RemoveObject(_ItemInfo);//将原生从列表中移除
                }
                else
                {
                    MessageBox.Show("操作失败!");
                }

            }
        }
コード例 #5
0
ファイル: MainFrm.cs プロジェクト: qq5013/StockControl_KPS
        /// <summary>
        /// 菜单初始化显示
        /// </summary>
        private void MenuInitShow()
        {
            LoginUserInfo _user = LoginManager.Instance.GetThisUserLoginInfo();//当前登录用户
            //if (!_user.IsAdministrator)
            //{
                #region 菜单禁用
                foreach (ToolStripItem _item in HeadInsertDataMenu.DropDownItems)
                {
                    _item.Enabled = false;
                }
                foreach (ToolStripItem _item in HeadDataQueryMenu.DropDownItems)
                {
                    _item.Enabled = false;
                }
                foreach (ToolStripItem _item in HeadTolMenu.DropDownItems)
                {
                    _item.Enabled = false;
                }
                foreach (ToolStripItem _item in TolMenuData.DropDownItems)
                {
                    _item.Enabled = false;
                }

                btnBuyInsert.Enabled = false;
                btnBuyQuery.Enabled = false;
                btnSellInsert.Enabled = false;
                btnSellQuery.Enabled = false;
                btnInventoryQuery.Enabled = false;
                btnInventoryQueryTotal.Enabled = false;

                #endregion
                KPS.BLL.PermissionManager Pmanager = new BLL.PermissionManager();
                List<KPS.Model.PermissionInfo> Authlist = Pmanager.GetModelList(string.Format("userName='******'", _user.LoginName));
                if (Authlist != null && Authlist.Count > 0)
                {
                    foreach (KPS.Model.PermissionInfo _pinfo in Authlist)
                    {
                        MenuEnableTrue(_pinfo);
                    }
                }
            //}
        }
コード例 #6
0
        /// <summary>
        /// 保存权限
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (_SelUser != null)
            {
                //if (_SelUser.userName == "admin")
                //{
                //    MessageBox.Show("管理员权限不可设置!");
                //}
                //else
                //{
                    List<Model.PermissionInfo> list = GetSelectNodesAuth();

                    //1.删除原用户权限
                    string strPIDList="";
                    if(UserListPerms!=null && UserListPerms.Count>0)
                    {
                        foreach(KPS.Model.PermissionInfo _pinfo in UserListPerms)
                        {
                            strPIDList=strPIDList+_pinfo.permissionID+",";
                        }
                        strPIDList=strPIDList.Substring(0,strPIDList.Length-1);
                    }
                    KPS.BLL.PermissionManager pmanager = new BLL.PermissionManager();
                    bool _bolstate = true;
                    try
                    {
                        if (strPIDList != "")
                        {
                            _bolstate = pmanager.DeleteList(strPIDList);
                        }

                        //2.重新添加用户权限
                        if (_bolstate)
                        {
                            foreach (KPS.Model.PermissionInfo _pinfo in list)
                            {
                                if (!pmanager.Add(_pinfo))
                                {
                                    _bolstate = false;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    if (_bolstate)
                    {
                        MessageBox.Show("保存成功!");
                    }
                    else
                    {
                        MessageBox.Show("保存失败!");
                    }

                //}
            }
            else
            {
                MessageBox.Show("您未选择任何用户!");
            }
        }
コード例 #7
0
        /// <summary>
        /// 选中项发生更改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _RecordListView_SelectionChanged(object sender, EventArgs e)
        {
            if (this._RecordListView.SelectedObjects != null && this._RecordListView.SelectedObjects.Count > 0)
            {
                _SelUser = (KPS.Model.UserInfo)this._RecordListView.SelectedObjects[0];

                KPS.BLL.PermissionManager Pmanager = new BLL.PermissionManager();
                UserListPerms = Pmanager.GetModelList(string.Format("userName='******'", _SelUser.userName));

                ShowUserAuthMenu(UserListPerms, _SelUser);//显示用户权限菜单
            }
        }