/// <summary> /// 刪除 VDS_CRM_ORDER_MAIN 和 VDS_CRM_ORDER_DETL 的資料 /// </summary> /// <param name="ParameterList">MASTER TABLE 的變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> /// <param name="dt_Detail">DETAIL TABLE</param> public void DeleteCRMOrder(ArrayList ParameterList, DbTransaction RootDBT, DataTable dt_Detail) { bool IsRootTranscation = false; try { DBO.VDS_CRM_ORDER_MAINDBO VCOM = new VDS_CRM_ORDER_MAINDBO(ref USEDB); DBO.VDS_CRM_ORDER_DETLDBO VCOD = new VDS_CRM_ORDER_DETLDBO(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 //2010/09/20 reverse DETL & MAIN executive progress if (dt_Detail.Rows.Count != 0) { foreach (DataRow dRow in dt_Detail.Rows) { VCOD.DELETE_CRM041_DETL(ParameterList, DBT, dRow); } } VCOM.DELETE_CRM041_MAIN(ParameterList, DBT); #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 } }