//IVM153.aspx public DataTable GetBatchPickData(ArrayList ParameterList) { try { DBO.VDS_IVM15_DBO IVMDBO = new VDS_IVM15_DBO(ref USEDB); return IVMDBO.GetBatchPickData(ParameterList); } catch (Exception ex) { throw ex; } }
//IVM151.aspx /// <summary> /// 新增揀貨單公用函數CreateByBatchTrans /// </summary> /// <param name="ParameterList">string UserID, string PickDate, string AcceptDate, string BLocateSec, string ELocateSec</param> /// <param name="DBT">傳入的交易,傳入NULL自動新增交易</param> /// <param name="OK">是否可以新增資料FLAG 0:無資料 1.正常新增 2:OnHD_Qty小於INI_Pick_Qty </param> /// <param name="PickNo">回傳揀貨單號</param> /// <returns></returns> public bool CreateByBatchTrans(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 PickDataNo = string.Empty; string UserID = ParameterList[0].ToString(); string PickDate = ParameterList[1].ToString(); string AcceptDate = ParameterList[2].ToString(); string BLocateNo = ParameterList[3].ToString().Substring(0,1); string BLocateSec = ParameterList[3].ToString(); string ELocateNo = ParameterList[4].ToString().Substring(0,1); string ELocateSec = ParameterList[4].ToString(); 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(AcceptDate); DBOPara.Add(BLocateSec); DBOPara.Add(ELocateSec); DataTable dtPickData = IVMDBO.GetBatchPickData(DBOPara); if (dtPickData.Rows.Count == 0) { OK = "0"; PickNo = ""; return false; } else { for (int i = 0; i < dtPickData.Rows.Count; i++) { if(int.Parse(dtPickData.Rows[i]["onhd_qty"].ToString()) < int.Parse(dtPickData.Rows[i]["IniPickQty"].ToString())) { OK = "2"; } } } if (OK != "2") { 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("0","int",false)); DBOPara.Add(GetValueSetParameter("","string",false)); IVMDBO.CreatePickMain(DBOPara, DBT, out PID, out PickDataNo); PickNo = PickDataNo; 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 } }