Пример #1
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            SIS.DBClass.DBClsSysUserAuthority DbSUA = new SIS.DBClass.DBClsSysUserAuthority();
            DataTable DT = DbSUA.GetSysUserAuthorityDataTable(txtUserId.Text);

            // 取出TreeView的節點集合, PS此法只有一層
            //TreeNodeCollection nodes = treeView_Authority.Nodes;

            if (DT.Rows.Count > 0)
            {
                foreach (DataRow Rows in DT.Rows)
                {
                    FindTreeViewNodes(treeViewAuthority.Nodes, Rows["FuncId"].ToString(), Convert.ToBoolean(Rows["AuthStatus"]));
                }
                MessageBox.Show(this, "帳號[" + txtUserId.Text + "]有找到符合資料!!", "查詢結果");
                tSSL_UserId.Text = txtUserId.Text;
                FindTreeViewNodesText(treeViewUsers.Nodes, tSSL_UserId.Text);
                txtUserId.Text        = "";
                tSBSureChange.Enabled = true;
                groupBox4.Visible     = false;
            }
            else if (DT.Rows.Count == 0)
            {
                MessageBox.Show(this, "未找到任何符合資料!!", "查詢結果");
            }
        }
Пример #2
0
        //點選TreeView項目之後所觸發的事件
        private void treeViewUsers_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag != null)
            {
                tSSL_TreeViewPath.Text = e.Node.FullPath;
                tSSL_UserId.Text       = e.Node.Text;
                if (e.Node.Text != "人員管理子系統")
                {
                    tSBSureChange.Enabled = true;
                    SIS.DBClass.DBClsSysUserAuthority DbSUA = new SIS.DBClass.DBClsSysUserAuthority();
                    DataTable DT = DbSUA.GetSysUserAuthorityDataTable(e.Node.Text);

                    // 取出TreeView的節點集合, PS此法只有一層
                    //TreeNodeCollection nodes = treeView_Authority.Nodes;

                    foreach (DataRow Rows in DT.Rows)
                    {
                        FindTreeViewNodes(treeViewAuthority.Nodes, Rows["FuncId"].ToString(), Convert.ToBoolean(Rows["AuthStatus"]));
                    }
                }
                else
                {
                    tSBSureChange.Enabled = false;
                    tSSL_UserId.Text      = "使用者帳號";
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 權限處理
        /// </summary>
        /// <param name="UserID">使用者帳號</param>
        /// <param name="RoleName">角色名稱</param>
        /// <returns>處理成功回傳true,若失敗回傳false</returns>
        public bool AuthorityProcess(string UserID, string RoleName)
        {
            int i = 0;

            SIS.DBClass.DBClsSysUserAuthority SUA = new SIS.DBClass.DBClsSysUserAuthority();
            DataTable DT = SUA.GetSysUserAuthorityDataTable(UserID);

            foreach (object var in this.MdiParent.Controls)
            {
                //Start..設定MenuStrip權限
                if (var.GetType().ToString() == "System.Windows.Forms.MenuStrip")
                {
                    MenuStrip MS = (MenuStrip)var;

                    foreach (object MenuStripBuf in MS.Items)
                    {
                        ToolStripMenuItem TSMI = (ToolStripMenuItem)MenuStripBuf;

                        //TSMI.Enabled = SUA.VerifyAuthority(UserID, TSMI.Tag.ToString());
                        TSMI.Enabled = SUA.VerifyAuthorityPerformance(UserID, TSMI.Tag.ToString(), DT);

                        for (i = 0; i < TSMI.DropDownItems.Count; i++)
                        {
                            if (TSMI.DropDownItems[i].Tag != null)
                            {
                                //TSMI.DropDownItems[i].Enabled = SUA.VerifyAuthority(UserID, TSMI.DropDownItems[i].Tag.ToString());
                                TSMI.DropDownItems[i].Enabled = SUA.VerifyAuthorityPerformance(UserID, TSMI.DropDownItems[i].Tag.ToString(), DT);
                            }
                        }
                    }
                }
                //End ..設定MenuStrip權限


                //Start..設定ToolStrip權限
                if (var.GetType().ToString() == "System.Windows.Forms.ToolStrip")
                {
                    ToolStrip TS = (ToolStrip)var;

                    for (i = 0; i < TS.Items.Count; i++)
                    {
                        if (TS.Items[i].Tag != null)
                        {
                            //TS.Items[i].Enabled = SUA.VerifyAuthority(UserID, TS.Items[i].Tag.ToString());
                            TS.Items[i].Enabled = SUA.VerifyAuthorityPerformance(UserID, TS.Items[i].Tag.ToString(), DT);
                        }
                    }
                }
                //End..設定ToolStrip權限

                //Start..設定StatusStrip權限
                if (var.GetType().ToString() == "System.Windows.Forms.StatusStrip")
                {
                    StatusStrip SS = (StatusStrip)var;

                    for (i = 0; i < SS.Items.Count; i++)
                    {
                        if (SS.Items[i].Name == "tSSL_UserId")
                        {
                            SS.Items[i].Text      = UserID;
                            SS.Items[i].BackColor = Color.Navy;
                            SS.Items[i].ForeColor = Color.White;
                        }

                        if (SS.Items[i].Name == "tSSL_SysRole")
                        {
                            SS.Items[i].Text      = RoleName;
                            SS.Items[i].BackColor = Color.Crimson;
                            SS.Items[i].ForeColor = Color.White;
                        }
                    }
                }
                //End..設定StatusStrip權限
            }

            return(true);
        }