Пример #1
0
    /// <summary>
    /// 頁面載入
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        qryAreaGrant.ucServiceMethod         = AclExpress._AclAreaGrantServiceMethod;
        qryAreaGrant.ucCategory01            = "AreaID";
        qryAreaGrant.ucCategory02            = "GrantID";
        qryAreaGrant.ucDropDownListEnabled01 = true;
        qryAreaGrant.ucDropDownListEnabled02 = true;
        qryAreaGrant.ucDropDownListEnabled03 = false;
        qryAreaGrant.ucDropDownListEnabled04 = false;
        qryAreaGrant.ucDropDownListEnabled05 = false;
        qryAreaGrant.Refresh();

        if (!IsPostBack)
        {
            //首次載入
            qryRuleID.ucSourceDictionary = Util.getDictionary(AclExpress.getAclRuleData(), 0, 1, true);
            qryRuleID.Refresh();

            qryAuthType.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthTypeList());
            qryAuthType.Refresh();

            ucGridView1.ucDBName      = _DBName;
            ucGridView1.ucDataQrySQL  = _QryResultSQL;
            ucGridView1.ucDataKeyList = _PKList;

            Dictionary <string, string> dicDisplay = new Dictionary <string, string>();
            dicDisplay.Clear();
            dicDisplay.Add("AreaID", "區域代號");
            dicDisplay.Add("AreaName", "區域名稱");
            dicDisplay.Add("GrantID", "項目代號");
            dicDisplay.Add("GrantName", "項目名稱");
            dicDisplay.Add("AuthType", "授權類型");
            dicDisplay.Add("AllowActList", "限定動作");
            dicDisplay.Add("UpdUser", "更新人員");
            dicDisplay.Add("UpdDateTime", "更新時間@T");

            ucGridView1.ucDataGroupKey          = "RuleID";
            ucGridView1.ucDataDisplayDefinition = dicDisplay;
            ucGridView1.ucSelectEnabled         = false;
            ucGridView1.ucAddEnabled            = true;
            ucGridView1.ucEditEnabled           = true;
            ucGridView1.ucCopyEnabled           = true;
            ucGridView1.ucDeleteEnabled         = true;
            //Data Dump 2016.11.08
            ucGridView1.ucDataDumpEnabled = true;

            ucGridView1.Refresh(true);
        }

        //事件訂閱
        ucGridView1.RowCommand += new Util_ucGridView.GridViewRowClick(ucGridView1_RowCommand);
        ucModalPopup1.onClose  += ucModalPopup1_onClose;
    }
