///新增驗收單 /// *表頭參數: //(0)[@UserID] //(1)[@CreateDate] //(2)[@驗收日期] //(3)[@驗收時間] //(4)[@採購單號] //(5)[@廠商送貨單號] //(6)[@發票號碼] //(7)[@供應商] //(8)[@應稅總額] //(9)[@未稅總額] //(10)[@稅額] //*明細資料集參數: //(0)[@商品條碼] //(1)[@品號] //(2)[@期別] //(3)[@採購數量] //(4)[@預進日期] //(5)[@總驗收數] //(6)[@驗收數量] //(7)[@成本價] //(8)[@零售價] //(9)[@1包裝數] //(10)[@單品重量] //(11)[@單品長度] //(12)[@單品寬度] //(13)[@單品高度] //(14)[@包裝重量] //(15)[@包裝長度] //(16)[@包裝寬度] //(17)[@包裝高度] //(18)[@商品來源] //(19)[@製造日期] //(20)[@保存期限] //(21)[@有效日期] //(22)[@允收日期] //*品質檢驗資料集 //(1)[@品號] //(2)[@期別] //(3)[@檢查項目] //(4)[@是否正常] //(5)[@異常說明] //*贈品明細資料集參數: //(1)[@商品條碼] //(2)[@品號] //(3)[@期別] //(4)[@虛擬品號] //(5)[@採購數量] //(6)[@總驗收數] //(7)[@驗收數量] //(8)[@1包裝數] //(9)[@單品重量] //(10)[@單品長度] //(11)[@單品寬度] //(12)[@單品高度] //(13)[@包裝重量] //(14)[@包裝長度] //(15)[@包裝寬度] //(16)[@包裝高度] /// <summary> /// 建立驗收單 /// </summary> /// <param name="ParameterList"></param> /// <param name="dtDetls"></param> /// <param name="dtGifts"></param> /// <param name="RootDBT"></param> /// <param name="AcceptNo"></param> /// <param name="Statue"></param> /// <param name="ErrorItem"></param> public bool CreateAccept(ArrayList ParameterList, DataTable dtDetls, DataTable dtGifts, DbTransaction RootDBT, out string AcceptNo, out string Statue, out string ErrorItem) { bool IsRootTranscation = false; //檢查商品和贈品是不是都驗收了,未驗收結案才能繼續 ErrorItem = string.Empty; AcceptNo = string.Empty; Statue = string.Empty; int PID = -1; try { string UserID = ParameterList[0].ToString(); string UpdateDate = ParameterList[1].ToString(); string AcceptDate = ParameterList[2].ToString(); string AcceptTime = ParameterList[3].ToString(); string PurchaseNo = ParameterList[4].ToString(); string WaybillNo = ParameterList[5].ToString(); string InvoiceNo = ParameterList[6].ToString(); string Vender = ParameterList[7].ToString(); string TaxAmt = ParameterList[8].ToString(); string UtaxAmt = ParameterList[9].ToString(); string Tax = ParameterList[10].ToString(); DBO.MaintainAcceptDBO VGIDBO = new DBO.MaintainAcceptDBO(ref USEDB); DBO.MaintainAcceptQualityCheck VGIQC = new DBO.MaintainAcceptQualityCheck(strConn); PURDBO.MaintainGoodsInTransit PURDB = new PURDBO.MaintainGoodsInTransit(strConn); IVMDBO.MaintainStockInOut IVMDB = new IVMDBO.MaintainStockInOut(strConn); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion //新增主檔 ArrayList InsertParameter = new ArrayList(); InsertParameter.Clear(); InsertParameter.Add(UserID); InsertParameter.Add(UpdateDate); InsertParameter.Add(AcceptDate); InsertParameter.Add(AcceptTime); InsertParameter.Add(PurchaseNo); InsertParameter.Add(WaybillNo); InsertParameter.Add(InvoiceNo); InsertParameter.Add(Vender); InsertParameter.Add(TaxAmt); InsertParameter.Add(UtaxAmt); InsertParameter.Add(Tax); VGIDBO.CreateAcceptMain(InsertParameter, DBT, out PID, out AcceptNo); //新增明細 DataTable dtStockIn = new DataTable(); dtStockIn.Columns.Add("LocateNo"); dtStockIn.Columns.Add("LocateSec"); dtStockIn.Columns.Add("Item"); dtStockIn.Columns.Add("Period"); dtStockIn.Columns.Add("In_Qty"); dtStockIn.Columns.Add("Cost"); //取得入庫暫存儲區、儲格 string LocateNo = ""; string LocateSec = ""; LocateSec = VGIDBO.GetStockInTempLocateSec(); if (LocateSec == string.Empty) { throw new Exception("無法取得入庫暫存儲區或儲位"); } else { LocateNo = LocateSec.Substring(0, 1); } #region 商品明細 //barcode //item //period //purchase_Qty //In_Date //TAcc_Qty //Acc_Qty //Cost //Price //Package_Unit //S_Weight //S_Length //S_Width //S_Height //P_Weight //P_Length //P_Width //P_Height //Product_Source //Produce_Date //Reserved_Period //Valid_Date //AllowAccept_Date //Old_Qty //RowState for (int i = 0; i < dtDetls.Rows.Count; i++) { int DetlID = -1; string Barcode = dtDetls.Rows[i]["barcode"].ToString(); string Item = dtDetls.Rows[i]["item"].ToString(); string Period = dtDetls.Rows[i]["period"].ToString(); string PurchaseQty = dtDetls.Rows[i]["purchase_Qty"].ToString(); string In_Date = dtDetls.Rows[i]["In_Date"].ToString(); string TotalAcceptQty = dtDetls.Rows[i]["TAcc_Qty"].ToString(); string AcceptQty = dtDetls.Rows[i]["Acc_Qty"].ToString(); int accept_days = -1; int out_days = -1; //取得入庫單明細資料 DataRow drStockIn = dtStockIn.NewRow(); drStockIn["LocateNo"] = LocateNo; drStockIn["LocateSec"] = LocateSec; drStockIn["Item"] = Item; drStockIn["Period"] = Period; drStockIn["In_Qty"] = AcceptQty; drStockIn["Cost"] = dtDetls.Rows[i]["Cost"].ToString(); dtStockIn.Rows.Add(drStockIn); //寫入明細檔資料,逐筆寫入 InsertParameter.Clear(); InsertParameter.Add(UserID); InsertParameter.Add(UpdateDate); InsertParameter.Add(PID); InsertParameter.Add(AcceptNo); InsertParameter.Add(Barcode); //BarCode InsertParameter.Add(Item); //Item InsertParameter.Add(Period); //Period InsertParameter.Add(AcceptQty); //AcceptQty InsertParameter.Add(dtDetls.Rows[i]["Cost"].ToString()); //Cost InsertParameter.Add(dtDetls.Rows[i]["Price"].ToString()); //Price InsertParameter.Add(dtDetls.Rows[i]["Package_Unit"].ToString()); //Package_Unit InsertParameter.Add(dtDetls.Rows[i]["S_Weight"].ToString()); //S_Weight InsertParameter.Add(dtDetls.Rows[i]["S_Length"].ToString()); //S_Length InsertParameter.Add(dtDetls.Rows[i]["S_Width"].ToString()); //S_Width InsertParameter.Add(dtDetls.Rows[i]["S_Height"].ToString()); //S_Height InsertParameter.Add(dtDetls.Rows[i]["P_Weight"].ToString()); //P_Weight InsertParameter.Add(dtDetls.Rows[i]["P_Length"].ToString()); //P_Length InsertParameter.Add(dtDetls.Rows[i]["P_Width"].ToString()); //P_Width InsertParameter.Add(dtDetls.Rows[i]["P_Height"].ToString()); //P_Height InsertParameter.Add(dtDetls.Rows[i]["Product_Source"]); //Product_Source InsertParameter.Add(dtDetls.Rows[i]["Produce_Date"]); //Produce_Date InsertParameter.Add(dtDetls.Rows[i]["Reserved_Period"]); //Reserved_Period InsertParameter.Add(dtDetls.Rows[i]["Valid_Date"]); //Valid_Date InsertParameter.Add(dtDetls.Rows[i]["AllowAccept_Date"]); //AllowAccept_Date VGIDBO.CreateAcceptDetl(InsertParameter, DBT, out DetlID); //寫入商品檢驗結果 InsertParameter.Clear(); InsertParameter.Add(UserID); InsertParameter.Add(UpdateDate); InsertParameter.Add(DetlID); InsertParameter.Add(AcceptNo); InsertParameter.Add(Item); InsertParameter.Add(Period); VGIQC.CreateQualityCheck(InsertParameter, DBT); //若該商品品項的[@總驗收數]+[@驗收數量]>=[採購數量],則呼叫[MaintainPurchaseOrder.ClosePurchaseOrderDetail] if (int.Parse(TotalAcceptQty) + int.Parse(AcceptQty) >= int.Parse(PurchaseQty)) { InsertParameter.Clear(); InsertParameter.Add(UserID); InsertParameter.Add(PurchaseNo); InsertParameter.Add(Item); InsertParameter.Add(Period); //VirtualCode = Item InsertParameter.Add(Item); ClosePurchaseOrderDetail(InsertParameter, DBT); } //依傳入的明細資料集參數,將正常品資料回寫生效中(enable=1)的商品屬性檔(VDS_ITM_PERIOD_PROFILE)的下列欄位 InsertParameter.Clear(); InsertParameter.Add(Item); InsertParameter.Add(Period); InsertParameter.Add(dtDetls.Rows[i]["Package_Unit"].ToString()); //Package_Unit InsertParameter.Add(dtDetls.Rows[i]["S_Weight"].ToString()); //S_Weight InsertParameter.Add(dtDetls.Rows[i]["S_Length"].ToString()); //S_Length InsertParameter.Add(dtDetls.Rows[i]["S_Width"].ToString()); //S_Width InsertParameter.Add(dtDetls.Rows[i]["S_Height"].ToString()); //S_Height InsertParameter.Add(dtDetls.Rows[i]["P_Weight"].ToString()); //P_Weight InsertParameter.Add(dtDetls.Rows[i]["P_Length"].ToString()); //P_Length InsertParameter.Add(dtDetls.Rows[i]["P_Width"].ToString()); //P_Width InsertParameter.Add(dtDetls.Rows[i]["P_Height"].ToString()); //P_Height InsertParameter.Add(AcceptDate); InsertParameter.Add(AcceptQty); InsertParameter.Add(dtDetls.Rows[i]["Valid_Date"].ToString()); //Valid_Date InsertParameter.Add(dtDetls.Rows[i]["AllowAccept_Date"].ToString());//AllowAccept_Date UpdateItmPeriodProfile(UserID, UpdateDate, InsertParameter, DBT, out accept_days, out out_days); //呼叫[MaintainGoodsInTransit.UpdateGoodsInTrainsitByGoodsReceive],傳入[@品號],[@期別],[@虛擬品號],[@採購單號],[@驗收量](若品項為正常品,則[@虛擬品號]=[@品號]),更新在途量,若未找到相對應的在途單資料,表示未開立在途單,不需更新 InsertParameter.Clear(); InsertParameter.Add(PurchaseNo); InsertParameter.Add(Item); InsertParameter.Add(Period); InsertParameter.Add(Item); InsertParameter.Add(AcceptQty); PURDB.UpdateGoodsInTrainsitByGoodsReceive(InsertParameter, DBT); #region 贈品明細 //Barcode 商品條碼 //Item 品號 //Period 期別 //Virtual_Code 虛擬品號 //purchase_Qty 採購數量 //TAcc_Qty 總驗收數 //Accept_Qty 驗收數量 //accept_accqty //Old_Qty 驗收數量(原始 //Package_Unit 1包裝數 //S_Weight 單品重量 //S_Length 單品長度 //S_Width 單品寬度 //S_Height 單品高度 //P_Weight 包裝重量 //P_Length 包裝長度 //P_Width 包裝寬度 //P_Height 包裝高度 //RowState 包裝高度 //寫入贈品明細 for (int x = 0; x < dtGifts.Rows.Count; x++) { string GiftBarcode = dtGifts.Rows[x]["Barcode"].ToString(); string GiftItem = dtGifts.Rows[x]["Item"].ToString(); string GiftPeriod = dtGifts.Rows[x]["Period"].ToString(); string GiftVirtualCode = dtGifts.Rows[x]["Virtual_Code"].ToString(); string GiftTotalAcceptQty = dtGifts.Rows[x]["accept_accqty"].ToString(); //總驗收量 string GiftAcceptQty = dtGifts.Rows[x]["Accept_Qty"].ToString(); //驗收數量 string GiftAcceptQty_Old = dtGifts.Rows[x]["Old_Qty"].ToString(); string GiftPurchaseQty = dtGifts.Rows[x]["purchase_Qty"].ToString(); //採購數量 if (Barcode == GiftBarcode && Item == GiftItem && Period == GiftPeriod) { InsertParameter.Clear(); InsertParameter.Add(UserID); //0 InsertParameter.Add(UpdateDate); //1 InsertParameter.Add(DetlID); //2 InsertParameter.Add(dtGifts.Rows[x][0].ToString()); //3 Barcode InsertParameter.Add(GiftItem); //4 Item InsertParameter.Add(GiftPeriod); //5 Period InsertParameter.Add(GiftVirtualCode); //6 VirtualCode InsertParameter.Add(AcceptNo); //7 InsertParameter.Add(dtGifts.Rows[x]["purchase_Qty"].ToString()); //8 PurchaseQty InsertParameter.Add(dtGifts.Rows[x]["Accept_Qty"].ToString()); //9 AcceptQty InsertParameter.Add(dtGifts.Rows[x]["Package_Unit"].ToString()); //10 PackageUnit InsertParameter.Add(dtGifts.Rows[x]["S_Weight"].ToString()); //11 SWeight InsertParameter.Add(dtGifts.Rows[x]["S_Length"].ToString()); //12 SLength InsertParameter.Add(dtGifts.Rows[x]["S_Width"].ToString()); //13 SWidth InsertParameter.Add(dtGifts.Rows[x]["S_Height"].ToString()); //14 SHeigh InsertParameter.Add(dtGifts.Rows[x]["P_Weight"].ToString()); //15 PWeight InsertParameter.Add(dtGifts.Rows[x]["P_Length"].ToString()); //16 PLength InsertParameter.Add(dtGifts.Rows[x]["P_Width"].ToString()); //17 PWidth InsertParameter.Add(dtGifts.Rows[x]["P_Height"].ToString()); //18 PHeigh VGIDBO.CreateAcceptGift(InsertParameter, DBT); //若該贈品品項的[@總驗收數]+[@驗收數量]>=[採購數量],則呼叫[MaintainPurchaseOrder.ClosePurchaseOrderDetail] if (int.Parse(GiftTotalAcceptQty) + int.Parse(GiftAcceptQty) >= int.Parse(GiftPurchaseQty)) { InsertParameter.Clear(); InsertParameter.Add(UserID); //0 InsertParameter.Add(PurchaseNo); //1 InsertParameter.Add(GiftItem); //2 InsertParameter.Add(GiftPeriod); //3 InsertParameter.Add(GiftVirtualCode); //4 ClosePurchaseOrderDetail(InsertParameter, DBT); } //依傳入的贈品明細資料集參數,將贈品資料回寫贈品屬性檔(VDS_MKT_GIFT_PROFILE)的下列欄位 InsertParameter.Clear(); InsertParameter.Add(UserID); //0 InsertParameter.Add(UpdateDate); //1 InsertParameter.Add(GiftItem); //2 Item InsertParameter.Add(GiftPeriod); //3 Period InsertParameter.Add(GiftVirtualCode); //4 VirtualCode InsertParameter.Add(dtGifts.Rows[x]["Package_Unit"].ToString()); //5 PackageUnit InsertParameter.Add(dtGifts.Rows[x]["S_Weight"].ToString()); //6 SWeight InsertParameter.Add(dtGifts.Rows[x]["S_Length"].ToString()); //7 SLength InsertParameter.Add(dtGifts.Rows[x]["S_Width"].ToString()); //8 SWidth InsertParameter.Add(dtGifts.Rows[x]["S_Height"].ToString()); //9 SHeigh InsertParameter.Add(dtGifts.Rows[x]["P_Weight"].ToString()); //10 PWeight InsertParameter.Add(dtGifts.Rows[x]["P_Length"].ToString()); //11 PLength InsertParameter.Add(dtGifts.Rows[x]["P_Width"].ToString()); //12 PWidth InsertParameter.Add(dtGifts.Rows[x]["P_Height"].ToString()); //13 PHeigh InsertParameter.Add(AcceptDate); //14 InsertParameter.Add(dtGifts.Rows[x]["Accept_Qty"].ToString()); //15 InsertParameter.Add(accept_days); //16 InsertParameter.Add(out_days); //17 //UpdateGiftProfile(UserID, UpdateDate, accept_days, out_days, InsertParameter,DBT); DBO.MaintainAcceptDBO dbo = new DBO.MaintainAcceptDBO(ref USEDB); dbo.UpdateMktGiftProfile(InsertParameter, DBT); //呼叫[MaintainGoodsInTransit.UpdateGoodsInTrainsitByGoodsReceive],傳入[@品號],[@期別],[@虛擬品號],[@採購單號],[@驗收量](若品項為正常品,則[@虛擬品號]=[@品號]),更新在途量,若未找到相對應的在途單資料,表示未開立在途單,不需更新 InsertParameter.Clear(); InsertParameter.Add(PurchaseNo); //0 InsertParameter.Add(GiftItem); //1 InsertParameter.Add(GiftPeriod); //2 InsertParameter.Add(GiftVirtualCode); //3 InsertParameter.Add(Convert.ToString(int.Parse(GiftAcceptQty_Old) - int.Parse(GiftAcceptQty))); //4 PURDB.UpdateGoodsInTrainsitByGoodsReceive(InsertParameter, DBT); } } #endregion //判斷該品項是否需產生新的期別 //(1)該品項的期別(period)若不為[000000]且定期出刊(select attribute from vds_itm_item where item=[@item] , attribute的值為=1表示定期出刊),則需需產生下一期別資料 //(2)產生新期別的步驟如下: //*檢查該品項期別是否已產生下一期期別資料(select count(*) from vds_itm_period_main where item=@item and period=lpad(to_char(to_number(@period) +(select period_step from vds_itm_item where item=@item)),6,'0')),若尚未產生,則呼叫[MaintainSKUPeriod.ProcessAddNextPeriod]產生新的期別資料,傳入資料參數如[新增下一期別.doc]文件所述 InsertParameter.Clear(); InsertParameter.Add(Item); InsertParameter.Add(Period); string V_Next = VGIDBO.CheckNextPeriod(InsertParameter); if (V_Next == "1") { string Msg = ""; string Result = ""; InsertParameter.Clear(); InsertParameter.Add(AcceptNo); InsertParameter.Add(UserID); InsertParameter.Add(DateTime.Now); VGIDBO.AddNextPeriod(InsertParameter, DBT, out Msg, out Result); if (Result != "1") { throw new Exception("新增下一期別發生錯誤" + Msg); } } } #endregion //建立入庫單 //取得入庫單主檔資料 >輸入變數 0.CheckFreeze_Flag(預設1) 1.ReasonNo 2.ADJNo 3.SourceNo 4.UserID //(0)Flag //(1)出入庫原因 (InOut_Reason_No)=S1 //(2)調整單號 (Adjust_No)=null //(3)來源單號 (Source_No)=[@驗收單號] //(4)使用者 InsertParameter.Clear(); InsertParameter.Add("1"); InsertParameter.Add("S1"); InsertParameter.Add(""); InsertParameter.Add(AcceptNo); InsertParameter.Add(UserID); IVMDB.CreateStockIn(InsertParameter, dtStockIn, DBT); #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return true; } 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 } }
public bool UpdateAccept_2(ArrayList ParameterList, DataTable dtDetls, DataTable dtGifts, DbTransaction RootDBT, out string Statue, out string ErrorItem, out string ErrMsg) { bool IsRootTranscation = false; ErrorItem = string.Empty; Statue = string.Empty; ErrMsg = string.Empty; int ID = -1; int PID = -1; string Result = ""; try { string UserID = ParameterList[0].ToString(); string UpdateDate = ParameterList[1].ToString(); string AcceptNo = ParameterList[2].ToString(); string AcceptDate = ParameterList[3].ToString(); string PurchaseNo = ParameterList[4].ToString(); string WaybillNo = ParameterList[5].ToString(); string InvoiceNo = ParameterList[6].ToString(); string TaxAmt = ParameterList[7].ToString(); string UtaxAmt = ParameterList[8].ToString(); string Tax = ParameterList[9].ToString(); DBO.MaintainAcceptDBO VGIDBO = new DBO.MaintainAcceptDBO(ref USEDB); DBO.MaintainAcceptQualityCheck VGIQC = new DBO.MaintainAcceptQualityCheck(strConn); PURDBO.MaintainGoodsInTransit PURDB = new PURDBO.MaintainGoodsInTransit(strConn); IVMDBO.MaintainStockInOut IVMDB = new IVMDBO.MaintainStockInOut(strConn); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion ArrayList InsertParameter = new ArrayList(); #region 商品明細 //barcode //item //period //purchase_Qty //In_Date //TAcc_Qty //Acc_Qty //Cost //Price //Package_Unit //S_Weight //S_Length //S_Width //S_Height //P_Weight //P_Length //P_Width //P_Height //Product_Source //Produce_Date //Reserved_Period //Valid_Date //AllowAccept_Date //Old_Qty //RowState for (int i = 0; i < dtDetls.Rows.Count; i++) { int DetlID = -1; string Barcode = dtDetls.Rows[i]["barcode"].ToString(); string Item = dtDetls.Rows[i]["item"].ToString(); string Period = dtDetls.Rows[i]["period"].ToString(); string In_Date = dtDetls.Rows[i]["In_Date"].ToString(); string PurchaseQty = dtDetls.Rows[i]["purchase_Qty"].ToString(); string TotalAcceptQty = dtDetls.Rows[i]["TAcc_Qty"].ToString(); string AcceptQty = dtDetls.Rows[i]["Acc_Qty"].ToString(); string OLDQty = dtDetls.Rows[i]["Old_Qty"].ToString(); string DFlag = dtDetls.Rows[i]["RowState"].ToString(); int accept_days = -1; int out_days = -1; //寫入明細檔資料,逐筆寫入 InsertParameter.Clear(); InsertParameter.Add(UserID); InsertParameter.Add(UpdateDate); InsertParameter.Add(AcceptNo); InsertParameter.Add(Barcode); //BarCode InsertParameter.Add(Item); //Item InsertParameter.Add(Period); //Period InsertParameter.Add(AcceptQty); //NewQty InsertParameter.Add(dtDetls.Rows[i]["Cost"].ToString()); //Cost InsertParameter.Add(dtDetls.Rows[i]["Price"].ToString()); //Price InsertParameter.Add(dtDetls.Rows[i]["Package_Unit"].ToString()); //Package_Unit InsertParameter.Add(dtDetls.Rows[i]["S_Weight"].ToString()); //S_Weight InsertParameter.Add(dtDetls.Rows[i]["S_Length"].ToString()); //S_Length InsertParameter.Add(dtDetls.Rows[i]["S_Width"].ToString()); //S_Width InsertParameter.Add(dtDetls.Rows[i]["S_Height"].ToString()); //S_Height InsertParameter.Add(dtDetls.Rows[i]["P_Weight"].ToString()); //P_Weight InsertParameter.Add(dtDetls.Rows[i]["P_Length"].ToString()); //P_Length InsertParameter.Add(dtDetls.Rows[i]["P_Width"].ToString()); //P_Width InsertParameter.Add(dtDetls.Rows[i]["P_Height"].ToString()); //P_Height InsertParameter.Add(dtDetls.Rows[i]["Product_Source"].ToString()); //Product_Source InsertParameter.Add(dtDetls.Rows[i]["Produce_Date"].ToString()); //Produce_Date InsertParameter.Add(dtDetls.Rows[i]["Reserved_Period"].ToString()); //Reserved_Period InsertParameter.Add(dtDetls.Rows[i]["Valid_Date"].ToString()); //Valid_Date InsertParameter.Add(dtDetls.Rows[i]["AllowAccept_Date"].ToString());//AllowAccept_Date InsertParameter.Add(DFlag); //23.FLAG InsertParameter.Add(dtDetls.Rows[i]["UPDATEDATE"]); //OLD UPDATEDATE InsertParameter.Add(dtDetls.Rows[i]["UPDATEUID"]); //OLD UPDATEUID VGIDBO.UpdateAcceptDetl_2(InsertParameter, DBT, out DetlID); //依傳入的明細資料集參數,將正常品資料回寫生效中(enable=1)的商品屬性檔(VDS_ITM_PERIOD_PROFILE)的下列欄位 InsertParameter.Clear(); InsertParameter.Add(Item); InsertParameter.Add(Period); InsertParameter.Add(dtDetls.Rows[i]["Package_Unit"].ToString()); //Package_Unit InsertParameter.Add(dtDetls.Rows[i]["S_Weight"].ToString()); //S_Weight InsertParameter.Add(dtDetls.Rows[i]["S_Length"].ToString()); //S_Length InsertParameter.Add(dtDetls.Rows[i]["S_Width"].ToString()); //S_Width InsertParameter.Add(dtDetls.Rows[i]["S_Height"].ToString()); //S_Height InsertParameter.Add(dtDetls.Rows[i]["P_Weight"].ToString()); //P_Weight InsertParameter.Add(dtDetls.Rows[i]["P_Length"].ToString()); //P_Length InsertParameter.Add(dtDetls.Rows[i]["P_Width"].ToString()); //P_Width InsertParameter.Add(dtDetls.Rows[i]["P_Height"].ToString()); //P_Height InsertParameter.Add(AcceptDate); InsertParameter.Add(AcceptQty); //NewQty InsertParameter.Add(dtDetls.Rows[i]["Valid_Date"].ToString()); //Valid_Date InsertParameter.Add(dtDetls.Rows[i]["AllowAccept_Date"].ToString());//AllowAccept_Date //23.FLAG //24 OldQty UpdateItmPeriodProfile_2(UserID, UpdateDate, InsertParameter, DBT, out accept_days, out out_days); #region 贈品明細 //Barcode 商品條碼 //Item 品號 //Period 期別 //Virtual_Code 虛擬品號 //purchase_Qty 採購數量 //GiftName //Accept_Qty 驗收數量 //accept_accqty 總驗收數 //Old_Qty 驗收數量(原始) //SQty 剩餘數量 //Package_Unit 1包裝數 //S_Weight 單品重量 //S_Length 單品長度 //S_Width 單品寬度 //S_Height 單品高度 //P_Weight 包裝重量 //P_Length 包裝長度 //P_Width 包裝寬度 //P_Height 包裝高度 //UPDATEUID //UPDATEDATE //RowState "U"; if (DFlag == "U") { //更新贈品明細 for (int x = 0; x < dtGifts.Rows.Count; x++) { string GiftBarcode = dtGifts.Rows[x]["Barcode"].ToString(); string GiftItem = dtGifts.Rows[x]["Item"].ToString(); string GiftPeriod = dtGifts.Rows[x]["Period"].ToString(); string GiftVirtualCode = dtGifts.Rows[x]["Virtual_Code"].ToString(); string GFlag = dtGifts.Rows[x]["RowState"].ToString(); string GiftTotalAcceptQty = dtGifts.Rows[x]["accept_accqty"].ToString(); string GiftAcceptQty = dtGifts.Rows[x]["Accept_Qty"].ToString(); string GiftAcceptQty_Old = dtGifts.Rows[x]["Old_Qty"].ToString(); string GiftPurchaseQty = dtGifts.Rows[x]["purchase_Qty"].ToString(); if (Barcode == GiftBarcode && Item == GiftItem && Period == GiftPeriod) { InsertParameter.Clear(); InsertParameter.Add(UserID); //0 InsertParameter.Add(UpdateDate); //1 InsertParameter.Add(DetlID); //2 InsertParameter.Add(dtGifts.Rows[x]["Barcode"].ToString()); //3 Barcode InsertParameter.Add(GiftItem); //4 Item InsertParameter.Add(GiftPeriod); //5 Period InsertParameter.Add(GiftVirtualCode); //6 VirtualCode InsertParameter.Add(AcceptNo); //7 InsertParameter.Add(dtGifts.Rows[x]["purchase_Qty"].ToString());//8 PurchaseQty InsertParameter.Add(dtGifts.Rows[x]["Accept_Qty"].ToString()); //9 AcceptQty InsertParameter.Add(dtGifts.Rows[x]["Package_Unit"].ToString());//10 PackageUnit InsertParameter.Add(dtGifts.Rows[x]["S_Weight"].ToString()); //11 SWeight InsertParameter.Add(dtGifts.Rows[x]["S_Length"].ToString()); //12 SLength InsertParameter.Add(dtGifts.Rows[x]["S_Width"].ToString()); //13 SWidth InsertParameter.Add(dtGifts.Rows[x]["S_Height"].ToString()); //14 SHeigh InsertParameter.Add(dtGifts.Rows[x]["P_Weight"].ToString()); //15 PWeight InsertParameter.Add(dtGifts.Rows[x]["P_Length"].ToString()); //16 PLength InsertParameter.Add(dtGifts.Rows[x]["P_Width"].ToString()); //17 PWidth InsertParameter.Add(dtGifts.Rows[x]["P_Height"].ToString()); //18 PHeigh InsertParameter.Add(dtGifts.Rows[x]["RowState"].ToString()); //19 RowState InsertParameter.Add(dtGifts.Rows[x]["UPDATEDATE"]); //20 OLD UPDATEDATE InsertParameter.Add(dtGifts.Rows[x]["UPDATEUID"]); //21 OLD UPDATEUID VGIDBO.UpdateAcceptGift_2(InsertParameter, DBT); if (GFlag == "U") { //依傳入的贈品明細資料集參數,將贈品資料回寫贈品屬性檔(VDS_MKT_GIFT_PROFILE)的下列欄位 InsertParameter.Clear(); InsertParameter.Add(UserID); //0 InsertParameter.Add(UpdateDate); //1 InsertParameter.Add(GiftItem); //2 Item InsertParameter.Add(GiftPeriod); //3 Period InsertParameter.Add(GiftVirtualCode); //4 VirtualCode InsertParameter.Add(dtGifts.Rows[x]["Package_Unit"].ToString());//5 PackageUnit InsertParameter.Add(dtGifts.Rows[x]["S_Weight"].ToString()); //6 SWeight InsertParameter.Add(dtGifts.Rows[x]["S_Length"].ToString()); //7 SLength InsertParameter.Add(dtGifts.Rows[x]["S_Width"].ToString()); //8 SWidth InsertParameter.Add(dtGifts.Rows[x]["S_Height"].ToString()); //9 SHeigh InsertParameter.Add(dtGifts.Rows[x]["P_Weight"].ToString()); //10 PWeight InsertParameter.Add(dtGifts.Rows[x]["P_Length"].ToString()); //11 PLength InsertParameter.Add(dtGifts.Rows[x]["P_Width"].ToString()); //12 PWidth InsertParameter.Add(dtGifts.Rows[x]["P_Height"].ToString()); //13 PHeigh InsertParameter.Add(AcceptDate); //14 InsertParameter.Add(dtGifts.Rows[x]["Accept_Qty"].ToString()); //15 accept_qty InsertParameter.Add(accept_days); //16 InsertParameter.Add(out_days); //17 DBO.MaintainAcceptDBO dbo = new DBO.MaintainAcceptDBO(ref USEDB); dbo.UpdateMktGiftProfile_2(InsertParameter, DBT); } } } } #endregion } #endregion #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return true; } 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 } }
public bool CalculateReturnTaxByReturnNo(ArrayList ParameterList, DbTransaction RootDBT) { string ReturnNo = ParameterList[0].ToString(); string UserID = ParameterList[1].ToString(); string UpdateDate = ParameterList[2].ToString(); bool IsRootTranscation = false; ArrayList UpdateParamter = new ArrayList(); try { DBO.UpdateReturnData db = new UpdateReturnData(ref USEDB); IVMDBO.MaintainStockInOut dbStock = new IVMDBO.MaintainStockInOut(strConn); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion UpdateParamter.Clear(); UpdateParamter.Add(ReturnNo); UpdateParamter.Add(UserID); UpdateParamter.Add(UpdateDate); db.UpdateReturnMainTax(UpdateParamter, DBT); #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return true; } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw ex; } }
/// <summary> /// 更新退貨單及出庫單 /// </summary> /// <param name="ParameterList">0:UserID 1:UpdateDate 2:ReturnNo 3:ID 4.UpdateTime</param> /// <param name="dtUpdate">0:Item 1:Period 3:OnHD_Qty 3:New_Qty 4.ID 5: Old_Qty</param> /// <param name="RootDBT">Transaction</param> /// <returns></returns> public bool UpdateReturnData(ArrayList ParameterList, DataTable dtUpdate, DbTransaction RootDBT) { string UserID = ParameterList[0].ToString(); string UpdateDate = ParameterList[1].ToString(); string ReturnNo = ParameterList[2].ToString(); string UnTax_Total_Amt = ParameterList[3].ToString(); string Tax_Total_Amt = ParameterList[4].ToString(); string UnTax_ReMain_Amt = ParameterList[5].ToString(); string Tax_ReMain_Amt = ParameterList[6].ToString(); string Tax_Amt = ParameterList[7].ToString(); string ID = ParameterList[8].ToString(); string UpdateTime = ParameterList[9].ToString(); string LocateSection = ""; bool IsRootTranscation = false; ArrayList UpdateParamter = new ArrayList(); try { DBO.UpdateReturnData db = new UpdateReturnData(ref USEDB); IVMDBO.MaintainStockInOut dbStock = new IVMDBO.MaintainStockInOut(strConn); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion //更新主表資料 UpdateParamter.Clear(); UpdateParamter.Add(UserID); UpdateParamter.Add(UpdateDate); UpdateParamter.Add(ReturnNo); UpdateParamter.Add(UnTax_Total_Amt); UpdateParamter.Add(Tax_Total_Amt); UpdateParamter.Add(UnTax_ReMain_Amt); UpdateParamter.Add(Tax_ReMain_Amt); UpdateParamter.Add(Tax_Amt); UpdateParamter.Add(ID); UpdateParamter.Add(UpdateTime); db.UpdateReturnMain(UpdateParamter, DBT); //更新Detl資料 for (int i = 0; i < dtUpdate.Rows.Count; i++) { UpdateParamter.Clear(); UpdateParamter.Add(UserID); UpdateParamter.Add(UpdateDate); UpdateParamter.Add(dtUpdate.Rows[i]["ID"].ToString()); UpdateParamter.Add(int.Parse(dtUpdate.Rows[i]["return_qty"].ToString())); db.UpdateReturnDetl(UpdateParamter, DBT); } //更新稅額資料 UpdateParamter.Clear(); UpdateParamter.Add(ReturnNo); UpdateParamter.Add(UserID); UpdateParamter.Add(UpdateDate); db.UpdateReturnMainTax(UpdateParamter, DBT); //更新出庫單 //取得STOCKOUT儲區 LocateSection = db.QueryStockOutLocation(ReturnNo); if (LocateSection == string.Empty) { throw new Exception("查無對應的儲位可供更新!"); } UpdateParamter.Clear(); UpdateParamter.Add("1"); UpdateParamter.Add(ReturnNo); UpdateParamter.Add(UserID); //建立更新所使用的datatable DataTable dtStockout = new DataTable(); dtStockout.Columns.Add("Locate_No"); dtStockout.Columns.Add("Locate_Section"); dtStockout.Columns.Add("Item"); dtStockout.Columns.Add("Period"); dtStockout.Columns.Add("Old_Qty"); dtStockout.Columns.Add("New_Qty"); for(int i = 0; i<dtUpdate.Rows.Count; i++) { DataRow drStock = dtStockout.NewRow(); drStock["Locate_No"] = LocateSection.Substring(0,1) ; drStock["Locate_Section"] = LocateSection; drStock["Item"]= dtUpdate.Rows[i][0].ToString() ; drStock["Period"] = dtUpdate.Rows[i][1].ToString(); drStock["Old_Qty"] = int.Parse(dtUpdate.Rows[i][9].ToString()); drStock["New_Qty"] = int.Parse(dtUpdate.Rows[i][3].ToString()); dtStockout.Rows.Add(drStock); } dbStock.UpdStockOut(UpdateParamter, dtStockout, DBT); #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return true; } catch (Exception ex) { #region 交易失敗 if (IsRootTranscation) { //獨立呼叫Transcation失敗 DBT.Rollback(); } #endregion throw ex; } }
/// <summary> /// 建立退貨單主檔 /// </summary> /// <param name="ParameterList">0:UserID 1:ReturnDate(yyyy/MM/dd HH:mm:ss) 2:@IsAdj 3:退貨LocateSection 4:Vendor 5:ReturnNo 6:AdjustNo 7:UnTax_Total_Amt 8:Tax_Total_Amt 9:UnTax_ReMain_Amt 10:Tax_ReMain_Am 11:Tax_Amt</param> /// <param name="dtDetail">欄位 0:item 1:Period 2:tax_type 3:onhd_qty 4:return_qty 5:adjust_qty 6:cost 7:price</param> /// <param name="RootDBT">使用的交易 null代表無傳入交易系統可以自行產生</param> /// <param name="ReturnNo">退貨單號 10碼</param> /// <param name="MainID"> 主表單ID </param> /// <param name="AdjustNo">調整單號</param> /// <returns>是否成功</returns> public bool CreateReturnData(ArrayList ParameterList, DataTable dtDetail, DbTransaction RootDBT, out string ReturnNo, out string MainID, out string AdjustNo) { ReturnNo = ""; MainID = ""; AdjustNo = ""; string AdjMainID = ""; int PID = 0; bool IsRootTranscation = false; string UserID = ParameterList[0].ToString(); string ReturnDate = ParameterList[1].ToString(); string IsAdj = ParameterList[2].ToString(); string LocateSection = ParameterList[3].ToString(); string LocateNo = LocateSection.Substring(0,1); string Vendor = ParameterList[4].ToString(); string ReasonNo = ParameterList[5].ToString(); string AdjReason = ParameterList[6].ToString(); string strReasonNO = ""; ArrayList ErrorList = new ArrayList(); try { //建立退貨主檔資料 DBO.CreateReturnData db = new CreateReturnData(ref USEDB); DBO.UpdateReturnData dbu = new UpdateReturnData(ref USEDB); IVMDBO.MaintainAdjustData dbAdj = new IVMDBO.MaintainAdjustData(strConn); IVMDBO.MaintainStockInOut dbStock = new IVMDBO.MaintainStockInOut(strConn); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion if (IsAdj == "1") //建立調整單並建立出庫單 { ArrayList AdjustList = new ArrayList(); AdjustList.Add(UserID); AdjustList.Add(ReturnDate); AdjustList.Add(AdjReason); AdjustList.Add(ReasonNo); //轉換DataTable資料格式 DataTable DtAdjust = new DataTable(); //轉換DataTable資料格式 DtAdjust.Columns.Add("Locate_No", typeof(String)); DtAdjust.Columns.Add("Locate_Section", typeof(String)); DtAdjust.Columns.Add("Item", typeof(String)); DtAdjust.Columns.Add("Period", typeof(String)); DtAdjust.Columns.Add("Adjust_Qty", typeof(Int32)); DtAdjust.Columns.Add("Cost", typeof(Double)); for (int i = 0; i < dtDetail.Rows.Count; i++) { if (int.Parse(dtDetail.Rows[i]["Adjust_Qty"].ToString()) != 0) { DataRow dr = DtAdjust.NewRow(); dr["Locate_No"] = LocateNo; dr["Locate_Section"] = LocateSection; dr["Item"] = dtDetail.Rows[i][0].ToString(); dr["Period"] = dtDetail.Rows[i][1].ToString(); dr["Adjust_Qty"] = int.Parse(dtDetail.Rows[i][5].ToString()); dr["Cost"] = double.Parse(dtDetail.Rows[i][6].ToString()); DtAdjust.Rows.Add(dr); } } //建立調整單 dbAdj.CreateAdjustData(AdjustList, DtAdjust, DBT, out AdjMainID, out AdjustNo, out ErrorList); } ArrayList ReturnMainList = new ArrayList(); ReturnMainList.Add(UserID); ReturnMainList.Add(ReturnDate); ReturnMainList.Add(Vendor); ReturnMainList.Add(decimal.Parse(ParameterList[7].ToString())); ReturnMainList.Add(decimal.Parse(ParameterList[8].ToString())); ReturnMainList.Add(decimal.Parse(ParameterList[9].ToString())); ReturnMainList.Add(decimal.Parse(ParameterList[10].ToString())); ReturnMainList.Add(decimal.Parse(ParameterList[11].ToString())); db.CreateReturnMain(ReturnMainList, DBT, out PID,out ReturnNo); strReasonNO = ReturnNo; MainID = PID.ToString(); //建立Detail資料 ArrayList ReturnDetailList = new ArrayList(); for (int i = 0; i < dtDetail.Rows.Count; i++) { ReturnDetailList.Clear(); ReturnDetailList.Add(UserID); ReturnDetailList.Add(ReturnDate); ReturnDetailList.Add(PID); ReturnDetailList.Add(dtDetail.Rows[i][0].ToString()); //item ReturnDetailList.Add(dtDetail.Rows[i][1].ToString()); //Period ReturnDetailList.Add(dtDetail.Rows[i][2].ToString()); //tax_type ReturnDetailList.Add(dtDetail.Rows[i][3].ToString()); //onhd_qty ReturnDetailList.Add(dtDetail.Rows[i][4].ToString()); //return_qty ReturnDetailList.Add(dtDetail.Rows[i][5].ToString()); //adjust_qty ReturnDetailList.Add(dtDetail.Rows[i][6].ToString()); //cost ReturnDetailList.Add(dtDetail.Rows[i][7].ToString()); //price db.CreateReturnDetl(ReturnDetailList, DBT, out PID); } //計算稅額 ReturnMainList.Clear(); ReturnMainList.Add(ReturnNo); ReturnMainList.Add(UserID); ReturnMainList.Add(ReturnDate); dbu.UpdateReturnMainTax(ReturnMainList, DBT); //建立出庫單 ArrayList StockList = new ArrayList(); StockList.Add("1"); StockList.Add("S4"); StockList.Add(AdjustNo); StockList.Add(strReasonNO); StockList.Add(UserID); DataTable DtStock = new DataTable(); DtStock.Columns.Add("Locate_No", typeof(String)); DtStock.Columns.Add("Locate_Section", typeof(String)); DtStock.Columns.Add("Item", typeof(String)); DtStock.Columns.Add("Period", typeof(String)); DtStock.Columns.Add("InOut_Qty", typeof(Int32)); DtStock.Columns.Add("Cost", typeof(Double)); for (int i = 0; i < dtDetail.Rows.Count; i++) { DataRow dr = DtStock.NewRow(); dr["Locate_No"] = LocateNo; dr["Locate_Section"] = LocateSection; dr["Item"] = dtDetail.Rows[i][0].ToString(); dr["Period"] = dtDetail.Rows[i][1].ToString(); dr["InOut_Qty"] = int.Parse(dtDetail.Rows[i][4].ToString()); dr["Cost"] = double.Parse(dtDetail.Rows[i][6].ToString()); DtStock.Rows.Add(dr); } dbStock.CreateStockOut(StockList, DtStock, DBT); db.UpdateMainAdjustNo(MainID, AdjustNo, 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 } }
/// <summary> /// 新增調整單主程式 /// </summary> /// <param name="ParameterList">1.USER_ID 2.AdjustDate 3.AdjustReason 4.Option FALG(沒有的話就用預設值1) </param> /// <param name="dtDetail">Detail資訊</param> /// <param name="RootDBT">傳入的交易</param> /// <returns>true false 失敗</returns> /// <param name="ReturnList">[0]:ID [1]:AdjustNo [2]:ErrItem</param> public bool CreateAdjustData(ArrayList ParameterList, DataTable dtDetail, DbTransaction RootDBT, out string MainID, out string AdjustNo, out ArrayList ErrList) { bool HaveSpace = true; MainID = ""; AdjustNo = ""; int PID = 0; string UserID = ParameterList[0].ToString(); string AdjustDate = ParameterList[1].ToString(); string AdjustReason = ParameterList[2].ToString(); bool IsRootTranscation = false; string strDateNow = DateTime.Now.ToString("yyyyMMddHHmmss"); ArrayList ItemQtyList = new ArrayList(); try { VDS_IVM11_DBO dbo = new VDS_IVM11_DBO(ref USEDB); MaintainStockInOut BCOStock = new MaintainStockInOut(strConn); //判斷是否有傳入Root Transcation IsRootTranscation = (RootDBT == null) ? true : false; #region 啟動交易或指定RootTranscation if (IsRootTranscation) { //獨立呼叫啟動Transcation Conn = USEDB.CreateConnection(); Conn.Open(); DBT = Conn.BeginTransaction(); } else { DBT = RootDBT; } #endregion #region 檢查儲位大小是否可以新增 HaveSpace = CheckSpace(dtDetail, out ErrList, out ItemQtyList,DBT); if (HaveSpace == false) { if (IsRootTranscation) { DBT.Rollback(); } return HaveSpace; } #endregion #region 建立調整單主檔 ArrayList AdjustMainList = new ArrayList(); AdjustMainList.Clear(); AdjustMainList.Add(UserID); AdjustMainList.Add(AdjustDate); AdjustMainList.Add(AdjustReason); AdjustMainList.Add(strDateNow); dbo.CreateAdjustMain(AdjustMainList, DBT, out PID, out AdjustNo); MainID = PID.ToString(); #endregion #region Build AdjustDetail ArrayList AdjustDetlList = new ArrayList(); DataTable dtStockIn = dtDetail.Clone(); DataTable dtStockOut = dtDetail.Clone(); for (int i = 0; i < dtDetail.Rows.Count; i++) { AdjustDetlList.Clear(); AdjustDetlList.Add(UserID); AdjustDetlList.Add(PID); AdjustDetlList.Add(dtDetail.Rows[i][0].ToString()); AdjustDetlList.Add(dtDetail.Rows[i][1].ToString()); AdjustDetlList.Add(dtDetail.Rows[i][2].ToString()); AdjustDetlList.Add(dtDetail.Rows[i][3].ToString()); AdjustDetlList.Add(int.Parse(ItemQtyList[i].ToString())); AdjustDetlList.Add(int.Parse(dtDetail.Rows[i][4].ToString())); AdjustDetlList.Add(double.Parse(dtDetail.Rows[i][5].ToString())); AdjustDetlList.Add(strDateNow); dbo.CreateAdjustDetl(AdjustDetlList, DBT); //需要將資料表分成兩個 if (int.Parse(dtDetail.Rows[i][4].ToString()) > 0) { DataRow drIn = dtStockIn.NewRow(); for (int j = 0; j < dtDetail.Rows[i].ItemArray.Length; j++) { drIn[j] = dtDetail.Rows[i][j]; } dtStockIn.Rows.Add(drIn); } else if (int.Parse(dtDetail.Rows[i][4].ToString()) < 0) { DataRow drOut = dtStockOut.NewRow(); for (int j = 0; j < dtDetail.Rows[i].ItemArray.Length; j++) { if (j == 4) { drOut[j] = int.Parse(dtDetail.Rows[i][j].ToString()) * -1; } else { drOut[j] = dtDetail.Rows[i][j]; } } dtStockOut.Rows.Add(drOut); } } #region 出入庫單參數 ArrayList StockList = new ArrayList(); if (ParameterList.Count == 4) { StockList.Add(ParameterList[3].ToString()); } else { StockList.Add("1"); } StockList.Add("S6"); StockList.Add(""); StockList.Add(AdjustNo); StockList.Add(UserID); #endregion if (dtStockIn.Rows.Count > 0) { BCOStock.CreateStockIn(StockList, dtStockIn, DBT); } if (dtStockOut.Rows.Count > 0) { BCOStock.CreateStockOut(StockList, dtStockOut, DBT); } #endregion #region 交易成功 if (IsRootTranscation) { //獨立呼叫Transcation成立 DBT.Commit(); } #endregion return HaveSpace; } 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 } }