Пример #1
0
    /// <summary>
    /// 抓取功能號權限
    /// </summary>
    /// <param name="FunctionID">功能號代碼</param>
    /// <returns>回傳功能號權限資料</returns>
    private DataTable GetFuncCRUD(string FunctionID)
    {
        DataTable ReturnDt = new DataTable();
        DataColumn Dc = new DataColumn("CanCreate");
        ReturnDt.Columns.Add(Dc);
        DataColumn Dc1 = new DataColumn("CanRead");
        ReturnDt.Columns.Add(Dc1);
        DataColumn Dc2 = new DataColumn("CanUpdate");
        ReturnDt.Columns.Add(Dc2);
        DataColumn Dc3 = new DataColumn("CanDelete");
        ReturnDt.Columns.Add(Dc3);



        //如果是管理員
        if (Session["UID"].ToString() == "admin")
        {
            DataRow Dr = ReturnDt.NewRow();

            Dr["CanCreate"] = true;
            Dr["CanRead"] = true;
            Dr["CanUpdate"] = true;
            Dr["CanDelete"] = true;

            ReturnDt.Rows.Add(Dr);
        }
        else
        {
            SYSModel.MaintainUserprogauthrel PermissionProcess = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

            #region 輸入變數

            ParameterList.Clear();
            //使用者
            ParameterList.Add(Session["UID"].ToString());
            //功能代碼
            ParameterList.Add(FunctionID);

            #endregion

            DataTable Dt = PermissionProcess.QueryPermissionByUser(ParameterList);

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("找不到" + FunctionID + "的權限!");
            }
            else
            {
                DataRow Dr = ReturnDt.NewRow();

                Dr["CanCreate"] = (Dt.Rows[0]["CanCreate"].ToString() == "1") ? true : false;
                Dr["CanRead"] = (Dt.Rows[0]["CanRead"].ToString() == "1") ? true : false;
                Dr["CanUpdate"] = (Dt.Rows[0]["CanUpdate"].ToString() == "1") ? true : false;
                Dr["CanDelete"] = (Dt.Rows[0]["CanDelete"].ToString() == "1") ? true : false;

                ReturnDt.Rows.Add(Dr);

            }

        }

        return ReturnDt;
    }        
Пример #2
0
        /// <summary>
        /// 設定網頁功能權限
        /// </summary>
        private void SetPageCRUD()
        {
            string URLStr = Request.ServerVariables["URL"].ToString();
            string[] WebPageName = URLStr.Split('/');
            string WebPage = WebPageName[WebPageName.Length - 1];

            SYSModel.MaintainUserprogauthrel PermissionProcess = new SYSModel.MaintainUserprogauthrel(ConnectionDB);


            if (Request.QueryString["Code"] != null)
            {                
                #region 輸入變數

                ParameterList.Clear();
                //使用者
                ParameterList.Add(Session["UID"].ToString());
                //功能代碼
                if (Request.QueryString["Code"].ToString().Length < 5)
                {
                    ParameterList.Add(Request.QueryString["Code"].ToString());
                }
                else
                {
                    ParameterList.Add(Request.QueryString["Code"].ToString().Substring(0, 5));
                }

                #endregion                
            }
            else
            {
                #region 輸入變數

                ParameterList.Clear();
                //使用者
                ParameterList.Add(Session["UID"].ToString());
                //功能代碼
                ParameterList.Add(WebPage.ToString().Substring(0, 5));

                #endregion                                
            }

            if (isnumeric(WebPage.Substring(3,1))) //如果是程式頁(第4碼為數字)
            {                
                //如果是管理員
                if (Session["UID"].ToString() == __AdminUser)
                {
                    _CanCreate = true;
                    _CanRead = true;
                    _CanUpdate = true;
                    _CanDelete = true;
                }
                else
                {
                    DataTable Dt = PermissionProcess.QueryPermissionByUser(ParameterList);

                    if (Dt.Rows.Count > 0)
                    {
                        _CanCreate = (Dt.Rows[0]["CanCreate"].ToString() == "1") ? true : false;
                        _CanRead = (Dt.Rows[0]["CanRead"].ToString() == "1") ? true : false;
                        _CanUpdate = (Dt.Rows[0]["CanUpdate"].ToString() == "1") ? true : false;
                        _CanDelete = (Dt.Rows[0]["CanDelete"].ToString() == "1") ? true : false;
                    }
                }
            }

        }
