protected void BtnAddNewOK_ServerClick(object sender, System.EventArgs e)
    {
        PccMsg myMsg = new PccMsg();
        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"]);
        string strReturn = string.Empty;
        string strMsg = string.Empty;
        if (ViewState["ActionType"] != null && ViewState["ActionType"].ToString() == "New")
        {
            strReturn = mybs.DoReturnStr("Insert_DS_FGRP", GenDBXML(), string.Empty);
            strMsg = "新增成功";
        }
        else
        {
            strReturn = mybs.DoReturnStr("Update_DS_FGRP", GenDBXML(), string.Empty);
            strMsg = "修改成功";
        }
        myMsg.LoadXml(strReturn);
        string strUrl = FACTGROUPMAANGE + "?ApID=" + m_ApID + "&SelectedNode=" + TreeView1.SelectedValue;
        //string strUrl = FACTGROUPMAANGE + "?ApID=" + m_ApID + "&SelectedNode=" + TreeView1.SelectedNodeIndex;

        if (myMsg.Query("returnValue") == "0")
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(),"New", "<script language=javascript>alert('" + strMsg + "');window.parent.location.href='" + strUrl + "';</script>");
        }
        else
        {
            LblErrMsg.Font.Size = FontUnit.Large;
            LblErrMsg.Text = myMsg.Query("errmsg");
        }
    }
    protected void btnDelOK1_Click(object sender, System.EventArgs e)
    {
        string strReturn = "";
        PccMsg myMsg = new PccMsg();
        myMsg.CreateFirstNode("User_Id", Request.Params["User_ID"]);
        myMsg.CreateFirstNode("Ap_Id", CheckQueryString("ApID"));
        myMsg.CreateFirstNode("Fgrp_Id", m_Fgrp_Id);
        myMsg.CreateFirstNode("Upd_Id", Session["UserID"].ToString());

        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"]);

        strReturn = mybs.DoReturnStr("deleteUserGrpByFgrpIDAndUserID", myMsg.GetXmlStr, "");

        myMsg.LoadXml(strReturn);
        if (myMsg.Query("returnValue") == "0")
        {
            lblMsg.Text = "";
            // ting
            Response.Redirect(MYURL + "?ApID=" + m_ap_id + "&QueryCondition=" + GetQueryCondition());
        }
        else
        {
            lblMsg.Font.Size = 12;
            lblMsg.Text = myMsg.Query("errmsg");
        }
    }
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        if (ViewState["CurrentValue"] == null && tab_fact.Rows.Count == 0) return;

        Temporary();
        string strFact = "";
        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"]);
        strFact = Session["FactFgrpTemporary"].ToString();
        if (strFact.Length == 0)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(),"New", "<script language=javascript>alert('您還未選擇任何廠別唷!');</script>");
            GenMasterTable();
            return;
        }

        PccMsg myMsg = new PccMsg();
        myMsg.CreateFirstNode("Ap_Id", m_Ap_Id);
        myMsg.CreateFirstNode("Fgrp_Id", m_Fgrp_Id);
        myMsg.CreateFirstNode("Fact_Str", strFact);
        myMsg.CreateFirstNode("Upd_Id", Session["UserID"].ToString());
        string strReturn = mybs.DoReturnStr("PickMultiFactToFgrp", myMsg.GetXmlStr, string.Empty);
        myMsg.LoadXml(strReturn);

        if (myMsg.Query("returnValue") != "0")
        {
            lblMsg.Font.Size = 12;
            lblMsg.Text = myMsg.Query("errmsg");
            return;
        }
        else
        {
            Session["FactFgrpTemporary"] = string.Empty;
            Response.Redirect(FACTGROUPDETAIL + "?ApID=" + m_Ap_Id + "&SrcUp_Id=" + Request.QueryString["SrcUp_Id"] + "&Up_Id=" + Request.QueryString["Up_Id"] + "&QueryCondition=" + Request.QueryString["QueryCondition"]);
        }
    }
    protected void BtnOK_Click(object sender, System.EventArgs e)
    {
        if (CheckForm("JoinFgrpID") == "")
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(),"New", "<script language=javascript>alert('You not yet select Fact group!');</script>");
            GenMasterTable();
            return;
        }

        string strReturn = "";
        PccMsg myMsg = new PccMsg();
        myMsg.CreateFirstNode("User_Id", Request.Params["UserID"]);
        myMsg.CreateFirstNode("Ap_Id", CheckQueryString("ApID"));
        myMsg.CreateFirstNode("Fgrp_Str", CheckForm("JoinFgrpID"));
        myMsg.CreateFirstNode("Fgrp_Org", ViewState["Fgrp_Org"].ToString());
        myMsg.CreateFirstNode("Upd_Id", Session["UserID"].ToString());

        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"]);

        strReturn = mybs.DoReturnStr("joinFgrpByUserID", myMsg.GetXmlStr, "");

        myMsg.LoadXml(strReturn);

        if (myMsg.Query("returnValue") != "0")
        {
            lblMsg.Visible = true;
            lblMsg.Font.Size = FontUnit.Large;
            lblMsg.Text = myMsg.Query("errmsg");
            GenMasterTable();
        }
        else
        {
            Response.Redirect(USERFGRPVIEW + "?ApID=" + m_ApID + "&QueryCondition=" + CheckQueryString("QueryCondition"));
        }
    }
    protected void BtnDelFactOK_Click(object sender, System.EventArgs e)
    {
        PccMsg myMsg = new PccMsg();
        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"]);
        string strReturn = string.Empty;
        string strMsg = string.Empty;
        strReturn = mybs.DoReturnStr("delete_DS_FACTGRP", GenDBXML(), string.Empty);
        strMsg = "刪除成功";

        myMsg.LoadXml(strReturn);

        if (myMsg.Query("returnValue") == "0")
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(),"New", "<script language=javascript>alert('" + strMsg + "');</script>");
            Response.Redirect(MYURL + "?ApID=" + m_ApID + "&SrcUp_Id=" + m_SrcUp_Id + "&Up_Id=" + m_Up_Id + "&QueryCondition=" + GetQueryCondition());
        }
        else
        {
            LblErrMsg.Font.Size = FontUnit.Large;
            LblErrMsg.Text = myMsg.Query("errmsg");
        }
    }
    private void GenTree(ref TreeView tree)
    {
        //先把Tree設為空白
        tree.Nodes.Clear();

        //先建立廠別樹的根(Root)寶成寶成國際集團
        TreeNode node = new TreeNode();
        node.Text = "寶成國際集團";
        node.ImageUrl = "../../Images/TreeRoot.gif";
        node.Value = "0";
        //node.ID = "0";
        tree.Nodes.Add(node);

        //取得這顆樹的所有資料
        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", "N");

        DataSet ds = mybs.DoReturnDataSet("GetFgrpTree", myMsg.GetXmlStr, "");
        m_Table = ds.Tables["FgrpTree"];

        //取得這顆樹的第一層資料,條件為Up_ID = 0
        DataRow[] rows;
        rows = m_Table.Select("up_id = 0");

        //設定所要跑的迴圈變數 i
        int i;
        //設定這顆樹的根節點的集合,所有的節點由此往下長
        TreeNodeCollection RootNodes;
        RootNodes = tree.Nodes[0].ChildNodes;
        //RootNodes = tree.Nodes[0].Nodes;

        //跑第一層的迴圈
        for (i = 0; i < rows.Length; i++)
        {
            AddNode(ref RootNodes, int.Parse(rows[i]["Fgrp_Id"].ToString()), i);
        }
    }
    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)
    {
        PccErrMsg myErrMsg = new PccErrMsg(Server.MapPath(Session["PageLayer"] + "XmlDoc"), Session["CodePage"].ToString(), "Error");

        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", m_Ap_Id);
        myMsg.CreateFirstNode("Fgrp_Id", m_Fgrp_Id);

        myMsg.CreateFirstNode("Fact_No", txtfactno.Text);
        myMsg.CreateFirstNode("Fact_Nm", txtfactnm.Text);
        myMsg.CreateFirstNode("Fgrp_Nm", txtfgrpnm.Text);

        myMsg.CreateFirstNode("StartRecord", PageControl1.StartRecord.ToString());
        myMsg.CreateFirstNode("PageSize", PageControl1.PageSize.ToString());

        DataSet ds;

        //以後可以加入若是有Report和Send的權限,表示是群管理者,所以可以看到這個群的所有資料 20041125
        GetMenuAuth myAuth = new GetMenuAuth();
        myAuth.AspxFile = FACTGROUPMANAGE;

        ds = mybs.DoReturnDataSet("getFactByFgrpId", myMsg.GetXmlStr, "");
        DataTable myTable = ds.Tables["FactByFgrp"];

        PccRow myRow;

        if (myTable.Rows.Count > 0)
        {
            int MasterCount = 1;
            string MasterStyle = "";

            //取出資料總筆數
            PageControl1.TotalSize = ds.Tables["TCounts"].Rows[0]["Counts"].ToString();
            PageControl1.BuildPager();
            string cVal = "";
            foreach (DataRow myMasterRow in myTable.Rows)
            {
                if (MasterCount % 2 == 0) MasterStyle = "eee000"; else MasterStyle = "fff000";
                myRow = new PccRow(MasterStyle, HorizontalAlign.Center, VerticalAlign.Middle, 0);

                //勾選值 ==
                string chk = "";
                string factid = "";

                //session("")不是Nothing 也不是 ""時則執行
                if (Session["FactFgrpTemporary"] != null && Session["FactFgrpTemporary"].ToString() != "")
                {
                    string[] chkarray = Session["FactFgrpTemporary"].ToString().Split(',');
                    factid = myMasterRow["fact_id"].ToString().Trim();
                    for (int i = 0; i < chkarray.Length; i++)
                    {
                        if (factid == chkarray[i].ToString())
                        {
                            chk = "checked";
                            cVal += factid + ",";

                        }
                    }

                }
                //編號
                myRow.AddTextCell(PageControl1.ListCount, 5);
                //廠別編號
                myRow.AddTextCell(myMasterRow["fact_no"].ToString(), 20);
                //廠別名稱
                myRow.AddTextCell(myMasterRow["fact_nm"].ToString(), 25);
                //公司名稱
                myRow.AddTextCell(myMasterRow["comp_nm"].ToString(), 30);
                //事業群
                myRow.AddTextCell(myMasterRow["fgrp_nm"].ToString(), 15);
                //選取
                myRow.AddTextCell("<input type=checkbox name=fact_id id=fact_id" + MasterCount + " value=" + ((int)decimal.Parse(myMasterRow["fact_id"].ToString())).ToString() + " " + chk + ">", 5);

                tab_fact.Controls.Add(myRow.Row);
                MasterCount += 1;
            }
            Session["chkcount"] = MasterCount;
            ViewState["CurrentValue"] = "";
            if (cVal != "")
            {
                ViewState["CurrentValue"] = cVal.Substring(0, cVal.Length - 1);
            }
        }
        else
        {
            PageControl1.TotalSize = "0";
            Session["chkcount"] = 0;
            PageControl1.BuildPager();
            myRow = new PccRow("DGridTD", HorizontalAlign.Center, VerticalAlign.Middle, 5);
            myRow.AddTextCell("<b><font color='darkred'>" + myErrMsg.GetErrMsg("AdtWeb/msg0073") + "</font></b>", 100);
            tab_fact.Controls.Add(myRow.Row);
        }
    }
    private void GenMasterTableData(ref PccErrMsg myLabel)
    {
        PccErrMsg myErrMsg = new PccErrMsg(Server.MapPath(Session["PageLayer"] + "XmlDoc"), Session["CodePage"].ToString(), "Error");

        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();
        PccMsg myTempMsg = new PccMsg();
        myMsg.CreateFirstNode("Ap_Id", Request.QueryString["ApID"]);
        myMsg.CreateFirstNode("Upd_Id", Session["UserID"].ToString());
        myMsg.CreateFirstNode("Fact_No", txtfactno.Text);
        myMsg.CreateFirstNode("User_Desc", txtusernm.Text);
        myMsg.CreateFirstNode("OrderBy", "a.user_desc");

        myMsg.CreateFirstNode("StartRecord", PageControl1.StartRecord.ToString());
        myMsg.CreateFirstNode("PageSize", PageControl1.PageSize.ToString());

        GetMenuAuth myAuth = new GetMenuAuth();
        myAuth.AspxFile = FACTGROUPMANAGE;

        string strXML = myMsg.GetXmlStr;
        DataSet myUserDs = mybs.DoReturnDataSet("getAllUserInFgrp", strXML, "");

        DataTable myUserData = myUserDs.Tables["UserInFgrp"];
        DataTable myFgrpData, myFactData;
        Table myFgrpTable, myFactTable;

        PccRow myRow;

        if (myUserData.Rows.Count > 0)
        {
            int MasterCount = 0;
            string MasterStyle = "";

            //取出資料總筆數
            PageControl1.TotalSize = myUserDs.Tables["TCounts"].Rows[0]["Counts"].ToString();
            PageControl1.BuildPager();

            //再利用此Table再取得其每一列的資料,再Gen出主要的Table Row.
            foreach (DataRow myMasterRow in myUserData.Rows)
            {
                if (MasterCount % 2 == 0) MasterStyle = "eee000"; else MasterStyle = "fff000";
                myRow = new PccRow(MasterStyle, HorizontalAlign.Center, VerticalAlign.Middle, 0);
                //編號
                myRow.AddTextCell(PageControl1.ListCount, 5);
                //電子郵件帳號
                myRow.AddTextCell(myMasterRow["email"].ToString(), 40);
                //廠別
                myRow.AddTextCell(myMasterRow["fact_no"].ToString(), 10);
                //姓名
                if (myAuth.IsAddAuth())
                {
                    myTempMsg.CreateFirstNode("Href", PICKFGRP + "?ApID=" + m_ap_id + "&UserID=" + myMasterRow["user_id"] + "&UserDesc=" + myMasterRow["user_desc"].ToString().Trim() + "&QueryCondition=" + GetQueryCondition());
                    myTempMsg.CreateFirstNode("Text", myMasterRow["user_desc"].ToString().Trim());
                    myRow.AddLinkHrefCell(myTempMsg.GetXmlStr, 30);
                }
                else
                {
                    myRow.AddTextCell(myMasterRow["user_desc"].ToString(), 30);
                }
                //事業群
                myRow.AddTextCell(myMasterRow["fgrp_nm"].ToString(), 15);
                //檢視
                myTempMsg = new PccMsg();
                myTempMsg.CreateFirstNode("ToolTip", "檢視所屬的廠群組");
                myTempMsg.CreateFirstNode("LinkID", "HLinkView" + myMasterRow["user_id"].ToString());
                myTempMsg.CreateFirstNode("Image", Session["PageLayer"] + "images/detal.gif");
                myTempMsg.CreateFirstNode("ClickFun", "doSection(view_" + MasterCount.ToString() + ")");
                myRow.AddLinkCell(myTempMsg.GetXmlStr, 10);

                tblUser.Rows.Add(myRow.Row);

                //要取得明細資料的Table變數
                myTempMsg.ClearContext();
                myTempMsg.CreateFirstNode("Ap_Id", m_ap_id);
                myTempMsg.CreateFirstNode("User_Id", myMasterRow["user_id"].ToString());
                myTempMsg.CreateFirstNode("LoginUser_Id", Session["UserID"].ToString());
                myFgrpData = mybs.DoReturnDataSet("get_DS_FGRPByUserID", myTempMsg.GetXmlStr, string.Empty).Tables["FgrpInUser"];

                myFgrpTable = new Table();
                GenFgrpTableHeader(ref myFgrpTable);
                int DetailCount = 1;

                foreach (DataRow myDetailRow in myFgrpData.Rows)
                {
                    if (DetailCount % 2 == 0) MasterStyle = "eee000"; else MasterStyle = "ffd000";
                    myRow = new PccRow(MasterStyle, HorizontalAlign.Center, VerticalAlign.Middle, 0);
                    //編號
                    myRow.AddTextCell(DetailCount.ToString(), 10);
                    //廠群組名稱
                    myRow.AddTextCell(myDetailRow["Fgrp_Nm"].ToString(), 70);
                    //檢視
                    myTempMsg = new PccMsg();
                    myTempMsg.CreateFirstNode("ToolTip", "檢視所屬廠別");
                    myTempMsg.CreateFirstNode("LinkID", "HLinkView" + myDetailRow["Fgrp_Id"].ToString());
                    myTempMsg.CreateFirstNode("Image", Session["PageLayer"] + "images/detal.gif");
                    myTempMsg.CreateFirstNode("ClickFun", "doSection(view_D" + MasterCount.ToString() + "_" + DetailCount.ToString() + ")");
                    myRow.AddLinkCell(myTempMsg.GetXmlStr, 10);
                    //管理
                    myTempMsg = new PccMsg();
                    //先加入修改的Item
                    if (myAuth.IsDeleteAuth())
                    {
                        //再加入刪除的Item
                        myTempMsg.CreateNode("LinkButton");
                        myTempMsg.AddToNode("Image", Session["PageLayer"] + "images/del.gif");
                        myTempMsg.AddToNode("ToolTip", "刪除此使用者與廠群組的關係");
                        myTempMsg.AddToNode("href", MYURL + "?ApID=" + m_ap_id + "&User_Desc=" + myMasterRow["user_desc"].ToString() + "&User_Id=" + myMasterRow["user_id"].ToString());
                        myTempMsg.AddToNode("QueryCondition", GetQueryCondition());
                        myTempMsg.AddToNode("Method", GetMethod("DetailDelFunc", "Fgrp_Id", "Fgrp_Nm", myDetailRow));
                        myTempMsg.UpdateNode();
                    }

                    myRow.AddMultiLinkCell(myTempMsg.GetXmlStr, 10);

                    myFgrpTable.Controls.Add(myRow.Row);

                    //要取得廠別明細資料的Table變數
                    myTempMsg.ClearContext();
                    myTempMsg.CreateFirstNode("Fgrp_Id", myDetailRow["Fgrp_Id"].ToString());
                    myTempMsg.CreateFirstNode("LoginUser_Id", Session["UserID"].ToString());
                    myFactData = mybs.DoReturnDataSet("get_DS_FACTGRPByFgrpID", myTempMsg.GetXmlStr, string.Empty).Tables["DS_FACTGRP"];

                    myFactTable = new Table();
                    GenFactTableHeader(ref myFactTable);
                    int FactDetailCount = 1;
                    foreach (DataRow myFactDetailRow in myFactData.Rows)
                    {
                        if (DetailCount % 2 == 0) MasterStyle = "eee000"; else MasterStyle = "ffd000";
                        myRow = new PccRow(MasterStyle, HorizontalAlign.Center, VerticalAlign.Middle, 0);

                        //編號
                        myRow.AddTextCell(FactDetailCount.ToString(), 10);
                        //廠別
                        myRow.AddTextCell(myFactDetailRow["Fact_No"].ToString(), 10);
                        //廠別名稱
                        myRow.AddTextCell(myFactDetailRow["Fact_Nm"].ToString(), 40);
                        //事業群
                        myRow.AddTextCell(myFactDetailRow["Fgrp_Nm"].ToString(), 20);
                        //公司編號
                        myRow.AddTextCell(myFactDetailRow["Comp_No"].ToString(), 20);

                        myFactTable.Controls.Add(myRow.Row);

                        FactDetailCount += 1;
                    }

                    myRow.Reset();
                    myRow.SetRowCss("off");
                    myRow.SetRowID("view_D" + MasterCount.ToString() + "_" + DetailCount);
                    myRow.SetDefaultCellData("DGridTD", HorizontalAlign.Center, 0, 10);
                    myRow.AddControl(myFactTable, 100);

                    myFgrpTable.Controls.Add(myRow.Row);

                    DetailCount += 1;

                }

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

                tblUser.Controls.Add(myRow.Row);

                MasterCount += 1;
            }
        }
        else
        {
            PageControl1.TotalSize = "0";
            PageControl1.BuildPager();
            myRow = new PccRow("DGridTD", HorizontalAlign.Center, VerticalAlign.Middle, 6);
            myRow.AddTextCell("<b><font color='darkred'>" + myErrMsg.GetErrMsg("AdtWeb/msg0072") + "</font></b>", 100);
            tblUser.Controls.Add(myRow.Row);
        }
    }
    private void GenTree(ref TreeView tree)
    {
        //判斷是否為系統超級管理者
        string superAdmin = "N";
        if (ConfigurationManager.AppSettings["superAdminEmail"].ToLower().Equals(Session["UserAccount"].ToString().ToLower()))
        {
            superAdmin = "Y";
        }

        //先把Tree設為空白
        tree.Nodes.Clear();

        //先建立廠別樹的根(Root)寶成寶成國際集團
        TreeNode node = new TreeNode();
        node.ImageUrl = "../../Images/TreeRoot.gif";
        node.Value = "0";
        //node.ID = "0";
        if (superAdmin.Equals("Y"))
        {
            node.Text = "<B>寶成國際集團</B>";
            node.NavigateUrl = FACTGROUPDETAIL + "?ApID=" + m_ApID + "&SrcUp_Id=0";
            node.Target = "doc";
        }
        else
        {
            node.Text = "<Font color=gray>寶成國際集團</Font>";
        }
        tree.Nodes.Add(node);

        //取得這顆樹的所有資料
        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);

        DataSet ds = mybs.DoReturnDataSet("GetFgrpTree", myMsg.GetXmlStr, "");
        m_Table = ds.Tables["FgrpTree"];

        //取得這顆樹的第一層資料,條件為Up_ID = 0
        DataRow[] rows;
        rows = m_Table.Select("up_id = 0");

        //設定所要跑的迴圈變數 i
        int i;
        //設定這顆樹的根節點的集合,所有的節點由此往下長
        TreeNodeCollection RootNodes;
        RootNodes = tree.Nodes[0].ChildNodes;
        //RootNodes = tree.Nodes[0].Nodes;

        //跑第一層的迴圈
        for (i = 0; i < rows.Length; i++)
        {
            AddNode(ref RootNodes, int.Parse(rows[i]["Fgrp_Id"].ToString()), i);
        }
    }
    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();
        }
    }