public bool Lp_area_disqty_all(ArrayList ParameterList, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; try { VDS_ALO_COMMON_DBO ALOM = 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 bResult = ALOM.doLp_area_disqty_all(ParameterList, RootDBT); ; #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 UpdateDisItemAndStore(DataTable dtDisStore, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; try { VDS_ALO_COMMON_DBO DBO_COMMM = new VDS_ALO_COMMON_DBO(ref USEDB); VDS_ALO_DIS_STORE_DBO DBO_DIS_STORE = new VDS_ALO_DIS_STORE_DBO(ref USEDB); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; string strLastDisNO = ""; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion ArrayList ParameterList = new ArrayList(); if (dtDisStore != null && dtDisStore.Rows.Count > 0) { for (Int32 i = 0; i <= dtDisStore.Rows.Count - 1; i++) { #region //a) 配本序號異動時(目前配本序號<>前一配本序號)時,需更新配本其他相關記錄檔。 #region if (strLastDisNO != "" && strLastDisNO != dtDisStore.Rows[i]["DIS_NO", DataRowVersion.Original].ToString()) { ParameterList.Clear(); ParameterList.Add(strLastDisNO); ParameterList.Add("X"); bResult = DBO_COMMM.doLp_area_disqty_all(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("執行 {0} 發生失敗", "配本序號異動時")); } #endregion //b) 逐筆更新配本門市。 #region ParameterList.Clear(); ParameterList.Add(dtDisStore.Rows[i]["DIS_QTY", DataRowVersion.Original]); ParameterList.Add(dtDisStore.Rows[i]["UPDATEDATE", DataRowVersion.Original]); ParameterList.Add(dtDisStore.Rows[i]["UPDATEUID", DataRowVersion.Original]); ParameterList.Add(dtDisStore.Rows[i]["DIS_NO", DataRowVersion.Original]); ParameterList.Add(dtDisStore.Rows[i]["ITEM", DataRowVersion.Original]); ParameterList.Add(dtDisStore.Rows[i]["PERIOD", DataRowVersion.Original]); ParameterList.Add(dtDisStore.Rows[i]["CHAN_NO", DataRowVersion.Original]); ParameterList.Add(dtDisStore.Rows[i]["STORE", DataRowVersion.Original]); ParameterList.Add(dtDisStore.Rows[i]["N_NEW_DIS_QTY", DataRowVersion.Current]); ParameterList.Add(dtDisStore.Rows[i]["UPDATEDATE", DataRowVersion.Current]); ParameterList.Add(dtDisStore.Rows[i]["UPDATEUID", DataRowVersion.Current]); bResult = DBO_DIS_STORE.doUpdateDisStoreForStoreCheck(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("執行 {0} 發生失敗", "逐筆更新配本門市")); #endregion strLastDisNO = dtDisStore.Rows[i]["DIS_NO", DataRowVersion.Original].ToString(); #endregion } //c) 最後一筆需更新配本其他相關記錄檔。 #region if (strLastDisNO != "") { ParameterList.Clear(); ParameterList.Add(strLastDisNO); ParameterList.Add("X"); bResult = DBO_COMMM.doLp_area_disqty_all(ParameterList, DBT); if (!bResult) throw new Exception(string.Format("執行 {0} 發生失敗", "配本序號異動時")); } #endregion } #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } bResult = true; #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 }