//IVM154.aspx public DataTable GetPickDatabyTrans(ArrayList ParameterList) { try { DBO.VDS_IVM15_DBO IVMDBO = new VDS_IVM15_DBO(ref USEDB); return IVMDBO.GetPickDatabyTrans(ParameterList); } catch (Exception ex) { throw ex; } }
//IVM154.aspx /// <summary> /// 建立揀貨單(門市進貨剩餘移轉) /// </summary> /// <param name="ParameterList">UserID、PickDate、AcceptDate、BLocateSec、ELocateSec</param> /// <param name="RootDBT">傳入的交易</param> /// <param name="OK">OK Flag</param> /// <param name="PickNo">新增的PickNo</param> /// <returns></returns> public bool CreateByLeftTrans(ArrayList ParameterList, DbTransaction RootDBT, out string OK, out string PickNo) { OK = string.Empty; PickNo = string.Empty; ArrayList DBOPara = new ArrayList(); bool IsRootTranscation = false; int PID = -1; string UserID = ParameterList[0].ToString(); string PickDate = ParameterList[1].ToString(); string AcceptDate = ParameterList[2].ToString(); string BLocateSec = ParameterList[3].ToString(); string ELocateSec = ParameterList[4].ToString(); string BLocateNo = string.Empty; if (BLocateSec.Length > 0) BLocateNo = BLocateSec.Substring(0, 1); string ELocateNo = string.Empty; if (ELocateSec.Length > 0) ELocateNo = ELocateSec.Substring(0, 1); try { DBO.VDS_IVM15_DBO IVMDBO = new VDS_IVM15_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 DBOPara.Clear(); DBOPara.Add(GetValueSetParameter(AcceptDate,"string",false)); DBOPara.Add(GetValueSetParameter(BLocateSec,"string",false)); DataTable dtPickData = IVMDBO.GetPickDatabyTrans(DBOPara); if (dtPickData.Rows.Count == 0) { OK = "0"; PickNo = ""; return false; } else { OK = "1"; } DBOPara.Clear(); DBOPara.Add(GetValueSetParameter(UserID, "string", false)); DBOPara.Add(GetValueSetParameter(AcceptDate, "string", false)); DBOPara.Add(GetValueSetParameter("", "string", false)); DBOPara.Add(GetValueSetParameter(PickDate, "string", false)); DBOPara.Add(GetValueSetParameter("3", "int", false)); DBOPara.Add(GetValueSetParameter("", "string", false)); IVMDBO.CreatePickMain(DBOPara, DBT, out PID, out PickNo); for (int i = 0; i < dtPickData.Rows.Count; i++) { DBOPara.Clear(); DBOPara.Add(GetValueSetParameter(UserID, "string", false)); DBOPara.Add(GetValueSetParameter(PickDate, "string", false)); DBOPara.Add(GetValueSetParameter(PID.ToString(), "int", false)); DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["item"].ToString(), "string", false)); DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["period"].ToString(), "string", false)); DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["Onhd_Qty"].ToString(), "int", false)); DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["IniPickQty"].ToString(), "int", false)); DBOPara.Add(GetValueSetParameter(dtPickData.Rows[i]["RealPickQty"].ToString(), "int", false)); DBOPara.Add(GetValueSetParameter(BLocateNo, "string", false)); DBOPara.Add(GetValueSetParameter(BLocateSec, "string", false)); DBOPara.Add(GetValueSetParameter(ELocateNo, "string", false)); DBOPara.Add(GetValueSetParameter(ELocateSec, "string", false)); DBOPara.Add(GetValueSetParameter("", "int", false)); IVMDBO.CreatePickDetl(DBOPara, DBT); } #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } return true; #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 } }