//保存 protected override void UpdateDomainObject(object domainObject) { if (_InventoryFacade == null) { _InventoryFacade = new InventoryFacade(base.DataProvider); } WarehouseFacade facade = new WarehouseFacade(base.DataProvider); if (_IsAdd) { #region 在invinouttrans表中增加一条数据 ASN asn = (ASN)domainObject; DBDateTime dbTime = FormatHelper.GetNowDBDateTime(this.DataProvider); InvInOutTrans trans = facade.CreateNewInvInOutTrans(); trans.CartonNO = string.Empty; trans.DqMCode = string.Empty; trans.FacCode = asn.FacCode; trans.FromFacCode = asn.FromFacCode; trans.FromStorageCode = asn.FromStorageCode; trans.InvNO = asn.InvNo; trans.InvType = asn.StType; trans.LotNo = string.Empty; trans.MaintainDate = dbTime.DBDate; trans.MaintainTime = dbTime.DBTime; trans.MaintainUser = this.GetUserCode(); trans.MCode = string.Empty; trans.ProductionDate = 0; trans.Qty = 0; trans.Serial = 0; trans.StorageAgeDate = 0; trans.StorageCode = asn.StorageCode; trans.SupplierLotNo = string.Empty; trans.TransNO = asn.StNo; trans.TransType = "IN"; trans.Unit = string.Empty; trans.ProcessType = "ASN"; facade.AddInvInOutTrans(trans); #endregion this._InventoryFacade.AddASN((ASN)domainObject); } else { this._InventoryFacade.UpdateASN((ASN)domainObject); } }
private string autoCreateASNFromCheckoutInfo(string invNo, Pick pick) { try { InvoicesDetail invD = (InvoicesDetail)_InventoryFacade.GetInvoicesDetail(invNo); CARTONINVOICES[] cartos = _warehouseFacade.GetGrossAndWeight(pick.PickNo); string stno = CreateStNO(); Asn asn = new Asn(); asn.Stno = stno; asn.StType = "UB"; asn.CDate = FormatHelper.TODateInt(DateTime.Now); asn.CTime = FormatHelper.TOTimeInt(DateTime.Now); asn.CUser = GetUserCode(); asn.Status = "Release"; asn.Invno = invNo; asn.FacCode = pick.FacCode; if (cartos.Length > 0) { asn.Gross_weight = (decimal)cartos[0].GROSS_WEIGHT; asn.Volume = cartos[0].VOLUME; } asn.StorageCode = invD.StorageCode ?? " "; asn.MaintainUser = GetUserCode(); asn.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); asn.MaintainDate = FormatHelper.TODateInt(DateTime.Now); CartonInvDetailMaterial[] cartonMs = _warehouseFacade.GetCartonInvDetailMaterial(pick.PickNo); MOModel.ItemFacade _itemfacade = new BenQGuru.eMES.MOModel.ItemFacade(this.DataProvider); int i = 1; this.DataProvider.BeginTransaction(); foreach (CartonInvDetailMaterial m in cartonMs) { object materobj = _itemfacade.GetMaterial(m.MCODE); Domain.MOModel.Material mater = materobj as Domain.MOModel.Material; if (materobj == null) { this.DataProvider.RollbackTransaction(); throw new Exception("物料表没有物料:" + m.MCODE); } string custMCode = _warehouseFacade.GetCustMCodeForUB(pick.PickNo, m.DQMCODE); if (mater.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_KEYPARTS) { ASNDetail asnd = new ASNDetail(); asnd.ActQty = 0; //asnd.CartonNo = " "; asnd.DQMCode = m.DQMCODE; asnd.Qty = (int)m.QTY; asnd.StLine = i.ToString(); asnd.CustMCode = custMCode; asnd.MCode = m.MCODE; asnd.Status = "Release"; asnd.StNo = stno; asnd.MDesc = mater.MchshortDesc; asnd.Unit = m.UNIT; asnd.CDate = FormatHelper.TODateInt(DateTime.Now); asnd.CTime = FormatHelper.TOTimeInt(DateTime.Now); asnd.CUser = GetUserCode(); asnd.MaintainDate = FormatHelper.TODateInt(DateTime.Now); asnd.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); asnd.MaintainUser = GetUserCode(); asnd.LotNo = " "; CARTONINVDETAILSN[] sns = _warehouseFacade.GetCartonInvDetailSn(m.CARTONNO, pick.PickNo); List <string> snList = new List <string>(); if (sns.Length > 0) { foreach (CARTONINVDETAILSN sn in sns) { snList.Add(sn.SN); } Asndetail detail = _warehouseFacade.GetFirstCheckInAsnDetail(snList); if (detail != null) { asnd.ProductionDate = detail.Production_Date; asnd.SupplierLotNo = detail.Supplier_lotno; asnd.LotNo = detail.Lotno; asnd.StorageAgeDate = detail.StorageageDate; } } DBDateTime dbTime = FormatHelper.GetNowDBDateTime(this.DataProvider); Asndetailitem detailitem = _warehouseFacade.CreateNewAsndetailitem(); detailitem.CDate = dbTime.DBDate; detailitem.CTime = dbTime.DBTime; detailitem.CUser = this.GetUserCode(); detailitem.MaintainDate = dbTime.DBDate; detailitem.MaintainTime = dbTime.DBTime; detailitem.MaintainUser = this.GetUserCode(); detailitem.Stline = i.ToString(); detailitem.Stno = asn.Stno; detailitem.MCode = asnd.MCode; detailitem.DqmCode = asnd.DQMCode; //查找对应的SAP单 object[] qtyobjs = _warehouseFacade.GetSAPNOandLinebyMCODE(asn.Invno, asnd.MCode, asnd.DQMCode); if (qtyobjs == null) { this.DataProvider.RollbackTransaction(); throw new Exception("入库需求" + asn.Invno + " 没有相关物料" + asnd.MCode + "," + asnd.DQMCode + "或者此行已被取消!"); } decimal sub = asnd.Qty; for (int k = 0; k < qtyobjs.Length; k++) { InvoicesDetail invdetail = qtyobjs[k] as InvoicesDetail; decimal subNeed = 0; object findNeedQTY_old = _warehouseFacade.GetNeedImportQtyOLD(invdetail.InvNo, invdetail.InvLine, asnd.StNo); //找这个invoice行已经导入了多少,和判退多少 Asndetailitem subItemOld = findNeedQTY_old as Asndetailitem; object findNeedQTY_now = _warehouseFacade.GetNeedImportQtyNow(invdetail.InvNo, invdetail.InvLine, asnd.StNo); //找这个invoice行已经导入了多少,和判退多少 Asndetailitem subItemNow = findNeedQTY_now as Asndetailitem; subNeed = invdetail.PlanQty - subItemOld.Qty + (subItemOld.Qty - subItemOld.ReceiveQty) + (subItemOld.ReceiveQty - subItemOld.QcpassQty); subNeed = subNeed - subItemNow.Qty; if (subNeed == 0) { continue; } //如果箱数量大于需求数量差---进行拆分 if (sub > subNeed) { sub = sub - subNeed; // sub是剩余的 detailitem.Qty = subNeed; detailitem.Invline = invdetail.InvLine.ToString(); detailitem.Invno = invdetail.InvNo; detailitem.ActQty = detailitem.Qty; detailitem.QcpassQty = detailitem.Qty; detailitem.ReceiveQty = detailitem.Qty; _warehouseFacade.AddAsndetailitem(detailitem); } //如果箱单数量小于等于需求数量差--直接填入 else { detailitem.Qty = sub; detailitem.Invline = invdetail.InvLine.ToString(); detailitem.Invno = invdetail.InvNo; detailitem.ActQty = detailitem.Qty; detailitem.QcpassQty = detailitem.Qty; detailitem.ReceiveQty = detailitem.Qty; _warehouseFacade.AddAsndetailitem(detailitem); sub = 0; } if (sub == 0) { break; } } //如果sub>0,说明导入数量过多,报错 if (sub > 0) { this.DataProvider.RollbackTransaction(); throw new Exception("箱单导入数量与需求数量不符!"); } foreach (CARTONINVDETAILSN sn in sns) { Asndetailsn asnSN = new Asndetailsn(); asnSN.CDate = FormatHelper.TODateInt(DateTime.Now); asnSN.CTime = FormatHelper.TOTimeInt(DateTime.Now); asnSN.CUser = GetUserCode(); asnSN.MaintainDate = FormatHelper.TODateInt(DateTime.Now); asnSN.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); asnSN.MaintainUser = GetUserCode(); asnSN.Sn = sn.SN; asnSN.Stline = i.ToString(); asnSN.Stno = stno; _warehouseFacade.AddAsndetailsn(asnSN); } _InventoryFacade.AddASNDetail(asnd); } else if (mater.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_LOT || mater.MCONTROLTYPE == SAP_CONTROLTYPE.SAP_ITEM_CONTROL_NOCONTROL) { ASNDetail asnd = new ASNDetail(); asnd.ActQty = 0; asnd.CustMCode = custMCode; asnd.DQMCode = m.DQMCODE; asnd.Qty = (int)m.QTY; asnd.StLine = i.ToString(); asnd.MCode = m.MCODE; asnd.StNo = stno; asnd.Status = "Release"; asnd.MDesc = mater.MchshortDesc; asnd.Unit = m.UNIT; asnd.CDate = FormatHelper.TODateInt(DateTime.Now); asnd.CTime = FormatHelper.TOTimeInt(DateTime.Now); asnd.CUser = GetUserCode(); asnd.MaintainDate = FormatHelper.TODateInt(DateTime.Now); asnd.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); asnd.MaintainUser = GetUserCode(); asnd.LotNo = " "; Pickdetailmaterial pickMaterial = (Pickdetailmaterial)_warehouseFacade.GetLotNOInformationFromDQMCODE(m.DQMCODE, pick.PickNo); if (pickMaterial != null) { asnd.ProductionDate = pickMaterial.Production_Date; asnd.SupplierLotNo = pickMaterial.Supplier_lotno; asnd.LotNo = pickMaterial.Lotno; asnd.StorageAgeDate = pickMaterial.StorageageDate; } else { throw new Exception(pick.PickNo + "没有找到检料信息!"); } _InventoryFacade.AddASNDetail(asnd); DBDateTime dbTime = FormatHelper.GetNowDBDateTime(this.DataProvider); Asndetailitem detailitem = _warehouseFacade.CreateNewAsndetailitem(); detailitem.CDate = dbTime.DBDate; detailitem.CTime = dbTime.DBTime; detailitem.CUser = this.GetUserCode(); detailitem.MaintainDate = dbTime.DBDate; detailitem.MaintainTime = dbTime.DBTime; detailitem.MaintainUser = this.GetUserCode(); detailitem.Stline = i.ToString(); detailitem.Stno = asn.Stno; detailitem.MCode = asnd.MCode; detailitem.DqmCode = asnd.DQMCode; //查找对应的SAP单 object[] qtyobjs = _warehouseFacade.GetSAPNOandLinebyMCODE(asn.Invno, asnd.MCode, asnd.DQMCode); if (qtyobjs == null) { this.DataProvider.RollbackTransaction(); throw new Exception("箱单导入数量与需求数量不符!"); } decimal sub = asnd.Qty; for (int k = 0; k < qtyobjs.Length; k++) { InvoicesDetail invdetail = qtyobjs[k] as InvoicesDetail; decimal subNeed = 0; object findNeedQTY_old = _warehouseFacade.GetNeedImportQtyOLD(invdetail.InvNo, invdetail.InvLine, asnd.StNo); //找这个invoice行已经导入了多少,和判退多少 Asndetailitem subItemOld = findNeedQTY_old as Asndetailitem; object findNeedQTY_now = _warehouseFacade.GetNeedImportQtyNow(invdetail.InvNo, invdetail.InvLine, asnd.StNo); //找这个invoice行已经导入了多少,和判退多少 Asndetailitem subItemNow = findNeedQTY_now as Asndetailitem; subNeed = invdetail.PlanQty - subItemOld.Qty + (subItemOld.Qty - subItemOld.ReceiveQty) + (subItemOld.ReceiveQty - subItemOld.QcpassQty); subNeed = subNeed - subItemNow.Qty; if (subNeed == 0) { continue; } //如果箱数量大于需求数量差---进行拆分 if (sub > subNeed) { sub = sub - subNeed; // sub是剩余的 detailitem.Qty = subNeed; detailitem.Invline = invdetail.InvLine.ToString(); detailitem.Invno = invdetail.InvNo; detailitem.ActQty = detailitem.Qty; detailitem.QcpassQty = detailitem.Qty; detailitem.ReceiveQty = detailitem.Qty; _warehouseFacade.AddAsndetailitem(detailitem); } //如果箱单数量小于等于需求数量差--直接填入 else { detailitem.Qty = sub; detailitem.Invline = invdetail.InvLine.ToString(); detailitem.Invno = invdetail.InvNo; detailitem.ActQty = detailitem.Qty; detailitem.QcpassQty = detailitem.Qty; detailitem.ReceiveQty = detailitem.Qty; _warehouseFacade.AddAsndetailitem(detailitem); sub = 0; } if (sub == 0) { break; } } //如果sub>0,说明导入数量过多,报错 if (sub > 0) { this.DataProvider.RollbackTransaction(); throw new Exception("箱单导入数量与需求数量不符!"); } } i++; } _warehouseFacade.AddAsn(asn); WarehouseFacade facade = new WarehouseFacade(base.DataProvider); #region 在invinouttrans表中增加一条数据 //ASN asn = (ASN)domainObject; DBDateTime dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider); InvInOutTrans trans = facade.CreateNewInvInOutTrans(); trans.CartonNO = string.Empty; trans.DqMCode = string.Empty; trans.FacCode = asn.FacCode; trans.FromFacCode = asn.FromfacCode; trans.FromStorageCode = asn.FromstorageCode; trans.InvNO = asn.Invno; trans.InvType = asn.StType; trans.LotNo = string.Empty; trans.MaintainDate = dbTime1.DBDate; trans.MaintainTime = dbTime1.DBTime; trans.MaintainUser = this.GetUserCode(); trans.MCode = string.Empty; trans.ProductionDate = 0; trans.Qty = 0; trans.Serial = 0; trans.StorageAgeDate = 0; trans.StorageCode = asn.StorageCode; trans.SupplierLotNo = string.Empty; trans.TransNO = asn.Stno; trans.TransType = "IN"; trans.Unit = string.Empty; trans.ProcessType = "UBCreateASN"; facade.AddInvInOutTrans(trans); #endregion this.DataProvider.CommitTransaction(); return(stno); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); throw ex; } }
private void ToSTS(string oqcNo) { if (_OQCFacade == null) { _OQCFacade = new OQCFacade(base.DataProvider); } _InventoryFacade = new InventoryFacade(base.DataProvider); WarehouseFacade _WarehouseFacade = new WarehouseFacade(base.DataProvider); //1、更新OQC单表(TBLOQC) _OQCFacade.UpdateOQC(OQCType.OQCType_ExemptCheck, OQCStatus.OQCStatus_OQCClose, "Y", oqcNo); //2、更新OQC单明细表(TBLOQCDETAIL) _OQCFacade.UpdateOQCDetail("Y", oqcNo); //3、更新OQC单明细SN信息表(TBLOQCDETAILSN) _OQCFacade.UpdateOQCDetailSN("Y", oqcNo); //4、更新发货箱单头信息表(TBLCartonInvoices) Pick pick = (Pick)_InventoryFacade.GetPickByOqcNo(oqcNo); if (pick != null) { //if (pick.GFFlag == "X") //{ // if (CheckAllOQCStatusIsOQCClose(oqcNo)) // { // CARTONINVOICES cartonInvoices = (CARTONINVOICES)_WarehouseFacade.GetCartoninvoicesByOqcNo(oqcNo); // if (cartonInvoices != null) // { // cartonInvoices.STATUS = CartonInvoices_STATUS.Status_OQCClose; // _WarehouseFacade.UpdateCartoninvoices(cartonInvoices); // } // } // else // { // throw new Exception("OQC单号" + oqcNo + "没有全部检验完成"); // } //} //else //{ if (_OQCFacade.IsOQCFinish(pick.PickNo)) { pick.Status = PickHeadStatus.PickHeadStatus_PackingListing; _WarehouseFacade.UpdatePick(pick); } CARTONINVOICES cartonInvoices = (CARTONINVOICES)_WarehouseFacade.GetCartoninvoicesByOqcNo(oqcNo); if (cartonInvoices != null) { cartonInvoices.STATUS = CartonInvoices_STATUS.Status_OQCClose; _WarehouseFacade.UpdateCartoninvoices(cartonInvoices); } //} #region 在invinouttrans表中增加一条数据 WarehouseFacade facade = new WarehouseFacade(base.DataProvider); DBDateTime dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider); InvInOutTrans trans1 = facade.CreateNewInvInOutTrans(); trans1.CartonNO = string.Empty; trans1.DqMCode = string.Empty; trans1.FacCode = string.Empty; trans1.FromFacCode = string.Empty; trans1.FromStorageCode = string.Empty; trans1.InvNO = pick.InvNo;//.InvNo; trans1.InvType = pick.PickType; trans1.LotNo = string.Empty; trans1.MaintainDate = dbTime1.DBDate; trans1.MaintainTime = dbTime1.DBTime; trans1.MaintainUser = this.GetUserCode(); trans1.MCode = string.Empty; trans1.ProductionDate = 0; trans1.Qty = 0; trans1.Serial = 0; trans1.StorageAgeDate = 0; trans1.StorageCode = string.Empty; trans1.SupplierLotNo = string.Empty; trans1.TransNO = pick.PickNo;// asnIqc.IqcNo; trans1.TransType = "OUT"; trans1.Unit = string.Empty; trans1.ProcessType = "OQC"; facade.AddInvInOutTrans(trans1); Domain.OQC.OQC asnIqcHead = (Domain.OQC.OQC)_OQCFacade.GetOQC(oqcNo); object[] objs_oqcDetail = _OQCFacade.GetOQCDetailByOqcNo(oqcNo); if (objs_oqcDetail != null) { foreach (OQCDetail asnIqc in objs_oqcDetail) { InvInOutTrans trans = facade.CreateNewInvInOutTrans(); trans.CartonNO = string.Empty; trans.DqMCode = asnIqc.DQMCode; trans.FacCode = string.Empty; trans.FromFacCode = string.Empty; trans.FromStorageCode = string.Empty; trans.InvNO = asnIqc.CarInvNo;//.InvNo; trans.InvType = asnIqcHead.OqcType; trans.LotNo = string.Empty; trans.MaintainDate = dbTime1.DBDate; trans.MaintainTime = dbTime1.DBTime; trans.MaintainUser = this.GetUserCode(); trans.MCode = asnIqc.MCode; trans.ProductionDate = 0; trans.Qty = asnIqc.Qty; trans.Serial = 0; trans.StorageAgeDate = 0; trans.StorageCode = string.Empty; trans.SupplierLotNo = string.Empty; trans.TransNO = oqcNo;// asnIqc.IqcNo; trans.TransType = "OUT"; trans.Unit = string.Empty; trans.ProcessType = "OQC"; facade.AddInvInOutTrans(trans); } } #endregion } }
private void ToSTS(string iqcNo, string userCode) { IQCFacade _IQCFacade = new IQCFacade(DataProvider); InventoryFacade _InventoryFacade = new InventoryFacade(DataProvider); //1、更新送检单TBLASNIQC AsnIQC asnIqc = (AsnIQC)_IQCFacade.GetAsnIQC(iqcNo); if (asnIqc != null) { asnIqc.IqcType = "ExemptCheck"; asnIqc.Status = IQCStatus.IQCStatus_IQCClose; asnIqc.QcStatus = "Y"; _IQCFacade.UpdateAsnIQC(asnIqc); #region 在invinouttrans表中增加一条数据 WarehouseFacade facade = new WarehouseFacade(DataProvider); //ASN asn = (ASN)domainObject; DBDateTime dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider); InvInOutTrans trans = facade.CreateNewInvInOutTrans(); trans.CartonNO = string.Empty; trans.DqMCode = asnIqc.DQMCode; trans.FacCode = string.Empty; trans.FromFacCode = string.Empty; trans.FromStorageCode = string.Empty; trans.InvNO = asnIqc.InvNo; trans.InvType = asnIqc.IqcType; trans.LotNo = string.Empty; trans.MaintainDate = dbTime1.DBDate; trans.MaintainTime = dbTime1.DBTime; trans.MaintainUser = userCode; trans.MCode = asnIqc.MCode; trans.ProductionDate = 0; trans.Qty = asnIqc.Qty; trans.Serial = 0; trans.StorageAgeDate = 0; trans.StorageCode = string.Empty; trans.SupplierLotNo = string.Empty; trans.TransNO = asnIqc.IqcNo; trans.TransType = "IN"; trans.Unit = string.Empty; trans.ProcessType = "IQC"; facade.AddInvInOutTrans(trans); #endregion } object[] objAsnIqcDetail = _IQCFacade.GetAsnIQCDetailByIqcNo(iqcNo); if (objAsnIqcDetail != null) { foreach (AsnIQCDetail asnIqcDetail in objAsnIqcDetail) { //2、更新送检单明细TBLASNIQCDETAIL asnIqcDetail.QcPassQty = asnIqcDetail.Qty; asnIqcDetail.QcStatus = "Y"; _IQCFacade.UpdateAsnIQCDetail(asnIqcDetail); //4、更新ASN明细TBLASNDETAIL ASNDetail asnDetail = (ASNDetail)_InventoryFacade.GetASNDetail(Convert.ToInt32(asnIqcDetail.StLine), asnIqcDetail.StNo); if (asnDetail != null) { asnDetail.QcPassQty = asnDetail.ReceiveQty; asnDetail.Status = IQCStatus.IQCStatus_IQCClose; _InventoryFacade.UpdateASNDetail(asnDetail); } //5、更新ASN明细对应单据行明细TBLASNDETAILITEM object[] objAsnDetaileItem = _InventoryFacade.GetAsnDetailItem(asnIqcDetail.StNo, Convert.ToInt32(asnIqcDetail.StLine)); if (objAsnDetaileItem != null) { foreach (Asndetailitem asnDetaileItem in objAsnDetaileItem) { asnDetaileItem.QcpassQty = asnDetaileItem.ReceiveQty; _InventoryFacade.UpdateAsndetailitem(asnDetaileItem); } } } } object[] objAsnIqcDetailSN = _IQCFacade.GetAsnIqcDetailSNByIqcNo(iqcNo); if (objAsnIqcDetailSN != null) { foreach (AsnIqcDetailSN asnIqcDetailSN in objAsnIqcDetailSN) { //3、更新送检单明细SNTBLASNIQCDETAILSN asnIqcDetailSN.QcStatus = "Y"; _IQCFacade.UpdateAsnIqcDetailSN(asnIqcDetailSN); //6、更新ASN明细SN TBLASNDETAILSN Asndetailsn asnDetailSn = (Asndetailsn)_InventoryFacade.GetAsndetailsn(asnIqcDetailSN.Sn, asnIqcDetailSN.StNo, Convert.ToInt32(asnIqcDetailSN.StLine)); if (asnDetailSn != null) { asnDetailSn.QcStatus = "Y"; _InventoryFacade.UpdateAsndetailsn(asnDetailSn); } } } //7、以上表数据更新完成后检查ASN明细表(TBLASNDETAIL)所有行记录状态为:IQCClose:IQC完成 or OnLocation:上架 or Close:入库 or Cancel:取消时, // 更新ASN主表(TBLASN)状态(TBLASN.STATUS)为:OnLocation:上架 bool isAllIQCClose = CheckAllASNDetailIsIQCClose(iqcNo); bool isAllOnLocation = CheckAllASNDetailIsOnLocation(iqcNo); bool isAllClose = CheckAllASNDetailIsClose(iqcNo); bool isAllCancel = CheckAllASNDetailIsCancel(iqcNo); if (isAllIQCClose || isAllOnLocation || isAllClose || isAllCancel ) { ASN asn = (ASN)_InventoryFacade.GetASN(asnIqc.StNo); if (asn != null) { asn.Status = ASNHeadStatus.OnLocation; _InventoryFacade.UpdateASN(asn); } } }
public bool FirstCheckWithUser(string[] asns, string userCode, out string message) { try { WarehouseFacade facade = new WarehouseFacade(DataProvider); InventoryFacade facade1 = new InventoryFacade(DataProvider); message = string.Empty; Asn asn = (Asn)facade.GetAsn(asns[0]); if (asn.Direct_flag.ToUpper() == "Y") { message = "该入库指令是供应商直发,不能做以下操作[取消下发][初检][申请IQC]"; return(false); } if (asn.Status == ASNHeadStatus.WaitReceive) { this.DataProvider.BeginTransaction(); string stNo = string.Format("'{0}'", asn.Stno); facade1.UpdateASNStatusByStNo(ASNHeadStatus.Receive, stNo); facade1.UpdateASNDetailStatusByStNo(ASNHeadStatus.Receive, stNo); DBDateTime dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider); WarehouseFacade _wa = new WarehouseFacade(DataProvider); InvInOutTrans trans = _wa.CreateNewInvInOutTrans(); trans.CartonNO = string.Empty; trans.DqMCode = " "; trans.FacCode = asn.FacCode; trans.FromFacCode = string.Empty; trans.FromStorageCode = string.Empty; trans.InvNO = asn.Invno; trans.InvType = asn.StType; trans.LotNo = string.Empty; trans.MaintainDate = dbTime1.DBDate; trans.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); trans.MaintainUser = userCode; trans.MCode = " "; trans.ProductionDate = 0; trans.Qty = 0; trans.Serial = 0; trans.StorageAgeDate = 0; trans.StorageCode = asn.StorageCode; trans.SupplierLotNo = string.Empty; trans.TransNO = asn.Stno; trans.TransType = "IN"; trans.Unit = string.Empty; trans.ProcessType = "RECEIVEBEGIN"; _wa.AddInvInOutTrans(trans); this.DataProvider.CommitTransaction(); message = "初检成功"; return(true); } else if (asn.Status == ASNHeadStatus.Receive) { message = "初检成功"; return(true); } else { message = "状态必须是初见签收中或者待收货!"; return(false); } } catch (Exception ex) { DataProvider.RollbackTransaction(); BenQGuru.eMES.Common.Log.Error(ex.StackTrace); throw ex; } }
protected void CmdConfirmOweQtyObjects(object[] pickList) { // 点击该按钮,初始TBLPICKDETAIL. OweQTY为空or零, //点击该按钮后保存TBLPICKDETAIL. OweQTY= TBLPICKDETAIL. SQTY //注:只有状态为:Owe:欠料的物料行可以执行此按钮,确认后该行更新状态为ClosePick:拣料完成 if (facade == null) { facade = new InventoryFacade(base.DataProvider); } if (_WarehouseFacade == null) { _WarehouseFacade = new WarehouseFacade(base.DataProvider); } DBDateTime dbTime = FormatHelper.GetNowDBDateTime(this.DataProvider); try { this.DataProvider.BeginTransaction(); foreach (PickDetail pickdetail in pickList) { if (pickdetail.Status == PickDetail_STATUS.Status_Owe) { if (pickdetail.OweQTY == 0 || string.IsNullOrEmpty(pickdetail.OweQTY.ToString())) { PickDetail oldpickdetail = (PickDetail)facade.GetPickDetail(pickdetail.PickNo, pickdetail.PickLine); oldpickdetail.OweQTY = oldpickdetail.SQTY; oldpickdetail.Status = PickDetail_STATUS.Status_ClosePick; facade.UpdatePickDetail(oldpickdetail); } else { WebInfoPublish.Publish(this, "已申请欠料发货!", this.languageComponent1); return; } } else { WebInfoPublish.Publish(this, "只有状态为欠料的物料行可以执行此按钮", this.languageComponent1); return; } } #region 在invinouttrans表中增加一条数据 箱单完成日期 WarehouseFacade wfacade = new WarehouseFacade(base.DataProvider); DBDateTime dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider); foreach (PickDetail pickDetail in pickList) { Pick pick = facade.GetPick(pickDetail.PickNo) as Pick; InvInOutTrans trans = wfacade.CreateNewInvInOutTrans(); trans.CartonNO = string.Empty; trans.DqMCode = pickDetail.DQMCode; trans.FacCode = string.Empty; trans.FromFacCode = string.Empty; trans.FromStorageCode = string.Empty; trans.InvNO = pick.InvNo;//.InvNo; trans.InvType = pick.PickType; trans.LotNo = string.Empty; trans.MaintainDate = dbTime1.DBDate; trans.MaintainTime = dbTime1.DBTime; trans.MaintainUser = this.GetUserCode(); trans.MCode = pickDetail.MCode; trans.ProductionDate = 0; trans.Qty = pickDetail.QTY; trans.Serial = 0; trans.StorageAgeDate = 0; trans.StorageCode = string.Empty; trans.SupplierLotNo = string.Empty; trans.TransNO = pickDetail.PickNo; trans.TransType = "OUT"; trans.Unit = string.Empty; trans.ProcessType = "ClosePick"; wfacade.AddInvInOutTrans(trans); } #endregion string pickno = FormatHelper.CleanString(this.txtPickNoQuery.Text); bool isUpdatePick = facade.QueryPickDetailCount(pickno, PickDetail_STATUS.Status_ClosePick) == 0; if (isUpdatePick) { facade.UpdatePickStatusByPickno(pickno, PickHeadStatus.PickHeadStatus_MakePackingList); } #region 创建发货箱单 string carInvNo = string.Empty; object obj = _WarehouseFacade.GetCartonInvoices(pickno); if (obj == null) { CARTONINVOICES CartonH = _WarehouseFacade.CreateNewCartoninvoices(); object objLot = _WarehouseFacade.GetNewLotNO("K", dbTime.DBDate.ToString().Substring(2, 6).ToString()); Serialbook serbook = _WarehouseFacade.CreateNewSerialbook(); if (objLot == null) { #region CartonH.CARINVNO = "K" + dbTime.DBDate.ToString().Substring(2, 6).ToString() + "001"; CartonH.PICKNO = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtPickNoQuery.Text)); CartonH.STATUS = CartonInvoices_STATUS.Status_Release; CartonH.CDATE = dbTime.DBDate; CartonH.CTIME = dbTime.DBTime; CartonH.CUSER = this.GetUserCode(); CartonH.MDATE = dbTime.DBDate; CartonH.MTIME = dbTime.DBTime; CartonH.MUSER = this.GetUserCode(); _WarehouseFacade.AddCartoninvoices(CartonH); serbook.SNprefix = "K" + dbTime.DBDate.ToString().Substring(2, 6).ToString(); serbook.MAXSerial = "2"; serbook.MUser = this.GetUserCode(); serbook.MDate = dbTime.DBDate; serbook.MTime = dbTime.DBTime; _WarehouseFacade.AddSerialbook(serbook); #endregion } else { #region string MAXNO = (objLot as Serialbook).MAXSerial; string SNNO = (objLot as Serialbook).SNprefix; CartonH.CARINVNO = SNNO + Convert.ToString(MAXNO).PadLeft(3, '0'); CartonH.PICKNO = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtPickNoQuery.Text)); CartonH.STATUS = CartonInvoices_STATUS.Status_Release; CartonH.CDATE = dbTime.DBDate; CartonH.CTIME = dbTime.DBTime; CartonH.CUSER = this.GetUserCode(); CartonH.MDATE = dbTime.DBDate; CartonH.MTIME = dbTime.DBTime; CartonH.MUSER = this.GetUserCode(); _WarehouseFacade.AddCartoninvoices(CartonH); //更新tblserialbook serbook.SNprefix = SNNO; serbook.MAXSerial = Convert.ToString((int.Parse(MAXNO) + 1)); serbook.MUser = this.GetUserCode(); serbook.MDate = dbTime.DBDate; serbook.MTime = dbTime.DBTime; _WarehouseFacade.UpdateSerialbook(serbook); #endregion } } # endregion this.DataProvider.CommitTransaction(); WebInfoPublish.Publish(this, "确认欠料发货数量成功", this.languageComponent1); }
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 void InitialObjects(object[] asnList) { //1> 入库指令号状态为:WaitReceive:待收货,则修改入库指令号(TBLASN、TBLASNDETAIL)状态为:Release:初始化 //2> 入库指令号状态不为:WaitReceive:待收货,则报错提示当前入库指令号不能取消下发 try { InventoryFacade facade = new InventoryFacade(base.DataProvider); WarehouseFacade _wa = new WarehouseFacade(DataProvider); //foreach (ASN asn in asnList) // { ASN asn = (ASN)asnList[0]; if (asn.Status != "Release" && asn.Status != "Receive" && asn.Status != "WaitReceive") { WebInfoPublish.Publish(this, asn.StNo + "入库指令号不能取消下发,状态必须是到货初检中才能取消下发", this.languageComponent1); return; } this.DataProvider.BeginTransaction(); _wa.UpdateASNForCancelDown(new string[] { asn.StNo }, "Release"); facade.UpdateASNDetail(asn.StNo, ASNHeadStatus.Release); facade.UpdateASNDetailSN(asn.StNo); //facade.UpdateASNDetailItem(asn.StNo); DBDateTime dbTime1 = FormatHelper.GetNowDBDateTime(this.DataProvider); InvInOutTrans trans = _wa.CreateNewInvInOutTrans(); trans.CartonNO = string.Empty; trans.DqMCode = " "; trans.FacCode = asn.FacCode; trans.FromFacCode = string.Empty; trans.FromStorageCode = string.Empty; trans.InvNO = asn.InvNo; trans.InvType = asn.StType; trans.LotNo = string.Empty; trans.MaintainDate = dbTime1.DBDate; trans.MaintainTime = FormatHelper.TOTimeInt(DateTime.Now); trans.MaintainUser = this.GetUserCode(); trans.MCode = " "; trans.ProductionDate = 0; trans.Qty = 0; trans.Serial = 0; trans.StorageAgeDate = 0; trans.StorageCode = asn.StorageCode; trans.SupplierLotNo = string.Empty; trans.TransNO = asn.StNo; trans.TransType = "IN"; trans.Unit = string.Empty; trans.ProcessType = "CANCELISSUE"; _wa.AddInvInOutTrans(trans); this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); throw ex; } }