Пример #2
0
    /// <summary>
    /// 更新授權資料(By User)
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUpdByUserID_Click(object sender, EventArgs e)
    {
        //by UserID
        ucSeleGrantList.ucSourceDictionary = _DicGrantList;
        ucSeleGrantList.Refresh();

        if (_UserGrantList != ucSeleGrantList.ucSelectedIDList)
        {
            try
            {
                string[] tmpList  = null;
                string   strTable = "AclAuthUserAreaGrantList";
                Dictionary <string, string> dicKey = new Dictionary <string, string>();
                DbHelper db     = new DbHelper(AclExpress._AclDBName);
                string   strSQL = "";
                //刪除既有授權資料
                if (!string.IsNullOrEmpty(_UserGrantList))
                {
                    tmpList = _UserGrantList.Split(',');
                    for (int i = 0; i < tmpList.Count(); i++)
                    {
                        dicKey.Clear();
                        dicKey.Add("UserID", ucSeleUserID.ucSelectedID);
                        dicKey.Add("AreaID", PageAclAreaID);
                        dicKey.Add("GrantID", tmpList[i]);
                        AclExpress.IsAclTableLog(strTable, dicKey, LogHelper.AppTableLogType.Delete);

                        strSQL = Util.getDataDeleteSQL(Util.getArray(dicKey, 0), Util.getArray(dicKey, 1), strTable.Split(','));
                        db.ExecuteNonQuery(strSQL);
                    }
                }

                //添加新的授權資料
                if (!string.IsNullOrEmpty(ucSeleGrantList.ucSelectedIDList))
                {
                    string strAuthType = AclExpress.getAclAuthTypeList().Keys.Last();
                    tmpList = ucSeleGrantList.ucSelectedIDList.Split(',');
                    for (int i = 0; i < tmpList.Count(); i++)
                    {
                        dicKey.Clear();
                        dicKey.Add("UserID", ucSeleUserID.ucSelectedID);
                        dicKey.Add("AreaID", PageAclAreaID);
                        dicKey.Add("GrantID", tmpList[i]);

                        strSQL  = "Insert " + strTable + " (UserID,AreaID,GrantID,UserName,AuthType,AllowActList,Remark,UpdUser,UpdDateTime) ";
                        strSQL += string.Format(" Values ('{0}','{1}','{2}','{3}','{4}','','By AclAuthUtil','{5}',getdate());", dicKey["UserID"], dicKey["AreaID"], dicKey["GrantID"], UserInfo.findUserName(dicKey["UserID"]), strAuthType, UserInfo.getUserInfo().UserID);
                        db.ExecuteNonQuery(strSQL);

                        AclExpress.IsAclTableLog(strTable, dicKey, LogHelper.AppTableLogType.Create);
                    }
                }

                _UserGrantList = ucSeleGrantList.ucSelectedIDList;
                Util.NotifyMsg(AclRS.Resources.Msg_AclAuthUpdateSucceed, Util.NotifyKind.Success);  //[ACL] 授權資料更新成功!
            }
            catch (Exception ex)
            {
                LogHelper.WriteAppLog(AclExpress._AclDBName, LogHelper.AppLogType.Error, "AclExpress", "AclAuthUtil", ex.Message);
                Util.NotifyMsg(AclRS.Resources.Msg_AclAuthUpdateFail, Util.NotifyKind.Error);  //[ACL] 授權資料更新失敗!
            }
        }
        else
        {
            Util.NotifyMsg(AclRS.Resources.Msg_AclAuthUpdateNoAction);  //[ACL] 無異動,不需更新授權資料!
        }
    }
