private void GenMasterTableData(ref PccErrMsg myLabel)
    {
        PccMsg myMsg = new PccMsg();
        string strUserID = "";
        if (CheckQueryString("Method") != "")
        {
            myMsg.LoadXml(CheckQueryString("Method"));
            strUserID = myMsg.Query("Key");
            ViewState["UserID"] = strUserID;
        }
        else
        {
            lblMsg.Text = "Load Error!!!";
            return;
        }

        bs_GroupManage mybs = new PccBsSystemForC.bs_GroupManage(ConfigurationManager.AppSettings["ConnectionType"], ConfigurationManager.AppSettings["ConnectionServer"], ConfigurationManager.AppSettings["ConnectionDB"], ConfigurationManager.AppSettings["ConnectionUser"], ConfigurationManager.AppSettings["ConnectionPwd"], Session["UserIDAndName"].ToString(), ConfigurationManager.AppSettings["EventLogPath"]);
        myMsg.LoadXml();
        myMsg.CreateFirstNode("ap_id", CheckQueryString("ApID"));
        myMsg.CreateFirstNode("user_id", strUserID);
        myMsg.CreateFirstNode("StartRecord", "0");
        myMsg.CreateFirstNode("PageSize", "3000");
        myMsg.CreateFirstNode("group_nm", "");

        //加入判斷是否要有事業群之判斷20041116
        myMsg.CreateFirstNode("page_check", "UserJoinGroup104");
        myMsg.CreateFirstNode("login_user_id", Session["UserID"].ToString());
        GetMenuAuth myAuth = new GetMenuAuth();
        myAuth.AspxFile = "UserManage104.aspx";

        //判斷是否要利用事業群來分設權限
        if (ConfigurationManager.AppSettings[m_apid + "-FactByGroup"] != null && ConfigurationManager.AppSettings[m_apid + "-FactByGroup"].ToString() == "Y")
        {
            //判斷此使用者是否可以分配不同的事業群權限
            if (!myAuth.IsReportAuth())
            {
                //表示他必須區分事業群
                myMsg.CreateFirstNode("GroupFilter", "Y");
            }
            else
            {
                myMsg.CreateFirstNode("GroupFilter", "N");
            }
        }
        else
        {
            myMsg.CreateFirstNode("GroupFilter", "N");
        }

        if (ConfigurationManager.AppSettings[m_apid + "-FactFilter"] != null && ConfigurationManager.AppSettings[m_apid + "-FactFilter"].ToString() == "Y")
        {
            //表示他必須區分廠管理 20041118 注意要區別廠管理的先決條件是要區分事業群
            myMsg.CreateFirstNode("FactFilter", "Y");
        }

        DataSet myGroupDs = mybs.DoReturnDataSet("GetGroupAndUserCheckByApID", myMsg.GetXmlStr, "");
        DataTable myGroupData = myGroupDs.Tables["Group"];

        if (myGroupData.Rows.Count > 0)
        {
            ViewState["group_org"] = "";

            int MasterCount = 0;
            string MasterStyle = "";
            PccMsg myTempMsg;

            PccRow myRow;

            //明細資料類別之共同參數
            myMsg.LoadXml();
            myMsg.CreateFirstNode("TableClass", "ActDocTB");
            myMsg.CreateFirstNode("RowHeaderClass", "TDShowHeader");
            myMsg.CreateFirstNode("RowClass1", "ffd000");
            myMsg.CreateFirstNode("RowClass2", "fff000");
            string strClassXML = myMsg.GetXmlStr;

            //明細資料的欄位參數
            string[] Fields = { "編號", "選單名稱", "顯示權限", "新增權限", "更新權限", "刪除權限", "報表權限", "發信權限" };
            int[] FieldsPercent = { 5, 35, 10, 10, 10, 10, 10, 10 };
            string[] FieldsItem = { "--NO--", "menu_nm", "show_mk", "add_mk", "upd_mk", "del_mk", "rpt_mk", "send_mk" };
            string[] FieldsType = new string[8];
            FieldsType[0] = "--NO--";
            FieldsType[1] = "<PccMsg><Type>Text</Type></PccMsg>";
            FieldsType[2] = "<PccMsg><Type>CheckBoxReadOnly</Type><Value>menu_id</Value></PccMsg>";
            FieldsType[3] = "<PccMsg><Type>CheckBoxReadOnly</Type><Value>menu_id</Value></PccMsg>";
            FieldsType[4] = "<PccMsg><Type>CheckBoxReadOnly</Type><Value>menu_id</Value></PccMsg>";
            FieldsType[5] = "<PccMsg><Type>CheckBoxReadOnly</Type><Value>menu_id</Value></PccMsg>";
            FieldsType[6] = "<PccMsg><Type>CheckBoxReadOnly</Type><Value>menu_id</Value></PccMsg>";
            FieldsType[7] = "<PccMsg><Type>CheckBoxReadOnly</Type><Value>menu_id</Value></PccMsg>";

            //要取得明細資料的Table變數
            DataTable tblMenuByGroupID;

            //再利用此Table再取得其每一列的資料,再Gen出主要的Table Row.
            foreach (DataRow myMasterRow in myGroupData.Rows)
            {
                if (MasterCount % 2 == 0) MasterStyle = "eee000"; else MasterStyle = "fff000";
                myRow = new PccRow("", HorizontalAlign.Center, 0, 0);
                myRow.SetRowCss(MasterStyle);
                //編號
                myRow.AddTextCell(ListCount, 10);
                //群組名稱
                myRow.AddTextCell(myMasterRow["group_nm"].ToString(), 60);
                //檢視
                myTempMsg = new PccMsg();
                myTempMsg.CreateFirstNode("ToolTip", myLabel.GetErrMsg("lbl0021", "ADTPurDoc/GroupManage"));
                myTempMsg.CreateFirstNode("LinkID", "HlinkView" + myMasterRow["group_id"].ToString());
                myTempMsg.CreateFirstNode("Image", Session["PageLayer"] + "images/detal.gif");
                myTempMsg.CreateFirstNode("ClickFun", "doSection(view_" + MasterCount.ToString() + ")");
                myRow.AddLinkCell(myTempMsg.GetXmlStr, 20);
                //選擇
                myTempMsg.LoadXml();
                myTempMsg.CreateFirstNode("Checked", myMasterRow["UserCheck"].ToString());
                myTempMsg.CreateFirstNode("Name", "JoinGroupID");
                myTempMsg.CreateFirstNode("Value", myMasterRow["group_id"].ToString());
                myRow.AddCheckBoxByValueCell(myTempMsg.GetXmlStr, 10);

                //設定原始的GroupID的資料
                if (myMasterRow["UserCheck"].ToString() == "Y")
                    ViewState["group_org"] += myMasterRow["group_id"].ToString() + ",";

                tblGroup.Rows.Add(myRow.Row);

                tblMenuByGroupID = mybs.DoReturnDataSet("GetMenuByGroupID", "<PccMsg><group_id>" + myMasterRow["group_id"].ToString() + "</group_id></PccMsg>", "").Tables["MenuGroup"];

                //設定選單明細資料類別之參數
                PccDetailTable myDTable = new PccDetailTable("DT" + myMasterRow["group_id"].ToString());
                myDTable.ClassXML = strClassXML;
                myDTable.Fields = Fields;
                myDTable.FieldsPercent = FieldsPercent;
                myDTable.FieldsItem = FieldsItem;
                myDTable.FieldsType = FieldsType;
                myDTable.NewDataTable = tblMenuByGroupID;

                myDTable.Create();

                myRow.Reset();
                myRow.SetRowCss("off");
                myRow.SetRowID("view_" + MasterCount);
                myRow.SetDefaultCellData("DGridTD", HorizontalAlign.Center, 0, 10);
                myRow.AddControl(myDTable.NewTable, 100);

                tblGroup.Rows.Add(myRow.Row);

                MasterCount += 1;

            } // end of foreach datarow

            if (ViewState["group_org"].ToString() != "")
                ViewState["group_org"] = ViewState["group_org"].ToString().Substring(0, ViewState["group_org"].ToString().Length - 1);
            else
                ViewState["group_org"] = "";

        } // end of if table count is 0
    }
