public bool CreateDisChan(ArrayList ParameterList, DbTransaction RootDBT)
        {
            #region
            bool bResult = false;
            bool IsRootTranscation = false;

            try
            {
                VDS_ALO_DIS_CHAN_DBO ALOM = new VDS_ALO_DIS_CHAN_DBO(ref USEDB);

                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;


                #region 啟動交易或指定RootTranscation

                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                    System.Web.HttpContext.Current.Trace.Warn(string.Format("使用者:{0} 於{1}.CreateDisChan.Open Connetction:{2} ",
                                                                     System.Web.HttpContext.Current.Session["UID"].ToString(),
                                                                      DateTime.Now.ToString(),
                                                                      DBT.GetHashCode().ToString())
                                                              );


                }
                else
                {
                    DBT = RootDBT;
                    System.Web.HttpContext.Current.Trace.Warn(string.Format("使用者:{0} 於{1}.CreateDisChan.Used Old Connetction:{2} ",
                                                                     System.Web.HttpContext.Current.Session["UID"].ToString(),
                                                                      DateTime.Now.ToString(),
                                                                      DBT.GetHashCode().ToString())
                                                              );

                }

                #endregion

                bResult = ALOM.doCreateDisChan(ParameterList, DBT);

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion
            }
            catch (Exception ex)
            {
                #region 交易失敗

                bResult = false;

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

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

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

                #endregion

            }

            return bResult;
            #endregion
        }
        public bool CreateDisCRMRecord(DataTable dtDisMain, DataTable dtDisItem, DataTable dtDisStore, out string vDisNo, DbTransaction RootDBT)
        {
            #region
            bool bResult = false;
            bool IsRootTranscation = false;

            try
            {
                VDS_ALO_DIS_MAIN_DBO DBO_MAIN = new VDS_ALO_DIS_MAIN_DBO(ref USEDB);
                VDS_ALO_DIS_ITEM_DBO DBO_ITEM = new VDS_ALO_DIS_ITEM_DBO(ref USEDB);
                VDS_ALO_DIS_CHAN_DBO DBO_CHAN = new VDS_ALO_DIS_CHAN_DBO(ref USEDB);
                VDS_ALO_DIS_STORE_DBO DBO_STORE = new VDS_ALO_DIS_STORE_DBO(ref USEDB);
                VDS_ALO_COMMON_DBO DBO_COMM = new VDS_ALO_COMMON_DBO(ref USEDB);


                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;


                #region 啟動交易或指定RootTranscation

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

                #endregion

                vDisNo = "";
                string strCode = "", strCodeLast = "";

                ArrayList ParameterList = new ArrayList();

                //配本主檔:VDS_ALO_DIS_MAIN                           

                if (dtDisMain != null && dtDisMain.Rows.Count > 0)
                {
                    ParameterList.Clear();
                    ParameterList.Add(dtDisMain.Rows[0]["UPDATEDATE"]);
                    ParameterList.Add(dtDisMain.Rows[0]["UPDATEUID"]);
                    ParameterList.Add(dtDisMain.Rows[0]["DIS_DATE"]);
                    ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);
                    ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                    ParameterList.Add(dtDisMain.Rows[0]["PO_SOURCE_NO"]);

                    vDisNo = DBO_MAIN.doCreateDisCRMMain(ParameterList, DBT);
                }

                if (vDisNo != "")
                {
                    foreach (DataRow dr in dtDisItem.Rows)
                    {
                        #region 配本商品檔:VDS_ALO_DIS_ITEM
                        ParameterList.Clear();
                        ParameterList.Add(dr["CREATEDATE"]);
                        ParameterList.Add(dr["CREATEUID"]);
                        ParameterList.Add(vDisNo);
                        ParameterList.Add(dr["ITEM"]);
                        ParameterList.Add(dr["PERIOD"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(dr["DIS_QTY"]);
                        ParameterList.Add(dr["ACCEPT_QTY"]);
                        ParameterList.Add(dr["DIS_STO_QTY"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(dr["TAX_TYPE"]);
                        ParameterList.Add(dr["ROOT_NO"]);
                        ParameterList.Add(dr["PMA"]);
                        ParameterList.Add(dr["PATTERN_NO"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        bResult = DBO_ITEM.doCreateDisItem(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("寫入 {0} 發生失敗", "配本商品檔:VDS_ALO_DIS_ITEM"));

                        #endregion

                        #region 配本通路檔:VDS_ALO_DIS_CHAN
                        ParameterList.Clear();
                        ParameterList.Add(vDisNo);
                        ParameterList.Add(dr["ITEM"]);
                        ParameterList.Add(dr["PERIOD"]);
                        ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(dr["CREATEDATE"]);
                        ParameterList.Add(dr["CREATEUID"]);
                        ParameterList.Add(DBNull.Value); //2009-05-04 cyhsu add for V_DIS_PRE_CQTY
                        ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);
                        bResult = DBO_CHAN.doCreateDisChan(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("寫入 {0} 發生失敗", "配本通路檔:VDS_ALO_DIS_CHAN"));

                        #endregion

                        #region 配本門市檔:VDS_ALO_DIS_STORE
                        if (dtDisStore != null && dtDisStore.Rows.Count > 0)
                        {
                            foreach (DataRow dr2 in dtDisStore.Rows)
                            {
                                strCode = string.Format("{0}_{1}_{2}_{3}_{4}",
                                    vDisNo, dr2["ITEM"].ToString().Trim(), dr2["PERIOD"].ToString().Trim(), dtDisMain.Rows[0]["RCHAN_NO"].ToString().Trim(), dr2["STORE"].ToString().Trim());

                                if (strCode != strCodeLast)
                                {
                                    ParameterList.Clear();
                                    ParameterList.Add(strCode);
                                    ParameterList.Add(dr2["UPDATEDATE"]);
                                    ParameterList.Add(dr2["UPDATEUID"]);
                                    ParameterList.Add(vDisNo);
                                    ParameterList.Add(dr2["ITEM"]);
                                    ParameterList.Add(dr2["PERIOD"]);
                                    ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                                    ParameterList.Add(dr2["STORE"]);
                                    //ParameterList.Add(dr2["ROUTE"]);//是否需要? doCreateDisCRMStore 參數不相符
                                    //ParameterList.Add(dr2["STEP"]);
                                    ParameterList.Add(dr2["DIS_QTY"]);
                                    ParameterList.Add(dr2["PO_SOURCE_NO"]);
                                    ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);

                                    bResult = DBO_STORE.doCreateDisCRMStore(ParameterList, DBT);
                                }

                                strCodeLast = string.Format("{0}_{1}_{2}_{3}_{4}",
                                    vDisNo, dr2["ITEM"].ToString().Trim(), dr2["PERIOD"].ToString().Trim(), dtDisMain.Rows[0]["RCHAN_NO"].ToString().Trim(), dr2["STORE"].ToString().Trim());
                            }

                        }

                        if (!bResult)
                            throw new Exception(string.Format("寫入 {0} 發生失敗", "配本門市檔:VDS_ALO_DIS_STORE"));

                        #endregion

                        #region 呼叫 PKG_VDS_ALO_COMM.lf_area_qty
                        ParameterList.Clear();
                        ParameterList.Add(vDisNo);
                        ParameterList.Add(dr["ITEM"]);
                        ParameterList.Add(dr["PERIOD"]);
                        ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                        ParameterList.Add("X");
                        bResult = DBO_COMM.doLp_area_disqty(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("{0} 發生失敗", "呼叫 PKG_VDS_ALO_COMM.lf_area_qty"));
                        #endregion

                    }
                }
                else
                {
                    throw new Exception(string.Format("{0} 發生失敗", "呼叫 PKG_VDS_ALO_DIS_MAIN.CreateDisCRMMain"));
                }

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion

                bResult = true;
            }
            catch (Exception ex)
            {
                #region 交易失敗

                bResult = false;

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

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

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

                #endregion

            }

            return bResult;
            #endregion
        }