private void IIB_LastScanChangedEvent(object sender, string e) { ItemInventoryBatch iib = (ItemInventoryBatch)sender; if (e == string.Empty) { return; } scancount++; string scan = e; PropertyEditor editor; BarcodeUtil2 gdu = new BarcodeUtil2(); if (scan.Length < 30) { string message = "You did not scan a GS1 2d barcode."; //string caption = "Error Detected in Input"; // MessageBoxButtons buttons = MessageBoxButtons.OK; //DialogResult result; Application.ShowViewStrategy.ShowMessage(message); editor = ((DetailView)View).FindItem("LastScan") as PropertyEditor; if (editor != null) { (editor.Control as Control).Focus(); } return; } if (iib.Oid == -1) { iib.Save(); } AddToItem(iib, e); AddToItemSerial(iib, e); // now set the focus back to LastScan and empty out values editor = ((DetailView)View).FindItem("LastScan") as PropertyEditor; if (editor != null) { IIB.LastScan = string.Empty; (editor.Control as Control).Focus(); } }
private void ShInventoryController_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) { ; TargetViewId = "ItemInventoryBatch_DetailView"; IObjectSpace objectSpace = Application.CreateObjectSpace(); IIB = objectSpace.CreateObject <ItemInventoryBatch>(); // subscribe to the LastScanChanged event to capture the scans IIB.LastScanChangedEvent += IIB_LastScanChangedEvent; //objectSpace.ObjectEndEdit IIB.CreatedDate = DateTime.Now; IIB.InventoryType = eInventoryBatchType.Partial; IIB.CreatedBy = SecuritySystem.CurrentUserName; e.View = Application.CreateDetailView(objectSpace, TargetViewId, true, IIB); e.View.Caption = e.View.Caption + " - " + IIB?.Oid.ToString(); IIB.Save(); }
private int AddToItems(object sender, string itemnumber, string lot, string expdate, string scan) { // this counts for non serialized numbers // editor1 = ((DetailView)View).FindItem("Items") as ListPropertyEditor; IObjectSpace objectspace = this.ObjectSpace.CreateNestedObjectSpace(); // InventoryItemBatchItems iiBi = this.ObjectSpace.GetObject<InventoryItemBatchItems>(); ItemInventoryBatch iib = objectToShow; // Find the item in the item list // bool found = false; Session session; session = objectToShow.Session; CriteriaOperator op = GroupOperator.Combine(GroupOperatorType.And, new BinaryOperator("InventoryBatch", iib.Oid), new BinaryOperator("NDC", itemnumber), new BinaryOperator("Lot", lot)); InventoryItemBatchItems itemToUpdate = (InventoryItemBatchItems)session.FindObject(typeof(InventoryItemBatchItems), op, true); if (itemToUpdate != null) { itemToUpdate.Qty++; itemToUpdate.Save(); session.CommitTransaction(); } else { InventoryItemBatchItems iibi; iibi = objectspace.CreateObject <InventoryItemBatchItems>(); iibi.InventoryBatch = objectspace.GetObject <ItemInventoryBatch>((ItemInventoryBatch)this.View.CurrentObject); //iibi.InventoryBatch.Oid = iib.Oid; iibi.NDC = itemnumber; iibi.Lot = lot; iibi.Qty = 1; DateTime result; if (DateTime.TryParse(expdate, out result)) { iibi.ExpirationDate = result; } iibi.Save(); objectspace.CommitChanges(); // objectspace.Refresh(); } objectToShow.Save(); this.View.ObjectSpace.CommitChanges(); objectToShow.ItemInventoryBatchS.Reload(); objectToShow.Item.Reload(); //jectSpace.ReloadObject(); this.View.ObjectSpace.Refresh(); return(1); }