Exemple #1
0
        public static void UpdateDatabase(TDCustomizationPlugin plugin, ref List <Tuple <string, object[]> > errors)
        {
            string companyName = PXAccess.GetCompanyName();

            NonStockItemMaint graph = PXGraph.CreateInstance <NonStockItemMaint>();
            InventoryItem     item;
            INItemClass       itemClass;

            try
            {
                itemClass = PXSelectReadonly <INItemClass, Where <INItemClass.itemClassCD, Equal <Required <INItemClass.itemClassCD> > > > .Select(graph, "EXPENSES");

                if (itemClass != null)
                {
                    item               = graph.Item.Insert();
                    item.InventoryCD   = "CLEANROOM";
                    item               = graph.Item.Update(item);
                    item.ItemClassID   = itemClass.ItemClassID;
                    item               = graph.ItemSettings.Update(item);
                    item.TaxCategoryID = "EXEMPT";
                    item               = graph.ItemSettings.Update(item);
                    item.Descr         = "House Cleaning Service";
                    item               = graph.ItemSettings.Update(item);
                    graph.Save.Press();

                    graph.Clear();
                }
            }
            catch (Exception)
            {
                errors.Add(new Tuple <string, object[]>(TDMessages.ErrorInsertingItems, new object[] { companyName }));
            }
        }
        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());
        }