Hashtable 的用法

   /// <summary>
    /// 获取按钮权限
    /// </summary>
    /// <param name="pageCode"></param>
    /// <param name="buttonList"></param>
    /// <returns></returns>
    public Hashtable GetPageButton(string pageCode, List<string> buttonList)
    {
        Hashtable ht = new Hashtable();
        if (!ISRG)
            ht = ManagementJurProxy.GetPageButton(ts.CurrentUser.User_ID, pageCode, buttonList);
        else
        {
            foreach (string but in buttonList)
            {
                ht.Add(but, true);
            }
        }
        return ht;
    }


//Hashtable 的用法
  Hashtable ht = new Hashtable();
        List<string> list = new List<string>();
        list.Add("Open_Object_btnCraetProj");
        list.Add("Open_Object_lbtnUpdata");
        list.Add("Open_Object_lbtnDelete");
        list.Add("Open_Object_lbtnToExcel");
        list.Add("Open_Object_ModelManage");

        ht = base.GetPageButton("Open_Object", list);
       this.btnCraetProj.Visible = bool.Parse(ht["Open_Object_btnCraetProj"].ToString());
       this.btnManage.Visible = bool.Parse(ht["Open_Object_ModelManage"].ToString());

 

 

 

  #region 获取按钮权限
        /// <summary>
        /// 获取按钮权限
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="pageCode"></param>
        /// <param name="buttonCode"></param>
        /// <returns></returns>
        public static Hashtable GetPageButton(Guid userID, string pageCode, List<string> buttonCode)
        {
            List<bool> list = new List<bool>();
            Hashtable ht = new Hashtable();
            List<string> code = new List<string>();
            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.Database.BnspData);
                using (DbCommand command = db.GetSqlStringCommand(SQL_GetPageButton))
                {
                    db.AddInParameter(command, "userID", DbType.Guid, userID);
                    db.AddInParameter(command, "pageCode", DbType.String, pageCode);
                    using (IDataReader dr = db.ExecuteReader(command))
                    {
                        while (dr.Read())
                        {
                            code.Add(dr["function_code"].ToString());
                        }
                    }

                    foreach (string i in buttonCode)
                    {
                        if (code.Contains(i))
                            ht.Add(i, true);
                        else
                            ht.Add(i, false);
                    }
                    return ht;
                }
            }
            catch
            {
                throw;
            }
        }
        #endregion

转载于:https://www.cnblogs.com/yingpp/archive/2008/11/27/1342066.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值