Esempio n. 2
0
    public bool Create()
    {
        bool bReturn = false;

        if (m_Table == null) return bReturn;

        GenDetailTableHeader();

        int i, Start_SC = 1;
        string Style_SC;
        PccRow myRow;
        PccMsg myMsg;
        PccMsg myTempMsg;

        GetMenuAuth myAuth = new GetMenuAuth();

        if (m_myDTableData != null)
        {
            foreach (DataRow myDRow in m_myDTableData.Rows)
            {
                if (Start_SC % 2 == 0) Style_SC = m_RowClass1; else Style_SC = m_RowClass2;

                myRow = new PccRow("", HorizontalAlign.Center, VerticalAlign.Middle, 0);
                myRow.SetRowCss(Style_SC);

                string strData = "";

                for (i = 0; i < m_FieldsItem.Length; i++)
                {
                    if (m_FieldsItem[i] != "--NO--")
                    {
                        myMsg = new PccMsg(m_FieldsType[i]);

                        if (myMsg.Query("Type") != "Space")
                        {
                            if (Convert.IsDBNull(myDRow[m_FieldsItem[i]]))
                            {
                                strData = "";
                            }
                            else
                            {
                                if (m_TransFunc.Length != 0)
                                {
                                    try
                                    {
                                        strData = CallTrnasFunc(m_objThis, m_TransFunc[i], myDRow[m_FieldsItem[i]].ToString());
                                    }
                                    catch (Exception ex)
                                    {
                                        strData = myDRow[m_FieldsItem[i]].ToString() + ex.Message;
                                    }

                                }
                                else
                                {
                                    strData = myDRow[m_FieldsItem[i]].ToString();
                                }
                            }
                        }

                        switch (myMsg.Query("Type"))
                        {
                            case "Text":
                                //myRow.AddTextCell(myDRow[m_FieldsItem[i]].ToString(),m_FieldsPercent[i]);
                                //myRow.AddTextCell(strData,m_FieldsPercent[i]);
                                if (myMsg.Query("HAlign").Equals(string.Empty))
                                    myRow.AddTextCell(strData, m_FieldsPercent[i]);
                                else
                                {
                                    switch (myMsg.Query("HAlign"))
                                    {
                                        case "Center":
                                            myRow.AddTextCell(strData, m_FieldsPercent[i], HorizontalAlign.Center);
                                            break;
                                        case "Right":
                                            if ((myMsg.Query("Round").Equals(string.Empty)) || (strData.Equals(string.Empty)))
                                            {
                                                myRow.AddTextCell(strData, m_FieldsPercent[i], HorizontalAlign.Right);
                                            }
                                            else
                                            {
                                                int round = int.Parse(myMsg.Query("Round"));
                                                decimal temp = decimal.Parse(strData);
                                                temp = Math.Round(temp, round);
                                                myRow.AddTextCell(temp.ToString(), m_FieldsPercent[i], HorizontalAlign.Right);

                                            }
                                            break;
                                        case "Left":
                                            myRow.AddTextCell(strData, m_FieldsPercent[i], HorizontalAlign.Left);
                                            break;
                                    }
                                }
                                break;
                            case "ImageButton":
                                break;
                            case "HyperLink":
                                break;
                            case "LinkButton":
                                break;
                            case "CheckBox":
                                myTempMsg = new PccMsg();
                                //myTempMsg.CreateFirstNode("Checked",myDRow[m_FieldsItem[i]].ToString());
                                myTempMsg.CreateFirstNode("Checked", strData);
                                myTempMsg.CreateFirstNode("Name", m_TableName);
                                myTempMsg.CreateFirstNode("Value", myDRow[myMsg.Query("Value")].ToString());
                                myRow.AddCheckBoxByValueCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);
                                break;
                            case "CheckBoxReadOnly":
                                myTempMsg = new PccMsg();
                                //myTempMsg.CreateFirstNode("Checked",myDRow[m_FieldsItem[i]].ToString());
                                myTempMsg.CreateFirstNode("Checked", strData);
                                myTempMsg.CreateFirstNode("Name", m_FieldsItem[i] + m_TableName);
                                myTempMsg.CreateFirstNode("Value", myDRow[myMsg.Query("Value")].ToString());
                                myRow.AddCheckBoxReadOnlyCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);
                                break;
                            case "CheckBoxByValue":
                                myTempMsg = new PccMsg();
                                //myTempMsg.CreateFirstNode("Checked",myDRow[m_FieldsItem[i]].ToString());
                                myTempMsg.CreateFirstNode("Checked", strData);
                                myTempMsg.CreateFirstNode("Name", m_FieldsItem[i] + m_TableName);
                                myTempMsg.CreateFirstNode("Value", myDRow[myMsg.Query("Value")].ToString());
                                myRow.AddCheckBoxByValueCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);
                                break;
                            case "CheckBoxByValueJudgeUserRight":
                                myTempMsg = new PccMsg();
                                myTempMsg.CreateFirstNode("Checked", strData);
                                myTempMsg.CreateFirstNode("Name", m_FieldsItem[i] + m_TableName);
                                myTempMsg.CreateFirstNode("Value", myDRow[myMsg.Query("Value")].ToString());
                                myAuth.Url = myDRow["menu_link"].ToString();
                                if (myAuth.GetAuth(m_FieldsItem[i]) == "Y")
                                    myRow.AddCheckBoxByValueCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);
                                else
                                    myRow.AddCheckBoxReadOnlyCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);

                                break;
                            case "MultiLink":
                                myRow.AddMultiLinkCell(GenMultiLinkXML(myDRow, m_FieldsType[i]), m_FieldsPercent[i]);
                                break;
                            case "Space":
                                myRow.AddTextCell("", m_FieldsPercent[i]);
                                break;
                            default:
                                break;
                        }
                    }
                    else
                    {
                        myRow.AddTextCell(Start_SC.ToString(), m_FieldsPercent[i]);
                    }
                }

                m_Table.Controls.Add(myRow.Row);

                Start_SC += 1;
            }
        }
        else
        {
            foreach (DataRow myDRow in m_myRows)
            {
                if (Start_SC % 2 == 0) Style_SC = m_RowClass1; else Style_SC = m_RowClass2;

                myRow = new PccRow("", HorizontalAlign.Center, VerticalAlign.Middle, 0);
                myRow.SetRowCss(Style_SC);

                string strData = "";

                for (i = 0; i < m_FieldsItem.Length; i++)
                {
                    if (m_FieldsItem[i] != "--NO--")
                    {
                        myMsg = new PccMsg(m_FieldsType[i]);

                        if (myMsg.Query("Type") != "Space")
                        {
                            if (Convert.IsDBNull(myDRow[m_FieldsItem[i]]))
                            {
                                strData = "";
                            }
                            else
                            {
                                if (m_TransFunc.Length != 0)
                                {
                                    try
                                    {
                                        strData = CallTrnasFunc(m_objThis, m_TransFunc[i], myDRow[m_FieldsItem[i]].ToString());
                                    }
                                    catch (Exception ex)
                                    {
                                        strData = myDRow[m_FieldsItem[i]].ToString() + ex.Message;
                                    }

                                }
                                else
                                {
                                    strData = myDRow[m_FieldsItem[i]].ToString();
                                }
                            }
                        }

                        switch (myMsg.Query("Type"))
                        {
                            case "Text":
                                //myRow.AddTextCell(myDRow[m_FieldsItem[i]].ToString(),m_FieldsPercent[i]);
                                if (myMsg.Query("HAlign").Equals(string.Empty))
                                    myRow.AddTextCell(strData, m_FieldsPercent[i]);
                                else
                                {
                                    switch (myMsg.Query("HAlign"))
                                    {
                                        case "Center":
                                            myRow.AddTextCell(strData, m_FieldsPercent[i], HorizontalAlign.Center);
                                            break;
                                        case "Right":
                                            if ((myMsg.Query("Round").Equals(string.Empty)) || (strData.Equals(string.Empty)))
                                            {
                                                myRow.AddTextCell(strData, m_FieldsPercent[i], HorizontalAlign.Right);
                                            }
                                            else
                                            {
                                                int round = int.Parse(myMsg.Query("Round"));
                                                decimal temp = decimal.Parse(strData);
                                                temp = Math.Round(temp, round);
                                                myRow.AddTextCell(temp.ToString(), m_FieldsPercent[i], HorizontalAlign.Right);

                                            }
                                            break;
                                        case "Left":
                                            myRow.AddTextCell(strData, m_FieldsPercent[i], HorizontalAlign.Left);
                                            break;
                                    }
                                }

                                break;
                            case "ImageButton":
                                break;
                            case "HyperLink":
                                break;
                            case "LinkButton":
                                break;
                            case "CheckBox":
                                myTempMsg = new PccMsg();
                                //myTempMsg.CreateFirstNode("Checked",myDRow[m_FieldsItem[i]].ToString());
                                myTempMsg.CreateFirstNode("Checked", strData);
                                myTempMsg.CreateFirstNode("Name", m_TableName);
                                myTempMsg.CreateFirstNode("Value", myDRow[myMsg.Query("Value")].ToString());
                                myRow.AddCheckBoxByValueCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);
                                break;
                            case "CheckBoxReadOnly":
                                myTempMsg = new PccMsg();
                                //myTempMsg.CreateFirstNode("Checked",myDRow[m_FieldsItem[i]].ToString());
                                myTempMsg.CreateFirstNode("Checked", strData);
                                myTempMsg.CreateFirstNode("Name", m_FieldsItem[i] + m_TableName);
                                myTempMsg.CreateFirstNode("Value", myDRow[myMsg.Query("Value")].ToString());
                                myRow.AddCheckBoxReadOnlyCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);
                                break;
                            case "CheckBoxByValue":
                                myTempMsg = new PccMsg();
                                //myTempMsg.CreateFirstNode("Checked",myDRow[m_FieldsItem[i]].ToString());
                                myTempMsg.CreateFirstNode("Checked", strData);
                                myTempMsg.CreateFirstNode("Name", m_FieldsItem[i] + m_TableName);
                                myTempMsg.CreateFirstNode("Value", myDRow[myMsg.Query("Value")].ToString());
                                myRow.AddCheckBoxByValueCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);
                                break;
                            case "CheckBoxByValueJudgeUserRight":
                                myTempMsg = new PccMsg();
                                myTempMsg.CreateFirstNode("Checked", strData);
                                myTempMsg.CreateFirstNode("Name", m_FieldsItem[i] + m_TableName);
                                myTempMsg.CreateFirstNode("Value", myDRow[myMsg.Query("Value")].ToString());
                                myAuth.Url = myDRow["menu_link"].ToString();
                                if (myAuth.GetAuth(m_FieldsItem[i]) == "Y")
                                    myRow.AddCheckBoxByValueCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);
                                else
                                    myRow.AddCheckBoxReadOnlyCell(myTempMsg.GetXmlStr, m_FieldsPercent[i]);

                                break;
                            case "MultiLink":
                                myRow.AddMultiLinkCell(GenMultiLinkXML(myDRow, m_FieldsType[i]), m_FieldsPercent[i]);
                                break;
                            case "Space":
                                myRow.AddTextCell("", m_FieldsPercent[i]);
                                break;
                            default:
                                break;
                        }
                    }
                    else
                    {
                        myRow.AddTextCell(Start_SC.ToString(), m_FieldsPercent[i]);
                    }
                }

                m_Table.Controls.Add(myRow.Row);

                Start_SC += 1;
            }
        }

        bReturn = true;
        return bReturn;
    }
    private void GenMasterTableData(ref PccErrMsg myLabel)
    {
        #region 取得Login的使用者是否有刪除的權限

        GetMenuAuth myAuth = new GetMenuAuth();
        myAuth.AspxFile = "FactGroupManage104.aspx";
        bool del_auth = myAuth.IsDeleteAuth();

        //判斷是否為系統超級管理者
        string superAdmin = "N";
        if (ConfigurationManager.AppSettings["superAdminEmail"].Equals(Session["UserEMail"].ToString()))
        {
            superAdmin = "Y";
        }

        #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("Ap_Id", Request.Params["ApID"]);
        myMsg.CreateFirstNode("LoginUser_Id", Session["UserID"].ToString());
        myMsg.CreateFirstNode("SuperAdmin", superAdmin);
        myMsg.CreateFirstNode("CheckUser_Id", Request.Params["UserID"]);
        string strXML = myMsg.GetXmlStr;

        DataSet myDS_FGRPDs = mybs.DoReturnDataSet("GetFgrpByLoginUserAndCheck", strXML, "");
        DataTable myDS_FGRPData = myDS_FGRPDs.Tables["FgrpByLoginUserAndCheck"];

        #endregion

        if (myDS_FGRPData != null && myDS_FGRPData.Rows.Count > 0)
        {
            #region 定義基本變數

            ViewState["group_org"] = "";
            int MasterCount = 0;
            string MasterStyle = string.Empty;
            PccMsg myTempMsg;
            PccMsg myMsg1;
            PccRow myRow;

            #endregion

            #region 明細資料類別之共同參數

            myMsg.LoadXml();
            myMsg.CreateFirstNode("TableClass", "ActDocTB");
            myMsg.CreateFirstNode("RowHeaderClass", "TDShowHeader");
            myMsg.CreateFirstNode("RowClass1", "ffd000");
            myMsg.CreateFirstNode("RowClass2", "fff000");
            string strClassXML = myMsg.GetXmlStr;

            //要取得明細資料的Table變數
            DataTable tblFactGroup;

            #endregion

            #region 內建廠別明細資料的欄位參數

            string[] FFields = { "編號", "廠別", "廠別名稱", "事業群", "公司編號" };
            int[] FFieldsPercent = { 5, 15, 40, 20, 20 };
            string[] FFieldsItem = { "--NO--", "fact_no", "fact_nm", "fgrp_nm", "comp_no" };
            string[] FFieldType = new string[5];
            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

            //再利用此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(MasterCount.ToString(), 5);
                //廠群組名稱
                myRow.AddTextCell(myMasterRow["Fgrp_Nm"].ToString(), 60);
                //廠別檢視
                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, 20);
                //選取
                myTempMsg.LoadXml();
                myTempMsg.CreateFirstNode("Checked", myMasterRow["IsChecked"].ToString());
                myTempMsg.CreateFirstNode("Name", "JoinFgrpID");
                myTempMsg.CreateFirstNode("Value", myMasterRow["Fgrp_Id"].ToString());
                myRow.AddCheckBoxByValueCell(myTempMsg.GetXmlStr, 15);

                //設定原始的FgrpID的資料
                if (myMasterRow["IsChecked"].ToString() == "Y")
                    ViewState["Fgrp_Org"] += myMasterRow["Fgrp_Id"].ToString() + ",";

                TblDs_Fgrp.Rows.Add(myRow.Row);

                #endregion

                #region 內建廠別明細資料的欄位參數,此處會取得資料,並設定給主表格

                //設定要取得廠別資料的XML
                myMsg1 = new PccMsg();
                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

                MasterCount += 1;
            } // end of foreach datarow

            if (ViewState["Fgrp_Org"] != null && ViewState["Fgrp_Org"].ToString() != "")
                ViewState["Fgrp_Org"] = ViewState["Fgrp_Org"].ToString().Substring(0, ViewState["Fgrp_Org"].ToString().Length - 1);
            else
                ViewState["Fgrp_Org"] = "";
        }// end of if table count is 0
        else
        {
            //PageControl1.TotalSize = "0";
            //PageControl1.BuildPager();
        }
    }