protected void createStockItem() { var result = CreateStockItemDialog.AskExt((graph, viewname) => { CreateStockItemDialog.Cache.Clear(); }); if (result != WebDialogResult.OK) { return; } var itemParams = CreateStockItemDialog.Current; if (string.IsNullOrEmpty(itemParams.InventoryCD)) { CreateStockItemDialog.Cache.RaiseExceptionHandling <CreateStockItemParams.inventoryCD>(itemParams, itemParams.InventoryCD, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName <CreateStockItemParams.inventoryCD>(CreateStockItemDialog.Cache))); return; } InventoryItemMaint maint = PXGraph.CreateInstance <InventoryItemMaint>(); var newItem = new InventoryItem(); newItem.InventoryCD = itemParams.InventoryCD; newItem = maint.Item.Insert(newItem); newItem.ItemClassID = Base.itemclass.Current.ItemClassID; maint.Item.Update(newItem); throw new PXRedirectRequiredException(maint, "New Stock Item"); }
public virtual IEnumerable viewDetails(PXAdapter adapter) { if (Members.Current != null) { InventoryItem _inventoryItem = InventoryItem.PK.Find(this, Members.Current.InventoryID); if (_inventoryItem != null) { if (_inventoryItem.StkItem == true) { InventoryItemMaint graph = PXGraph.CreateInstance <InventoryItemMaint>(); PXResult result = graph.Item.Search <InventoryItem.inventoryID>(Members.Current.InventoryID); if (result != null) { InventoryItem _ninventoryItem = result[typeof(InventoryItem)] as InventoryItem; graph.Item.Current = _ninventoryItem; PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Same); } } else { NonStockItemMaint graph = PXGraph.CreateInstance <NonStockItemMaint>(); PXResult result = graph.Item.Search <InventoryItem.inventoryID>(Members.Current.InventoryID); if (result != null) { InventoryItem _sinventoryItem = result[typeof(InventoryItem)] as InventoryItem; graph.Item.Current = _sinventoryItem; PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.Same); } } } } return(adapter.Get()); }
protected virtual void AssignInventoryBoxes(InventoryItemMaint graph, IEnumerable<INItemBoxEx> templateItemBoxes) { INItemBoxEx[] itemBoxes = graph.Boxes.Select().RowCast<INItemBoxEx>().ToArray(); foreach (INItemBoxEx templateItemBox in templateItemBoxes) { INItemBoxEx itemBox = itemBoxes.FirstOrDefault(ic => ic.BoxID == templateItemBox.BoxID) ?? graph.Boxes.Insert(new INItemBoxEx { BoxID = templateItemBox.BoxID }); var copy = (INItemBoxEx)graph.Boxes.Cache.CreateCopy(itemBox); graph.Boxes.Cache.RestoreCopy(copy, templateItemBox); var excludeFields = new Type[] { typeof(INItemBoxEx.inventoryID), typeof(INItemBoxEx.Tstamp), typeof(INItemBoxEx.createdByID), typeof(INItemBoxEx.createdByScreenID), typeof(INItemBoxEx.createdDateTime), typeof(INItemBoxEx.lastModifiedByID), typeof(INItemBoxEx.lastModifiedByScreenID), typeof(INItemBoxEx.lastModifiedDateTime), typeof(INItemBoxEx.noteID), }; foreach (Type excludeField in excludeFields) { graph.Boxes.Cache.SetValue(copy, excludeField.Name, graph.Boxes.Cache.GetValue(itemBox, excludeField.Name)); } itemBox = graph.Boxes.Update(copy); } }
protected virtual IEnumerable ViewItem(PXAdapter a) { if (this.ResultRecords.Current != null) { InventoryItemMaint.Redirect(this.ResultRecords.Current.InventoryID, true); } return(a.Get()); }
protected INUnit GetINUnit(InventoryItemMaint maint, EntityValueField fromUnit, EntityValueField toUnit) { var conversions = maint.itemunits.Select(); return(conversions.Select(c => c[typeof(INUnit)] as INUnit) .FirstOrDefault(c => c != null && (toUnit == null || string.IsNullOrEmpty(toUnit.Value) || string.Equals(c.ToUnit, toUnit.Value)) && string.Equals(c.FromUnit, fromUnit.Value))); }
public virtual IEnumerable viewInventoryItem(PXAdapter adapter) { if (VendorCatalogue.Current != null && VendorCatalogue.Current.InventoryID.HasValue) { InventoryItemMaint graph = PXGraph.CreateInstance <InventoryItemMaint>(); InventoryItem invItem = graph.Item.Search <InventoryItem.inventoryID>(VendorCatalogue.Current.InventoryID); if (invItem != null) { graph.Item.Current = invItem; throw new PXRedirectRequiredException(graph, true, "View Inventory Item") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } return(adapter.Get()); }
public virtual IEnumerable updateDoc(PXAdapter adapter) { if (this.Base.Document.Current != null) { InventoryItemMaint itemMaint = PXGraph.CreateInstance <InventoryItemMaint>(); /*you can access an instance of a BLC extension through the base BLC * object by using the GetExtension< T > (object)generic method of the PXGraph class*/ var itemMaintExt = itemMaint.GetExtension <InventoryItemMaintExt>(); foreach (SOLine line in this.Base.Transactions.Select()) { InventoryItem inventory = PXSelectorAttribute.Select <SOLine.inventoryID>(this.Base.Transactions.Cache, line, line.InventoryID) as InventoryItem; if (inventory != null) { InventoryItem inventoryNew = itemMaintExt.UpdatePrice(itemMaint, inventory); line.CuryUnitPrice = inventoryNew.BasePrice; this.Base.Transactions.Update(this.Base.Transactions.Current); } } this.Base.Save.PressButton(); } return(adapter.Get()); }
public virtual IEnumerable ViewInventory(PXAdapter adapter) { InventoryItem inv = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Current <PMTran.inventoryID> > > > .SelectSingleBound(this, new object[] { Transactions.Current }); if (inv != null && inv.StkItem == true) { InventoryItemMaint graph = CreateInstance <InventoryItemMaint>(); graph.Item.Current = inv; throw new PXRedirectRequiredException(graph, "Inventory Item") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } else if (inv != null) { NonStockItemMaint graph = CreateInstance <NonStockItemMaint>(); graph.Item.Current = graph.Item.Search <InventoryItem.inventoryID>(inv.InventoryID); throw new PXRedirectRequiredException(graph, "Inventory Item") { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } return(adapter.Get()); }
public virtual void CreateUpdateMatrixItems(InventoryItemMaintBase graph, InventoryItem templateItem, IEnumerable<MatrixInventoryItem> itemsToCreateUpdate, bool create, Action<MatrixInventoryItem, InventoryItem> beforeSave = null) { Dictionary<string, string> templateAttrValues = PXSelectReadonly<CSAnswers, Where<CSAnswers.refNoteID, Equal<Required<InventoryItem.noteID>>>> .Select(graph, templateItem.NoteID) .RowCast<CSAnswers>() .ToDictionary(a => a.AttributeID, a => a.Value, StringComparer.OrdinalIgnoreCase); IEnumerable<POVendorInventory> templateVendorInvs = graph.VendorItems.View.SelectMultiBound(new[] { templateItem }) .RowCast<POVendorInventory>() .ToArray(); IEnumerable<INUnit> templateItemConvs = graph.itemunits.View.SelectMultiBound(new[] { templateItem }) .RowCast<INUnit>() .ToArray(); IEnumerable<INItemCategory> templateItemCategs = graph.Category.View.SelectMultiBound(new[] { templateItem }) .RowCast<INItemCategory>() .ToArray(); IEnumerable<INItemBoxEx> templateBoxes = null; InventoryItemMaint stockItemGraph = null; if (templateItem.StkItem == true) { stockItemGraph = (InventoryItemMaint)graph; templateBoxes = stockItemGraph.Boxes.View.SelectMultiBound(new[] { templateItem }) .RowCast<INItemBoxEx>() .ToArray(); } foreach (MatrixInventoryItem itemToCreateUpdate in itemsToCreateUpdate) { graph.Clear(); InventoryItem item; if (create) { item = new InventoryItem { InventoryCD = itemToCreateUpdate.InventoryCD }; item = graph.Item.Insert(item); } else { item = graph.Item.Current = graph.Item.Search<InventoryItem.inventoryCD>(itemToCreateUpdate.InventoryCD); } if (item == null) { throw new PXInvalidOperationException(); } if (create) { item = AssignInventoryField<InventoryItem.descr>(graph, item, itemToCreateUpdate.Descr); PXDBLocalizableStringAttribute.CopyTranslations<MatrixInventoryItem.descr, InventoryItem.descr>(graph, itemToCreateUpdate, item); } item = AssignInventoryField<InventoryItem.itemClassID>(graph, item, templateItem.ItemClassID); item = AssignInventoryField<InventoryItem.postClassID>(graph, item, templateItem.PostClassID); AssignConversionsSettings(graph, item, templateItem); item = AssignRestInventoryFields(graph, item, templateItem); item = AssignInventoryField<InventoryItem.templateItemID>(graph, item, templateItem.InventoryID); AssignInventoryAttributes(graph, itemToCreateUpdate, templateAttrValues); AssignVendorInventory(graph, templateVendorInvs); AssignInventoryConversions(graph, templateItemConvs); AssignInventoryCategories(graph, templateItemCategs); if (templateItem.StkItem == true) AssignInventoryBoxes(stockItemGraph, templateBoxes); beforeSave?.Invoke(itemToCreateUpdate, item); graph.Save.Press(); itemToCreateUpdate.InventoryID = item.InventoryID; } }