//display rcard information private void DisplayRCardInfo(Domain.DataCollect.SimulationReport sim) { txtCurrentCarton.Value = sim.CartonCode; txtItemCode.Value = sim.ItemCode; txtMoCode.Value = sim.MOCode; txtOPCode.Value = sim.OPCode; txtResCode.Value = sim.ResourceCode; txtCartonNO.TextFocus(true, true); }
private void GetLotNo() { DataCollect.DataCollectFacade dcf = new BenQGuru.eMES.DataCollect.DataCollectFacade(DataProvider); string rCard = this.ucLabelEditRCard.Value.Trim().ToUpper(); string cartonCode = txtCartonCode.Value.ToUpper().Trim(); string sourceRCard = dcf.GetSourceCard(rCard, string.Empty); if (rCard.Length > 0) { object objSimulationReport = dcf.GetLastSimulationReport(sourceRCard); if (objSimulationReport != null) { Domain.DataCollect.SimulationReport simulationReport = objSimulationReport as Domain.DataCollect.SimulationReport; this.ucLabelEditLotNo.Value = simulationReport.LOTNO; if (simulationReport.LOTNO == string.Empty) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SN_NOT_EXIST_LOT")); this.ucLabelEditRCard.TextFocus(false, true); return; } Messages msg = this.LoadLotInfo(); if (!msg.IsSuccess()) { ApplicationRun.GetInfoForm().Add(msg); this.m_LotNo = string.Empty; this.ucLabelEditSizeAndCapacity.Value = ""; this.ucLabelEditItemCode.Value = ""; this.labelItemDescription.Text = ""; } else { this.m_LotNo = this.ucLabelEditLotNo.Value.Trim().ToUpper(); this.LoadSampleList(m_LotNo); this.LoadCheckList(m_LotNo); this.LoadBaseList(m_LotNo); this.ucLabelEditLotNo.TextFocus(false, true); } } else { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$NoSimulationInfo")); this.m_LotNo = string.Empty; this.ucLabelEditSizeAndCapacity.Value = ""; this.ucLabelEditItemCode.Value = ""; this.labelItemDescription.Text = ""; this.ucLabelEditRCard.TextFocus(false, true); } } //add by alex 2010.11.19 else if (cartonCode != String.Empty) { OQCFacade oqcFacade = new OQCFacade(this.DataProvider); object obj = oqcFacade.GetLot2CartonByCartonNo(cartonCode); if (obj != null) { Lot2Carton lot2Carton = obj as Lot2Carton; this.ucLabelEditLotNo.Value = lot2Carton.OQCLot; if (lot2Carton.OQCLot == string.Empty) { Messages messages = new Messages(); messages.Add(new UserControl.Message(MessageType.Error, "$CS_CARTON_NOT_EXIST_LOT")); ApplicationRun.GetInfoForm().Add(messages); this.txtCartonCode.TextFocus(false, true); return; } Messages msg = this.LoadLotInfo(); if (!msg.IsSuccess()) { ApplicationRun.GetInfoForm().Add(msg); this.m_LotNo = string.Empty; this.ucLabelEditSizeAndCapacity.Value = ""; this.ucLabelEditItemCode.Value = ""; this.labelItemDescription.Text = ""; } else { this.m_LotNo = this.ucLabelEditLotNo.Value.Trim().ToUpper(); this.LoadSampleList(m_LotNo); this.LoadCheckList(m_LotNo); this.LoadBaseList(m_LotNo); this.ucLabelEditLotNo.TextFocus(false, true); } } else { Messages messages = new Messages(); messages.Add(new UserControl.Message(MessageType.Error, "$NoLol2CartonInfo")); ApplicationRun.GetInfoForm().Add(messages); this.txtCartonCode.TextFocus(false, true); } } else { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Please_Input_RunningCard")); this.ucLabelEditSizeAndCapacity.Value = ""; this.m_LotNo = string.Empty; this.ucLabelEditItemCode.Value = ""; this.labelItemDescription.Text = ""; this.ucLabelEditRCard.TextFocus(false, true); } }
//Process Carton NO private void ProcessCarton(string cartonno) { DataCollectFacade dcf = new DataCollectFacade(DataProvider); string rCard = txtRCard.Value.Trim().ToUpper(); rCard = dcf.GetSourceCard(rCard, string.Empty); //箱号为空时,表示序列号从旧箱中移除 if (cartonno == String.Empty) { #region RCARD 从 Carton中移出 if (DialogResult.OK == MessageBox.Show(this, MutiLanguages.ParserString("$CS_Confirm_Transfer_1") + " " + txtRCard.Value.Trim().ToUpper() + " " + MutiLanguages.ParserString("$CS_Confirm_Transfer_2") + txtCurrentCarton.Value.Trim().ToUpper() + " " + MutiLanguages.ParserString("$CS_Confirm_Transfer_3"), MutiLanguages.ParserString("$ShowConfirm"), MessageBoxButtons.OKCancel)) { InventoryFacade materialDCF = new InventoryFacade(DataProvider); object objSimulationReport = dcf.GetLastSimulationReport(rCard); //在制品存在 if (objSimulationReport != null) { Domain.DataCollect.SimulationReport sim = objSimulationReport as Domain.DataCollect.SimulationReport; sim.CartonCode = String.Empty; PackageFacade pf = new PackageFacade(DataProvider); #region 移出操作 DataProvider.BeginTransaction(); try { dcf.RemoveFromCarton(sim.RunningCard, ApplicationService.Current().UserCode); //dcf.RemoveFromPallet2RCard(sim.RunningCard); DataProvider.CommitTransaction(); ucMessage.Add(new UserControl.Message(MessageType.Success , "$CS_RCARD_BREAK_FROM_CARTON_SUCCESS $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper())); txtRCard.TextFocus(true, true); txtCartonNO.Value = String.Empty; ClearRCardInfo(); } catch (Exception ex) { DataProvider.RollbackTransaction(); ucMessage.Add(new UserControl.Message(ex)); txtCartonNO.TextFocus(true, true); } finally { (DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection(); } #endregion } else//在制品不存在 { ucMessage.Add(new UserControl.Message(MessageType.Error , "$NoSimulation $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper())); ClearRCardInfo(); txtRCard.TextFocus(true, true); } } #endregion } else { #region RCARD 从当前Carton移转到另外一个Carton InventoryFacade materialDCF = new InventoryFacade(DataProvider); //ActionOnLineHelper onlineHelper = new ActionOnLineHelper(DataProvider); if (!CheckTargetCarton(cartonno)) { if (!m_NeedAddNewCarton) { txtCartonNO.TextFocus(true, true); return; } } string sourceCard = dcf.GetSourceCard(txtRCard.Value.Trim().ToUpper(), string.Empty); object objSimulationReport = dcf.GetLastSimulationReport(sourceCard); if (objSimulationReport != null) { Domain.DataCollect.SimulationReport simulationReport = objSimulationReport as Domain.DataCollect.SimulationReport; simulationReport.CartonCode = cartonno.Trim().ToUpper(); Package.PackageFacade pf = new BenQGuru.eMES.Package.PackageFacade(DataProvider); #region 移转操作 DataProvider.BeginTransaction(); try { //Add By Bernard @ 2010-11-01 string moCode = txtMoCode.Value.Trim().ToUpper(); string oldCartonno = txtCurrentCarton.Value.Trim().ToUpper(); bool m_HasCartonAdded = false; //end //包装箱不存在,为CartonInfo表增加一个包装箱信息 if (m_NeedAddNewCarton) { DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider); BenQGuru.eMES.Domain.Package.CARTONINFO newCarton = new BenQGuru.eMES.Domain.Package.CARTONINFO(); newCarton.CARTONNO = cartonno.Trim().ToUpper(); newCarton.CAPACITY = ((new ItemFacade(DataProvider)).GetItem(simulationReport.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Item).ItemCartonQty; newCarton.COLLECTED = 0; newCarton.EATTRIBUTE1 = ""; newCarton.PKCARTONID = System.Guid.NewGuid().ToString().ToUpper(); newCarton.MUSER = ApplicationService.Current().UserCode; newCarton.MDATE = currentDateTime.DBDate; newCarton.MTIME = currentDateTime.DBTime; pf.AddCARTONINFO(newCarton); //0.向tblcarton2rcard表增加一个包装箱 Add By Bernard @ 2010-11-01 Carton2RCARD newCarton2RCard = new Carton2RCARD(); newCarton2RCard.CartonCode = cartonno.Trim().ToUpper(); newCarton2RCard.Rcard = rCard; newCarton2RCard.MUser = ApplicationService.Current().UserCode; newCarton2RCard.MDate = currentDateTime.DBDate; newCarton2RCard.MTime = currentDateTime.DBTime; newCarton2RCard.Eattribute1 = ""; newCarton2RCard.MOCode = moCode; pf.AddCarton2RCARD(newCarton2RCard); m_HasCartonAdded = true; //end } //1.判断新箱与旧箱内产品工单代码是否一致 Add By Bernard @ 2010-11-01 object oldObj = pf.GetCarton2RCARD(oldCartonno, rCard); //modified by lisa @20120829 //string newMOCode = moCode; object[] newObj = pf.GetCarton2RCARDByCartonNO(FormatHelper.CleanString(this.txtCartonNO.Value.Trim())); string newMOCode = ((Carton2RCARD)newObj[0]).MOCode; //end add string oldMOCode = ((Carton2RCARD)oldObj).MOCode; if (oldMOCode == newMOCode) //工单代码一致 { if (m_HasCartonAdded == false) //箱号没有新增,则向Carton2RCard新增一条记录 { DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider); Carton2RCARD carton2rcard = new Carton2RCARD(); carton2rcard.Rcard = rCard; carton2rcard.CartonCode = cartonno; carton2rcard.MOCode = moCode; carton2rcard.MUser = ApplicationService.Current().UserCode; carton2rcard.MDate = currentDateTime.DBDate; carton2rcard.MTime = currentDateTime.DBTime; carton2rcard.Eattribute1 = ""; pf.AddCarton2RCARD(carton2rcard); } //end dcf.RemoveFromCarton(simulationReport.RunningCard, ApplicationService.Current().UserCode); pf.UpdateCollected(cartonno.Trim().ToUpper()); Domain.DataCollect.Simulation simulation = (Domain.DataCollect.Simulation)dcf.GetSimulation(simulationReport.RunningCard); if (simulation != null) { simulation.CartonCode = cartonno.Trim().ToUpper(); dcf.UpdateSimulation(simulation); } dcf.UpdateSimulationReport(simulationReport); //记log pf.addCarton2RCARDLog(cartonno, simulationReport.RunningCard, ApplicationService.Current().UserCode); //end } else//新旧包装箱工单代码不一致 Add By Bernard @ 2010-11-01 { if (m_HasCartonAdded == true) { //删除CartonInfo表新增加的包装箱 CARTONINFO cartoninfo = new CARTONINFO(); cartoninfo.CARTONNO = cartonno; pf.DeleteCARTONINFO(cartoninfo); //删除旧Carton2RCARD表新增加的箱号 Carton2RCARD carton2rcard = new Carton2RCARD(); carton2rcard.Rcard = rCard; carton2rcard.CartonCode = cartonno; pf.DeleteCarton2RCARD(carton2rcard); } else { DataProvider.RollbackTransaction(); ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_CARTON_NO :" + cartonno + "$CS_Which_MOCode_With_RCard :" + rCard + "$CS_For_Carton_No's_MOCode_Is_Different")); txtCartonNO.TextFocus(true, true); return; } } //end DataProvider.CommitTransaction(); ucMessage.Add(new UserControl.Message(MessageType.Success , "$CS_RCARD_TRANSFER_CARTON_SUCCESS $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper())); txtRCard.TextFocus(true, true); txtCartonNO.Value = String.Empty; ClearRCardInfo(); } catch (Exception ex) { DataProvider.RollbackTransaction(); ucMessage.Add(new UserControl.Message(ex)); txtCartonNO.TextFocus(true, true); } finally { (DataProvider as SQLDomainDataProvider).PersistBroker.CloseConnection(); } #endregion } else { ucMessage.Add(new UserControl.Message(MessageType.Error, "$NoSimulation $CS_Param_ID =" + txtRCard.Value.Trim().ToUpper())); ClearRCardInfo(); txtRCard.TextFocus(true, true); } #endregion } }