public DataTable QuerySwitch(QueryType QT, ArrayList ParameterList)
        {
            DBO.VDS_CRM_CHANMSG_MAIN_DBO VCCM = new VDS_CRM_CHANMSG_MAIN_DBO(ref USEDB);
            DBO.VDS_CRM_CHANMSG_DETL_DBO VCCD = new VDS_CRM_CHANMSG_DETL_DBO(ref USEDB);

            DataTable Dt;

            try
            {
                switch (QT)
                {
                    case QueryType.CRM121_Query_All:
                        Dt = VCCM.do_CRM121_Query_All(ParameterList);
                        break;
                    case QueryType.CODE:
                        Dt = VCCM.doQueryByCode(ParameterList);
                        break;
                    case QueryType.ID:
                        Dt = VCCM.doQueryByID(ParameterList);
                        break;
                    case QueryType.Custom:
                        Dt = VCCM.doQueryByFind(ParameterList);
                        break;
                    case QueryType.CRM122_DETL_Schema:
                        Dt = VCCD.do_CRM122_DETL_Schema();
                        break;
                    case QueryType.CRM122_Query_Master_By_ID:
                        Dt = VCCM.doQueryByID(ParameterList);
                        break;
                    case QueryType.CRM122_Query_Detail_By_ID:
                        Dt = VCCD.doQueryByID(ParameterList);
                        break;
                    default:
                        Dt = new DataTable();
                        break;
                }

                return Dt;
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }
        }
        /// <summary>
        /// 基本表單新增BCO
        /// </summary>
        /// <param name="ParameterList">輸入變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳影響筆數</returns>
        public int CreateMasterAndDetail(ArrayList ParameterList, DbTransaction RootDBT,DataTable dt_Detail)
        {
            int ID = 0;
            bool IsRootTranscation = false;

            try
            {
                DBO.VDS_CRM_CHANMSG_MAIN_DBO VCCM = new VDS_CRM_CHANMSG_MAIN_DBO(ref USEDB);
                DBO.VDS_CRM_CHANMSG_DETL_DBO VCCD = new VDS_CRM_CHANMSG_DETL_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

                //寫入 Master Table
                ID = VCCM.doCreate_Master(ParameterList, DBT);

                //寫入 Detail Table
                foreach (DataRow dRow in dt_Detail.Rows)
                {
                    VCCD.doCreate_detail(DBT, dRow,ID);
                }

                #region 交易成功

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

                #endregion

                return ID;
            }
            catch (Exception ex)
            {
                #region 交易失敗

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

                #endregion

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

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

                #endregion

            }
        }
        public void UpdateMasterAndDetail(ArrayList ParameterList, DbTransaction RootDBT, DataTable dt_Detail)
        {
            bool IsRootTranscation = false;
            string s_LogUser = string.Empty;
            DateTime d_DateNow;

            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

                DBO.VDS_CRM_CHANMSG_MAIN_DBO VCCM = new VDS_CRM_CHANMSG_MAIN_DBO(ref USEDB);
                DBO.VDS_CRM_CHANMSG_DETL_DBO VCCD = new VDS_CRM_CHANMSG_DETL_DBO(ref USEDB);
                
                VCCM.doUpdate(ParameterList, DBT);

                s_LogUser = ParameterList[15].ToString();
                d_DateNow = DateTime.Parse(ParameterList[14].ToString());

                foreach (DataRow dRow in dt_Detail.Rows)
                {
                    if (dRow["STATUS"].ToString() == "ADD")
                    { VCCD.doCreate_detail(DBT, dRow, int.Parse(dRow["PID"].ToString())); }
                    else if (dRow["STATUS"].ToString() == "DELETE")
                    { VCCD.doDelete(DBT, dRow, s_LogUser, d_DateNow); }
                }

                #region 交易成功

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

                #endregion

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

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

                #endregion

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

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

                #endregion

            }
        }