Exemple #1
0
    public CascadingDropDownNameValue[] Util_GetCompDeptUser(string knownCategoryValues, string category, string contextKey)
    {
        //拆解 CategoryValues
        StringDictionary dicCategory = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
        StringDictionary dicContext  = CascadingDropDown.ParseKnownCategoryValuesString(contextKey);

        //資料改從 OrgInfo / UserInfo 的方法取得 2016.11.02
        bool IsChkValid = true;

        string[]  ValidKeyList = null;
        DataTable dt           = null;

        //判斷要處理那一階選單
        switch (category)
        {
        case "CompID":
            IsChkValid   = (dicContext["IsChkValid"].ToString().ToUpper() == "Y") ? true : false;
            ValidKeyList = (!string.IsNullOrEmpty(dicContext["ValidKeyList"])) ? dicContext["ValidKeyList"].Split(',') : null;
            if (dicContext["IsReadOnly"].ToString().ToUpper() == "Y")
            {
                ValidKeyList = dicContext["SelectedValue"].Split(',');     //若為「唯讀」,自動限定資料為目前的 SelectedValue
            }

            dt = Util.getDataTable(OrgInfo.getOrgDictionary(true, false, false, IsChkValid, ValidKeyList));
            if (!dt.IsNullOrEmpty())
            {
                dt.Columns.Remove("Value");
            }

            break;

        case "DeptID":
            IsChkValid   = (dicContext["IsChkValid"].ToString().ToUpper() == "Y") ? true : false;
            ValidKeyList = (!string.IsNullOrEmpty(dicContext["ValidKeyList"])) ? dicContext["ValidKeyList"].Split(',') : null;
            if (dicContext["IsReadOnly"].ToString().ToUpper() == "Y")
            {
                ValidKeyList = dicContext["SelectedValue"].Split(',');     //若為「唯讀」,自動限定資料為目前的 SelectedValue
            }

            dt = Util.getDataTable(OrgInfo.getOrgDictionary(false, true, false, IsChkValid, dicCategory["CompID"].Split(','), ValidKeyList));
            if (!dt.IsNullOrEmpty())
            {
                dt.Columns.Remove("Value");
            }

            break;

        case "OrganID":
            IsChkValid   = (dicContext["IsChkValid"].ToString().ToUpper() == "Y") ? true : false;
            ValidKeyList = (!string.IsNullOrEmpty(dicContext["ValidKeyList"])) ? dicContext["ValidKeyList"].Split(',') : null;
            if (dicContext["IsReadOnly"].ToString().ToUpper() == "Y")
            {
                ValidKeyList = dicContext["SelectedValue"].Split(',');     //若為「唯讀」,自動限定資料為目前的 SelectedValue
            }

            dt = Util.getDataTable(OrgInfo.getOrgDictionary(false, false, true, IsChkValid, dicCategory["CompID"].Split(','), dicCategory["DeptID"].Split(','), ValidKeyList));
            if (!dt.IsNullOrEmpty())
            {
                dt.Columns.Remove("Value");
            }

            break;

        case "UserID":
            IsChkValid   = (dicContext["IsChkValid"].ToString().ToUpper() == "Y") ? true : false;
            ValidKeyList = (!string.IsNullOrEmpty(dicContext["ValidKeyList"])) ? dicContext["ValidKeyList"].Split(',') : null;
            if (dicContext["IsReadOnly"].ToString().ToUpper() == "Y")
            {
                ValidKeyList = dicContext["SelectedValue"].Split(',');     //若為「唯讀」,自動限定資料為目前的 SelectedValue
            }

            dt = UserInfo.getUserData(dicCategory["CompID"], dicCategory["DeptID"], dicCategory["OrganID"], IsChkValid);
            if (ValidKeyList != null && ValidKeyList.Length > 0)
            {
                DataRow[] oRows = dt.Select(string.Format(" UserID in ('{0}') ", Util.getStringJoin(ValidKeyList, "','")));
                if (oRows != null || oRows.Count() > 0)
                {
                    dt = oRows.CopyToDataTable();
                }
            }

            if (!dt.IsNullOrEmpty())
            {
                dt = dt.DefaultView.ToTable(true, "UserID,UserName".Split(','));     //可能包含兼職資料,預防 UserID 發生重複
                dt = Util.getDataTable(Util.getDictionary(dt));
                dt.Columns.Remove("Value");
            }

            break;

        default:
            break;
        }
        return(Util.getCascadingArray(dt));
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Chche List
        labCacheList.Text = string.Format("快取清單:<br><ul><li>{0}</ul>", Util.getStringJoin(CacheHelper.getCacheList(), "<li>"));

        //設定 ucPageInfo1
        ucPageInfo1.ucIsShowApplication     = true;
        ucPageInfo1.ucIsShowEnvironmentInfo = true;
        ucPageInfo1.ucIsShowQueryString     = false;
        ucPageInfo1.ucIsShowRequestForm     = false;
        ucPageInfo1.ucIsShowSession         = true;

        //設定 TinyMCE
        //預設MCE
        Util.setJS_TinyMCE(txtMCE.ID);
        btnMCEClear.OnClientClick = string.Format("document.getElementById('{0}').innerHTML = '';return false;", txtMCEResult.ClientID);
        //自訂MCE
        string strCustToolList1 = "newdocument undo redo | fontsizeselect bold italic underline | bullist numlist outdent indent";
        string strCustToolList2 = "cut copy paste pastetext | alignleft aligncenter alignright | forecolor backcolor removeformat | table link";

        Util.setJS_TinyMCE(txtCustMCE.ID, 500, 150, false, strCustToolList1, strCustToolList2);
        btnCustMCEClear.OnClientClick = string.Format("document.getElementById('{0}').innerHTML = '';return false;", txtCustMCEResult.ClientID);

        //設定可繞過Valid檢查的相關物件
        ArrayList arBypassList = new ArrayList();

        arBypassList.Add(txtMCE.ID);
        arBypassList.Add(txtMCEResult.ID);
        arBypassList.Add(txtCustMCE.ID);
        arBypassList.Add(txtCustMCEResult.ID);

        arBypassList.Add(txtMailFrom.ID);
        arBypassList.Add(txtMailTo.ID);
        arBypassList.Add(txtMailCC.ID);
        arBypassList.Add(txtMailBCC.ID);

        arBypassList.Add(txtMailFrom2.ID);
        arBypassList.Add(txtMailTo2.ID);
        arBypassList.Add(txtMailCC2.ID);
        arBypassList.Add(txtMailBCC2.ID);

        Util.setRequestValidatorBypassIDList(Util.getStringJoin(arBypassList));

        //Upload相關
        ucUploadButton1.ucBtnWidth          = 100;
        ucUploadButton1.ucBtnCaption        = "上傳(對話框)";
        ucUploadButton1.ucPopupHeader       = "匯入作業";
        ucUploadButton1.ucUploadFileExtList = "xls,xlsx";
        ucUploadButton1.onClose            += new Util_ucUploadButton.Close(ucUploadButton1_onClose);

        //2015.06.24 新增
        ucUploadButton2.ucBtnWidth          = 100;
        ucUploadButton2.ucBtnCaption        = "上傳(新視窗)";
        ucUploadButton2.ucPopupHeader       = "匯入作業";
        ucUploadButton2.ucUploadFileExtList = "xls,xlsx";
        ucUploadButton2.ucIsPopNewWindow    = true;
        ucUploadButton2.onClose            += ucUploadButton2_onClose;


        //附檔相關
        ucAttachAdminButton1.ucBtnWidth          = 100;
        ucAttachAdminButton1.ucBtnCaption        = "管理(對話框)";
        ucAttachAdminButton1.ucAttachDB          = txtAttachDB.Text;
        ucAttachAdminButton1.ucAttachID          = txtAttachID.Text;
        ucAttachAdminButton1.ucAttachFileMaxQty  = int.Parse("0" + txtAttachFileMaxQty.Text);
        ucAttachAdminButton1.ucAttachFileMaxKB   = int.Parse("0" + txtAttachFileMaxKB.Text);
        ucAttachAdminButton1.ucAttachFileTotKB   = int.Parse("0" + txtAttachFileTotKB.Text);
        ucAttachAdminButton1.ucAnonymousYN       = ddlAnonymousYN.SelectedValue;
        ucAttachAdminButton1.ucAttachFileExtList = txtAttachFileExtList.Text;

        ucAttachAdminButton2.ucBtnWidth          = 100;
        ucAttachAdminButton2.ucBtnCaption        = "管理(新視窗)";
        ucAttachAdminButton2.ucIsPopNewWindow    = true;
        ucAttachAdminButton2.ucAttachDB          = txtAttachDB.Text;
        ucAttachAdminButton2.ucAttachID          = txtAttachID.Text;
        ucAttachAdminButton2.ucAttachFileMaxQty  = int.Parse("0" + txtAttachFileMaxQty.Text);
        ucAttachAdminButton2.ucAttachFileMaxKB   = int.Parse("0" + txtAttachFileMaxKB.Text);
        ucAttachAdminButton2.ucAttachFileTotKB   = int.Parse("0" + txtAttachFileTotKB.Text);
        ucAttachAdminButton2.ucAnonymousYN       = ddlAnonymousYN.SelectedValue;
        ucAttachAdminButton2.ucAttachFileExtList = txtAttachFileExtList.Text;

        ucAttachDownloadButton1.ucBtnWidth   = 100;
        ucAttachDownloadButton1.ucBtnCaption = "清單(對話框)";
        ucAttachDownloadButton1.ucAttachDB   = txtAttachDB.Text;
        ucAttachDownloadButton1.ucAttachID   = txtAttachID.Text;

        ucAttachDownloadButton2.ucBtnWidth       = 100;
        ucAttachDownloadButton2.ucBtnCaption     = "清單(新視窗)";
        ucAttachDownloadButton2.ucIsPopNewWindow = true;
        ucAttachDownloadButton2.ucAttachDB       = txtAttachDB.Text;
        ucAttachDownloadButton2.ucAttachID       = txtAttachID.Text;

        //設定單選的「候選清單」
        ucCommSingleSelect1.ucSourceDictionary = Util.getDictionary(getSampleData(), 0, 1, true);

        //彈出[複選清單](ucButton)

        ucCommMultiSelectButton1.ucSourceDictionary = OrgInfo.getOrgDictionary(); //2016.07.01 調整
        ucCommMultiSelectButton1.ucSelectedIDListToParentObjClientID   = txtPopupID1.ClientID;
        ucCommMultiSelectButton1.ucSelectedInfoListToParentObjClientID = txtPopupInfo1.ClientID;
        ucCommMultiSelectButton1.ucSelectAllConfirmMsg = "這樣會造成災難,確定?";

        //設定[關聯選單](ucButton)
        ucCommCascadeSelectButton1.ucIsSelectUserYN  = ddlIsSeleUser1.SelectedValue;
        ucCommCascadeSelectButton1.ucIsMultiSelectYN = ddlIsMultiSele1.SelectedValue;
        ucCommCascadeSelectButton1.ucDefCompID       = txtDefComp1.Text;
        ucCommCascadeSelectButton1.ucDefDeptID       = txtDefDept1.Text;
        ucCommCascadeSelectButton1.ucDefUserIDList   = txtDefUser1.Text;
        ucCommCascadeSelectButton1.ucSelectedCompIDToParentObjClientID       = txtComp1.ClientID;
        ucCommCascadeSelectButton1.ucSelectedDeptIDToParentObjClientID       = txtDept1.ClientID;
        ucCommCascadeSelectButton1.ucSelectedUserIDListToParentObjClientID   = txtUser1.ClientID;
        ucCommCascadeSelectButton1.ucSelectedCompInfoToParentObjClientID     = txtCompInfo1.ClientID;
        ucCommCascadeSelectButton1.ucSelectedDeptInfoToParentObjClientID     = txtDeptInfo1.ClientID;
        ucCommCascadeSelectButton1.ucSelectedUserInfoListToParentObjClientID = txtUserInfo1.ClientID;

        //設定Ajax關聯式下拉選單
        ucCascadingDropDown1.SetDefault(); //使用預設設定
        ucCascadingDropDown1.Refresh();

        //訂閱所需的彈出視窗事件,方便關閉視窗後,視需要進行相關後續處理
        ucModalPopup1.onComplete += new Util_ucModalPopup.btnCompleteClick(ucModalPopup1_onComplete);
        ucModalPopup1.onCancel   += new Util_ucModalPopup.btnCancelClick(ucModalPopup1_onCancel);
        ucModalPopup1.onClose    += new Util_ucModalPopup.btnCloseClick(ucModalPopup1_onClose);

        if (!IsPostBack)
        {
            //設定彈出視窗內的頁框來源URL
            txtPopupURL.Text = "";

            //設定 Cust64Key
            txtCust64Seed.Text = Util.getAppSetting("app://CfgCust64Seed/");

            //設定 HtmlMsg Kind
            ddlHtmlMsg.DataSource     = Util.getDictionary(typeof(Util.HtmlMessageKind));
            ddlHtmlMsg.DataTextField  = "value";
            ddlHtmlMsg.DataValueField = "key";
            ddlHtmlMsg.DataBind();

            //設定Mail
            txtMailFrom.Text  = string.Format("{0} < {1} >", Util.getAppSetting("appMailAddrDisplay"), Util.getAppSetting("appMailFrom"));
            txtMailFrom2.Text = string.Format("{0} < {1} >", Util.getAppSetting("appMailAddrDisplay"), Util.getAppSetting("appMailFrom"));
            //txtMailAttach2.Text = "{\"AttachDB\":\"ezFlowAttach\",\"AttachID\":\"eDoc-20130130.00002.00010\",\"SeqNo\":\"1\"}";
            txtMailAttach2.Text = "[{'AttachDB':'ezFlowAttach','AttachID':'eDoc-20130130.00002.00010','SeqNo':'10'}]";
        }
        else
        {
            //顯示 ucCommCascadeSelect1 傳回值
            txtComp2.Text     = ucCommCascadeSelect1.ucSelectedCompID;
            txtDept2.Text     = ucCommCascadeSelect1.ucSelectedDeptID;
            txtUser2.Text     = ucCommCascadeSelect1.ucSelectedUserIDList;
            txtCompInfo2.Text = ucCommCascadeSelect1.ucSelectedCompInfo;
            txtDeptInfo2.Text = ucCommCascadeSelect1.ucSelectedDeptInfo;
            txtUserInfo2.Text = ucCommCascadeSelect1.ucSelectedUserInfoList;
        }
    }