Exemplo n.º 1
0
        public void AddInventory()
        {
            inventory    inv       = new inventory();
            AddInventory addWindow = new AddInventory();

            // Sets the window's context and gives it the types available, that aren't deleted
            addWindow.DataContext = new { inventory = inv, merchandise = dataHandler.GetEntities().merchandise.ToList().FindAll(type => { return(!type.deleted); }) };
            addWindow.ShowDialog();

            try
            {
                dataHandler.AddOrUpdate(inv);
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show("Error: " + e.Message);
            }
            NotifyOfPropertyChange("Inventory");
        }
Exemplo n.º 2
0
        public void Modify(inventory inv)
        {
            AddInventory addWindow = new AddInventory();

            // Sets the window's context and gives it the types available, that aren't deleted
            addWindow.DataContext = new { inventory = inv, merchandise = dataHandler.GetEntities().merchandise.ToList().FindAll(type => { return(!type.deleted); }) };
            if (addWindow.ShowDialog() == true)
            {
                try
                {
                    dataHandler.AddOrUpdate(inv);
                }
                catch (Exception e)
                {
                    System.Windows.MessageBox.Show("Error: " + e.Message);
                }
            }
            else
            {
                ((System.Data.Entity.Infrastructure.IObjectContextAdapter)dataHandler.GetEntities()).ObjectContext.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, inv);
            }
            NotifyOfPropertyChange("Inventory");
        }