private void btnCommission_Click(object sender, System.EventArgs e) { // IObjectSpace objectSpace = XafApplication.cre; IObjectSpace objectSpace = this.application.CreateObjectSpace(); // CriteriaOperator op = CriteriaOperator.Parse("RepackLot.LotId = ? AND SerialNo = ? AND GTIN = ?", txtLot.Text, txtSerial.Text, txtOuterScan.Text); CriteriaOperator op = CriteriaOperator.Parse("RepackLot.LotId = ? AND SerialNo = ? ", txtLot.Text, txtSerial.Text); RepackLotSerialNo lsnOutside = objectSpace.FindObject <RepackLotSerialNo>(op); if (lsnOutside == null) { return; } lsnOutside.IsCommission = true; lsnOutside.Save(); objectSpace.CommitChanges(); // scroll through the list and find the serial number in the system // IObjectSpace objectSpace = Application.ObjectSpaceProvider.CreateObjectSpace() //ObjectSpace os = new ObjectSpace(new UnitOfWork(Session.DataLayer), XafTypesInfo.Instance); RepackLotSerialNo lsna; foreach (var barcode in INBCList) { op = CriteriaOperator.Parse("RepackLot.LotId = ? AND SerialNo = ?", barcode.lot, barcode.serial); lsna = objectSpace.FindObject <RepackLotSerialNo>(op); if (lsna == null) { return; } lsna.ParentSerialNo = txtSerial.Text; lsna.IsCommission = true; lsna.Save(); objectSpace.CommitChanges(); } Clearinfo(); }
private void GenSerialNo_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) { // eRFXLImpType impType = eRFXLImpType.Production; IObjectSpace objectSpace = Application.CreateObjectSpace(); // IObjectSpace objectSpace = ObjectSpace.CreateNestedObjectSpace(); RepackLotGenerate lotGenSerial = (RepackLotGenerate)e.PopupWindowView.CurrentObject; RepackLots lsg = lotGenSerial.LotId; RepackLots RL = (RepackLots)objectSpace.GetObjectByKey(typeof(RepackLots), lsg.Oid); eSerialTypes stype; int snumber = 1965; if (lsg == null) { stype = eSerialTypes.sequential; } stype = RL.RepackItem.SerialType; //lsg.RepackItem.SerialType; switch (stype) { case eSerialTypes.sequential: { int lastSerialNumber = 0; lastSerialNumber = RL.LastSerialNumber; //Generates Partials for (int i = 1; i < lotGenSerial.QtyOfPartial + 1; i++) { lastSerialNumber++; string snum = lastSerialNumber.ToString().PadLeft(2, '0'); RepackLotSerialNo LotSerial = objectSpace.CreateObject <RepackLotSerialNo>(); LotSerial.RepackLot = RL; LotSerial.LabelType = eLabelType.InnerCarton; LotSerial.GTIN = RL.RepackItem.Gtin; LotSerial.isPartial = true; LotSerial.GTIN = RL.RepackItem.Gtin; LotSerial.SerialNo = RL.LotId.PadRight(2, '0') + snum; LotSerial.Save(); } //Generates non partials for (int i = 1; i < lotGenSerial.QtyToGenerate + 1; i++) { lastSerialNumber++; string snum = lastSerialNumber.ToString().PadLeft(2, '0'); RepackLotSerialNo LotSerial = objectSpace.CreateObject <RepackLotSerialNo>(); LotSerial.RepackLot = RL; LotSerial.LabelType = eLabelType.InnerCarton; LotSerial.GTIN = RL.RepackItem.Gtin; LotSerial.GTIN = RL.RepackItem.Gtin; LotSerial.SerialNo = RL.LotId.PadRight(2, '0') + snum; LotSerial.Save(); } RL.LastSerialNumber = lastSerialNumber; RL.Save(); break; } case eSerialTypes.Random: Random getRandom = new Random(); for (int i = 0; i < lotGenSerial.QtyToGenerate; i++) { IObjectSpace objectSpace2 = Application.CreateObjectSpace(); RepackLotSerialNo LotSerial = objectSpace2.CreateObject <RepackLotSerialNo>(); LotSerial.RepackLot = RL; LotSerial.LabelType = eLabelType.InnerCarton; LotSerial.GTIN = RL.RepackItem.Gtin; LotSerial.SerialNo = lotGenSerial.LotId.ToString() + snumber.ToString("000000") + getRandom.Next(3, 999999).ToString("000000"); LotSerial.Save(); } break; case eSerialTypes.RFXcel: string gtin = RL.RepackItem.Gtin; RFEXCEL rfc = new RFEXCEL(gtin, lotGenSerial.QtyToGenerate, Application, impType); //************************************************ // // Go Get Serial Number from RXexcel // //*********************************************** rfc.PostRequest(gtin, lotGenSerial.QtyToGenerate, e); for (int i = 0; i < lotGenSerial.QtyToGenerate; i++) { // string is1 = "12345.6789.1111111111"; //int lastdot = is1.LastIndexOf("."); //string is2 = is1.Substring(lastdot +1 ); RepackLotSerialNo LotSerial = objectSpace.CreateObject <RepackLotSerialNo>(); LotSerial.RepackLot = RL; LotSerial.LabelType = eLabelType.InnerCarton; LotSerial.SerialNo = rfc.SerialList[i]; LotSerial.sGTIN = rfc.sGTIN[i]; LotSerial.GTIN = RL.RepackItem.Gtin; //LotSerial.SerialNo = RL.LotId.ToString() + snumber.ToString("000000") + i + 1.ToString("000000"); LotSerial.Save(); } break; } objectSpace.CommitChanges(); ObjectSpace.Refresh(); MessageOptions options = new MessageOptions(); options.Duration = 20000; options.Message = string.Format("{0} Serial Number for Lot {1} has been entered", lotGenSerial.QtyToGenerate, lotGenSerial.LotId.LotId.ToString()); options.Type = InformationType.Success; options.Web.Position = InformationPosition.Right; options.Win.Caption = "Success"; options.Win.Type = WinMessageType.Alert; //options.OkDelegate = () => { // IObjectSpace os = Application.CreateObjectSpace(typeof(Customer)); // DetailView newTaskDetailView = Application.CreateDetailView(os, os.CreateObject<ItemRequest>()); // Application.ShowViewStrategy.ShowViewInPopupWindow(newTaskDetailView); //}; Application.ShowViewStrategy.ShowMessage(options); }