Пример #1
0
        void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            //根据用户ID获取对应的数据权限
            string        usrId     = selectedUserBtn.UserId;
            List <string> allowData = UserAdmin.GetAllowDataByUser(usrId);

            foreach (BtnDataset cbx in panelDataset.Children)
            {
                string dsName = cbx.DatasetName;
                if ((bool)cbx.isSelected)
                {
                    if (!allowData.Contains(dsName))
                    {
                        UserAdmin.AddUserPrivilege(usrId, dsName);
                    }
                }
                else
                {
                    if (allowData.Contains(dsName))
                    {
                        UserAdmin.DeleteUserPrivilege(usrId, dsName);
                    }
                }
            }

            btnSelectAll.IsEnabled  = false;
            btnSelectNone.IsEnabled = false;
            btnSave.IsEnabled       = false;
            btnCancel.IsEnabled     = false;
            panelDataset.IsEnabled  = false;
            panelUser.IsEnabled     = true;
            btnModify.IsEnabled     = true;
            WindowAdmin.notify.SetStatusMessage(string.Format("成功修改了用户{0}的所对应的数据集权限!", usrId));
        }
Пример #2
0
        void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            btnSelectAll.IsEnabled  = false;
            btnSelectNone.IsEnabled = false;
            btnSave.IsEnabled       = false;
            btnCancel.IsEnabled     = false;
            panelDataset.IsEnabled  = false;
            panelUser.IsEnabled     = true;
            btnModify.IsEnabled     = true;

            //根据用户ID获取对应的数据权限
            List <string> allowData = UserAdmin.GetAllowDataByUser(selectedUserBtn.UserId);

            foreach (BtnDataset cbx in panelDataset.Children)
            {
                cbx.isSelected = (allowData.Contains(cbx.DatasetName));
            }
        }
Пример #3
0
        //选中某个用户时,可以修改该用户对应的数据集权限
        private void btnUser_Click(object sender, RoutedEventArgs e)
        {
            BtnUserInfo btnUser = sender as BtnUserInfo;

            if (selectedUserBtn != null)
            {
                selectedUserBtn.isSelected = false;
            }
            selectedUserBtn     = btnUser;
            btnUser.isSelected  = true;
            btnModify.IsEnabled = true;

            //根据用户ID获取对应的数据权限
            List <string> allowData = UserAdmin.GetAllowDataByUser(btnUser.UserId);

            foreach (BtnDataset cbx in panelDataset.Children)
            {
                cbx.isSelected = (allowData.Contains(cbx.DatasetName));
            }
        }
Пример #4
0
        public void RefreshDB(IMyTreeDB treeDB, string userId)
        {
            mainPanel.Children.Clear();
            List <DatasetInfo> dbList = treeDB.GetDatasets();

            if (userId != "")            //如果用户权限启用,则进行用户数据集权限筛选
            {
                List <DatasetInfo> allowDbList = new List <DatasetInfo>();
                List <string>      allowDbName = UserAdmin.GetAllowDataByUser(userId);
                foreach (DatasetInfo db in dbList)
                {
                    if (allowDbName.Contains(db.Name))
                    {
                        allowDbList.Add(db);
                    }
                }
                dbList = allowDbList;
            }
            if (dbList.Count > 0)
            {
                foreach (DatasetInfo db in dbList)
                {
                    DatasetBtn btn = new DatasetBtn(db);
                    btn.MouseDown += Btn_Click;
                    btn.Background = Brushes.Azure;
                    mainPanel.Children.Add(btn);
                }
            }
            else
            {
                Button btn = new Button();
                btn.Content    = "没有发现可用的数据!";
                btn.Height     = 50;
                btn.Width      = 200;
                btn.Background = Brushes.Red;
                mainPanel.Children.Add(btn);
            }
        }