Пример #3
0
    /// <summary>
    /// fmMain 資料繫結事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void fmMain_DataBound(object sender, EventArgs e)
    {
        //初始物件
        Util_ucTextBox           oText;
        Util_ucCascadingDropDown oCascad;
        Util_ucCommSingleSelect  oDdl;
        Util_ucCheckBoxList      oChkList;

        string  strObjID;
        DataRow dr = null;

        if (fmMain.DataSource != null)
        {
            dr = ((DataTable)fmMain.DataSource).Rows[0];
        }

        //「新增」「資料複製」模式
        if (fmMain.CurrentMode == FormViewMode.Insert)
        {
            //自訂檢核失敗時的JS提醒訊息
            Util.setJS_AlertPageNotValid("btnInsert");

            strObjID = "RuleID";
            oDdl     = (Util_ucCommSingleSelect)fmMain.FindControl(strObjID);
            oDdl.ucSourceDictionary = Util.getDictionary(AclExpress.getAclRuleData(), 0, 1, true);
            if (dr != null)
            {
                oDdl.ucSelectedID = dr[strObjID].ToString().Trim();
            }
            oDdl.Refresh();

            strObjID = "AreaGrant";
            oCascad  = (Util_ucCascadingDropDown)fmMain.FindControl(strObjID);
            oCascad.ucServiceMethod         = AclExpress._AclAreaGrantServiceMethod;
            oCascad.ucCategory01            = "AreaID";
            oCascad.ucCategory02            = "GrantID";
            oCascad.ucDropDownListEnabled01 = true;
            oCascad.ucDropDownListEnabled02 = true;
            oCascad.ucDropDownListEnabled03 = false;
            oCascad.ucDropDownListEnabled04 = false;
            oCascad.ucDropDownListEnabled05 = false;
            if (dr != null)
            {
                oCascad.ucDefaultSelectedValue01 = dr["AreaID"].ToString().Trim();
            }
            if (dr != null)
            {
                oCascad.ucDefaultSelectedValue02 = dr["GrantID"].ToString().Trim();
            }
            oCascad.Refresh();

            strObjID = "AuthType";
            oDdl     = (Util_ucCommSingleSelect)fmMain.FindControl(strObjID);
            oDdl.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthTypeList());
            if (dr != null)
            {
                oDdl.ucSelectedID = dr[strObjID].ToString().Trim();
            }
            oDdl.Refresh();

            strObjID = "AllowActList";
            oChkList = (Util_ucCheckBoxList)fmMain.FindControl(strObjID);
            oChkList.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthActList());
            if (dr != null)
            {
                oChkList.ucSelectedIDList = dr[strObjID].ToString().Trim();
            }
            oChkList.Refresh();

            strObjID = "Remark";
            oText    = (Util_ucTextBox)fmMain.FindControl(strObjID);
            if (dr != null)
            {
                oText.ucTextData = dr[strObjID].ToString().Trim();
            }
        }

        //「編輯」模式
        if (fmMain.CurrentMode == FormViewMode.Edit)
        {
            //自訂檢核失敗時的JS提醒訊息
            Util.setJS_AlertPageNotValid("btnUpdate");

            strObjID = "RuleID";
            oDdl     = (Util_ucCommSingleSelect)fmMain.FindControl(strObjID);
            oDdl.ucSourceDictionary = Util.getDictionary(AclExpress.getAclRuleData(), 0, 1, true);
            oDdl.ucIsReadOnly       = true; //鍵值欄位需為唯讀
            if (dr != null)
            {
                oDdl.ucSelectedID = dr[strObjID].ToString().Trim();
            }
            oDdl.Refresh();

            strObjID = "AreaGrant";
            oCascad  = (Util_ucCascadingDropDown)fmMain.FindControl(strObjID);
            oCascad.ucServiceMethod         = AclExpress._AclAreaGrantServiceMethod;
            oCascad.ucCategory01            = "AreaID";
            oCascad.ucCategory02            = "GrantID";
            oCascad.ucDropDownListEnabled01 = true;
            oCascad.ucDropDownListEnabled02 = true;
            oCascad.ucDropDownListEnabled03 = false;
            oCascad.ucDropDownListEnabled04 = false;
            oCascad.ucDropDownListEnabled05 = false;
            oCascad.ucIsReadOnly01          = true; //鍵值欄位需為唯讀
            oCascad.ucIsReadOnly02          = true; //鍵值欄位需為唯讀
            if (dr != null)
            {
                oCascad.ucDefaultSelectedValue01 = dr["AreaID"].ToString().Trim();
            }
            if (dr != null)
            {
                oCascad.ucDefaultSelectedValue02 = dr["GrantID"].ToString().Trim();
            }
            oCascad.Refresh();

            strObjID = "AuthType";
            oDdl     = (Util_ucCommSingleSelect)fmMain.FindControl(strObjID);
            oDdl.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthTypeList());
            if (dr != null)
            {
                oDdl.ucSelectedID = dr[strObjID].ToString().Trim();
            }
            oDdl.Refresh();

            strObjID = "AllowActList";
            oChkList = (Util_ucCheckBoxList)fmMain.FindControl(strObjID);
            oChkList.ucSourceDictionary = Util.getDictionary(AclExpress.getAclAuthActList());
            if (dr != null)
            {
                oChkList.ucSelectedIDList = dr[strObjID].ToString().Trim();
            }
            oChkList.Refresh();

            strObjID = "Remark";
            oText    = (Util_ucTextBox)fmMain.FindControl(strObjID);
            if (dr != null)
            {
                oText.ucTextData = dr[strObjID].ToString().Trim();
            }

            //刪除確認訊息
            Button oBtn = (Button)fmMain.FindControl("btnDelete");
            if (oBtn != null)
            {
                Util.ConfirmBox(oBtn, RS.Resources.Msg_Confirm_Delete);
            }
        }
    }