//如果FunctionNo = 6 or 8,需要再額外判斷移轉單資料是否需要分成兩筆,分完之後要合併重複的資料 private DataTable SplitSectionSecData(DataTable Dt) { try { ArrayList ParameterList = new ArrayList(); DataTable DtResult = MakeNewDataTable(); DataTable dtTemp1 = MakeNewDataTable(); DataTable dtTemp2 = MakeNewDataTable(); for (int i = 0; i < Dt.Rows.Count; i++) { string BSec = Dt.Rows[i]["BLocate_Section"].ToString(); string ESec = Dt.Rows[i]["ELocate_Section"].ToString(); string Item = Dt.Rows[i]["Item"].ToString(); string Period = Dt.Rows[i]["Period"].ToString(); string PickQty = Dt.Rows[i]["Real_Pick_Qty"].ToString(); string Cost = Dt.Rows[i]["Cost"].ToString(); DBO.MaintainRemoveByPick BCOIVM = new DBO.MaintainRemoveByPick(strConn); ParameterList.Clear(); ParameterList.Add(ESec.Substring(0, 1)); ParameterList.Add("1"); string LocateSec = BCOIVM.GetLocateSecByAttr(ParameterList); if (BSec.Substring(0, 1) == ESec.Substring(0, 1) || LocateSec == ESec) //同儲區移動或移到暫存儲位的 { DataRow dr = dtTemp1.NewRow(); dr["BLocate_Section"] = BSec; dr["ELocate_Section"] = ESec; dr["Item"] = Item; dr["Period"] = Period; dr["Real_Pick_Qty"] = PickQty; dr["Cost"] = Cost; dtTemp1.Rows.Add(dr); } else //跨儲區移動 { //先移到暫存區 DataRow dr = dtTemp1.NewRow(); dr["BLocate_Section"] = BSec; dr["ELocate_Section"] = LocateSec; dr["Item"] = Item; dr["Period"] = Period; dr["Real_Pick_Qty"] = PickQty; dr["Cost"] = Cost; dtTemp1.Rows.Add(dr); //從暫存區移到正式儲區 DataRow dr2 = dtTemp2.NewRow(); dr2["BLocate_Section"] = LocateSec; dr2["ELocate_Section"] = ESec; dr2["Item"] = Item; dr2["Period"] = Period; dr2["Real_Pick_Qty"] = PickQty; dr2["Cost"] = Cost; dtTemp2.Rows.Add(dr2); } } //先處理同儲區移轉及搬到暫存區的資料 for (int a = 0; a < dtTemp1.Rows.Count; a++) { DataRow drResult = DtResult.NewRow(); drResult["BLocate_Section"] = dtTemp1.Rows[a]["BLocate_Section"].ToString(); drResult["ELocate_Section"] = dtTemp1.Rows[a]["ELocate_Section"].ToString(); drResult["Item"] = dtTemp1.Rows[a]["Item"].ToString(); drResult["Period"] = dtTemp1.Rows[a]["Period"].ToString(); drResult["Real_Pick_Qty"] = dtTemp1.Rows[a]["Real_Pick_Qty"].ToString(); drResult["Cost"] = dtTemp1.Rows[a]["Cost"].ToString(); DtResult.Rows.Add(drResult); } //再處理暫存區到正式儲區資料 for (int b = 0; b < dtTemp2.Rows.Count; b++) { DataRow drResult = DtResult.NewRow(); drResult["BLocate_Section"] = dtTemp2.Rows[b]["BLocate_Section"].ToString(); drResult["ELocate_Section"] = dtTemp2.Rows[b]["ELocate_Section"].ToString(); drResult["Item"] = dtTemp2.Rows[b]["Item"].ToString(); drResult["Period"] = dtTemp2.Rows[b]["Period"].ToString(); drResult["Real_Pick_Qty"] = dtTemp2.Rows[b]["Real_Pick_Qty"].ToString(); drResult["Cost"] = dtTemp2.Rows[b]["Cost"].ToString(); DtResult.Rows.Add(drResult); } //把dtTemp1 dtTemp2資源釋放 dtTemp1 = null; dtTemp2 = null; //合併並計算重複的資料 DataTable DtResult2 = MakeNewDataTable(); for (int i = 0; i < DtResult.Rows.Count; i++) { string BLocate_Section = DtResult.Rows[i][0].ToString(); string ELocate_Section = DtResult.Rows[i][1].ToString(); string Item = DtResult.Rows[i][2].ToString(); string Period = DtResult.Rows[i][3].ToString(); string Real_Pick_Qty = DtResult.Rows[i][4].ToString(); string Cost = DtResult.Rows[i][5].ToString(); bool HaveSec = false; int U = -1; for (int x = 0; x < DtResult2.Rows.Count; x++) { if (BLocate_Section == DtResult2.Rows[x]["BLocate_Section"].ToString() && ELocate_Section == DtResult2.Rows[x]["ELocate_Section"].ToString() && Item == DtResult2.Rows[x]["Item"].ToString() && Period == DtResult2.Rows[x]["Period"].ToString()) { HaveSec = true; U = x; } } if (HaveSec == true) { DtResult2.Rows[U]["Real_Pick_Qty"] = int.Parse(DtResult2.Rows[U]["Real_Pick_Qty"].ToString()) + int.Parse(Real_Pick_Qty); DtResult2.Rows[U]["Cost"] = decimal.Parse(DtResult2.Rows[U]["Cost"].ToString()) + decimal.Parse(Cost); } else { DataRow drResult2 = DtResult2.NewRow(); drResult2["BLocate_Section"] = BLocate_Section; drResult2["ELocate_Section"] = ELocate_Section; drResult2["Item"] = Item; drResult2["Period"] = Period; drResult2["Real_Pick_Qty"] = Real_Pick_Qty; drResult2["Cost"] = Cost; DtResult2.Rows.Add(drResult2); } } DtResult = null; return DtResult2; } catch (Exception ex) { throw ex; } }
public static string GetLocateByAttr(string ELocateNo) { string LocateSection = ""; //INVModel.MaintainStockTmpLocate BCO = new INVModel.MaintainStockTmpLocate(ConntionDB); IVMModel.MaintainRemoveByPick BCO = new IVMModel.MaintainRemoveByPick(ConntionDB); ParameterList.Clear(); ParameterList.Add(ELocateNo); ParameterList.Add("1"); LocateSection = BCO.GetLocateSecByAttr(ParameterList); return LocateSection; }
public static string GetLocateSecByAttr(string LocateNo,string strAttr,string Item,string Period) { int OnHd_Qty = 0; IVMModel.MaintainRemoveByPick BCOIVM = new IVMModel.MaintainRemoveByPick(ConntionDB); ParameterList.Clear(); ParameterList.Add(LocateNo); ParameterList.Add(strAttr); string LocateSec = BCOIVM.GetLocateSecByAttr(ParameterList); bool getSuccess = BCOIVM.GetStockQtyByLocateSec(Item, Period, LocateSec, out OnHd_Qty); if (getSuccess == false) { return LocateSec + "|" + "0"; } else { return LocateSec + "|" + OnHd_Qty.ToString(); } }
public static string GetTempLocate(string InSec) { try { IVMModel.MaintainRemoveByPick BCOStock = new IVMModel.MaintainRemoveByPick(ConntionDB); ParameterList.Clear(); ParameterList.Add(InSec); ParameterList.Add("1"); string InLocateSec = BCOStock.GetLocateSecByAttr(ParameterList); return InLocateSec; } catch { return "000000"; } }