private void GenMasterTableData(ref PccErrMsg myLabel) { #region 取得Login的使用者是否有刪除的權限 GetMenuAuth myAuth = new GetMenuAuth(); myAuth.AspxFile = "FactGroupManage104.aspx"; bool del_auth = myAuth.IsDeleteAuth(); #endregion #region 取得廠群組的主資料ByUpID bs_FactGroupManage mybs = new bs_FactGroupManage(ConfigurationManager.AppSettings["ConnectionType"], ConfigurationManager.AppSettings["ConnectionServer"], ConfigurationManager.AppSettings["ConnectionDB"], ConfigurationManager.AppSettings["ConnectionUser"], ConfigurationManager.AppSettings["ConnectionPwd"], Session["UserIDAndName"].ToString(), ConfigurationManager.AppSettings["EventLogPath"]); PccMsg myMsg = new PccMsg(); myMsg.CreateFirstNode("StartRecord", PageControl1.StartRecord.ToString()); myMsg.CreateFirstNode("PageSize", PageControl1.PageSize.ToString()); myMsg.CreateFirstNode("Up_Id", m_SrcUp_Id); myMsg.CreateFirstNode("Ap_Id", m_ApID); myMsg.CreateFirstNode("Fgrp_Nm", TxtQueryFgrpNm.Text); string strXML = myMsg.GetXmlStr; DataSet myDS_FGRPDs = mybs.DoReturnDataSet("Get_DS_FGRPByUpID", strXML, ""); DataTable myDS_FGRPData = myDS_FGRPDs.Tables["DS_FGRPByUpID"]; #endregion if (myDS_FGRPData != null && myDS_FGRPData.Rows.Count > 0) { #region 定義基本變數 int MasterCount = 0; string MasterStyle = string.Empty; PccMsg myTempMsg; PccMsg myMsg1; PccRow myRow; //取出資料總筆數 PageControl1.TotalSize = myDS_FGRPDs.Tables["TCounts"].Rows[0]["Counts"].ToString(); PageControl1.BuildPager(); #endregion #region 明細資料類別之共同參數 myMsg.LoadXml(); myMsg.CreateFirstNode("TableClass", "ActDocTB"); myMsg.CreateFirstNode("RowHeaderClass", "TDShowHeader"); myMsg.CreateFirstNode("RowClass1", "ffd000"); myMsg.CreateFirstNode("RowClass2", "fff000"); string strClassXML = myMsg.GetXmlStr; XmlElement myNode; //要取得明細資料的Table變數 DataTable tblUserGroup, tblFactGroup; #endregion #region 內建廠別明細資料的欄位參數 string[] FFields = { "編號", "廠別", "廠別名稱", "事業群", "公司編號", "刪除" }; int[] FFieldsPercent = { 5, 15, 35, 20, 15, 10 }; string[] FFieldsItem = { "--NO--", "fact_no", "fact_nm", "fgrp_nm", "comp_no", "factgrp_id" }; string[] FFieldType = new string[6]; FFieldType[0] = "--NO--"; FFieldType[1] = "<PccMsg><Type>Text</Type></PccMsg>"; FFieldType[2] = "<PccMsg><Type>Text</Type></PccMsg>"; FFieldType[3] = "<PccMsg><Type>Text</Type></PccMsg>"; FFieldType[4] = "<PccMsg><Type>Text</Type></PccMsg>"; #endregion #region 內建使用者明細資料的欄位參數 string[] UFields = { "編號", "電子郵件帳號", "姓名", "廠別", "事業群", "分機", "刪除" }; int[] UFieldsPercent = { 5, 30, 15, 15, 15, 10, 10 }; string[] UFieldsItem = { "--NO--", "email", "user_desc", "fact_no", "fgrp_nm", "ext", "usergrp_id" }; string[] UFieldType = new string[7]; UFieldType[0] = "--NO--"; UFieldType[1] = "<PccMsg><Type>Text</Type></PccMsg>"; UFieldType[2] = "<PccMsg><Type>Text</Type></PccMsg>"; UFieldType[3] = "<PccMsg><Type>Text</Type></PccMsg>"; UFieldType[4] = "<PccMsg><Type>Text</Type></PccMsg>"; UFieldType[5] = "<PccMsg><Type>Text</Type></PccMsg>"; #endregion //再利用此Table再取得其每一列的資料,再Gen出主要的Table Row. foreach (DataRow myMasterRow in myDS_FGRPData.Rows) { #region 主要廠群組的資料列設定 if (MasterCount % 2 == 0) MasterStyle = "eee000"; else MasterStyle = "fff000"; myRow = new PccRow("", HorizontalAlign.Center, 0, 0); myRow.SetRowCss(MasterStyle); //編號 myRow.AddTextCell(PageControl1.ListCount, 5); //廠群組名稱 if (myAuth.IsAddAuth()) { myTempMsg = new PccMsg(); myTempMsg.CreateFirstNode("Href", PICKFACT + "?ApID=" + m_ApID + "&SrcUp_Id=" + m_SrcUp_Id + "&Up_Id=" + myMasterRow["Up_Id"].ToString() + "&Method=" + GetMethod("PickFactToFgrpFunc", "Fgrp_Id", "Fgrp_Nm", myMasterRow) + "&QueryCondition=" + GetQueryCondition()); myTempMsg.CreateFirstNode("Text", myMasterRow["Fgrp_Nm"].ToString().Trim()); myRow.AddLinkHrefCell(myTempMsg.GetXmlStr, 56); } else { myRow.AddTextCell(myMasterRow["Fgrp_Nm"].ToString(), 56); } //廠別檢視 myTempMsg = new PccMsg(); myTempMsg.CreateFirstNode("ToolTip", "檢視所屬廠別"); myTempMsg.CreateFirstNode("LinkID", "HLinkView" + myMasterRow["Fgrp_Id"].ToString()); myTempMsg.CreateFirstNode("Image", Session["PageLayer"] + "images/detal.gif"); myTempMsg.CreateFirstNode("ClickFun", "doSection(view_F" + MasterCount.ToString() + ")"); myRow.AddLinkCell(myTempMsg.GetXmlStr, 12); //使用者檢視 myTempMsg = new PccMsg(); myTempMsg.CreateFirstNode("ToolTip", "檢視所屬使用者"); myTempMsg.CreateFirstNode("LinkID", "HLinkView" + myMasterRow["Fgrp_Id"].ToString()); myTempMsg.CreateFirstNode("Image", Session["PageLayer"] + "images/detal.gif"); myTempMsg.CreateFirstNode("ClickFun", "doSection(view_U" + MasterCount.ToString() + ")"); myRow.AddLinkCell(myTempMsg.GetXmlStr, 12); //管理 myTempMsg = new PccMsg(); //判斷是否和上層ID是一樣的 if (myMasterRow["Fgrp_Id"].ToString() != Request.Params["SrcUp_Id"]) { //先加入修改的Item if (myAuth.IsUpdateAuth()) { myTempMsg.CreateNode("LinkButton"); myTempMsg.AddToNode("Image", Session["PageLayer"] + "images/edit.gif"); myTempMsg.AddToNode("ToolTip", myLabel.GetErrMsg("lbl0014", "SysManager/ApManager")); myTempMsg.AddToNode("href", MYURL + "?ApID=" + m_ApID + "&SrcUp_Id=" + m_SrcUp_Id + "&Up_Id=" + myMasterRow["Up_Id"].ToString()); myTempMsg.AddToNode("QueryCondition", GetQueryCondition()); myTempMsg.AddToNode("Method", GetMethod("MasterUpdateFunc", "Fgrp_Id", "Fgrp_Nm", myMasterRow)); myTempMsg.UpdateNode(); } if (del_auth) { //再加入刪除的Item myTempMsg.CreateNode("LinkButton"); myTempMsg.AddToNode("Image", Session["PageLayer"] + "images/del.gif"); myTempMsg.AddToNode("ToolTip", myLabel.GetErrMsg("lbl0015", "SysManager/ApManager")); myTempMsg.AddToNode("href", MYURL + "?ApID=" + m_ApID + "&SrcUp_Id=" + m_SrcUp_Id + "&Up_Id=" + myMasterRow["Up_Id"].ToString()); myTempMsg.AddToNode("QueryCondition", GetQueryCondition()); myTempMsg.AddToNode("Method", GetMethod("MasterDelFunc", "Fgrp_Id", "Fgrp_Nm", myMasterRow)); myTempMsg.UpdateNode(); } //再加入加入使用者的Item if (myAuth.IsAddAuth()) { myTempMsg.CreateNode("LinkButton"); myTempMsg.AddToNode("Image", Session["PageLayer"] + "images/add.gif"); myTempMsg.AddToNode("ToolTip", "加入使用者"); myTempMsg.AddToNode("href", PICKUSER + "?ApID=" + m_ApID + "&SrcUp_Id=" + m_SrcUp_Id + "&Up_Id=" + myMasterRow["Up_Id"].ToString()); myTempMsg.AddToNode("QueryCondition", GetQueryCondition()); myTempMsg.AddToNode("Method", GetMethod("AddUserFunc", "Fgrp_Id", "Fgrp_Nm", myMasterRow)); myTempMsg.UpdateNode(); } } myRow.AddMultiLinkCell(myTempMsg.GetXmlStr, 15); TblDs_Fgrp.Rows.Add(myRow.Row); #endregion #region 內建廠別明細資料的欄位參數,此處會取得資料,並設定給主表格 //設定廠別明細欄位中多個Link Image的參數 myMsg1 = new PccMsg(); if (del_auth && myMasterRow["Fgrp_Id"].ToString() != Request.Params["SrcUp_Id"]) { myMsg1.CreateFirstNode("Type", "MultiLink"); myMsg1.CreateNode("LinkButton"); myMsg1.AddToNode("Image", Session["PageLayer"] + "images/del.gif"); myMsg1.AddToNode("ToolTip", "刪除此廠別與此廠群組之關係"); myMsg1.AddToNode("href", MYURL + "?ApID=" + m_ApID + "&SrcUp_Id=" + m_SrcUp_Id + "&Up_Id=" + myMasterRow["Up_Id"].ToString() + "&Fgrp_Nm=" + myMasterRow["Fgrp_Nm"].ToString()); myMsg1.AddToNode("QueryCondition", GetQueryCondition()); myNode = myMsg1.CreateParentNode("Method"); myMsg1.AddToNode("MethodName", "FactDelFunc", ref myNode); myMsg1.AddToNode("Key", "factgrp_id", ref myNode); myMsg1.AddToNode("KeyOther", "fact_no", ref myNode); myMsg1.UpdateNode(myNode); myMsg1.UpdateNode(); } else { myMsg1.CreateFirstNode("Type", "Space"); } FFieldType[5] = myMsg1.GetXmlStr; //設定要取得廠別資料的XML myMsg1.LoadXml(); myMsg1.CreateFirstNode("Fgrp_Id", myMasterRow["Fgrp_Id"].ToString()); tblFactGroup = mybs.DoReturnDataSet("get_DS_FACTGRPByFgrpID", myMsg1.GetXmlStr, string.Empty).Tables["DS_FACTGRP"]; PccDetailTable myFDTable = new PccDetailTable("FDT" + myMasterRow["Fgrp_Id"].ToString()); myFDTable.ClassXML = strClassXML; myFDTable.Fields = FFields; myFDTable.FieldsPercent = FFieldsPercent; myFDTable.FieldsItem = FFieldsItem; myFDTable.FieldsType = FFieldType; myFDTable.NewDataTable = tblFactGroup; myFDTable.Create(); myRow.Reset(); myRow.SetRowCss("off"); myRow.SetRowID("view_F" + MasterCount); myRow.SetDefaultCellData("DGridTD", HorizontalAlign.Center, 0, 10); myRow.AddControl(myFDTable.NewTable, 100); TblDs_Fgrp.Rows.Add(myRow.Row); #endregion #region 內建使用者明細資料的欄位參數,此處會取得資料,並設定給主表格 //設定廠別明細欄位中多個Link Image的參數 myMsg1 = new PccMsg(); if (del_auth && myMasterRow["Fgrp_Id"].ToString() != Request.Params["SrcUp_Id"]) { myMsg1.CreateFirstNode("Type", "MultiLink"); myMsg1.CreateNode("LinkButton"); myMsg1.AddToNode("Image", Session["PageLayer"] + "images/del.gif"); myMsg1.AddToNode("ToolTip", "刪除此使用者與此廠群組之關係"); myMsg1.AddToNode("href", MYURL + "?ApID=" + m_ApID + "&SrcUp_Id=" + m_SrcUp_Id + "&Up_Id=" + myMasterRow["Up_Id"].ToString() + "&Fgrp_Nm=" + myMasterRow["Fgrp_Nm"].ToString()); myMsg1.AddToNode("QueryCondition", GetQueryCondition()); myNode = myMsg1.CreateParentNode("Method"); myMsg1.AddToNode("MethodName", "UserDelFunc", ref myNode); myMsg1.AddToNode("Key", "usergrp_id", ref myNode); myMsg1.AddToNode("KeyOther", "user_desc", ref myNode); myMsg1.UpdateNode(myNode); myMsg1.UpdateNode(); } else { myMsg1.CreateFirstNode("Type", "Space"); } UFieldType[6] = myMsg1.GetXmlStr; //設定要取得廠別資料的XML myMsg1.LoadXml(); myMsg1.CreateFirstNode("Fgrp_Id", myMasterRow["Fgrp_Id"].ToString()); tblUserGroup = mybs.DoReturnDataSet("get_DS_USERGRPByFgrpID", myMsg1.GetXmlStr, string.Empty).Tables["DS_USERGRP"]; PccDetailTable myUDTable = new PccDetailTable("UDT" + myMasterRow["Fgrp_Id"].ToString()); myUDTable.ClassXML = strClassXML; myUDTable.Fields = UFields; myUDTable.FieldsPercent = UFieldsPercent; myUDTable.FieldsItem = UFieldsItem; myUDTable.FieldsType = UFieldType; myUDTable.NewDataTable = tblUserGroup; myUDTable.Create(); myRow.Reset(); myRow.SetRowCss("off"); myRow.SetRowID("view_U" + MasterCount); myRow.SetDefaultCellData("DGridTD", HorizontalAlign.Center, 0, 10); myRow.AddControl(myUDTable.NewTable, 100); TblDs_Fgrp.Rows.Add(myRow.Row); #endregion MasterCount += 1; } // end of foreach datarow }// end of if table count is 0 else { PageControl1.TotalSize = "0"; PageControl1.BuildPager(); } }
private void GenMasterTableData(ref PccErrMsg myLabel) { //取得Login的使用者是否有刪除的權限 GetMenuAuth myAuth = new GetMenuAuth(); bool del_auth = myAuth.IsDeleteAuth(); PccBsSystemForC.bs_ApManager mybs = new PccBsSystemForC.bs_ApManager(ConfigurationManager.AppSettings["ConnectionType"], ConfigurationManager.AppSettings["ConnectionServer"], ConfigurationManager.AppSettings["ConnectionDB"], ConfigurationManager.AppSettings["ConnectionUser"], ConfigurationManager.AppSettings["ConnectionPwd"], Session["UserIDAndName"].ToString(), ConfigurationManager.AppSettings["EventLogPath"]); PccMsg myMsg = new PccMsg(); myMsg.CreateFirstNode("StartRecord", PageControl1.StartRecord.ToString()); myMsg.CreateFirstNode("PageSize", PageControl1.PageSize.ToString()); myMsg.CreateFirstNode("Vpath", ConfigurationManager.AppSettings["vpath"].ToString()); myMsg.CreateFirstNode("ApName", txtApName.Text); string strXML = myMsg.GetXmlStr; DataSet myApDs = mybs.DoReturnDataSet("GetApByVpath", strXML, ""); DataTable myApData = myApDs.Tables["Ap"]; if (myApData.Rows.Count > 0) { int MasterCount = 0; string MasterStyle = ""; PccMsg myTempMsg; PccRow myRow; //取出資料總筆數 PageControl1.TotalSize = myApDs.Tables["TCounts"].Rows[0]["Counts"].ToString(); PageControl1.BuildPager(); //明細資料類別之共同參數 myMsg.LoadXml(); myMsg.CreateFirstNode("TableClass", "ActDocTB"); myMsg.CreateFirstNode("RowHeaderClass", "TDShowHeader"); myMsg.CreateFirstNode("RowClass1", "ffd000"); myMsg.CreateFirstNode("RowClass2", "fff000"); string strClassXML = myMsg.GetXmlStr; XmlElement myNode; //明細資料的欄位參數 string strOrgFields5 = "link-新增選單-" + MENUADDNEW + "?ApID=" + Request.Params["ApID"].ToString() + "&Type=New&QueryCondition=" + GetQueryCondition(); string[] Fields = { "編號", "選單編碼", "選單名稱", "選單連結", "管理區", strOrgFields5 }; int[] FieldsPercent = { 5, 8, 17, 50, 10, 10 }; string[] FieldsItem = { "--NO--", "menu_no", "menu_nm", "menu_link", "manage_mk", "menu_id" }; string[] FieldsType = new string[6]; FieldsType[0] = "--NO--"; FieldsType[1] = "<PccMsg><Type>Text</Type></PccMsg>"; FieldsType[2] = "<PccMsg><Type>Text</Type></PccMsg>"; FieldsType[3] = "<PccMsg><Type>Text</Type></PccMsg>"; FieldsType[4] = "<PccMsg><Type>Text</Type></PccMsg>"; //設定明細欄位中多個Link Image的參數 myMsg.LoadXml(); myMsg.CreateFirstNode("Type", "MultiLink"); //設定第一個更新選單的Image參數 myMsg.CreateNode("LinkButton"); myMsg.AddToNode("Image", Session["PageLayer"] + "images/edit.gif"); myMsg.AddToNode("ToolTip", "更新選單"); myMsg.AddToNode("href", MENUADDNEW + "?ApID=" + Request.Params["ApID"].ToString()); myMsg.AddToNode("QueryCondition", GetQueryCondition()); myNode = myMsg.CreateParentNode("Method"); myMsg.AddToNode("MethodName", "DetailUpdFunc", ref myNode); myMsg.AddToNode("Key", "menu_id", ref myNode); myMsg.AddToNode("KeyOther", "menu_nm", ref myNode); myMsg.UpdateNode(myNode); myMsg.UpdateNode(); if (del_auth) { //設定第二個刪除選單的Image參數 myMsg.CreateNode("LinkButton"); myMsg.AddToNode("Image", Session["PageLayer"] + "images/del.gif"); myMsg.AddToNode("ToolTip", "刪除選單"); myMsg.AddToNode("href", APMANAGE + "?ApID=" + Request.Params["ApID"].ToString()); myMsg.AddToNode("QueryCondition", GetQueryCondition()); myNode = myMsg.CreateParentNode("Method"); myMsg.AddToNode("MethodName", "DetailDelFunc", ref myNode); myMsg.AddToNode("Key", "menu_id", ref myNode); myMsg.AddToNode("KeyOther", "menu_nm", ref myNode); myMsg.UpdateNode(myNode); myMsg.UpdateNode(); } FieldsType[5] = myMsg.GetXmlStr; //要取得明細資料的Table變數 DataTable tblMenuByApID; //再利用此Table再取得其每一列的資料,再Gen出主要的Table Row. foreach (DataRow myMasterRow in myApData.Rows) { if (MasterCount % 2 == 0) MasterStyle = "eee000"; else MasterStyle = "fff000"; myRow = new PccRow(); myRow.SetRowCss(MasterStyle); //編號 myRow.AddTextCell(PageControl1.ListCount, 5); //應用程式編碼 myRow.AddTextCell(myMasterRow["ap_id"].ToString(), 10); //應用程式名稱 myRow.AddTextCell(myMasterRow["ap_name"].ToString(), 15); //應用程式連結 myRow.AddTextCell(myMasterRow["ap_link"].ToString(), 40); //應用程式目錄 myRow.AddTextCell(myMasterRow["ap_vpath"].ToString(), 15); //檢視 myTempMsg = new PccMsg(); myTempMsg.CreateFirstNode("ToolTip", myLabel.GetErrMsg("lbl0018", "SysManager/ApManager")); myTempMsg.CreateFirstNode("LinkID", "HLinkView" + myMasterRow["ap_id"].ToString()); myTempMsg.CreateFirstNode("Image", Session["PageLayer"] + "images/detal.gif"); myTempMsg.CreateFirstNode("ClickFun", "doSection(view_" + MasterCount.ToString() + ")"); myRow.AddLinkCell(myTempMsg.GetXmlStr, 5); //管理 myTempMsg.LoadXml(); //先加入修改的Item myTempMsg.CreateNode("LinkButton"); myTempMsg.AddToNode("Image", Session["PageLayer"] + "images/edit.gif"); myTempMsg.AddToNode("ToolTip", myLabel.GetErrMsg("lbl0014", "SysManager/ApManager")); myTempMsg.AddToNode("href", APADDNEW + "?ApID=" + Request.Params["ApID"].ToString()); myTempMsg.AddToNode("QueryCondition", GetQueryCondition()); myTempMsg.AddToNode("Method", GetMethod("MasterUpdateFunc", "ap_id", "ap_name", myMasterRow)); myTempMsg.UpdateNode(); if (del_auth) { //再加入刪除的Item myTempMsg.CreateNode("LinkButton"); myTempMsg.AddToNode("Image", Session["PageLayer"] + "images/del.gif"); myTempMsg.AddToNode("ToolTip", myLabel.GetErrMsg("lbl0015", "SysManager/ApManager")); myTempMsg.AddToNode("href", APMANAGE + "?ApID=" + Request.Params["ApID"].ToString()); myTempMsg.AddToNode("QueryCondition", GetQueryCondition()); myTempMsg.AddToNode("Method", GetMethod("MasterDelFunc", "ap_id", "ap_name", myMasterRow)); myTempMsg.UpdateNode(); } myRow.AddMultiLinkCell(myTempMsg.GetXmlStr, 5); tblAp.Rows.Add(myRow.Row); tblMenuByApID = mybs.DoReturnDataSet("GetMenuByApID", "<PccMsg><ap_id>" + myMasterRow["ap_id"].ToString() + "</ap_id></PccMsg>", "").Tables["Menu"]; //設定選單明細資料類別之參數 PccDetailTable myDTable = new PccDetailTable("DT" + myMasterRow["ap_id"].ToString()); myDTable.ClassXML = strClassXML; Fields[5] = strOrgFields5 + "&Key=" + myMasterRow["ap_id"].ToString(); myDTable.Fields = Fields; myDTable.FieldsPercent = FieldsPercent; myDTable.FieldsItem = FieldsItem; myDTable.FieldsType = FieldsType; myDTable.NewDataTable = tblMenuByApID; myDTable.Create(); myRow.Reset(); myRow.SetRowCss("off"); myRow.SetRowID("view_" + MasterCount); myRow.SetDefaultCellData("DGridTD", HorizontalAlign.Center, 0, 10); myRow.AddControl(myDTable.NewTable, 100); tblAp.Rows.Add(myRow.Row); MasterCount += 1; } // end of foreach datarow } // end of if table count is 0 else { PageControl1.TotalSize = "0"; PageControl1.BuildPager(); } }