コード例 #1
0
        public void LoadFromXml(XElement xmlElement)
        {
            IdManager idManager = IdManager.GetIdManager();

            InventoryItems = new List<InventoryItem>();

            foreach (XElement inventoryItemsElement in xmlElement.Elements("InventoryItems"))
            {
                foreach (XElement inventoryItemElement in inventoryItemsElement.Elements("InventoryItem"))
                {
                    InventoryItem inventoryItem = new InventoryItem();

                    inventoryItem.LoadFromXml(inventoryItemElement);

                    InventoryItems.Add(inventoryItem);
                }
            }

            foreach (var locationsElement in xmlElement.Elements("Locations"))
            {
                foreach (var locationElement in locationsElement.Elements("Location"))
                {
                    Location location = new Location();

                    location.LoadFromXml(locationElement);

                    Locations.Add(location);

                    idManager.RegisterId(location, location.Id);
                }
            }

            MerryUpLocationsWithInventoryItems();
        }
コード例 #2
0
 public InventoryItem()
 {
     CatalogItem = new CatalogItem();
     Location = new Location();
     QtyOnHand = 0;
     ReOrderPoint = 0;
     ReOrderQuantity = 0;
 }
コード例 #3
0
        public bool Contains(Location location, CatalogItem catalogItem)
        {
            foreach(InventoryItem inventoryItem in InventoryItems)
            {
                if(inventoryItem.Location.Equals(location) && inventoryItem.CatalogItem.Equals(catalogItem))
                {
                    return true;
                }
            }

            return false;
        }
コード例 #4
0
        void SetSelectedLocation(Location location)
        {
            if(location != null)
            {
                cbxLocation.SelectedItem = location;
            }

            if(cbxLocation.SelectedIndex < 0 && cbxLocation.Items.Count > 0)
            {
                cbxLocation.SelectedIndex = 0;
            }

            if (cbxLocation.SelectedIndex > -1)
            {
                Location selectedLocation = cbxLocation.SelectedItem as Location;

                if (selectedLocation != null)
                {
                    txtLocationDescription.Text = selectedLocation.Description;
                }
            }
        }
コード例 #5
0
        void SaveLocation()
        {
            bool locationWasFound = false;
            _currentLocation = null;

            foreach (Location location in cbxLocation.Items)
            {
                if(location.Name == cbxLocation.Text)
                {
                    locationWasFound = true;
                    _currentLocation = location;
                    location.Description = txtLocationDescription.Text;
                    break;
                }
            }

            if(!locationWasFound)
            {
                _currentLocation = new Location();

                _currentLocation.Name = cbxLocation.Text;
                _currentLocation.Description = txtLocationDescription.Text;
                _productGraph.Inventory.Locations.Add(_currentLocation);
                _productGraph.Inventory.Locations.Sort();
            }
        }
コード例 #6
0
        //Creates a dummy file
        private void WriteFile(string filePath)
        {
            Model.Location tempLocation = new Location {Description = "Shop", Name = "Shop"};
            Model.Location warehouseLocation = new Location{Description = "Storage Room", Name = "Storage"};
            Vendor gracoVendor = new Vendor
                                     {
                                         Addresses = new List<Address>
                                         {
                                             new Address{City = "Temple", State = "TX", Street = "4001 North Point Blvd", Zip = "76502"}
                                         },
                                         Id = "Graco",
                                         Name = "Graco",
                                         PhoneNumber = "254 555-1234",
                                         PointOfContact = "Jimmy Walker"

                                     };

            ProductGraph productGraph = new ProductGraph();

            productGraph.Inventory = new Inventory();
            productGraph.Catalog = new Catalog();

            productGraph.Inventory.Locations.Add(tempLocation);
            productGraph.Inventory.Locations.Add(warehouseLocation);

            productGraph.Inventory.InventoryItems.Add(
                new InventoryItem{Id = "0000001", Location = tempLocation, ReOrderPoint = 10, ReOrderQuantity = 10, QtyOnHand = 21}
                );

            productGraph.Inventory.InventoryItems.Add(
            new InventoryItem { Id = "0000002", Location = warehouseLocation, ReOrderPoint = 10, ReOrderQuantity = 10, QtyOnHand = 21 }
            );
            productGraph.Catalog.CatalogItems.Add( new CatalogItem()
                                                      {
                                                  Description        = "Mat 32x40, Chinese Red, White Core", Supplier = gracoVendor, UnitCost = 10m, VendorAssignedProductId = "132343"
                                                      });
            productGraph.Catalog.CatalogItems.Add(new CatalogItem
            {
                Description = "Mat 32x40, Sky Blue, White Core",
                Supplier = gracoVendor,
                UnitCost = 10m,
                VendorAssignedProductId = "132343"
            });

            productGraph.Catalog.BoxedItems.Add(new BoxedItem
            {
                Description = "Glass Clear, 16in x 20in",
                Supplier = gracoVendor,
                UnitCost = 10m,
                VendorAssignedProductId = "000000224324",
                BoxCost = 40,
                UnitsInBox = 8

            });

            productGraph.Catalog.BoxedItems.Add(new BoxedItem
            {
                Description = "Glass Clear, 32in x 40in",
                Supplier = gracoVendor,
                VendorAssignedProductId = "00000003",
                BoxCost = 80,
                UnitsInBox = 4

            });

            productGraph.Catalog.BoxedItems.Add(new BoxedItem
            {
                Description = "Framing Nails 1/8in",
                Supplier = gracoVendor,
                VendorAssignedProductId = "00000003",
                BoxCost = 25,
                UnitsInBox = 12
            });

            productGraph.Catalog.VolumeItems.Add(new VolumeItem
            {
                Description = "Gold Decor Molding 4in Wide",
                Supplier = gracoVendor,
                UnitCost = 10m,
                VendorAssignedProductId = "00000005",
                MininumVolume = 4,
                UnitOfMeasure = "Ft"
            });

            productGraph.Catalog.VolumeItems.Add(new VolumeItem
            {
                Description = "Gold Decor Molding 2in Wide",
                Supplier = gracoVendor,
                UnitCost = 5m,
                VendorAssignedProductId = "00000007",
                MininumVolume = 4,
                UnitOfMeasure = "Ft"
            });

            productGraph.Suppliers = new List<Vendor>{gracoVendor};

            List<string> xml = productGraph.ProduceXml("", true);

            using(StreamWriter writer = new StreamWriter(filePath))
            {
                foreach (string line in xml)
                {
                    writer.WriteLine(line);
                }
            }
        }