public string OnShelves(DataTable dt, string cartonNO, string UserCode) { WarehouseFacade facade = null; InventoryFacade _Invenfacade = null; DBDateTime dbTime = FormatHelper.GetNowDBDateTime(DataProvider); object obj = null; if (facade == null) { facade = new WarehouseFacade(DataProvider); } if (_Invenfacade == null) { _Invenfacade = new InventoryFacade(DataProvider); } this.DataProvider.BeginTransaction(); try { string Stno = string.Empty; for (int j = 0; j < dt.Rows.Count; j++) { obj = facade.GetAsndetail(int.Parse(dt.Rows[j]["stline"].ToString()), dt.Rows[j]["stno"].ToString()); if (obj != null) { Stno = (obj as Asndetail).Stno; #region 更新asndetail表 更新actqty和状态 //update actqty and status Asndetail asndetail = obj as Asndetail; asndetail.ActQty = asndetail.QcpassQty; asndetail.Status = ASNDetail_STATUS.ASNDetail_Close; asndetail.MaintainDate = dbTime.DBDate; asndetail.MaintainTime = dbTime.DBTime; asndetail.MaintainUser = UserCode; facade.UpdateAsndetail(asndetail); #endregion #region 更新asndetailitem表 更新 actqty 和更新invoicedetail表,更新actqty object[] itemobjs = facade.GetASNDetailItembyStnoAndStline(asndetail.Stno, asndetail.Stline.ToString()); if (itemobjs != null) { for (int i = 0; i < itemobjs.Length; i++) { Asndetailitem asnitem = itemobjs[i] as Asndetailitem; asnitem.ActQty = asnitem.QcpassQty; asnitem.MaintainDate = dbTime.DBDate; asnitem.MaintainTime = dbTime.DBTime; asnitem.MaintainUser = UserCode; facade.UpdateAsndetailitem(asnitem); object invoiobj = _Invenfacade.GetInvoicesDetail(asnitem.Invno, int.Parse(asnitem.Invline)); InvoicesDetail inv = invoiobj as InvoicesDetail; inv.ActQty += Convert.ToInt32(asnitem.QcpassQty); inv.MaintainDate = dbTime.DBDate; inv.MaintainTime = dbTime.DBTime; inv.MaintainUser = UserCode; _Invenfacade.UpdateInvoicesDetail(inv); } } #endregion //新增数据tblstoragedetail object asnobj = facade.GetAsn(asndetail.Stno); if (asnobj == null) { this.DataProvider.RollbackTransaction(); // WebInfoPublish.Publish(this, "$Error_ASN_NO_DATA", this.languageComponent1); return("ASN 中没有数据:" + asndetail.Stno); } Asn asn = asnobj as Asn; #region 在storagedetail表中增加一条数据 StorageDetail stordetail = _Invenfacade.CreateNewStorageDetail(); stordetail.AvailableQty = asndetail.ActQty; stordetail.CartonNo = asndetail.Cartonno; stordetail.CDate = dbTime.DBDate; stordetail.CTime = dbTime.DBTime; stordetail.CUser = UserCode; stordetail.DQMCode = asndetail.DqmCode; stordetail.FacCode = (asnobj as Asn).FacCode; stordetail.FreezeQty = 0; stordetail.LastStorageAgeDate = dbTime.DBDate; stordetail.LocationCode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(cartonNO)); stordetail.Lotno = asndetail.Lotno; stordetail.MaintainDate = dbTime.DBDate; stordetail.MaintainTime = dbTime.DBTime; stordetail.MaintainUser = UserCode; stordetail.MCode = asndetail.MCode; stordetail.MDesc = asndetail.MDesc; stordetail.ProductionDate = asndetail.Production_Date; stordetail.ReworkApplyUser = (asnobj as Asn).ReworkapplyUser; stordetail.StorageAgeDate = string.IsNullOrEmpty(asndetail.StorageageDate.ToString()) ? dbTime.DBDate : int.Parse(asndetail.StorageageDate); stordetail.StorageCode = (asnobj as Asn).StorageCode; stordetail.StorageQty = asndetail.ActQty; stordetail.SupplierLotNo = asndetail.Supplier_lotno; stordetail.Unit = asndetail.Unit; _Invenfacade.AddStorageDetail(stordetail); #endregion #region 在StorageDetailSN表中增加数据 //新增数据tblStorageDetailSN object[] snobj = facade.GetASNDetailSNbyStnoandStline(asndetail.Stno, asndetail.Stline.ToString()); if (snobj == null) { this.DataProvider.RollbackTransaction(); // WebInfoPublish.Publish(this, "$Error_ASNDetail_NO_DATA", this.languageComponent1); return("ASNDetail表中没有数据:" + asndetail.Stno + "/" + asndetail.Stline.ToString()); } for (int i = 0; i < snobj.Length; i++) { StorageDetailSN storDetailSN = _Invenfacade.CreateNewStorageDetailSN(); Asndetailsn detailSN = snobj[i] as Asndetailsn; storDetailSN.CartonNo = detailSN.Cartonno; storDetailSN.CDate = dbTime.DBDate; storDetailSN.CTime = dbTime.DBTime; storDetailSN.CUser = UserCode; storDetailSN.MaintainDate = dbTime.DBDate; storDetailSN.MaintainTime = dbTime.DBTime; storDetailSN.MaintainUser = UserCode; storDetailSN.PickBlock = "N"; storDetailSN.SN = detailSN.Sn; _Invenfacade.AddStorageDetailSN(storDetailSN); } #endregion #region 在invinouttrans表中增加一条数据 InvInOutTrans trans = facade.CreateNewInvInOutTrans(); trans.CartonNO = asndetail.Cartonno; trans.DqMCode = asndetail.DqmCode; trans.FacCode = asn.FacCode; trans.FromFacCode = asn.FromfacCode; trans.FromStorageCode = asn.FromstorageCode; trans.InvNO = asn.Invno; trans.InvType = asn.StType; trans.LotNo = asndetail.Lotno; trans.MaintainDate = dbTime.DBDate; trans.MaintainTime = dbTime.DBTime; trans.MaintainUser = UserCode; trans.MCode = asndetail.MCode; trans.ProductionDate = asndetail.Production_Date; trans.Qty = asndetail.ActQty; trans.Serial = 0; trans.StorageAgeDate = int.Parse(asndetail.StorageageDate); trans.StorageCode = asn.StorageCode; trans.SupplierLotNo = asndetail.Supplier_lotno; trans.TransNO = asn.Stno; trans.TransType = "IN"; trans.Unit = asndetail.Unit; facade.AddInvInOutTrans(trans); #endregion } } #region 架完成后,检查这个stno在asndetail中的状态是否都是close,cancel,如果是将asn表的状态更新为close,cancel if (facade.JudgeASNDetailStatus(Stno, ASNDetail_STATUS.ASNDetail_Close)) { object asnobj = facade.GetAsn(Stno); if (asnobj == null) { this.DataProvider.RollbackTransaction(); //WebInfoPublish.Publish(this, "$Error_ASN_NO_DATA", this.languageComponent1); return("ASN 中没有数据:" + Stno); } Asn asn = asnobj as Asn; asn.Status = ASN_STATUS.ASN_Close; asn.MaintainDate = dbTime.DBDate; asn.MaintainTime = dbTime.DBTime; asn.MaintainUser = UserCode; facade.UpdateAsn(asn); } if (facade.JudgeASNDetailStatus(Stno, ASNDetail_STATUS.ASNDetail_Cancel)) { object asnobj = facade.GetAsn(Stno); if (asnobj == null) { this.DataProvider.RollbackTransaction(); //WebInfoPublish.Publish(this, "$Error_ASN_NO_DATA", this.languageComponent1); return("ASN中没有数据:" + Stno); } Asn asn = asnobj as Asn; asn.Status = ASN_STATUS.ASN_Cancel; asn.MaintainDate = dbTime.DBDate; asn.MaintainTime = dbTime.DBTime; asn.MaintainUser = UserCode; facade.UpdateAsn(asn); } #endregion #region 通过入库指令号,查找invno,检查actqty是否等于planqty,如果等于将finishflag=Y object asnobj1 = facade.GetAsn(Stno); if (asnobj1 == null) { this.DataProvider.RollbackTransaction(); //WebInfoPublish.Publish(this, "$Error_ASN_NO_DATA", this.languageComponent1); return("ASN中没有数据:" + Stno); } Asn asn1 = asnobj1 as Asn; if (facade.JudgeInvoiceDetailStatus(asn1.Invno)) { object invobj = _Invenfacade.GetInvoices(asn1.Invno); if (invobj == null) { this.DataProvider.RollbackTransaction(); //WebInfoPublish.Publish(this, "$Error_INV_NO_DATA", this.languageComponent1); return("INV中没有数据:" + asn1.Invno); } Invoices inv = invobj as Invoices; inv.FinishFlag = "Y"; inv.MaintainDate = dbTime.DBDate; inv.MaintainTime = dbTime.DBTime; inv.MaintainUser = UserCode; _Invenfacade.UpdateInvoices(inv); } #endregion this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); } return("上架成功"); }
public string Commit_Click(string userCode, string statusList, string transNo, string tLocationCode, string fromCarton, string tcarton, string inputsn, string inputqty) { string msg; #region facade InventoryFacade facade = new InventoryFacade(this.DataProvider); if (_WarehouseFacade == null) { _WarehouseFacade = new WarehouseFacade(this.DataProvider); } ItemFacade itemFacade = new ItemFacade(); DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); #endregion #region check if (string.IsNullOrEmpty(transNo)) { msg = "移转单号不能为空"; return(msg); } StorageDetail storageCarton = (StorageDetail)facade.GetStorageDetail(fromCarton); if (storageCarton == null) { //A 根据原箱号和数量操作。根据原箱号(cartonno)到TBLStorageDetail中查找数据。没有报错。 msg = "转储单中没有对应的原箱号"; return(msg); } if (string.IsNullOrEmpty(tLocationCode)) { msg = "目标货位不能为空"; return(msg); } if (string.IsNullOrEmpty(tcarton)) { msg = "目标箱号不能为空"; return(msg); } Storloctrans storloctrans = (Storloctrans)_WarehouseFacade.GetStorloctrans(transNo); if (storloctrans == null) { msg = "移转单号不存在"; return(msg); } #endregion string msgsn = ""; StorageDetail fromStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(fromCarton); StorageDetail toStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(tcarton); if (fromStorageDetail == null) { return("原箱号在库存中不存在!"); } StorloctransDetail storloctransdetailObj = (StorloctransDetail)_WarehouseFacade.GetStorloctransdetail(transNo, fromStorageDetail.MCode); if (storloctransdetailObj == null) { return("转储单中没有对应的物料号"); } Location tLocation = (Location)facade.GetLocation(tLocationCode, 1); if (fromStorageDetail.StorageCode != tLocation.StorageCode) { return("原货位的库位必须与目标货位的库位一致!"); } if (toStorageDetail != null && toStorageDetail.StorageCode != fromStorageDetail.StorageCode) { return("目标箱号的库位必须原箱号的库位一样!"); } if (tcarton != fromCarton && toStorageDetail != null && toStorageDetail.LocationCode != tLocation.LocationCode) { return("目标箱号的货位必须与填写的目标货位一致!"); } if (toStorageDetail != null && toStorageDetail.DQMCode != fromStorageDetail.DQMCode) { return("目标箱号的物料必须与原箱号的物料一致!"); } if ((statusList == CartonType.CartonType_SplitCarton) && (tcarton == fromCarton)) { return("拆箱必须原箱号和目标箱号不同!"); } try { this.DataProvider.BeginTransaction(); InvInOutTrans trans = _WarehouseFacade.CreateNewInvInOutTrans(); trans.CartonNO = tcarton; trans.DqMCode = fromStorageDetail.DQMCode; trans.FacCode = fromStorageDetail.FacCode; trans.FromFacCode = fromStorageDetail.FacCode; trans.FromStorageCode = fromStorageDetail.StorageCode; trans.InvNO = " "; trans.InvType = " "; trans.LotNo = " "; trans.MaintainDate = dbDateTime.DBDate; trans.MaintainTime = dbDateTime.DBTime; trans.MaintainUser = userCode; trans.MCode = fromStorageDetail.MCode; trans.ProductionDate = fromStorageDetail.ProductionDate; trans.Qty = fromStorageDetail.StorageQty; trans.Serial = 0; trans.StorageAgeDate = fromStorageDetail.StorageAgeDate; trans.StorageCode = fromStorageDetail.StorageCode; trans.SupplierLotNo = fromStorageDetail.SupplierLotNo; trans.TransNO = transNo; trans.TransType = "IN"; trans.ProcessType = "LocationTrans"; trans.Unit = fromStorageDetail.Unit; _WarehouseFacade.AddInvInOutTrans(trans); #region【整箱】: if (statusList == CartonType.CartonType_AllCarton) { msgsn = "箱号:" + fromCarton; if (fromStorageDetail.FreezeQty > 0) { return("此箱号以被占用不能移动"); } if (_WarehouseFacade.GetStorageDetailSNPickBlockCount(fromCarton) > 0) { return("此箱号SN已被被占用不能移动"); } if (_WarehouseFacade.GetStorloctransdetailcarton(transNo, fromCarton, tcarton) != null) { return(transNo + "此单下已存在" + fromCarton + "移动到" + tcarton + ",请另行创建单据!"); } facade.DeleteStorageDetail(fromStorageDetail); toStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(tcarton); if (toStorageDetail == null) { toStorageDetail = new StorageDetail(); toStorageDetail.AvailableQty = 0; toStorageDetail.CartonNo = tcarton; toStorageDetail.CDate = FormatHelper.TODateInt(DateTime.Now); toStorageDetail.CTime = FormatHelper.TOTimeInt(DateTime.Now); toStorageDetail.CUser = userCode; toStorageDetail.DQMCode = fromStorageDetail.DQMCode; toStorageDetail.FacCode = fromStorageDetail.FacCode; toStorageDetail.FreezeQty = 0; toStorageDetail.LastStorageAgeDate = fromStorageDetail.LastStorageAgeDate; toStorageDetail.LocationCode = tLocationCode; toStorageDetail.Lotno = fromStorageDetail.Lotno; toStorageDetail.MaintainDate = FormatHelper.TODateInt(DateTime.Now); toStorageDetail.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); toStorageDetail.MaintainUser = userCode; toStorageDetail.MCode = fromStorageDetail.MCode; toStorageDetail.MDesc = fromStorageDetail.MDesc; toStorageDetail.ProductionDate = fromStorageDetail.ProductionDate; toStorageDetail.ReworkApplyUser = fromStorageDetail.ReworkApplyUser; toStorageDetail.StorageAgeDate = fromStorageDetail.StorageAgeDate; toStorageDetail.StorageCode = fromStorageDetail.StorageCode; toStorageDetail.StorageQty = 0; toStorageDetail.SupplierLotNo = fromStorageDetail.SupplierLotNo; toStorageDetail.Unit = fromStorageDetail.Unit; toStorageDetail.ValidStartDate = fromStorageDetail.ValidStartDate; facade.AddStorageDetail(toStorageDetail); } toStorageDetail.StorageQty += fromStorageDetail.StorageQty; toStorageDetail.AvailableQty += fromStorageDetail.AvailableQty; facade.UpdateStorageDetail(toStorageDetail); StorloctransDetail storloctransDetail = (StorloctransDetail)_WarehouseFacade.GetStorloctransdetail(transNo, fromStorageDetail.MCode); storloctransDetail.Qty += fromStorageDetail.AvailableQty; _WarehouseFacade.UpdateStorloctransdetail(storloctransDetail); #region 4, 向TBLStorLocTransDetailCarton插入一笔数据。 StorloctransDetailCarton newstorlocDetailCarton = new StorloctransDetailCarton(); newstorlocDetailCarton.Transno = transNo; //storlocDetailCarton.Transno = StorLocTransDetail.TransNo; newstorlocDetailCarton.MCode = fromStorageDetail.MCode; //MCODE:TBLStorLocTransDetail.MCODE newstorlocDetailCarton.DqmCode = fromStorageDetail.DQMCode; newstorlocDetailCarton.FacCode = "10Y2"; newstorlocDetailCarton.Qty = fromStorageDetail.StorageQty; //QTY: TBLStorageDetail. storageQTY newstorlocDetailCarton.LocationCode = tLocationCode; //LocationCode: TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找) newstorlocDetailCarton.Cartonno = tcarton; //CARTONNO:PDA页面的目标箱号 txtTLocationCartonEdit newstorlocDetailCarton.FromlocationCode = fromStorageDetail.LocationCode; //FromLocationCode:TBLStorageDetail.LocationCode newstorlocDetailCarton.Fromcartonno = fromStorageDetail.CartonNo; //FromCARTONNO:TBLStorageDetail. CARTONNO newstorlocDetailCarton.Lotno = fromStorageDetail.Lotno; //LotNo:TBLStorageDetail. LotNo newstorlocDetailCarton.CUser = userCode; // CUSER newstorlocDetailCarton.CDate = dbDateTime.DBDate; // CDATE newstorlocDetailCarton.CTime = dbDateTime.DBTime; // CTIME newstorlocDetailCarton.MaintainDate = dbDateTime.DBDate; // MDATE newstorlocDetailCarton.MaintainTime = dbDateTime.DBTime; // MTIME newstorlocDetailCarton.MaintainUser = userCode; _WarehouseFacade.AddStorloctransdetailcarton(newstorlocDetailCarton); #endregion //5, 如果原箱号在TBLStorageDetailSN有SN信息,将SN信息插入到TBLStorLocTransDetailSN表 object[] storageDetailSnlist = facade.GetStorageDetailSnbyCarton(fromCarton); if (storageDetailSnlist != null) { foreach (StorageDetailSN newStorageDetailSn in storageDetailSnlist) { #region add TBLStorageDetailSN StorloctransDetailSN newStorloctransDetailSn = new StorloctransDetailSN(); newStorloctransDetailSn.Sn = newStorageDetailSn.SN; //SN:TBLStorageDetailSN.SN newStorloctransDetailSn.Transno = transNo; // TBLStorLocTransDetail. TransNo newStorloctransDetailSn.Fromcartonno = fromCarton; //FromCARTONNO:TBLStorageDetail.LocationCode newStorloctransDetailSn.Cartonno = tcarton; //FormatHelper.CleanString(txtTLocationCodeEdit.Text);//CARTONNO:TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找) newStorloctransDetailSn.MaintainDate = dbDateTime.DBDate; // MDATE newStorloctransDetailSn.MaintainTime = dbDateTime.DBTime; // MTIME newStorloctransDetailSn.MaintainUser = userCode; _WarehouseFacade.AddStorloctransdetailsn(newStorloctransDetailSn); newStorageDetailSn.CartonNo = tcarton; newStorageDetailSn.MaintainDate = FormatHelper.TODateInt(DateTime.Now); newStorageDetailSn.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); newStorageDetailSn.MaintainUser = userCode; facade.UpdateStorageDetailSN(newStorageDetailSn); #endregion } } } #endregion #region【拆箱】: else if (statusList == CartonType.CartonType_SplitCarton) { Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(storageCarton.MCode); if (material != null) { //2单件管控IsInt if (material.MCONTROLTYPE == BOMItemControlType.ITEM_CONTROL_KEYPARTS) { #region 单件管控: msgsn = "SN:" + inputsn; if (string.IsNullOrEmpty(inputsn)) { msg = "此箱为单件管控,请输入SN。"; return(msg); } StorageDetailSN storageDetailSn = (StorageDetailSN)facade.GetStorageDetailSN(inputsn); if (storageDetailSn == null) { return("此SN不存在!"); } if (storageDetailSn.CartonNo != fromCarton) { return("原箱中不存在此SN!"); } decimal storageQTY = fromStorageDetail.StorageQty - fromStorageDetail.FreezeQty; if (storageQTY <= 0) { return("原箱号的库存数量不足:" + storageQTY); } if (toStorageDetail == null) { toStorageDetail = new StorageDetail(); toStorageDetail.AvailableQty = 0; toStorageDetail.CartonNo = tcarton; toStorageDetail.CDate = FormatHelper.TODateInt(DateTime.Now); toStorageDetail.CTime = FormatHelper.TOTimeInt(DateTime.Now); toStorageDetail.CUser = userCode; toStorageDetail.DQMCode = fromStorageDetail.DQMCode; toStorageDetail.FacCode = fromStorageDetail.FacCode; toStorageDetail.FreezeQty = 0; toStorageDetail.LastStorageAgeDate = fromStorageDetail.LastStorageAgeDate; toStorageDetail.LocationCode = tLocationCode; toStorageDetail.Lotno = fromStorageDetail.Lotno; toStorageDetail.MaintainDate = FormatHelper.TODateInt(DateTime.Now); toStorageDetail.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); toStorageDetail.MaintainUser = userCode; toStorageDetail.MCode = fromStorageDetail.MCode; toStorageDetail.MDesc = fromStorageDetail.MDesc; toStorageDetail.ProductionDate = fromStorageDetail.ProductionDate; toStorageDetail.ReworkApplyUser = fromStorageDetail.ReworkApplyUser; toStorageDetail.StorageAgeDate = fromStorageDetail.StorageAgeDate; toStorageDetail.StorageCode = fromStorageDetail.StorageCode; toStorageDetail.StorageQty = 0; toStorageDetail.SupplierLotNo = fromStorageDetail.SupplierLotNo; toStorageDetail.Unit = fromStorageDetail.Unit; toStorageDetail.ValidStartDate = fromStorageDetail.ValidStartDate; facade.AddStorageDetail(toStorageDetail); } #region add by sam 2016年4月27日 storageDetailSn.CartonNo = tcarton; facade.UpdateStorageDetailSN(storageDetailSn); fromStorageDetail.StorageQty -= 1; fromStorageDetail.AvailableQty -= 1; facade.UpdateStorageDetail(fromStorageDetail); toStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(tcarton); toStorageDetail.StorageQty += 1; toStorageDetail.AvailableQty += 1; facade.UpdateStorageDetail(toStorageDetail); #endregion StorloctransDetail storloctransDetail = (StorloctransDetail)_WarehouseFacade.GetStorloctransdetail(transNo, fromStorageDetail.MCode); storloctransDetail.Qty += fromStorageDetail.AvailableQty; _WarehouseFacade.UpdateStorloctransdetail(storloctransDetail); StorloctransDetailCarton storloctransDetailCarton = (StorloctransDetailCarton) _WarehouseFacade.GetStorloctransdetailcarton(transNo, fromCarton, tcarton); if (storloctransDetailCarton != null) {// 如果有: 更新TBLStorLocTransDetailCarton.QTY+ PDA页面填的数量,MDate,MTime,MUser。 storloctransDetailCarton.Qty += 1; storloctransDetailCarton.MaintainDate = dbDateTime.DBDate; storloctransDetailCarton.MaintainTime = dbDateTime.DBTime; storloctransDetailCarton.MaintainUser = userCode; _WarehouseFacade.UpdateStorloctransdetailcarton(storloctransDetailCarton); } else { #region 4, 向TBLStorLocTransDetailCarton插入一笔数据。 StorloctransDetailCarton newstorlocDetailCarton = new StorloctransDetailCarton(); newstorlocDetailCarton.Transno = transNo;// storloctransdetailObj.Transno; //storlocDetailCarton.Transno = StorLocTransDetail.TransNo; newstorlocDetailCarton.DqmCode = storloctransdetailObj.DqmCode; newstorlocDetailCarton.FacCode = "10Y2"; newstorlocDetailCarton.MCode = storloctransdetailObj.MCode; //MCODE:TBLStorLocTransDetail.MCODE newstorlocDetailCarton.Qty = 1; // //QTY: 1 newstorlocDetailCarton.LocationCode = tLocationCode; // FormatHelper.CleanString(txtTLocationCodeEdit.Text);//LocationCode: TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找) newstorlocDetailCarton.Cartonno = tcarton; // FormatHelper.CleanString(txtTLocationCartonEdit.Text);//CARTONNO:PDA页面的目标箱号 txtTLocationCartonEdit newstorlocDetailCarton.FromlocationCode = fromStorageDetail.LocationCode; //FromLocationCode:TBLStorageDetail.LocationCode newstorlocDetailCarton.Fromcartonno = fromCarton; // rageDetail.CartonNo; //FromCARTONNO:TBLStorageDetail. CARTONNO newstorlocDetailCarton.Lotno = fromStorageDetail.Lotno; //LotNo:TBLStorageDetail. LotNo newstorlocDetailCarton.CUser = userCode; // CUSER newstorlocDetailCarton.CDate = dbDateTime.DBDate; // CDATE newstorlocDetailCarton.CTime = dbDateTime.DBTime; // CTIME newstorlocDetailCarton.MaintainDate = dbDateTime.DBDate; // MDATE newstorlocDetailCarton.MaintainTime = dbDateTime.DBTime; // MTIME newstorlocDetailCarton.MaintainUser = userCode; _WarehouseFacade.AddStorloctransdetailcarton(newstorlocDetailCarton); #endregion //说明:表中没有的字段来自TBLStorageDetail中对应字段 //F 向表TBLStorLocTransDetailSN插入一条数据。 StorloctransDetailSN newStorloctransDetailSn = new StorloctransDetailSN(); newStorloctransDetailSn.Sn = inputsn; //SN:TBLStorageDetailSN.SN newStorloctransDetailSn.Transno = storloctransdetailObj.Transno; // TBLStorLocTransDetail. TransNo newStorloctransDetailSn.Fromcartonno = fromCarton; //TBLStorageDetail.LocationCode newStorloctransDetailSn.Cartonno = tcarton; // FormatHelper.CleanString(txtTLocationCodeEdit.Text);//CARTONNO:TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找) newStorloctransDetailSn.MaintainDate = dbDateTime.DBDate; // MDATE newStorloctransDetailSn.MaintainTime = dbDateTime.DBTime; // MTIME newStorloctransDetailSn.MaintainUser = userCode; _WarehouseFacade.AddStorloctransdetailsn(newStorloctransDetailSn); } #endregion } else { #region 和非单件管控 //B 检查TBLStorageDetail. AvailableQTY>PDA页面填的数量。如果否,提示:输入的数量大于库存可用数量。 #region Check 数量 int qty; if (!string.IsNullOrEmpty(inputqty)) { try { qty = Int32.Parse(inputqty); } catch (Exception ex) { msg = "数量只能输入大于0的数字"; return(msg); } if (qty <= 0) { msg = "数量只能输入大于0的数字"; return(msg); } } else { msg = "数量不能为空"; return(msg); } #endregion decimal stroageQTY = fromStorageDetail.StorageQty - fromStorageDetail.FreezeQty; if (stroageQTY < qty) { msg = "输入的数量大于库存可用数量"; return(msg); } fromStorageDetail.AvailableQty -= qty; fromStorageDetail.StorageQty -= qty; facade.UpdateStorageDetail(fromStorageDetail); if (toStorageDetail == null) { toStorageDetail = new StorageDetail(); toStorageDetail.AvailableQty = 0; toStorageDetail.CartonNo = tcarton; toStorageDetail.CDate = FormatHelper.TODateInt(DateTime.Now); toStorageDetail.CTime = FormatHelper.TOTimeInt(DateTime.Now); toStorageDetail.CUser = userCode; toStorageDetail.DQMCode = fromStorageDetail.DQMCode; toStorageDetail.FacCode = fromStorageDetail.FacCode; toStorageDetail.FreezeQty = 0; toStorageDetail.LastStorageAgeDate = fromStorageDetail.LastStorageAgeDate; toStorageDetail.LocationCode = tLocationCode; toStorageDetail.Lotno = fromStorageDetail.Lotno; toStorageDetail.MaintainDate = FormatHelper.TODateInt(DateTime.Now); toStorageDetail.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); toStorageDetail.MaintainUser = userCode; toStorageDetail.MCode = fromStorageDetail.MCode; toStorageDetail.MDesc = fromStorageDetail.MDesc; toStorageDetail.ProductionDate = fromStorageDetail.ProductionDate; toStorageDetail.ReworkApplyUser = fromStorageDetail.ReworkApplyUser; toStorageDetail.StorageAgeDate = fromStorageDetail.StorageAgeDate; toStorageDetail.StorageCode = fromStorageDetail.StorageCode; toStorageDetail.StorageQty = 0; toStorageDetail.SupplierLotNo = fromStorageDetail.SupplierLotNo; toStorageDetail.Unit = fromStorageDetail.Unit; toStorageDetail.ValidStartDate = fromStorageDetail.ValidStartDate; facade.AddStorageDetail(toStorageDetail); } toStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(tcarton); toStorageDetail.StorageQty += qty; toStorageDetail.AvailableQty += qty; facade.UpdateStorageDetail(toStorageDetail); StorloctransDetailCarton storloctransDetailCarton = (StorloctransDetailCarton) _WarehouseFacade.GetStorloctransdetailcarton(transNo, fromCarton, tcarton); if (storloctransDetailCarton != null) { // 如果有: 更新TBLStorLocTransDetailCarton.QTY+ PDA页面填的数量,MDate,MTime,MUser。 storloctransDetailCarton.Qty += qty; // int.Parse(txtNumEdit.Text); storloctransDetailCarton.MaintainDate = dbDateTime.DBDate; storloctransDetailCarton.MaintainTime = dbDateTime.DBTime; storloctransDetailCarton.MaintainUser = userCode; _WarehouseFacade.UpdateStorloctransdetailcarton(storloctransDetailCarton); } else { #region 如果没有:插入一条数据 向TBLStorLocTransDetailCarton插入一笔数据。 StorloctransDetailCarton newstorlocDetailCarton = new StorloctransDetailCarton(); newstorlocDetailCarton.Transno = transNo; // storloctransdetailObj.Transno; newstorlocDetailCarton.DqmCode = fromStorageDetail.DQMCode; // storloctransdetailObj.DqmCode; newstorlocDetailCarton.FacCode = fromStorageDetail.FacCode; newstorlocDetailCarton.MCode = storageCarton.MCode; // storloctransdetailObj.MCode;//MCODE:TBLStorLocTransDetail.MCODE newstorlocDetailCarton.Qty = qty; //QTY: 1 newstorlocDetailCarton.LocationCode = tLocationCode; //FormatHelper.CleanString(txtTLocationCodeEdit.Text);//LocationCode: TBLLOCATION.LOCATIONCODE(根据PDA页面的目标货位找) newstorlocDetailCarton.Cartonno = tcarton; // FormatHelper.CleanString(txtTLocationCartonEdit.Text);//CARTONNO:PDA页面的目标箱号 txtTLocationCartonEdit newstorlocDetailCarton.FromlocationCode = fromStorageDetail.LocationCode; //FromLocationCode:TBLStorageDetail.LocationCode newstorlocDetailCarton.Fromcartonno = fromCarton; // storageDetail.CartonNo; //FromCARTONNO:TBLStorageDetail. CARTONNO newstorlocDetailCarton.Lotno = storageCarton.Lotno; //LotNo:TBLStorageDetail. LotNo newstorlocDetailCarton.CUser = userCode; // CUSER newstorlocDetailCarton.CDate = dbDateTime.DBDate; // CDATE newstorlocDetailCarton.CTime = dbDateTime.DBTime; // CTIME newstorlocDetailCarton.MaintainDate = dbDateTime.DBDate; // MDATE newstorlocDetailCarton.MaintainTime = dbDateTime.DBTime; // MTIME newstorlocDetailCarton.MaintainUser = userCode; _WarehouseFacade.AddStorloctransdetailcarton(newstorlocDetailCarton); #endregion } #endregion } } } #endregion fromStorageDetail = (StorageDetail)_WarehouseFacade.GetStorageDetail(fromCarton); if (fromStorageDetail != null && fromStorageDetail.StorageQty == 0) { _WarehouseFacade.DeleteStorageDetail(fromStorageDetail); } string documentno = CreateAutoDocmentsNo(); SaveDocmentsNo(documentno, userCode); this.DataProvider.CommitTransaction(); msg = "提交成功"; return(msg); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); msg = ex.Message; return(msg); } }
protected override void DeleteDomainObjects(ArrayList domainObjects) { if (_WarehouseFacade == null) { _WarehouseFacade = new WarehouseFacade(base.DataProvider); } if (_InventoryFacade == null) { _InventoryFacade = new InventoryFacade(this.DataProvider); } Pickdetailmaterialsn[] pickdetailmaterialList = ((Pickdetailmaterialsn[])domainObjects.ToArray(typeof(Pickdetailmaterialsn))); try { this.DataProvider.BeginTransaction(); foreach (Pickdetailmaterialsn pickdetailm in pickdetailmaterialList) { #region delete //请先删除箱单信息 string sn = pickdetailm.Sn; object[] list = _WarehouseFacade.GetCartoninvdetailsnBySn(sn); if (list != null) { this.DataProvider.RollbackTransaction(); WebInfoPublish.Publish(this, "请先删除箱单信息", this.languageComponent1); return; } #region delete 检查 //1、只有行明细是拣料中和拣料完成状态,且拣货任务令头状态是拣料状态或制作箱单状态时才可以删除。 PickDetail pickDetail = _InventoryFacade.GetPickDetail(pickdetailm.Pickno, pickdetailm.Pickline) as PickDetail; Pick pickHead = _InventoryFacade.GetPick(pickdetailm.Pickno) as Pick; if (pickDetail == null || pickHead == null) { this.DataProvider.RollbackTransaction(); return; } if (!(pickDetail.Status == PickDetail_STATUS.Status_Pick || pickDetail.Status == PickDetail_STATUS.Status_WaitPick || pickDetail.Status == PickDetail_STATUS.Status_ClosePick || pickDetail.Status == PickDetail_STATUS.Status_Cancel)) { this.DataProvider.RollbackTransaction(); WebInfoPublish.Publish(this, "行明细是拣料中和拣料完成,取消状态,才可以删除", this.languageComponent1); return; } if (!(pickHead.Status == PickHeadStatus.PickHeadStatus_Pick || pickDetail.Status == PickDetail_STATUS.Status_WaitPick || pickHead.Status == PickHeadStatus.PickHeadStatus_MakePackingList || pickHead.Status == PickHeadStatus.PickHeadStatus_Cancel)) { this.DataProvider.RollbackTransaction(); WebInfoPublish.Publish(this, "拣货任务令头状态是拣料状态或制作箱单,取消状态时,才可以删除", this.languageComponent1); return; } //delete pickdetailmsn _WarehouseFacade.DeletePickdetailmaterialsn(pickdetailm); // tblPickdetailmaterial object[] snlist = _WarehouseFacade.QueryPickdetailmaterialsnByCartonno(pickdetailm.Pickno, pickdetailm.Cartonno); Pickdetailmaterial pickdetailmaterial = _WarehouseFacade.GetPickdetailmaterial(pickdetailm.Pickno, pickdetailm.Cartonno) as Pickdetailmaterial; if (pickdetailmaterial != null) { pickdetailmaterial.Qty -= 1; _WarehouseFacade.UpdatePickdetailmaterial(pickdetailmaterial); if (snlist == null) { _WarehouseFacade.DeletePickdetailmaterial(pickdetailmaterial); } } //3、所有已拣行明细删除后,拣货任务令状态变更为待拣料。 #endregion StorageDetail storageDetail = _WarehouseFacade.GetStorageDetail(pickdetailm.Cartonno) as StorageDetail; if (storageDetail != null) { storageDetail.FreezeQty -= 1; storageDetail.AvailableQty += 1; _WarehouseFacade.UpdateStorageDetail(storageDetail); } StorageDetailSN storageDetailsn = _InventoryFacade.GetStorageDetailSN(pickdetailm.Sn) as StorageDetailSN; if (storageDetailsn != null) { storageDetailsn.PickBlock = "N"; _InventoryFacade.UpdateStorageDetailSN(storageDetailsn); } int count = _WarehouseFacade.GetPickdetailmaterialCount(pickdetailm.Pickno); pickDetail.SQTY -= 1; if (pickDetail.Status != "Cancel") { pickDetail.Status = PickDetail_STATUS.Status_Pick; } if (count == 0) { //pickHead.Status = PickHeadStatus.PickHeadStatus_WaitPick; _WarehouseFacade.UpdatePick(pickHead); //pickDetail.Status = PickDetail_STATUS.Status_WaitPick; } _WarehouseFacade.UpdatePickdetail(pickDetail); #endregion } this.DataProvider.CommitTransaction(); WebInfoPublish.Publish(this, "删除成功", this.languageComponent1); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); WebInfoPublish.PublishInfo(this, ex.Message, this.languageComponent1); } }
public string Submit(string transNo, string fromCartonNo, string qty, string sn, string locationCode, string rdoSelectType, string mUser, IDomainDataProvider DataProvider) { InventoryFacade _InventoryFacade = new InventoryFacade(DataProvider); WarehouseFacade _WarehouseFacade = new WarehouseFacade(DataProvider); DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(DataProvider); int mDate = dbDateTime.DBDate; int mTime = dbDateTime.DBTime; try { DataProvider.BeginTransaction(); #region Check Storloctrans storloctrans = (Storloctrans)_WarehouseFacade.GetStorloctrans(transNo); if (storloctrans == null) { DataProvider.RollbackTransaction(); return("无此转储单信息"); } //原箱号:后台获取其库位和货位(TBLStorageDetail),查找条件:根据箱号到TBLStorageDetail中查找库存信息; //若库位和出库库位(TBLStorLocTrans. FromStorageCode)不符则报错。 StorageDetail storageDetail = (StorageDetail)_InventoryFacade.GetStorageDetail(fromCartonNo); if (storageDetail == null) { DataProvider.RollbackTransaction(); return("库存明细信息表里没有对应箱号的数据"); } if (!storageDetail.StorageCode.Equals(storloctrans.FromstorageCode)) { DataProvider.RollbackTransaction(); return("库位和出库库位不符"); } //一 根据箱号到TBLStorageDetail查找mcode,根据(转单号,mcode)查找TBLStorLocTransDetail 中数据,如果没有则报错:转储单中没有对应的SAP物料号 StorloctransDetail storloctransDetail = _WarehouseFacade.GetStorloctransdetail(transNo, storageDetail.MCode) as StorloctransDetail; if (storloctransDetail == null) { DataProvider.RollbackTransaction(); return("转储单中没有对应的SAP物料号"); } //二 判断(CartonNO对应的MCode),(TransNo)在TBLStorLocTransDetail中的状态是否为Close:完成, //如果是提示该料转储已经完成,如果是Release(初始化),更新状态为(Pick,拣料中) 。 if (storloctransDetail.Status == "Close") { DataProvider.RollbackTransaction(); return("该料转储已经完成"); } decimal total = _WarehouseFacade.GetStorloctransDetailDqmCodeQtySum(transNo, storageDetail.DQMCode); decimal smaller = _WarehouseFacade.GetStorloctransDetailCartonDqmCodeQtySum(transNo, storageDetail.DQMCode); if (rdoSelectType == "整箱") { smaller += storageDetail.StorageQty; } else { smaller += string.IsNullOrEmpty(sn) ? decimal.Parse(qty) : 1; } if (smaller > total) { DataProvider.RollbackTransaction(); return("此物料的转储数量已经超过转储单" + transNo + "规定的数量!"); } if (storloctransDetail.Status == "Release") { storloctransDetail.Status = "Pick"; storloctransDetail.MaintainUser = mUser; storloctransDetail.MaintainDate = mDate; storloctransDetail.MaintainTime = mTime; _WarehouseFacade.UpdateStorloctransdetail(storloctransDetail); } #endregion if (rdoSelectType == "整箱") { #region 整箱 //1, 检查TBLStorageDetail.FreezeQTY是否为零?不为零,检查是否TBLStorageDetail.FreezeQTY= //TBLStorageDetail. STORAGEQTY?如果是:提示此箱在拣料中;如果不是提示此箱SN部分拣料中,请拆箱拣料。 #region TBLStorageDetail if (storageDetail.FreezeQty != 0) { if (storageDetail.FreezeQty == storageDetail.StorageQty) { DataProvider.RollbackTransaction(); return("此箱在拣料中"); } else { DataProvider.RollbackTransaction(); return("此箱SN部分拣料中,请拆箱拣料"); } } //2, 更新TBLStorageDetail. FreezeQTY= TBLStorageDetail. STORAGEQTY,TBLStorageDetail. AvailableQTY=0。 storageDetail.FreezeQty = storageDetail.StorageQty; storageDetail.AvailableQty = 0; storageDetail.MaintainUser = mUser; storageDetail.MaintainDate = mDate; storageDetail.MaintainTime = mTime; _InventoryFacade.UpdateStorageDetail(storageDetail); #endregion //3, 更新TBLStorageDetailSN. PICKBLOCK=Y。 //StorageDetail[] storageDetails = _WarehouseFacade.GetStorageDetailsFromCARTONNO(fromCartonNo); Material mar = _WarehouseFacade.GetMaterialFromDQMCode(storageDetail.DQMCode); if (mar == null) { DataProvider.RollbackTransaction(); return("原箱号物料信息不存在"); } bool issn = false || mar.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_KEYPARTS; //单件管控 List <string> snList = new List <string>(); #region storageDetailSN if (issn) { object[] objs = _WarehouseFacade.GetStorageDetailSnbyCartonNo(fromCartonNo); if (objs == null) { DataProvider.RollbackTransaction(); return("库存明细SN信息表里没有对应箱号的数据"); } foreach (StorageDetailSN storageDetailSN in objs) { snList.Add(storageDetailSN.SN);//记sn号 storageDetailSN.PickBlock = "Y"; storageDetailSN.MaintainUser = mUser; storageDetailSN.MaintainDate = mDate; storageDetailSN.MaintainTime = mTime; _InventoryFacade.UpdateStorageDetailSN(storageDetailSN); } } #endregion #region StorloctransDetailCarton LocationCode为空 StorloctransDetailCarton storCarton = _WarehouseFacade.GetStorLocTransDetailCarton(transNo, fromCartonNo); if (storCarton == null) { StorloctransDetailCarton storloctransDetailCarton = new StorloctransDetailCarton(); storloctransDetailCarton.Transno = transNo; storloctransDetailCarton.MCode = storloctransDetail.MCode; storloctransDetailCarton.DqmCode = storageDetail.DQMCode; storloctransDetailCarton.MDesc = storageDetail.MDesc; storloctransDetailCarton.Unit = storageDetail.Unit; storloctransDetailCarton.Supplier_lotno = storageDetail.SupplierLotNo; storloctransDetailCarton.Production_Date = storageDetail.ProductionDate; storloctransDetailCarton.StorageageDate = storageDetail.StorageAgeDate; storloctransDetailCarton.LaststorageageDate = storageDetail.LastStorageAgeDate; storloctransDetailCarton.ValidStartDate = storageDetail.ValidStartDate; storloctransDetailCarton.FacCode = storageDetail.FacCode; storloctransDetailCarton.Qty = storageDetail.StorageQty; storloctransDetailCarton.LocationCode = locationCode; storloctransDetailCarton.Cartonno = " "; storloctransDetailCarton.FromlocationCode = storageDetail.LocationCode; storloctransDetailCarton.Fromcartonno = storageDetail.CartonNo; storloctransDetailCarton.Lotno = storageDetail.Lotno; storloctransDetailCarton.CUser = mUser; storloctransDetailCarton.CDate = mDate; storloctransDetailCarton.CTime = mTime; storloctransDetailCarton.MaintainUser = mUser; storloctransDetailCarton.MaintainDate = mDate; storloctransDetailCarton.MaintainTime = mTime; _WarehouseFacade.AddStorloctransdetailcarton(storloctransDetailCarton); } #endregion #region 6.如果原箱号在TBLStorageDetailSN有SN信息,将SN信息插入到TBLStorLocTransDetailSN表 if (issn) { if (snList.Count > 0) { StorloctransDetailSN storloctransDetailSN = new StorloctransDetailSN(); foreach (string storageDetailSn in snList) { storloctransDetailSN.Transno = transNo; storloctransDetailSN.Cartonno = " "; storloctransDetailSN.Fromcartonno = fromCartonNo; storloctransDetailSN.Sn = storageDetailSn;// storageDetailSN.SN; storloctransDetailSN.MaintainUser = mUser; storloctransDetailSN.MaintainDate = mDate; storloctransDetailSN.MaintainTime = mTime; _WarehouseFacade.AddStorloctransdetailsn(storloctransDetailSN); } } } #endregion #endregion } else { #region 拆箱 //1, 无论输入是【原箱号】,【SN】,首先判断管控类型,如果是单件管控,已输入SN为条件进行录入; //如果是批管控或不管控则以【原箱号】和【数量】为录入条件。 StorageDetail[] storageDetails = _WarehouseFacade.GetStorageDetailsFromCARTONNO(fromCartonNo); if (storageDetails == null) { DataProvider.RollbackTransaction(); return("原箱号无库存信息"); } Material mar = _WarehouseFacade.GetMaterialFromDQMCode(storageDetails[0].DQMCode); if (mar == null) { DataProvider.RollbackTransaction(); return("原箱号物料信息不存在"); } bool issn = false || mar.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_KEYPARTS; if (mar.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_KEYPARTS) //单件管控 { #region 单件管控 if (string.IsNullOrEmpty(sn)) { DataProvider.RollbackTransaction(); return("必须输入SN号码"); } if (!string.IsNullOrEmpty(qty)) { DataProvider.RollbackTransaction(); return("单件管控料不需要输入数量"); } //A 根据SN在TBLStorageDetail查看是否TBLStorageDetail.FreezeQTY= TBLStorageDetail. STORAGEQTY?如果等于,提示:此箱在拣料中;如果不等于0,检查TBLStorageDetailSN. PICKBLOCK是否是Y,如果是提示:此SN正在拣料中。 StorageDetailSN storageDetailSN = _InventoryFacade.GetStorageDetailSN(sn) as StorageDetailSN; if (storageDetailSN == null) { DataProvider.RollbackTransaction(); return("刷入SN条码不存在"); } StorageDetail _storageDetail = _InventoryFacade.GetStorageDetail(storageDetailSN.CartonNo) as StorageDetail; if (_storageDetail == null) { DataProvider.RollbackTransaction(); return("输入的SN找不到库存信息"); } if (_storageDetail.FreezeQty == _storageDetail.StorageQty) { DataProvider.RollbackTransaction(); return("此箱在拣料中"); } else { if (storageDetailSN.PickBlock == "Y") { DataProvider.RollbackTransaction(); return("此SN正在拣料中"); } } //B 根据SN在TBLStorageDetail中查找mcode信息,再根据(mcode+TransNo)信息在TBLStorLocTransDetail中是否有数据,如果没有则报错:转储单中没有对应的SAP物料号。 StorloctransDetail _storloctransDetail = _WarehouseFacade.GetStorloctransdetail(transNo, _storageDetail.MCode) as StorloctransDetail; if (_storloctransDetail == null) { DataProvider.RollbackTransaction(); return("转储单中没有对应的SAP物料号"); } //C 更新TBLStorageDetail. FreezeQTY= TBLStorageDetail. FreezeQTY+1,TBLStorageDetail. AvailableQTY= TBLStorageDetail.STORAGEQTY-TBLStorageDetail. FreezeQTY。 _storageDetail.FreezeQty += 1; _storageDetail.AvailableQty = _storageDetail.StorageQty - _storageDetail.FreezeQty; _storageDetail.MaintainUser = mUser; _storageDetail.MaintainDate = mDate; _storageDetail.MaintainTime = mTime; _InventoryFacade.UpdateStorageDetail(_storageDetail); //D 更新TBLStorageDetailSN. PICKBLOCK=Y。 storageDetailSN.PickBlock = "Y"; storageDetailSN.MaintainUser = mUser; storageDetailSN.MaintainDate = mDate; storageDetailSN.MaintainTime = mTime; _InventoryFacade.UpdateStorageDetailSN(storageDetailSN); //E 需要输入目标箱号,根据SN信息在TBLStorageDetailSN中查找原箱号信息; //根据(目标箱号+TransNo+FromCARTONNO原箱号)在TBLStorLocTransDetailCarton是否有记录。 #region objStorLocTransDetailCarton StorloctransDetailCarton storloctransDetailCarton = _WarehouseFacade.GetStorLocTransDetailCarton(transNo, storageDetailSN.CartonNo); if (storloctransDetailCarton == null) { storloctransDetailCarton = new StorloctransDetailCarton(); storloctransDetailCarton.Transno = transNo; storloctransDetailCarton.MCode = _storloctransDetail.MCode; storloctransDetailCarton.DqmCode = _storageDetail.DQMCode; storloctransDetailCarton.MDesc = _storageDetail.MDesc; storloctransDetailCarton.Unit = _storageDetail.Unit; storloctransDetailCarton.Supplier_lotno = _storageDetail.SupplierLotNo; storloctransDetailCarton.Production_Date = _storageDetail.ProductionDate; storloctransDetailCarton.StorageageDate = _storageDetail.StorageAgeDate; storloctransDetailCarton.LaststorageageDate = _storageDetail.LastStorageAgeDate; storloctransDetailCarton.ValidStartDate = _storageDetail.ValidStartDate; storloctransDetailCarton.FacCode = _storageDetail.FacCode; storloctransDetailCarton.Qty = 1; storloctransDetailCarton.LocationCode = locationCode; storloctransDetailCarton.Cartonno = " "; storloctransDetailCarton.FromlocationCode = _storageDetail.LocationCode; storloctransDetailCarton.Fromcartonno = _storageDetail.CartonNo; storloctransDetailCarton.Lotno = _storageDetail.Lotno; storloctransDetailCarton.CUser = mUser; storloctransDetailCarton.CDate = mDate; storloctransDetailCarton.CTime = mTime; storloctransDetailCarton.MaintainUser = mUser; storloctransDetailCarton.MaintainDate = mDate; storloctransDetailCarton.MaintainTime = mTime; _WarehouseFacade.AddStorloctransdetailcarton(storloctransDetailCarton); } else { //如果有记录,检查记录中的料号是否有与原箱的料号一致,如果不一致则提示:(目标箱号物料不一致) object objStorageDetail = _InventoryFacade.GetStorageDetail(fromCartonNo); if (!storloctransDetailCarton.MCode.Equals((objStorageDetail as StorageDetail).MCode)) { DataProvider.RollbackTransaction(); return("目标箱号物料不一致"); } //如果有: 更新TBLStorLocTransDetailCarton.QTY+1,MDate,MTime,MUser。 storloctransDetailCarton.Qty += 1; storloctransDetailCarton.MaintainUser = mUser; storloctransDetailCarton.MaintainDate = mDate; storloctransDetailCarton.MaintainTime = mTime; _WarehouseFacade.UpdateStorloctransdetailcarton(storloctransDetailCarton); } #endregion //F 向表TBLStorLocTransDetailSN插入一条数据。 StorloctransDetailSN storloctransDetailSN = new StorloctransDetailSN(); storloctransDetailSN.Transno = transNo; storloctransDetailSN.Cartonno = " "; storloctransDetailSN.Fromcartonno = fromCartonNo; storloctransDetailSN.Sn = storageDetailSN.SN; storloctransDetailSN.MaintainUser = mUser; storloctransDetailSN.MaintainDate = mDate; storloctransDetailSN.MaintainTime = mTime; _WarehouseFacade.AddStorloctransdetailsn(storloctransDetailSN); #endregion } else { #region 非单件管控 if (string.IsNullOrEmpty(qty)) { DataProvider.RollbackTransaction(); return("必须输入数量"); } #region 判断数量是否是数字格式 try { decimal _qty = decimal.Parse(qty); if (_qty <= 0) { DataProvider.RollbackTransaction(); return("数量必须为大于零的数字"); } } catch (Exception ex) { DataProvider.RollbackTransaction(); return("数量必须为大于零的数字"); } #endregion //B 检查TBLStorageDetail. AvailableQTY>PDA页面填的数量。如果否,提示:输入的数量大于库存可用数量。 StorageDetail _storageDetail = storageDetails[0] as StorageDetail; if (_storageDetail.AvailableQty < decimal.Parse(qty)) { DataProvider.RollbackTransaction(); return("输入的数量大于库存可用数量"); } //C 更新TBLStorageDetail. FreezeQTY= TBLStorageDetail. FreezeQTY+ PDA页面填的数量, //TBLStorageDetail. AvailableQTY= TBLStorageDetail.STORAGEQTY-TBLStorageDetail. FreezeQTY。 _storageDetail.FreezeQty += int.Parse(qty); _storageDetail.AvailableQty = _storageDetail.StorageQty - _storageDetail.FreezeQty; _storageDetail.MaintainUser = mUser; _storageDetail.MaintainDate = mDate; _storageDetail.MaintainTime = mTime; _InventoryFacade.UpdateStorageDetail(_storageDetail); #region D需要输入目标箱号,根据(目标箱号+TransNo+FromCARTONNO原箱号)在TBLStorLocTransDetailCarton是否有记录。 StorloctransDetailCarton objStorLocTransDetailCarton = _WarehouseFacade.GetStorLocTransDetailCarton(transNo, _storageDetail.CartonNo); if (objStorLocTransDetailCarton == null) { // //如果没有:插入一条数据 // if (!_WarehouseFacade.IsExistLocationCode(locationCode)) // { // DataProvider.RollbackTransaction(); // return"输入的目标货位不存在" ; // } StorloctransDetailCarton storloctransDetailCarton = new StorloctransDetailCarton(); storloctransDetailCarton.Transno = transNo; storloctransDetailCarton.MCode = storloctransDetail.MCode; storloctransDetailCarton.DqmCode = _storageDetail.DQMCode; storloctransDetailCarton.MDesc = _storageDetail.MDesc; storloctransDetailCarton.Unit = _storageDetail.Unit; storloctransDetailCarton.Supplier_lotno = _storageDetail.SupplierLotNo; storloctransDetailCarton.Production_Date = _storageDetail.ProductionDate; storloctransDetailCarton.StorageageDate = _storageDetail.StorageAgeDate; storloctransDetailCarton.LaststorageageDate = _storageDetail.LastStorageAgeDate; storloctransDetailCarton.ValidStartDate = _storageDetail.ValidStartDate; storloctransDetailCarton.FacCode = _storageDetail.FacCode; storloctransDetailCarton.Qty = decimal.Parse(qty); storloctransDetailCarton.LocationCode = locationCode; storloctransDetailCarton.Cartonno = " "; storloctransDetailCarton.FromlocationCode = _storageDetail.LocationCode; storloctransDetailCarton.Fromcartonno = _storageDetail.CartonNo; storloctransDetailCarton.Lotno = _storageDetail.Lotno; storloctransDetailCarton.CUser = mUser; storloctransDetailCarton.CDate = mDate; storloctransDetailCarton.CTime = mTime; storloctransDetailCarton.MaintainUser = mUser; storloctransDetailCarton.MaintainDate = mDate; storloctransDetailCarton.MaintainTime = mTime; _WarehouseFacade.AddStorloctransdetailcarton(storloctransDetailCarton); } else { //如果有记录,检查记录中的料号是否有与原箱的料号一致,如果不一致则提示:(目标箱号物料不一致) StorloctransDetailCarton storloctransDetailCarton = objStorLocTransDetailCarton as StorloctransDetailCarton; object _objStorageDetail = _InventoryFacade.GetStorageDetail(fromCartonNo); if (!storloctransDetailCarton.MCode.Equals((_objStorageDetail as StorageDetail).MCode)) { DataProvider.RollbackTransaction(); return("目标箱号物料不一致"); } //如果有: 更新TBLStorLocTransDetailCarton.QTY+ PDA页面填的数量,MDate,MTime,MUser。 storloctransDetailCarton.Qty += decimal.Parse(qty); storloctransDetailCarton.MaintainUser = mUser; storloctransDetailCarton.MaintainDate = mDate; storloctransDetailCarton.MaintainTime = mTime; _WarehouseFacade.UpdateStorloctransdetailcarton(storloctransDetailCarton); } #endregion #endregion } #endregion } ////三 判断条件TransNo,MCODE 下sum(TBLStorLocTransDetailCarton.QTY)是否等于需求数量TBLStorLocTransDetail.QTY。 /////如果等于则更新装填TBLStorLocTransDetail.Status=Close:完成状态。 //decimal sum = 0; //object[] _objs = _WarehouseFacade.GetStorloctransdetailcarton(transNo, storageDetail.MCode); //foreach (StorloctransDetailCarton storloctransDetailCarton in _objs) //{ // sum += storloctransDetailCarton.Qty; //} //if (sum == storloctransDetail.Qty) //{ // storloctransDetail.Status = "Close"; // storloctransDetail.MaintainUser = mUser; // storloctransDetail.MaintainDate = mDate; // storloctransDetail.MaintainTime = mTime; // _WarehouseFacade.UpdateStorloctransdetail(storloctransDetail); //} //else if (sum > storloctransDetail.Qty) //{ // DataProvider.RollbackTransaction(); // return "拣料数量超出需求数量"; //} DataProvider.CommitTransaction(); return("提交成功"); } catch (Exception ex) { DataProvider.RollbackTransaction(); return("提交失败:" + ex.Message); } }