//追溯計算 public void TraceCloseMonth(ArrayList ParameterList, DbTransaction RootDBT, out string V_MSG, out string V_STATUS_CREATEUID, out DateTime D_STATUS_CREATEDATE) { bool IsRootTranscation = false; 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.VDM_VendorAgmDBO dbo = new VDM_VendorAgmDBO(ref USEDB); dbo.TraceCloseMonthSKU(ParameterList, DBT, out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);//追溯計算.商品交易 if (V_MSG == "") { dbo.TraceCloseMonthContract(ParameterList, DBT, out V_MSG, out V_STATUS_CREATEUID, out D_STATUS_CREATEDATE);//追溯計算.合約交易 if (V_MSG == "") { dbo.UpdateTraceCalculate(ParameterList, DBT);//追溯計算完後異動合約主檔的追溯起、迄日及追溯掛帳年月 } } #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion } 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 } }