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 CreateDisChanFor111(DataTable dtDisChan, string vDisNo, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; try { //判斷是否有傳入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}.CreateDisChanFor111.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}.CreateDisChanFor111.Used Old Connetction:{2} ", System.Web.HttpContext.Current.Session["UID"].ToString(), DateTime.Now.ToString(), DBT.GetHashCode().ToString()) ); } #endregion ArrayList ParameterList = new ArrayList(); if (dtDisChan != null && dtDisChan.Rows.Count > 0) { for (Int32 i = 0; i <= dtDisChan.Rows.Count - 1; i++) { ParameterList.Clear(); ParameterList.Add(vDisNo); ParameterList.Add(dtDisChan.Rows[i]["ITEM"]); ParameterList.Add(dtDisChan.Rows[i]["PERIOD"]); ParameterList.Add(dtDisChan.Rows[i]["CHAN_NO"]); ParameterList.Add(dtDisChan.Rows[i]["DIS_TYPE"]); ParameterList.Add(dtDisChan.Rows[i]["CREATEDATE"]); ParameterList.Add(dtDisChan.Rows[i]["CREATEUID"]); ParameterList.Add(dtDisChan.Rows[i]["DIS_PRE_CQTY"]); ParameterList.Add(dtDisChan.Rows[i]["ST_ACCEPT_DATE"]); bResult = CreateDisChan(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 CreateDisItemReferForAll(DataTable dtDisItemRefer, DataTable dtDisChan, string vDisNo, string vItem, string vPeriod, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; try { VDS_ALO_DIS_ITEM_REFER_DBO ALOM = new VDS_ALO_DIS_ITEM_REFER_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}.CreateDisItemReferForAll.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}.CreateDisItemReferForAll.Used Old Connetction:{2} ", System.Web.HttpContext.Current.Session["UID"].ToString(), DateTime.Now.ToString(), DBT.GetHashCode().ToString()) ); } #endregion //a) 建立新資料 bResult = CreateItemAndChanRefer(dtDisItemRefer, dtDisChan, vDisNo, vItem, vPeriod, DBT); #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 }
}//end of CreateDisItemFor131 public bool CreateDisItem(DataTable dtDisItem, string vDisNo, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; try { VDS_ALO_DIS_ITEM_DBO ALOM = new VDS_ALO_DIS_ITEM_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}.CreateDisItem.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}.CreateDisItem.Used Old Connetction:{2} ", System.Web.HttpContext.Current.Session["UID"].ToString(), DateTime.Now.ToString(), DBT.GetHashCode().ToString()) ); } #endregion ArrayList ParameterList = new ArrayList(); if (dtDisItem != null && dtDisItem.Rows.Count > 0) { for (Int32 i = 0; i <= dtDisItem.Rows.Count - 1; i++) { ParameterList.Clear(); ParameterList.Add(dtDisItem.Rows[i]["CREATEDATE"]); ParameterList.Add(dtDisItem.Rows[i]["CREATEUID"]); ParameterList.Add(vDisNo); ParameterList.Add(dtDisItem.Rows[i]["ITEM"]); ParameterList.Add(dtDisItem.Rows[i]["PERIOD"]); ParameterList.Add(dtDisItem.Rows[i]["ONWAY_QTY"]); ParameterList.Add(dtDisItem.Rows[i]["DIS_PRE_QTY"]); ParameterList.Add(dtDisItem.Rows[i]["DIS_QTY"]); ParameterList.Add(dtDisItem.Rows[i]["ACCEPT_QTY"]); ParameterList.Add(dtDisItem.Rows[i]["DIS_STO_QTY"]); ParameterList.Add(dtDisItem.Rows[i]["DIS_MDC_QTY"]); ParameterList.Add(dtDisItem.Rows[i]["DIS_ISU_QTY"]); ParameterList.Add(dtDisItem.Rows[i]["B1_PERIOD"]); ParameterList.Add(dtDisItem.Rows[i]["B2_PERIOD"]); ParameterList.Add(dtDisItem.Rows[i]["B3_PERIOD"]); ParameterList.Add(dtDisItem.Rows[i]["B4_PERIOD"]); ParameterList.Add(dtDisItem.Rows[i]["B5_PERIOD"]); ParameterList.Add(dtDisItem.Rows[i]["B6_PERIOD"]); ParameterList.Add(dtDisItem.Rows[i]["PACKAGE_UNIT"]); ParameterList.Add(dtDisItem.Rows[i]["BASE_QTY"]); ParameterList.Add(dtDisItem.Rows[i]["TAX_TYPE"]); ParameterList.Add(dtDisItem.Rows[i]["ROOT_NO"]); ParameterList.Add(dtDisItem.Rows[i]["PMA"]); ParameterList.Add(dtDisItem.Rows[i]["PATTERN_NO"]); ParameterList.Add(dtDisItem.Rows[i]["INCLUDE_NON_EFF"]); ParameterList.Add(dtDisItem.Rows[i]["CHAN_TYPE"]); ParameterList.Add(dtDisItem.Rows[i]["OP_STATUS"]); ParameterList.Add(dtDisItem.Rows[i]["DIS_TYPE"]); ParameterList.Add(dtDisItem.Rows[i]["MEMO"]); bResult = ALOM.doCreateDisItem(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 }//end of CreateDisItem
public bool CreateItemAndChanRefer(DataTable dtDisItemRefer, DataTable dtDisChan, string vDisNo, string vItem, string vPeriod, DbTransaction RootDBT) { #region bool bResult = false; bool IsRootTranscation = false; try { //判斷是否有傳入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}.CreateItemAndChanRefer.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}.CreateItemAndChanRefer.Used Old Connetction:{2} ", System.Web.HttpContext.Current.Session["UID"].ToString(), DateTime.Now.ToString(), DBT.GetHashCode().ToString()) ); } #endregion DataTable dtAvailableChan = null; ArrayList ParameterList = new ArrayList(); ArrayList ParameterList2 = new ArrayList(); //4.1) 檢查目前配本通路暫存檔是否有值,無值則選擇所有可配通路 if (dtDisChan == null || dtDisChan.Rows.Count <= 0) { MaintainDisRecord BCODisRecord = new MaintainDisRecord(ConnectionDB); ParameterList.Clear(); ParameterList.Add(vItem); ParameterList.Add(vPeriod); dtAvailableChan = BCODisRecord.QueryForSelectDisChan(ParameterList); } else { dtAvailableChan = dtDisChan; } //4.2) 處理新增 if (dtDisItemRefer != null && dtDisItemRefer.Rows.Count > 0) { MaintainDisChanRefer BCODisChanRefer = new MaintainDisChanRefer(ConnectionDB); for (Int32 i = 0; i <= dtDisItemRefer.Rows.Count - 1; i++) { //1.逐筆建立商品參照檔資訊 ParameterList.Clear(); ParameterList.Add(vDisNo); ParameterList.Add(vItem); ParameterList.Add(vPeriod); ParameterList.Add(dtDisItemRefer.Rows[i]["RITEM"]); ParameterList.Add(dtDisItemRefer.Rows[i]["RPERIOD"]); ParameterList.Add(dtDisItemRefer.Rows[i]["REFER_RATE"]); ParameterList.Add(dtDisItemRefer.Rows[i]["CREATEDATE"]); ParameterList.Add(dtDisItemRefer.Rows[i]["CREATEUID"]); bResult = CreateDisItemReferFor111(ParameterList, DBT); //2.建立品項通路參照資訊 for (Int32 k = 0; k <= dtAvailableChan.Rows.Count - 1; k++) { ParameterList2.Clear(); ParameterList2.Add(vDisNo); ParameterList2.Add(vItem); ParameterList2.Add(vPeriod); ParameterList2.Add(dtAvailableChan.Rows[k]["CHAN_NO"]); ParameterList2.Add(dtDisItemRefer.Rows[i]["RITEM"]); ParameterList2.Add(dtDisItemRefer.Rows[i]["RPERIOD"]); ParameterList2.Add(dtDisItemRefer.Rows[i]["REFER_RATE"]); ParameterList2.Add(dtDisItemRefer.Rows[i]["CREATEDATE"]); ParameterList2.Add(dtDisItemRefer.Rows[i]["CREATEUID"]); bResult = BCODisChanRefer.CreateDisChanRefer(ParameterList2, 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 }