private string GetWelcome(string strLayer, string strApID, ref PccErrMsg myLabel) { string strReturn = string.Empty; bs_Security mySecurity = new bs_Security(ConfigurationManager.AppSettings["ConnectionType"], ConfigurationManager.AppSettings["ConnectionServer"], ConfigurationManager.AppSettings["ConnectionDB"], ConfigurationManager.AppSettings["ConnectionUser"], ConfigurationManager.AppSettings["ConnectionPwd"], Session["UserIDAndName"].ToString(), ConfigurationManager.AppSettings["EventLogPath"]); string strCount = "0"; PccCommonForC.PccMsg myMsg1 = new PccCommonForC.PccMsg(); if (strApID != null && int.Parse(strApID) > 0) { //新增這個系統的前置詞 myMsg1.CreateFirstNode("ap_id", strApID); myMsg1.CreateFirstNode("user_id", Session["UserID"].ToString()); if (((Hashtable)Session["APCounts"]).ContainsKey(strApID)) { strCount = ((Hashtable)Session["APCounts"])[strApID].ToString(); } else { strCount = mySecurity.DoReturnStr("GetAndUpdateApCounts", myMsg1.GetXmlStr, ""); ((Hashtable)Session["APCounts"]).Add(strApID, strCount); } } //060306 將原本Hard code的Menu內容改由LabelMsg_TC.xml抓取 string strWel = myLabel.GetErrMsg("M000001", "MenuItem"); string strCome = myLabel.GetErrMsg("M000002", "MenuItem"); string strUpdateUser = myLabel.GetErrMsg("M000011", "MenuItem"); string strAddSystem = myLabel.GetErrMsg("M000012", "MenuItem"); string strTransfer = myLabel.GetErrMsg("M000013", "MenuItem"); //strReturn += "\"歡迎" + Session["UserName"].ToString() + "光臨(" + strCount + ")\","; //第一個分區的圖形或文字 strReturn += "\"" + strWel + Session["UserName"].ToString() + strCome + "(" + strCount + ")\","; //第一個分區的圖形或文字 strReturn += "3,"; //第一個大項次的開始 //第一個分區的第一個小Item參數 //strReturn += "\"個人資料修改\","; //選單名稱 strReturn += "\"" + strUpdateUser + "\","; //選單名稱 strReturn += "\"" + strLayer + "images/MenuArea/DgyyWebWinNew/sFile1.gif\","; //選單的前置圖形 strReturn += "\"" + ConfigurationManager.AppSettings["PFSBaseWeb"] + "usermanage/UpdateUser.aspx?UserID=" + Session["UserID"].ToString() + "&AcctionType=Upd&UserAccount=" + Session["UserAccount"].ToString() + "\",";//選單的連結網頁 strReturn += "\"1\","; //型態表示開啟一個頁面在IFrame上,若為2表示呼叫一個函式。 //第一個分區的第二個小Item參數 //strReturn += "\"加入系統\","; //選單名稱 strReturn += "\"" + strAddSystem + "\","; //選單名稱 strReturn += "\"" + strLayer + "images/MenuArea/DgyyWebWinNew/sFile1.gif\","; //選單的前置圖形 strReturn += "\"ApplyAccount.aspx?Type=Update\",";//選單的連結網頁 strReturn += "\"1\","; //型態表示開啟一個頁面在IFrame上,若為2表示呼叫一個函式。 //第一個分區的第三個小Item參數 //strReturn += "\"中英文轉換\","; //選單名稱 strReturn += "\"" + strTransfer + "\","; //選單名稱 strReturn += "\"" + strLayer + "images/MenuArea/DgyyWebWinNew/sFile1.gif\","; //選單的前置圖形 strReturn += "\"ChangeLanguage.aspx?ApID=0\",";//選單的連結網頁 strReturn += "\"1\""; //型態表示開啟一個頁面在IFrame上,若為2表示呼叫一個函式。 return strReturn; }
private string GetUserXML(string user_id) { PccBsSystemForC.bs_UserManager mybs = new PccBsSystemForC.bs_UserManager(ConfigurationSettings.AppSettings["ConnectionType"] , ConfigurationSettings.AppSettings["ConnectionServer"], ConfigurationSettings.AppSettings["ConnectionDB"], ConfigurationSettings.AppSettings["ConnectionUser"], ConfigurationSettings.AppSettings["ConnectionPwd"],Session["UserIDAndName"].ToString(),ConfigurationSettings.AppSettings["EventLogPath"]); PccCommonForC.PccMsg myMsg = new PccCommonForC.PccMsg(); myMsg.CreateFirstNode("user_id",user_id); PccMsg myReturnMsg = new PccMsg(); myReturnMsg.LoadXml(mybs.DoReturnStr("GetUserData",myMsg.GetXmlStr,"")); //10/6還要繼續做XML的方法 20041006 string fact_id = myReturnMsg.Query("fact_id"); myReturnMsg.CreateFirstNode("fact_no", GetFactNoByFactID(fact_id)); return myReturnMsg.GetXmlStr; }
protected void Page_Load(object sender, EventArgs e) { if (Session["UserID"] == null) return; // 將使用者程式碼置於此以初始化網頁 string strLeftMenu = string.Empty; int AreaCount = 1; //利用LoginInfo取得此User的AP Detail Menu. PccCommonForC.PccErrMsg myLabel = new PccCommonForC.PccErrMsg(Server.MapPath(Session["PageLayer"] + "XmlDoc"), Session["CodePage"].ToString(), "Label"); string strDetailPageLayer = Session["PageLayer"].ToString(); if (Request.QueryString["ApID"] != null) { //取得應用程式之APID string strApID = Request.Params["ApID"]; //string ApFolder = "", MenuItem ="", MenuName =""; string ApFolder = string.Empty; PccCommonForC.PccMsg myMsg = new PccCommonForC.PccMsg(); myMsg.LoadXml(Session["XmlLoginInfo"].ToString()); if (strApID.Length > 0 && strDetailPageLayer.Length > 0) { //strDetailPageLayer = strDetailPageLayer.Substring(0,strDetailPageLayer.Length - 3); //判斷是否有系統可以使用,若沒有則直接跳出 if (myMsg.QueryNodes("Authorize") != null) { foreach (XmlNode myNode in myMsg.QueryNodes("Authorize")) { //假如不是點選這個系統則直接跳出並判斷下一個 if (strApID != myMsg.Query("APID", myNode)) continue; //取得這個AP的最上層之Folder ApFolder = GetApFolder(myMsg.Query("APLink", myNode)); //判斷是否有選單系統可以使用,若沒有則直接跳出 if (myMsg.QueryNodes("ApMenu", (XmlElement)myNode) != null) { foreach (XmlNode myDetailNode in myMsg.QueryNodes("ApMenu", (XmlElement)myNode)) { if (myMsg.Query("show_mk", myDetailNode).Equals("Y")) { //判斷是否為Web Service的Menu若是則直接跳過 2005/3/8 if (myMsg.Query("MenuLink", myDetailNode).IndexOf(".asmx", 0) > 0) continue; //本來在越南區還會做Menu的語系轉換,我認為沒有必要,因為那是直接從資料庫取得的資訊 //這是可以做修改的,而且可利用中(英)對照來解決。實做方式如下: //有一個很大的缺點,就是若在LabelMsg.xml中沒有加入相對應的值則無法顯示。20060626 /* //060306 判斷語系是否為中文 if(Session["CodePage"].ToString() =="CP950") { SaveDataToHashMenu(myMsg.Query("MenuManage",(XmlElement)myDetailNode),strDetailPageLayer,ApFolder,myMsg.Query("MenuNM",(XmlElement)myDetailNode),myMsg.Query("MenuLink",(XmlElement)myDetailNode)); } else { MenuItem = "M" + strApID + int.Parse(myMsg.Query("MENUID",myDetailNode)).ToString(); MenuName = myLabel.GetErrMsg(MenuItem,"MenuItem"); SaveDataToHashMenu(myMsg.Query("MenuManage",(XmlElement)myDetailNode),strDetailPageLayer, ApFolder, MenuName, myMsg.Query("MenuLink",(XmlElement)myDetailNode)); } */ SaveDataToHashMenu(myMsg.Query("MenuManage", (XmlElement)myDetailNode), strDetailPageLayer, ApFolder, myMsg.Query("MenuNM", (XmlElement)myDetailNode), myMsg.Query("MenuLink", (XmlElement)myDetailNode)); } } } } } } strLeftMenu += "var menus = new Array ("; int count = 1; if (m_Menu.Count > 0) { AreaCount += m_Menu.Count; strLeftMenu += AreaCount.ToString() + ","; //總共多少分區 strLeftMenu += GetWelcome(strDetailPageLayer, strApID, ref myLabel) + ","; /* 本來在這個地方越南地區也是有做語系的處理,就是在本來設定的image如:N_Open.gif變成N_Open_VN.gif 我持的理由還是一樣,我覺得Menu區不必做語系的轉換,因為這可以在早期就決定是會在那裡實做,而且可以 更新圖形即可,而且最好是放在某一個Floder,而其Floder的Name放在Cofig中,這樣比較有彈性。20060626 */ //設定一般區 if (m_Menu.ContainsKey("N")) { strLeftMenu += "\"<image src=" + strDetailPageLayer + "images/MenuArea/N_Open.gif />\","; count = m_Menu["N"].ToString().Split(',').Length / 4; strLeftMenu += count.ToString() + ","; //一個大項次的開始,表示有多少個Item strLeftMenu += m_Menu["N"].ToString(); } foreach (string strArea in m_Menu.Keys) { if (!strArea.Equals("N") && !strArea.Equals("Y")) { strLeftMenu += "\"<image src=" + strDetailPageLayer + "images/MenuArea/" + strArea + "_Open.gif />\","; count = m_Menu[strArea].ToString().Split(',').Length / 4; strLeftMenu += count.ToString() + ","; //第一個大項次的開始,表示有多少個Item strLeftMenu += m_Menu[strArea].ToString(); } } //設定權限管理區 if (m_Menu.ContainsKey("Y")) { strLeftMenu += "\"<image src=" + strDetailPageLayer + "images/MenuArea/Y_Open.gif />\","; count = m_Menu["Y"].ToString().Split(',').Length / 4; strLeftMenu += count.ToString() + ","; //一個大項次的開始,表示有多少個Item strLeftMenu += m_Menu["Y"].ToString(); } strLeftMenu = strLeftMenu.Substring(0, strLeftMenu.Length - 1); } else //表示沒有選單權限 { strLeftMenu += AreaCount.ToString() + ","; //總共多少分區 strLeftMenu += GetWelcome(strDetailPageLayer, strApID, ref myLabel); } strLeftMenu += ");"; } txtLeftMenu.Value = strLeftMenu; }
private string GetWelcome(string strLayer, string strApID) { string strReturn = string.Empty; bs_Security mySecurity = new bs_Security(ConfigurationSettings.AppSettings["ConnectionType"], ConfigurationSettings.AppSettings["ConnectionServer"], ConfigurationSettings.AppSettings["ConnectionDB"], ConfigurationSettings.AppSettings["ConnectionUser"], ConfigurationSettings.AppSettings["ConnectionPwd"], Session["UserIDAndName"].ToString(), ConfigurationSettings.AppSettings["EventLogPath"]); string strCount = "0"; PccCommonForC.PccMsg myMsg1 = new PccCommonForC.PccMsg(); if (strApID != null && int.Parse(strApID) > 0) { //新增這個系統的前置詞 myMsg1.CreateFirstNode("ap_id", strApID); myMsg1.CreateFirstNode("user_id", Session["UserID"].ToString()); if (((Hashtable)Session["APCounts"]).ContainsKey(strApID)) { strCount = ((Hashtable)Session["APCounts"])[strApID].ToString(); } else { strCount = mySecurity.DoReturnStr("GetAndUpdateApCounts", myMsg1.GetXmlStr, ""); ((Hashtable)Session["APCounts"]).Add(strApID, strCount); } } strReturn += "<div id=\"menu01\" class=\"sysMenu01_0\" onmouseover=\"fn_btnOver(this);\" onmouseout=\"fn_btnOut(this);\" onClick=\"fn_switchVisible(div_m00);\"><nobr>" + "歡迎 " + Session["UserName"].ToString() + " 光臨</nobr></div>"; //第一個分區的圖形或文字 strReturn += "<div id=\"div_m00\" class=\"sysMenu_div02\" style=\"display:none;\">"; strReturn += "<div><nobr><a href=\"" + strLayer + "UpdateLoginUser.aspx\" class=\"sysMenu02_0\" target=\"menuFrame\" onMouseOver=\"fn_btnOver(this);\" onMouseOut=\"fn_btnOut(this);\">個人資料修改</a></nobr></div>"; //選單名稱 strReturn += "<div><nobr><a href=\"../Pub/Module/ChangeLanguage.aspx?ApID=0\" class=\"sysMenu02_0\" target=\"menuFrame\" onMouseOver=\"fn_btnOver(this);\" onMouseOut=\"fn_btnOut(this);\">中英文轉換</a></nobr></div>"; //選單名稱 strReturn += "</div>"; return strReturn; }
private string GenMenuDetail() { string HTML = ""; PccErrMsg myLabel = new PccErrMsg(Server.MapPath("XmlDoc"), Session["CodeLang"].ToString(), "Label", true); PccCommonForC.PccMsg myMsg = new PccCommonForC.PccMsg(); myMsg.LoadXml(Session["XmlLoginInfo"].ToString()); //APID string ApFolder = "", MenuItem = "", MenuName = ""; string strApID = Request.Params["ApID"]; string strDetailPageLayer = Session["PageLayer"].ToString(); int index = 0; int ColsMenu = int.Parse(ConfigurationManager.AppSettings["ColsMenu"]); if (strApID.Length > 0 && strDetailPageLayer.Length > 0) { //strDetailPageLayer = strDetailPageLayer.Substring(0,strDetailPageLayer.Length - 3); if (myMsg.QueryNodes("Authorize") != null) { DataTable dtUser = GetQCFactDept(); foreach (XmlNode myNode in myMsg.QueryNodes("Authorize")) { if (strApID != myMsg.Query("APID", myNode)) continue; //Folder ApFolder = GetApFolder(myMsg.Query("APLink", myNode)); if (myMsg.QueryNodes("ApMenu", (XmlElement)myNode) != null) { HTML += "<table border='0' cellpadding='5' cellspacing='0' style='margin:0px auto;' class='CoverMenu'>"; foreach (XmlNode myDetailNode in myMsg.QueryNodes("ApMenu", (XmlElement)myNode)) { if (myMsg.Query("show_mk", myDetailNode).Equals("Y")) { if (myMsg.Query("MenuLink", myDetailNode).IndexOf(".asmx", 0) > 0) continue; MenuName = myMsg.Query("MenuNM", (XmlElement)myDetailNode); string MenuID = myMsg.Query("MENUID", myDetailNode); string Type_Check=""; if (MenuID == "2986") Type_Check = "1"; //QC cố định else if (MenuID == "2987" || MenuID == "2988") Type_Check = "2"; //QC tuần tra if (Type_Check.Length > 0) //xét quyền hạn type check { bool CheckQC = CheckAutQC(dtUser, Type_Check); if (!CheckQC) continue; } string Area = myMsg.Query("MenuManage", (XmlElement)myDetailNode); string MenuURL = ResolveUrl("~/Images/MenuArea/MenuItem/" + MenuID + ".png"); string MenuLink = myMsg.Query("MenuLink", (XmlElement)myDetailNode); if (Area.Equals("Y")) { MenuLink = strDetailPageLayer + "SysManager/" + MenuLink + ""; MenuURL = ResolveUrl("~/Images/MenuArea/MenuItem/Default.png"); } if (Session["CodeLang"].ToString().ToUpper() != "TC") { MenuItem = "M" + strApID + int.Parse(myMsg.Query("MENUID", myDetailNode)).ToString(); MenuName = myLabel.GetErrMsg(MenuItem, "MenuItem"); } if (index % (ColsMenu) == 0) { if (index != 0) { HTML += "</tr>"; } HTML += "<tr>"; } /*HTML += "<td style='text-align:center'>"; HTML += "<a href='" + MenuLink + "'><img src='" + MenuURL + "' border='0' width='60px' height='60px'></a>"; HTML += "</td>";*/ HTML += "<td >"; HTML += "<a href='" + MenuLink + "'><div>"; HTML += "<img src='" + MenuURL + "' border='0' width='60px' height='60px'><br>"; HTML += MenuName + ""; HTML += "</div></a>"; HTML += "</td>"; index++; } } HTML += "</tr></table>"; } } } } return HTML; }
private void SetMenu() { string strLeftMenu = string.Empty; int AreaCount = 1; //LoginInfoUser of AP Detail Menu. PccCommonForC.PccErrMsg myLabel = new PccCommonForC.PccErrMsg(Server.MapPath(Session["PageLayer"] + "XmlDoc"), Session["CodePage"].ToString(), "Label"); string strDetailPageLayer = Session["PageLayer"].ToString(); if (Request.QueryString["ApID"] != null) { //APID string strApID = Request.Params["ApID"]; string ApFolder = "", MenuItem = "", MenuName = ""; PccCommonForC.PccMsg myMsg = new PccCommonForC.PccMsg(); myMsg.LoadXml(Session["XmlLoginInfo"].ToString()); if (strApID.Length > 0 && strDetailPageLayer.Length > 0) { //strDetailPageLayer = strDetailPageLayer.Substring(0,strDetailPageLayer.Length - 3); if (myMsg.QueryNodes("Authorize") != null) { foreach (XmlNode myNode in myMsg.QueryNodes("Authorize")) { if (strApID != myMsg.Query("APID", myNode)) continue; //Folder ApFolder = GetApFolder(myMsg.Query("APLink", myNode)); if (myMsg.QueryNodes("ApMenu", (XmlElement)myNode) != null) { foreach (XmlNode myDetailNode in myMsg.QueryNodes("ApMenu", (XmlElement)myNode)) { if (myMsg.Query("show_mk", myDetailNode).Equals("Y")) { if (myMsg.Query("MenuLink", myDetailNode).IndexOf(".asmx", 0) > 0) continue; if (Session["CodePage"].ToString() == "CP950") { SaveDataToHashMenu(myMsg.Query("MenuManage", (XmlElement)myDetailNode), strDetailPageLayer, ApFolder, myMsg.Query("MenuNM", (XmlElement)myDetailNode), myMsg.Query("MenuLink", (XmlElement)myDetailNode)); } else { MenuItem = "M" + strApID + int.Parse(myMsg.Query("MENUID", myDetailNode)).ToString(); MenuName = myLabel.GetErrMsg(MenuItem, "MenuItem"); SaveDataToHashMenu(myMsg.Query("MenuManage", (XmlElement)myDetailNode), strDetailPageLayer, ApFolder, MenuName, myMsg.Query("MenuLink", (XmlElement)myDetailNode)); } // SaveDataToHashMenu(myMsg.Query("MenuManage", (XmlElement)myDetailNode), strDetailPageLayer, ApFolder, myMsg.Query("MenuNM", (XmlElement)myDetailNode), myMsg.Query("MenuLink", (XmlElement)myDetailNode)); } } } } } } strLeftMenu = "<div class='glossymenu'>"; string strLang = ""; ArrayList arrMenu = new ArrayList(); if (Session["CodePage"].ToString() != "CP950") { strLang = "_VN"; } myMsg = new PccMsg(); myMsg.Load(Server.MapPath(Session["PageLayer"] + @"XmlDoc\ApMenu" + strLang + ".xml")); if (myMsg.QueryNodes("Applications/Application") != null) { foreach (XmlNode apNode in myMsg.QueryNodes("Applications/Application")) { if (myMsg.Query("ApID", apNode) == Request.QueryString["ApID"]) { if (myMsg.QueryNodes("ApAreas/Area", apNode) != null) { foreach (XmlNode areaNode in myMsg.QueryNodes("ApAreas/Area", apNode)) { string AreaMK = myMsg.Query("AreaMK", areaNode); string AreaName = myMsg.Query("AreaName", areaNode); if (m_Menu.ContainsKey(AreaMK))//xet quyen han thay menu { strLeftMenu += "<a class='menuitem submenuheader' style='cursor:pointer'><span class='area_item'><img src='" + ResolveUrl("~/") + "Pub/EasyLayout/ImgBody/group_item.png" + "' border='0'>" + AreaName.ToUpper() + "</span></a>"; strLeftMenu += "<div class='submenu'>"; strLeftMenu += "<ul>"; //add child menu strLeftMenu += m_Menu[AreaMK].ToString(); strLeftMenu += "</ul>"; strLeftMenu += "</div>"; //end class=menu_body } } } break; } } } /* if (m_Menu.Count > 0) { AreaCount += m_Menu.Count; //strLeftMenu += GetWelcome(strDetailPageLayer, strApID); string[] strArrMenu = { "N", "R", "S", "W", "M", "Q" }; for (int w = 0; w < strArrMenu.Length; w++) { if (m_Menu.ContainsKey(strArrMenu[w])) { string area_mk = strArrMenu[w]; arrMenu.Add(area_mk); //GroupMenu strLeftMenu += "<a class='menuitem submenuheader' style='cursor:pointer'><img src='" + ResolveUrl("~/") + "images/MenuArea/" + area_mk + "_Open" + strLang + ".gif' border='0' ></a>"; strLeftMenu += "<div class='submenu'>"; strLeftMenu += "<ul>"; //child menu strLeftMenu += m_Menu[area_mk].ToString(); strLeftMenu += "</ul>"; strLeftMenu += "</div>"; //end class=menu_body } } foreach (string strArea in m_Menu.Keys) //cac nhom menu khac { bool isExits = false; for (int k = 0; k < arrMenu.Count; k++) //kiem tra co ton tai trong menu da co chua { if (strArea == arrMenu[k].ToString() || strArea == "Y") { isExits = true; break; } } if (!isExits) { string area_mk = strArea; //GroupMenu strLeftMenu += "<a class='menuitem submenuheader' style='cursor:pointer'><img src='" + ResolveUrl("~/") + "images/MenuArea/" + area_mk + "_Open" + strLang + ".gif' border='0' ></a>"; strLeftMenu += "<div class='submenu'>"; strLeftMenu += "<ul>"; //child menu strLeftMenu += m_Menu[area_mk].ToString(); strLeftMenu += "</ul>"; strLeftMenu += "</div>"; //end class=menu_body } } //Khu quan ly if (m_Menu.ContainsKey("Y")) { string area_mk = "Y"; arrMenu.Add(area_mk); //GroupMenu strLeftMenu += "<a class='menuitem submenuheader' style='cursor:pointer'><img src='" + ResolveUrl("~/") + "images/MenuArea/" + area_mk + "_Open" + strLang + ".gif' border='0' ></a>"; strLeftMenu += "<div class='submenu'>"; strLeftMenu += "<ul>"; //child menu strLeftMenu += m_Menu[area_mk].ToString(); strLeftMenu += "</ul>"; strLeftMenu += "</div>"; //end class=menu_body } } else //表示沒有選單權限 { //strLeftMenu += GetWelcome(strDetailPageLayer, strApID); }*/ strLeftMenu += "</div>"; //end div class='glossymenu' } ltrLeftMenu.Text = strLeftMenu; }
private void GetUserData(ref PccCommonForC.PccErrMsg myLabel, ref PccBsSystemForC.bs_UserManager mybs) { PccCommonForC.PccMsg myMsg = new PccCommonForC.PccMsg(); myMsg.CreateFirstNode("user_id", Session["UserID"].ToString()); myMsg.CreateFirstNode("ap_id", ddlApplcation.SelectedItem.Value); string strXML = myMsg.GetXmlStr; try { myMsg.LoadXml(mybs.DoReturnStr("GetUserData", strXML, "")); txtuser_desc.Text = myMsg.Query("user_desc"); txtuser_nm.Text = myMsg.Query("email"); //password always is 'password' txtusr_pas.Attributes["value"] = myMsg.Query("usr_pas"); txtReusr_pas.Attributes["value"] = myMsg.Query("usr_pas"); //ddldept_id.Items.FindByValue(myMsg.Query("dept_id")).Selected = true; ddlfact_id.Items.FindByValue(myMsg.Query("fact_id")).Selected = true; txtemp_no.Text = myMsg.Query("emp_no"); txtext.Text = myMsg.Query("ext"); SetTextColor(); } catch { lblMsg.Text = myLabel.GetErrMsg("msgLoadDataError"); btnApply.Enabled = false; } }