Пример #1
0
        protected void GenMenu()
        {
            cefUser   objEfUser = new cefUser();
            DataTable dtList    = new DataTable();
            DataTable dt        = new DataTable();

            DataRow[] drMenu;
            DataRow[] drMenu_sub;
            try
            {
                string strCriteria = string.Empty;
                strCriteria  = " And MenuParent = 0 ";
                strCriteria += " And UserGroupCode= '" + Session["UserGroupCode"] + "'";
                strCriteria += " And CanView= 'Y' ";
                strCriteria += " Order by MenuOrder ";
                dtList       = objEfUser.SP_USER_GROUP_MENU_SEL(strCriteria);

                strCriteria  = " And UserGroupCode='" + Session["UserGroupCode"] + "' ";
                strCriteria += " And CanView= 'Y' ";
                strCriteria += " Order by MenuOrder ";
                dt           = objEfUser.SP_USER_GROUP_MENU_SEL(strCriteria);

                ASPxMenu1.Items.Clear();
                for (int i = 0; i < dtList.Rows.Count; i++)
                {
                    var menuItem = new DevExpress.Web.ASPxMenu.MenuItem();
                    menuItem.Text        = dtList.Rows[i]["MenuName"].ToString();
                    menuItem.NavigateUrl = dtList.Rows[i]["MenuNavigationUrl"].ToString();
                    menuItem.Image.Url   = Helper.CStr(dtList.Rows[i]["MenuImageUrl"].ToString());
                    drMenu = dt.Select("MenuParent=" + dtList.Rows[i]["MenuID"].ToString());
                    for (int j = 0; j < drMenu.Length; j++)
                    {
                        var menuItem_sub = new DevExpress.Web.ASPxMenu.MenuItem();
                        menuItem_sub.Text        = drMenu[j]["MenuName"].ToString();
                        menuItem_sub.NavigateUrl = drMenu[j]["MenuNavigationUrl"].ToString();
                        menuItem_sub.Image.Url   = drMenu[j]["MenuImageUrl"].ToString();
                        drMenu_sub = dt.Select("MenuParent=" + drMenu[j]["MenuID"].ToString());
                        for (int k = 0; k < drMenu_sub.Length; k++)
                        {
                            var menuItem_sub2 = new DevExpress.Web.ASPxMenu.MenuItem();
                            menuItem_sub2.Text        = drMenu_sub[k]["MenuName"].ToString();
                            menuItem_sub2.NavigateUrl = drMenu_sub[k]["MenuNavigationUrl"].ToString();
                            menuItem_sub2.Image.Url   = drMenu_sub[k]["MenuImageUrl"].ToString();
                            menuItem_sub.Items.Add(menuItem_sub2);
                        }
                        menuItem.Items.Add(menuItem_sub);
                    }
                    ASPxMenu1.Items.Add(menuItem);
                }
            }
            catch (Exception ex)
            {
                MsgBox(ex.Message);
            }
            finally
            {
                dtList.Dispose();
                objEfUser.Dispose();
            }
        }
Пример #2
0
        private void CheckPermissionButton()
        {
            cefUser objEfUser = new cefUser();

            _strMessage  = string.Empty;
            _strCriteria = " and UserGroupCode = '" + base.UserGroupCode + "' " +
                           " and [MenuNavigationUrl] in ('~/App_Control/open/open_list.aspx' , '~/App_Control/loan/loan_list.aspx' , '~/App_Control/open/open_approve_list.aspx') and CanView = 'Y' ";
            DataTable dtTemp = objEfUser.SP_USER_GROUP_MENU_SEL(_strCriteria);

            pnlApprove.Visible = false;
            pnlLoan.Visible    = false;
            pnlOpen.Visible    = false;
            foreach (DataRow dr in dtTemp.Rows)
            {
                if (dr["MenuNavigationUrl"].ToString() == "~/App_Control/open/open_list.aspx")
                {
                    pnlOpen.Visible = true;
                }
                else if (dr["MenuNavigationUrl"].ToString() == "~/App_Control/loan/loan_list.aspx")
                {
                    pnlLoan.Visible = true;
                }
                else if (dr["MenuNavigationUrl"].ToString() == "~/App_Control/open/open_approve_list.aspx")
                {
                    pnlApprove.Visible = true;
                }
            }
        }
Пример #3
0
        public void InitUserAccessRight(string pUserGroupCode)
        {
            cefUser   objEfUserMenu = new cefUser();
            DataTable table         = new DataTable();

            try
            {
                string currentUrl = this.PermissionURL == "" ? this.GetCurrentUrl() : this.PermissionURL;
                currentUrl = Server.UrlDecode(currentUrl);
                string strCriteria = string.Empty;
                strCriteria = " And  MenuNavigationUrl='" + currentUrl + "' and UserGroupCode = '" + pUserGroupCode + "' ";
                table       = objEfUserMenu.SP_USER_GROUP_MENU_SEL(strCriteria);

                if (table.Rows.Count > 0)
                {
                    IsUserView    = false;
                    IsUserNew     = false;
                    IsUserEdit    = false;
                    IsUserDelete  = false;
                    IsUserApprove = false;
                    IsUserExtra   = false;
                    DataRow rowArray = table.Rows[0];
                    string  str6     = rowArray["CanView"].ToString();
                    string  str5     = rowArray["CanInsert"].ToString();
                    string  str3     = rowArray["CanEdit"].ToString();
                    string  str2     = rowArray["CanDelete"].ToString();
                    string  str      = rowArray["CanApprove"].ToString();
                    string  str4     = rowArray["CanExtra"].ToString();
                    if (str6 == "N")
                    {
                        Session["error_message"] = "คุณไม่มีสิทธิ์ในการใช้งานเมนู : " + rowArray["MenuName"].ToString();
                    }
                    if (str6 == "Y")
                    {
                        IsUserView = true;
                    }
                    if (str5 == "Y")
                    {
                        IsUserNew = true;
                    }
                    if (str3 == "Y")
                    {
                        IsUserEdit = true;
                    }
                    if (str2 == "Y")
                    {
                        IsUserDelete = true;
                    }
                    if (str == "Y")
                    {
                        IsUserApprove = true;
                    }
                    if (str4 == "Y")
                    {
                        IsUserExtra = true;
                    }
                    PageTitle = rowArray["MenuName"] + " (" + ProgramVersion + ")";
                    PageDes   = rowArray["MenuName"].ToString();
                }
            }
            catch (Exception ex)
            {
                table.Dispose();
            }
        }