private Messages DropLoadedParts(string rcard) { Messages msg = new Messages(); ActionOnLineHelper onLine = new ActionOnLineHelper(DataProvider); MaterialFacade materialFacade = new MaterialFacade(this.DataProvider); ItemFacade itemFacade = new ItemFacade(this.DataProvider); DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider); TSFacade tsFacade = new TSFacade(this.DataProvider); string sourceRCard = dataCollectFacade.GetSourceCard(rcard.Trim().ToUpper(), string.Empty); ProductInfo product = GetProduct(sourceRCard); if (product == null || product.LastSimulation == null) { msg.Add(new UserControl.Message(MessageType.Error, "$NoSimulation")); return(msg); } // Marked By HI1/Venus.Feng on 20081013 for Hisense Version : GOOD can do drop /* * if (product.LastSimulation.ProductStatus != ProductStatus.NG) * { * msg.Add(new UserControl.Message(MessageType.Error, "$DropMaterial_Need_NG")); * return msg; * } */ // End Marked msg.Add(new UserControl.Message(rcard)); //获取所有需要拆解或者替换的Parts ArrayList partsToUnload = new ArrayList(); for (int i = 0; i < this.ultraGridLoadedPart.Rows.Count; i++) { if (ultraGridLoadedPart.Rows[i].Cells[0].Text.ToLower() == "true") { InnoObject innoObject = new InnoObject(); innoObject.LineIndex = i; innoObject.MCard = ultraGridLoadedPart.Rows[i].Cells["PackedNo"].Text; innoObject.MCardType = ultraGridLoadedPart.Rows[i].Cells["MCardType"].Text; innoObject.ItemIndex = partsToUnload.Count + 1; innoObject.MItemCode = ultraGridLoadedPart.Rows[i].Cells["ItemCode"].Text; innoObject.MOCode = ultraGridLoadedPart.Rows[i].Cells["MOCode"].Text; innoObject.Qty = 1; innoObject.NewBarcode = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(ultraGridLoadedPart.Rows[i].Cells["NewBarcode"].Text.Trim())); partsToUnload.Add(innoObject); } } //对于需要替换的Parts,需要做类似上料中的解析和检查 for (int i = 0; i < partsToUnload.Count; i++) { InnoObject innoObject = (InnoObject)partsToUnload[i]; if (innoObject.NewBarcode.Trim().Length > 0) { //抓取物料的设定 Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(innoObject.MItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID); if (material == null) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_NotFound")); return(msg); } string barcode = innoObject.NewBarcode.Trim(); //模拟一个OPBOMDetail OPBOMDetail detailTemp = new OPBOMDetail(); detailTemp.OPBOMItemControlType = material.MaterialControlType; detailTemp.OPBOMParseType = material.MaterialParseType; detailTemp.OPBOMCheckType = material.MaterialCheckType; detailTemp.CheckStatus = material.CheckStatus; detailTemp.SerialNoLength = material.SerialNoLength; detailTemp.NeedVendor = material.NeedVendor; detailTemp.OPBOMSourceItemCode = innoObject.MItemCode; detailTemp.OPBOMItemCode = innoObject.MItemCode; detailTemp.OPBOMItemQty = 1; MINNO newMINNO = new MINNO(); newMINNO.MOCode = innoObject.MOCode.Trim(); newMINNO.MItemCode = material.MaterialCode.Trim(); Messages collectMessage = dataCollectFacade.GetMINNOByBarcode(detailTemp, barcode, newMINNO.MOCode, null, false, false, out newMINNO); if (collectMessage.IsSuccess()) { innoObject.NewLotNo = newMINNO.LotNO; innoObject.NewPCBA = newMINNO.PCBA; innoObject.NewBIOS = newMINNO.BIOS; innoObject.NewVersion = newMINNO.Version; innoObject.NewVendorItemCode = newMINNO.VendorItemCode; innoObject.NewVendorCode = newMINNO.VendorCode; innoObject.NewDateCode = newMINNO.DateCode; } else { msg.AddMessages(collectMessage); return(msg); } } } try { this.DataProvider.BeginTransaction(); //更新试流单 //下料中处理tbltry,tbltry2rcard for (int i = 0; i < partsToUnload.Count; i++) { InnoObject innoObject = (InnoObject)partsToUnload[i]; TryEventArgs tryEventArgs = new TryEventArgs( ActionType.DataCollectAction_TryNew, ApplicationService.Current().UserCode, product.LastSimulation.OPCode, ApplicationService.Current().ResourceCode, product.LastSimulation.ItemCode, sourceRCard, innoObject.MItemCode, innoObject.MCard, string.Empty, false, false); msg.AddMessages(onLine.ActionWithTransaction(tryEventArgs)); if (!msg.IsSuccess()) { DataProvider.RollbackTransaction(); return(msg); } } //更新试流单 //上料中处理tbltry,tbltry2rcard for (int i = 0; i < partsToUnload.Count; i++) { InnoObject innoObject = (InnoObject)partsToUnload[i]; if (innoObject.NewBarcode.Trim().Length > 0) { TryEventArgs tryEventArgs = new TryEventArgs( ActionType.DataCollectAction_TryNew, ApplicationService.Current().UserCode, product.LastSimulation.OPCode, ApplicationService.Current().ResourceCode, product.LastSimulation.ItemCode, sourceRCard, innoObject.MItemCode, innoObject.NewBarcode, string.Empty, true, true); msg.AddMessages(onLine.ActionWithTransaction(tryEventArgs)); if (!msg.IsSuccess()) { DataProvider.RollbackTransaction(); return(msg); } } } //检查新上料是否在TS中而不可用 for (int i = 0; i < partsToUnload.Count; i++) { InnoObject innoObject = (InnoObject)partsToUnload[i]; if (innoObject.NewBarcode.Trim().Length > 0) { if (!tsFacade.RunningCardCanBeClollected(innoObject.NewBarcode.Trim(), CardType.CardType_Part)) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTSOrScrapped $SERIAL_NO=" + innoObject.NewBarcode.Trim())); DataProvider.RollbackTransaction(); return(msg); } } } //拆解或者替换处理tblonwipitem,tblsimulationreport DropMaterialEventArgs dropMaterialEventArgs = new DropMaterialEventArgs(ActionType.DataCollectAction_DropMaterial, product.LastSimulation.RunningCard, ApplicationService.Current().UserCode, ApplicationService.Current().ResourceCode, product); dropMaterialEventArgs.OnwipItems = partsToUnload.ToArray(); msg.AddMessages(onLine.ActionWithTransaction(dropMaterialEventArgs)); if (!msg.IsSuccess()) { DataProvider.RollbackTransaction(); return(msg); } //针对拆解下的物料,做TS相关的动作 for (int i = 0; i < partsToUnload.Count; i++) { InnoObject innoObject = (InnoObject)partsToUnload[i]; if (_TSList[innoObject.LineIndex] != null) { if (_TSErrorCodeList[innoObject.LineIndex] == null) { msg.Add(new UserControl.Message(MessageType.Error, "$CS_Please_Select_ErrorCode")); DataProvider.RollbackTransaction(); return(msg); } Domain.TS.TS oldTS = (Domain.TS.TS)tsFacade.QueryLastTSByRunningCard(innoObject.MCard); if (oldTS != null) { if (oldTS.TSStatus == TSStatus.TSStatus_New || oldTS.TSStatus == TSStatus.TSStatus_Confirm || oldTS.TSStatus == TSStatus.TSStatus_TS) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_InTS")); DataProvider.RollbackTransaction(); return(msg); } else if (oldTS.TSStatus != TSStatus.TSStatus_Reflow && oldTS.TSStatus != TSStatus.TSStatus_Split && oldTS.TSStatus != TSStatus.TSStatus_Complete && oldTS.TSStatus != TSStatus.TSStatus_Scrap) { msg.Add(new UserControl.Message(MessageType.Error, "$Error_Material_WrongTSStatus")); DataProvider.RollbackTransaction(); return(msg); } } Domain.TS.TS newTS = (Domain.TS.TS)_TSList[innoObject.LineIndex]; tsFacade.AddTS(newTS); foreach (TSErrorCode tsErrorCode in (TSErrorCode[])_TSErrorCodeList[innoObject.LineIndex]) { tsErrorCode.RunningCard = newTS.RunningCard; tsErrorCode.RunningCardSequence = newTS.RunningCardSequence; tsErrorCode.ItemCode = newTS.ItemCode; tsErrorCode.ModelCode = newTS.ModelCode; tsErrorCode.MOCode = newTS.MOCode; tsErrorCode.MOSeq = newTS.MOSeq; tsErrorCode.MaintainUser = newTS.MaintainUser; tsErrorCode.MaintainDate = newTS.MaintainDate; tsErrorCode.MaintainTime = newTS.MaintainTime; tsFacade.AddTSErrorCode(tsErrorCode); } } } if (!msg.IsSuccess()) { DataProvider.RollbackTransaction(); return(msg); } if (msg.IsSuccess()) { DataProvider.CommitTransaction(); } else { DataProvider.RollbackTransaction(); } } catch (Exception e) { this.DataProvider.RollbackTransaction(); msg.Add(new UserControl.Message(e)); } return(msg); }
private void edtItemCode_TxtboxKeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { if (this.edtMoCode.Value.Trim() == string.Empty) { ApplicationRun.GetInfoForm().AddEx("$CS_CMPleaseInputMO"); this.edtMoCode.TextFocus(true, true); return; } if (this.edtCarton.Value.Trim() == string.Empty) { ApplicationRun.GetInfoForm().AddEx("$CS_PLEASE_INPUT_CARTONNO"); this.edtCarton.TextFocus(true, true); return; } if (ultraGridDetail.Rows.Count <= 0) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_GRID_NO_RECORD")); this.edtItemCode.TextFocus(true, true); return; } if (!this.CheckGrid()) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_GRID_SELECT_ONE_RECORD")); this.edtItemCode.TextFocus(false, true); return; } Package.PackageFacade packageFacade = new BenQGuru.eMES.Package.PackageFacade(this.DataProvider); DataCollect.DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider); ItemFacade itemFacade = new ItemFacade(this.DataProvider); SKDCartonDetail skdCartonDetail = (SKDCartonDetail)packageFacade.GetSKDCartonDetail(this.edtMoCode.Value.Trim().ToUpper(), this.edtItemCode.Value.Trim().ToUpper()); if (skdCartonDetail != null) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Carton_Have_In_This_moCode")); this.edtItemCode.TextFocus(true, true); return; } //下面做物料的检查 Messages msg = new Messages(); string materialCode = string.Empty; for (int i = 0; i < ultraGridDetail.Rows.Count; i++) { if (ultraGridDetail.Rows[i].Cells[0].Value.ToString().ToLower() == "true") { materialCode = ultraGridDetail.Rows[i].Cells[1].Value.ToString(); _itemCode = materialCode; break; } } Domain.MOModel.Material material = (Domain.MOModel.Material)itemFacade.GetMaterial(materialCode, GlobalVariables.CurrentOrganizations.First().OrganizationID); if (material == null) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$Error_Material_NotFound")); this.edtItemCode.TextFocus(true, true); return; } OPBOMDetail detailTemp = new OPBOMDetail(); //模拟一个OPBOMDetail detailTemp.OPBOMItemControlType = material.MaterialControlType; detailTemp.OPBOMParseType = material.MaterialParseType; detailTemp.OPBOMCheckType = material.MaterialCheckType; detailTemp.CheckStatus = material.CheckStatus; detailTemp.SerialNoLength = material.SerialNoLength; detailTemp.NeedVendor = material.NeedVendor; detailTemp.OPBOMSourceItemCode = materialCode; detailTemp.OPBOMItemCode = materialCode; detailTemp.OPBOMItemQty = 1; MINNO newMinno = new MINNO(); newMinno.MOCode = this.edtMoCode.Value.Trim().ToUpper(); newMinno.MItemCode = material.MaterialCode.Trim(); msg = dataCollectFacade.GetMINNOByBarcode(detailTemp, this.edtItemCode.Value.Trim().ToUpper(), this.edtMoCode.Value.Trim().ToUpper(), null, false, true, out newMinno); if (!msg.IsSuccess()) { ApplicationRun.GetInfoForm().Add(msg); this.edtItemCode.TextFocus(true, true); return; } //检查上料资料 if (this.checkCINNO.Checked) { object[] onWipItemObjects = dataCollectFacade.QueryOnWIPItemWithmoCode(this.edtItemCode.Value.Trim().ToUpper(), materialCode, this.edtMoCode.Value.Trim().ToUpper()); if (onWipItemObjects == null) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Have_CollectMertial")); this.edtItemCode.TextFocus(true, true); return; } } this.DataProvider.BeginTransaction(); try { MOFacade moFacade = new MOFacade(this.DataProvider); DBDateTime dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); Domain.MOModel.MO mo = (Domain.MOModel.MO)moFacade.GetMO(this.edtMoCode.Value.Trim().ToUpper()); SKDCartonDetail newSKDCartonDetail = new SKDCartonDetail(); newSKDCartonDetail.moCode = this.edtMoCode.Value.Trim().ToUpper(); newSKDCartonDetail.CartonNO = this.edtCarton.Value.Trim().ToUpper(); if (mo != null) { newSKDCartonDetail.ItemCode = mo.ItemCode; } newSKDCartonDetail.SBItemCode = materialCode; newSKDCartonDetail.MCard = this.edtItemCode.Value.Trim().ToUpper(); newSKDCartonDetail.MaintainUser = ApplicationService.Current().UserCode; newSKDCartonDetail.MaintainDate = dBDateTime.DBDate; newSKDCartonDetail.MaintainTime = dBDateTime.DBTime; packageFacade.AddSKDCartonDetail(newSKDCartonDetail); ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_SKDCarton_Succes")); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); msg.Add(new UserControl.Message(ex)); ApplicationRun.GetInfoForm().Add(msg); } finally { this.DataProvider.CommitTransaction(); this.LoadData(); this.MakeGridChecked(); this.edtItemCode.TextFocus(true, true); } } }