/// <summary> /// 基本表單刪除BCO /// </summary> /// <param name="htParams">刪除變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> /// <returns>回傳影響筆數</returns> public bool DeleteDetailAndLog(Hashtable htParams, DbTransaction RootDBT ) { bool IsRootTranscation = false; bool bResult = false; try { VDS_ALO_POSOURCE_NO_DETL_DBO ALOD = new VDS_ALO_POSOURCE_NO_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 ALOD.doDelAndLogbyPID(htParams, DBT); #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion bResult = true; return bResult; } 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 } }
/// <summary> /// 基本表單更新BCO /// </summary> /// <param name="DetailData">更新變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> /// <returns>回傳成功與否</returns> public bool UpdateDetail(DataTable dtForDetailAddedOrModified, string strUIDForLog, DataTable dtForDetailDeleted, DbTransaction RootDBT) { bool IsRootTranscation = false; bool bResult = false; try { VDS_ALO_POSOURCE_NO_DETL_DBO ALOD = new VDS_ALO_POSOURCE_NO_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 Hashtable htParams = new Hashtable(); if (dtForDetailDeleted != null) { for (Int32 i = 0; i <= dtForDetailDeleted.Rows.Count - 1; i++) { if (dtForDetailDeleted.Rows[i].RowState != DataRowState.Deleted) { #region htParams.Clear(); htParams.Add("ID", dtForDetailDeleted.Rows[i]["ID"]); htParams.Add("PID", dtForDetailDeleted.Rows[i]["PID"]); htParams.Add("CREATEDATE", dtForDetailDeleted.Rows[i]["CREATEDATE"]); htParams.Add("CREATEUID", dtForDetailDeleted.Rows[i]["CREATEUID"]); htParams.Add("UPDATEDATE", dtForDetailDeleted.Rows[i]["UPDATEDATE"]); htParams.Add("UPDATEUID", dtForDetailDeleted.Rows[i]["UPDATEUID"]); htParams.Add("STORE", dtForDetailDeleted.Rows[i]["STORE"]); htParams.Add("ST_ACCEPT_DATE", dtForDetailDeleted.Rows[i]["ST_ACCEPT_DATE"]); htParams.Add("ITEM", dtForDetailDeleted.Rows[i]["ITEM"]); htParams.Add("PERIOD", dtForDetailDeleted.Rows[i]["PERIOD"]); htParams.Add("PO_SOURCE_NO", dtForDetailDeleted.Rows[i]["PO_SOURCE_NO"]); htParams.Add("DATA_SOURCE", dtForDetailDeleted.Rows[i]["DATA_SOURCE"]); htParams.Add("DIS_NO", dtForDetailDeleted.Rows[i]["DIS_NO"]); htParams.Add("DIS_QTY", dtForDetailDeleted.Rows[i]["DIS_QTY"]); htParams.Add("CHAN_NO", dtForDetailDeleted.Rows[i]["CHAN_NO"]); htParams.Add("UIDForLog", strUIDForLog); ALOD.doDelete(htParams, DBT); #endregion } } } if (dtForDetailAddedOrModified != null) { for (Int32 i = 0; i <= dtForDetailAddedOrModified.Rows.Count - 1; i++) { if ((dtForDetailAddedOrModified.Rows[i].RowState == DataRowState.Added) || (dtForDetailAddedOrModified.Rows[i].RowState == DataRowState.Modified)) { #region //下列二欄位無值時表示只新增主檔,不更新明細檔 if (!(dtForDetailAddedOrModified.Rows[i]["ID_DETL"].ToString().Trim() == "" && dtForDetailAddedOrModified.Rows[i]["UPDATEDATE_DETL"].ToString().Trim() == "")) { htParams.Clear(); htParams.Add("ID", dtForDetailAddedOrModified.Rows[i]["ID_DETL"]); htParams.Add("PID", dtForDetailAddedOrModified.Rows[i]["PID"]); htParams.Add("CREATEDATE", dtForDetailAddedOrModified.Rows[i]["CREATEDATE_DETL"]); htParams.Add("CREATEUID", dtForDetailAddedOrModified.Rows[i]["CREATEUID_DETL"]); htParams.Add("UPDATEDATE", dtForDetailAddedOrModified.Rows[i]["UPDATEDATE_DETL"]); htParams.Add("UPDATEUID", dtForDetailAddedOrModified.Rows[i]["UPDATEUID_DETL"]); htParams.Add("STORE", dtForDetailAddedOrModified.Rows[i]["STORE"]); htParams.Add("ST_ACCEPT_DATE", dtForDetailAddedOrModified.Rows[i]["ST_ACCEPT_DATE"]); htParams.Add("ITEM", dtForDetailAddedOrModified.Rows[i]["ITEM"]); htParams.Add("PERIOD", dtForDetailAddedOrModified.Rows[i]["PERIOD"]); htParams.Add("PO_SOURCE_NO", dtForDetailAddedOrModified.Rows[i]["PO_SOURCE_NO"]); htParams.Add("DATA_SOURCE", dtForDetailAddedOrModified.Rows[i]["DATA_SOURCE"]); htParams.Add("DIS_NO", dtForDetailAddedOrModified.Rows[i]["DIS_NO"]); htParams.Add("DIS_QTY", dtForDetailAddedOrModified.Rows[i]["DIS_QTY"]); htParams.Add("CHAN_NO", dtForDetailAddedOrModified.Rows[i]["CHAN_NO"]);//CHAN_NO_DETL ALOD.doCreate(htParams, DBT); } #endregion } } } #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion bResult = true; return bResult; } 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 bool CheckChainPODetlIsExistedByFind(ArrayList ParameterList) { #region try { VDS_ALO_POSOURCE_NO_DETL_DBO ALOD = new VDS_ALO_POSOURCE_NO_DETL_DBO(ref USEDB); DataTable dt = ALOD.doQueryDetlByFind(ParameterList); if (dt != null && dt.Rows.Count > 0) { return true;//已存在 } else { return false;//不存在 } } catch (Exception ex) { throw GetNewException(ex); } #endregion }
/// <summary> /// 基本表單新增BCO /// </summary> /// <param name="DetailData">輸入變數</param> /// <param name="RootDBT">是否有主交易,無主交易輸入null</param> /// <returns>回傳異動筆數</returns> public void CreateDetail(Int32 PID, DataTable DetailData, DbTransaction RootDBT) { bool IsRootTranscation = false; try { VDS_ALO_POSOURCE_NO_DETL_DBO ALOD = new VDS_ALO_POSOURCE_NO_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 Hashtable htParams = new Hashtable(); for (Int32 i = 0; i <= DetailData.Rows.Count - 1; i++) { if (DetailData.Rows[i].RowState != DataRowState.Deleted) { htParams.Clear(); htParams.Add("PID", PID); htParams.Add("ID", DetailData.Rows[i]["ID"]); htParams.Add("CREATEDATE", DetailData.Rows[i]["CREATEDATE_DETL"]); htParams.Add("CREATEUID", DetailData.Rows[i]["CREATEUID_DETL"]); htParams.Add("UPDATEDATE", DetailData.Rows[i]["UPDATEDATE_DETL"]); htParams.Add("UPDATEUID", DetailData.Rows[i]["UPDATEUID_DETL"]); htParams.Add("STORE", DetailData.Rows[i]["STORE"]); htParams.Add("ST_ACCEPT_DATE", DetailData.Rows[i]["ST_ACCEPT_DATE"]); htParams.Add("ITEM", DetailData.Rows[i]["ITEM"]); htParams.Add("PERIOD", DetailData.Rows[i]["PERIOD"]); htParams.Add("PO_SOURCE_NO", DetailData.Rows[i]["PO_SOURCE_NO"]); htParams.Add("DATA_SOURCE", DetailData.Rows[i]["DATA_SOURCE"]); htParams.Add("DIS_NO", DetailData.Rows[i]["DIS_NO"]); htParams.Add("DIS_QTY", DetailData.Rows[i]["DIS_QTY"]); htParams.Add("CHAN_NO", DetailData.Rows[i]["CHAN_NO"]);//CHAN_NO_DETL ALOD.doCreate(htParams, 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 } }
public DataTable QueryChainPODetlByFind(ArrayList ParameterList) { #region try { VDS_ALO_POSOURCE_NO_DETL_DBO ALOD = new VDS_ALO_POSOURCE_NO_DETL_DBO(ref USEDB); DataTable dt = ALOD.doQueryDetlByFind(ParameterList); return dt; } catch (Exception ex) { throw GetNewException(ex); } #endregion }