Пример #3
0
    /// <summary>
  /// 處理權限
  /// </summary>
    private void ProcessAuthority()
    {
      try
      {
          bool PageCanCreate = false;
          bool PageCanRead = false;
          bool PageCanUpdate = false;
          bool PageCanDelete = false;

          if (_PageProgramCode != null) //有給PageProgramCode 使用Page
          {
              SYSModel.MaintainUserprogauthrel PermissionProcess = new SYSModel.MaintainUserprogauthrel(ConnectionDB);

              #region 輸入參數

              ParameterList.Clear();
              //使用者
              ParameterList.Add(Session["UID"].ToString());
              //功能代碼
              ParameterList.Add(_PageProgramCode);              

              #endregion

              DataTable Dt = PermissionProcess.QueryPermissionByUser(ParameterList);

              if (Dt.Rows.Count > 0)
              {
                  PageCanCreate = (Dt.Rows[0]["CanCreate"].ToString() == "1") ? true : false;
                  PageCanRead = (Dt.Rows[0]["CanRead"].ToString() == "1") ? true : false;
                  PageCanUpdate = (Dt.Rows[0]["CanUpdate"].ToString() == "1") ? true : false;
                  PageCanDelete = (Dt.Rows[0]["CanDelete"].ToString() == "1") ? true : false;
              }
          }
          else
          {
              PageCanCreate = ((WUI.BaseSecurePage)Page).CanCreate;
              PageCanRead = ((WUI.BaseSecurePage)Page).CanRead;
              PageCanUpdate = ((WUI.BaseSecurePage)Page).CanUpdate;
              PageCanDelete = ((WUI.BaseSecurePage)Page).CanDelete;
          }

          //管理員
          if (Session["UID"].ToString() == "admin")
          {
              PageCanCreate = true;
              PageCanRead = true;
              PageCanUpdate = true;
              PageCanDelete = true;
          }

          #region 無新增權限

          if (!PageCanCreate)
          {
              BtnNewEnable = false;
              BtnCopyEnable = false;              
          }

          #endregion

          #region 無讀取權限

          if (!PageCanRead)
          {
              BtnFindEnable = false;
              BtnFindExportEnable = false;

              BtnRecFirstEnable = false;
              BtnRecPreEnable = false;
              BtnRecNextEnable = false;
              BtnRecLastEnable = false;
          }

          #endregion

          #region 無更新權限

          if (!PageCanUpdate)
          {
              BtnEditEnable = false;              
          }

          #endregion

          #region 無刪除權限

          if (!PageCanDelete)
          {
              BtnDeleteEnable = false;
          }

          #endregion

          #region 儲存必須獨立判斷

          if (PageCanCreate || PageCanUpdate)
          {
              //由現在狀況判斷是否要開啟SAVE
              BtnSaveEnable = BtnSave.Enabled && true;
          }
          else
          {
              BtnSaveEnable = false;
          }

          #endregion

      }
      catch (Exception ex)
      {
          throw ex;
      }
    }
Пример #4
0
    protected void GetALO03A_Authority()
    {
        ArrayList ParameterList = new ArrayList();
        ParameterList.Clear();
        ParameterList.Add(Session["UID"].ToString()); //使用者
        ParameterList.Add("ALO03A"); //功能代碼
        PIC.VDS2G.COMMON.SYS.MaintainUserprogauthrel PermissionProcess = new PIC.VDS2G.COMMON.SYS.MaintainUserprogauthrel(ConnectionDB);
        DataTable Dt = PermissionProcess.QueryPermissionByUser(ParameterList);
        if (Dt.Rows.Count > 0)
        {
            CanCalculate = (Dt.Rows[0]["CanCreate"].ToString() == "1" || Dt.Rows[0]["CanUpdate"].ToString() == "1") ? true : false;
         }

         btn_Calculate.Visible = CanCalculate;
    }