public void AddCarton2Lot(string cartonCode, string lotCode, decimal cartonQty, string userCode, string moCode) { DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider); Carton2Lot carton2Lot = this.CreateNewCarton2Lot(); carton2Lot.CartonCode = cartonCode; carton2Lot.LotCode = lotCode; carton2Lot.CartonQty = cartonQty; carton2Lot.MOCode = moCode; carton2Lot.MUser = userCode; carton2Lot.MDate = dbDateTime.DBDate; carton2Lot.MTime = dbDateTime.DBTime; this.AddCarton2Lot(carton2Lot); }
//Process Carton NO private void ProcessCarton(string cartonno) { DataCollectFacade dcf = new DataCollectFacade(DataProvider); string lotCode = txtLotCode.Value.Trim().ToUpper(); #region lotCode 从当前Carton移转到另外一个Carton InventoryFacade materialDCF = new InventoryFacade(DataProvider); if (!CheckTargetCarton(cartonno)) { if (!m_NeedAddNewCarton) { ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo")); txtCartonNO.TextFocus(true, true); return; } } object objSimulationReport = dcf.GetLastLotSimulationReport(lotCode); if (objSimulationReport != null) { Domain.LotDataCollect.LotSimulationReport simulationReport = objSimulationReport as Domain.LotDataCollect.LotSimulationReport; //simulationReport.CartonCode = cartonno.Trim().ToUpper(); #region 移转操作 DataProvider.BeginTransaction(); try { //Add By Bernard @ 2010-11-01 string moCode = txtMoCode.Value.Trim().ToUpper(); string oldCartonno = ucLabelComboxCurrentCarton.SelectedItemText; bool m_HasCartonAdded = false; //end decimal oldCartonQty = 0; Carton2Lot oldCarton2Lot = (Carton2Lot)pf.GetCarton2Lot(oldCartonno.Trim().ToUpper(), lotCode.Trim().ToUpper()); if (oldCarton2Lot != null) { oldCartonQty = oldCarton2Lot.CartonQty; } int capaCity = ((new ItemFacade(DataProvider)).GetItem(simulationReport.ItemCode, GlobalVariables.CurrentOrganizations.First().OrganizationID) as Item).ItemCartonQty; //包装箱不存在,为CartonInfo表增加一个包装箱信息 if (m_NeedAddNewCarton) { if (oldCartonQty > capaCity) { ucMessage.Add(new UserControl.Message(MessageType.Error , "$CS_CartonQty_IS_Large $CS_Param_LotNO =" + txtLotCode.Value.Trim().ToUpper())); ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo")); this.DataProvider.RollbackTransaction(); txtCartonNO.TextFocus(true, true); return; } DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider); BenQGuru.eMES.Domain.Package.CARTONINFO newCarton = new BenQGuru.eMES.Domain.Package.CARTONINFO(); newCarton.CARTONNO = cartonno.Trim().ToUpper(); newCarton.CAPACITY = capaCity; 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 Carton2Lot newCarton2Lot = new Carton2Lot(); newCarton2Lot.CartonCode = cartonno.Trim().ToUpper(); newCarton2Lot.LotCode = lotCode; newCarton2Lot.CartonQty = oldCartonQty; newCarton2Lot.MUser = ApplicationService.Current().UserCode; newCarton2Lot.MDate = currentDateTime.DBDate; newCarton2Lot.MTime = currentDateTime.DBTime; newCarton2Lot.Eattribute1 = ""; newCarton2Lot.MOCode = moCode; pf.AddCarton2Lot(newCarton2Lot); m_HasCartonAdded = true; //end } //判断箱中采集数量是否大与包装容量 object obj = pf.GetCARTONINFO(cartonno.Trim().ToUpper()); Domain.Package.CARTONINFO carton = obj as Domain.Package.CARTONINFO; if ((carton.COLLECTED + oldCartonQty) > carton.CAPACITY) { this.DataProvider.RollbackTransaction(); ucMessage.Add(new UserControl.Message(MessageType.Error, "$CS_CartonQty_IS_Large $CS_CARTON_NO =" + cartonno.Trim().ToUpper())); ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo")); txtCartonNO.TextFocus(true, true); return; } //1.判断新箱与旧箱内产品工单代码是否一致 Add By Bernard @ 2010-11-01 object oldObj = pf.GetCarton2Lot(oldCartonno, lotCode); string newMOCode = moCode; string oldMOCode = ((Carton2Lot)oldObj).MOCode; if (oldMOCode == newMOCode) //工单代码一致 { if (m_HasCartonAdded == false) //箱号没有新增,则向Carton2RCard新增一条记录 { DBDateTime currentDateTime = FormatHelper.GetNowDBDateTime(DataProvider); object newObj = pf.GetCarton2Lot(cartonno, lotCode); if (newObj == null) { Carton2Lot carton2Lot = new Carton2Lot(); carton2Lot.LotCode = lotCode; carton2Lot.CartonQty = oldCartonQty; carton2Lot.CartonCode = cartonno; carton2Lot.MOCode = moCode; carton2Lot.MUser = ApplicationService.Current().UserCode; carton2Lot.MDate = currentDateTime.DBDate; carton2Lot.MTime = currentDateTime.DBTime; carton2Lot.Eattribute1 = ""; pf.AddCarton2Lot(carton2Lot); } else { Carton2Lot carton2Lot = newObj as Carton2Lot; carton2Lot.CartonQty = carton2Lot.CartonQty + oldCartonQty; carton2Lot.MUser = ApplicationService.Current().UserCode; carton2Lot.MDate = currentDateTime.DBDate; carton2Lot.MTime = currentDateTime.DBTime; pf.UpdateCarton2Lot(carton2Lot); } } //end dcf.RemoveFromCarton(simulationReport.LotCode, oldCartonno, ApplicationService.Current().UserCode); pf.UpdateCollected(cartonno.Trim().ToUpper(), oldCartonQty); //记log pf.AddCarton2LotLog(cartonno, simulationReport.LotCode, oldCartonQty, ApplicationService.Current().UserCode); //end } else { DataProvider.RollbackTransaction(); ucMessage.Add(new UserControl.Message(MessageType.Error, "$ERROR_CARTON_MOCODE $CS_CARTON_NO =" + cartonno.Trim().ToUpper())); ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo")); txtCartonNO.TextFocus(true, true); return; } //判断相中的批次是否属于同一批次 int mocodeCount = pf.GetMoCountByCartonNo(cartonno); if (mocodeCount > 1) { DataProvider.RollbackTransaction(); ucMessage.Add(new UserControl.Message(MessageType.Error, "$ERROR_CARTON_MOCODE $CS_CARTON_NO =" + cartonno.Trim().ToUpper())); ucMessage.Add(new UserControl.Message(MessageType.Normal, ">>$CS_PleaseInputCartonNo")); txtCartonNO.TextFocus(true, true); return; } //end DataProvider.CommitTransaction(); ucMessage.Add(new UserControl.Message(MessageType.Success , "$CS_LOTCODE_TRANSFER_CARTON_SUCCESS $CS_Param_LotNO =" + txtLotCode.Value.Trim().ToUpper())); ucMessage.Add(new UserControl.Message(">>$CS_Please_Input_LotCode")); txtLotCode.TextFocus(true, true); txtCartonNO.Value = String.Empty; ClearLotCodeInfo(); } 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_LotNO =" + txtLotCode.Value.Trim().ToUpper())); ucMessage.Add(new UserControl.Message(">>$CS_Please_Input_LotCode")); ClearLotCodeInfo(); txtLotCode.TextFocus(true, true); } #endregion }
public void UpdateCarton2Lot(Carton2Lot carton2Lot) { this._helper.UpdateDomainObject(carton2Lot); }
public void DeleteCarton2Lot(Carton2Lot carton2Lot) { this._helper.DeleteDomainObject(carton2Lot); }
public void AddCarton2Lot(Carton2Lot carton2Lot) { this._helper.AddDomainObject(carton2Lot); }