/// <summary>
        /// 基本表單新增BCO
        /// </summary>
        /// <param name="ParameterList">輸入變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳新增之ID</returns>
        public string CreateMasterAndDetail_Gift(ArrayList ParameterList,
                                                 DataTable DetailData,
                                                 DataTable GiftData,
                                                 DbTransaction RootDBT)
        {
            #region
            bool IsRootTranscation = false;
            Int32 PID = 0;
            string[] sID_NO;
            string sTemp = "";
            string sPurchaseNo = "";
            try
            {
                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;

                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                //寫入 Master Table
                sTemp = CreatePurchaseOrder(ParameterList, DBT);
                sID_NO = sTemp.Split(new Char[] { ';' });
                PID = int.Parse(sID_NO[0].ToString());
                sPurchaseNo = sID_NO[1].ToString();

                //將ParameterList內存放主檔ID與PURCHASRE_NO欄位值,換成PID與sPurchaseNo
                ParameterList[5] = sPurchaseNo;
                ParameterList[6] = PID;

                if (PID != 0)
                {
                    #region 新增明細資料與更新 VDS_MKT_PURCARD_MAIN.PUR_NO(雜誌採購卡) 或 VDS_MKT_BPURCARD_MAIN.PUR_NO(圖書採購卡)
                    foreach (DataRow dRow in DetailData.Rows)
                    {
                        CreatePurchaseOrderDetail(PID, ParameterList, dRow, DBT);

                        //更新期別屬性檔(VDS_ITM_PERIOD_PROFILE)中,該品號期別的交貨日期、採購日、採購量與採購單號
                        UpdatePeriodProfile(dRow["ITEM"].ToString().Trim(), dRow["PERIOD"].ToString().Trim(), dRow["PLAN_ACCEPT_DATE"].ToString().Trim(), ParameterList[0].ToString().Trim(),
                                            dRow["PURCHASE_QTY"].ToString().Trim(), sPurchaseNo, ParameterList[4].ToString().Trim(), DBT);

                        //更新圖書採購卡或雜誌採購卡採購單號
                        if (dRow["PERIOD"].ToString().Trim() == "000000") //在圖書裡其period值絕對是000000
                        {
                            Update_B_PURCARD(sPurchaseNo, dRow["ITEM"].ToString().Trim(), ParameterList[4].ToString().Trim(), DBT);
                        }
                        else
                        {
                            Update_PURCARD(sPurchaseNo, dRow["ITEM"].ToString().Trim(), dRow["PERIOD"].ToString().Trim(), ParameterList[4].ToString().Trim(), DBT);
                        }
                    }
                    #endregion

                    #region 新增明細贈品資料
                    if (GiftData != null)
                    {
                        foreach (DataRow gRow in GiftData.Rows)
                        {
                            CreatePurchaseOrderDetail(PID, ParameterList, gRow, DBT);

                            //更新贈品屬性檔(VDS_MKT_GIFT_PROFILE)資料中,該品號期別的交貨日期、採購日、採購量與採購單號
                            UpdateGiftProfile(gRow["ITEM"].ToString().Trim(), gRow["PERIOD"].ToString().Trim(), gRow["VIRTUAL_CODE"].ToString().Trim(),
                                              gRow["PLAN_ACCEPT_DATE"].ToString().Trim(), ParameterList[0].ToString().Trim(),
                                              gRow["PURCHASE_QTY"].ToString().Trim(), sPurchaseNo, ParameterList[4].ToString().Trim(), DBT);
                        }
                    }
                    #endregion


                    #region 交易成功
                    if (IsRootTranscation)
                    {
                        //獨立呼叫Transcation成立
                        DBT.Commit();
                    }
                    #endregion
                    DBO.PUR_PurchaseOrderDBO dbo = new PUR_PurchaseOrderDBO(ref USEDB);
                    sPurchaseNo = dbo.doQueryPurchase_NotByID(PID.ToString());
                }
                else
                {
                    throw new Exception("新增0筆資料!");
                }

                return sPurchaseNo;
            }
            catch (Exception ex)
            {
                #region 交易失敗
                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }
                #endregion

                throw ex;
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }
                #endregion
            }
            #endregion
        }