Example #1
0
        private void GetList_PermissionByUser(string strUser)
        {
            if (dtNotUse != null)
            {
                dtNotUse.Clear();
            }
            if (dtIsUse != null)
            {
                dtIsUse.Clear();
            }

            Class.S_TaiKhoan tk = new Class.S_TaiKhoan();
            tk.UserName           = strUser;
            dtNotUse              = tk.GetPermissionNotUseByUser();
            dtIsUse               = tk.GetPermissionByUser();
            gridIsUse.DataSource  = dtIsUse;
            gridNotUse.DataSource = dtNotUse;
            gridNotUseDetail.ExpandAllGroups();
            bandedgridNotUse.ExpandAllGroups();
            bandedgirdIsUse.ExpandAllGroups();
            bandedgridNotUse.BestFitColumns();
            bandedgirdIsUse.BestFitColumns();
        }
Example #2
0
        //private void btnNguoiDung_ItemClick(object sender, ItemClickEventArgs e)
        //{
        //    frmNguoiDung frm = new frmNguoiDung();
        //    frm.ShowDialog();
        //}

        //    #region Xu_Ly_Phan_quyen
        public void Permission_Show_Menu(string strUser)
        {
            Class.S_TaiKhoan tk = new Class.S_TaiKhoan();
            tk.UserName = strUser;
            DataTable _dtPermission = tk.GetPermissionByUser();

            try
            {
                //   Permission_Hide_Menu();
                for (int k = 0; k < ribbon.Pages.Count; k++)
                {
                    if (ribbon.Pages[k].Tag != null)
                    {
                        string page_tag = ribbon.Pages[k].Tag.ToString();
                        for (int m = 0; m < ribbon.Pages[k].Groups.Count; m++)
                        {
                            if (ribbon.Pages[k].Groups[m].Tag != null)
                            {
                                string group_tag = ribbon.Pages[k].Groups[m].Tag.ToString();
                                for (int l = 0; l < ribbon.Pages[k].Groups[m].ItemLinks.Count; l++)
                                {
                                    if (ribbon.Pages[k].Groups[m].ItemLinks[l].Item.Tag != null)
                                    {
                                        string item_tag = ribbon.Pages[k].Groups[m].ItemLinks[l].Item.Tag.ToString();
                                        for (int i = 0; i < _dtPermission.Rows.Count; i++)
                                        {
                                            string item_code = _dtPermission.Rows[i]["Object_ID"].ToString();
                                            if (item_code.CompareTo(item_tag) == 0)
                                            {
                                                ribbon.Pages[k].Groups[m].ItemLinks[l].Visible = true;
                                                int index_group = item_code.LastIndexOf("_");
                                                if (index_group > -1)
                                                {
                                                    string group_code = item_code.Substring(0, index_group);
                                                    if (group_code.CompareTo(group_tag) == 0)
                                                    {
                                                        ribbon.Pages[k].Groups[m].Visible = true;
                                                        int index_page = group_code.LastIndexOf("_");
                                                        if (index_page > -1)
                                                        {
                                                            string page_code = group_code.Substring(0, index_page);
                                                            if (page_code.CompareTo(page_tag) == 0)
                                                            {
                                                                ribbon.Pages[k].Visible = true;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //
            }
            catch (Exception ex)
            {
                string err = ex.ToString();
                throw;
            }
            Class.App.dtPermision = _dtPermission;


            //if (File.Exists(template_grid))
            //{
            //    ribbon.RestoreLayoutFromXml(template_grid);
            //}
        }