Exemple #1
0
        public override void SaveItem()
        {
            try
            {
                ArrayList associatedPartsToSave = new ArrayList();
                foreach (Part part in associatedPartsBindingList)
                {
                    associatedPartsToSave.Add(part);
                }

                if (isNew)
                {
                    Inventory.AddProduct(new Product(
                                             NameInput.Text,
                                             Convert.ToDouble(PriceInput.Text),
                                             Convert.ToInt32(CountInput.Text),
                                             Convert.ToInt32(MinCountInput.Text),
                                             Convert.ToInt32(MaxCountInput.Text),
                                             associatedPartsToSave
                                             ));
                }
                else
                {
                    Product updatedProduct;
                    updatedProduct = new Product(
                        Convert.ToInt32(IDInput.Text),
                        NameInput.Text,
                        Convert.ToDouble(PriceInput.Text),
                        Convert.ToInt32(CountInput.Text),
                        Convert.ToInt32(MinCountInput.Text),
                        Convert.ToInt32(MaxCountInput.Text),
                        associatedPartsToSave
                        );
                    Inventory.UpdateProduct(Convert.ToInt32(IDInput.Text), updatedProduct);
                }
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"A problem occurred during save: {ex.Message}");
                return;
            }
        }
Exemple #2
0
        private void CreateDummyData()
        {
            // Dummy Data
            Inventory.AddPart(new Inhouse("Small Wheel", 5.00, 50, 0, 100, 1));
            Inventory.AddPart(new Inhouse("Small Frame", 23.45, 40, 0, 300, 2));
            Inventory.AddPart(new Outsourced("Handle Bars", 12.10, 75, 0, 200, "Acme Co."));
            Inventory.AddPart(new Inhouse("Large Wheel", 10.00, 2, 0, 100, 1));
            Inventory.AddPart(new Inhouse("Large Frame", 27.85, 40, 3, 300, 2));
            Inventory.AddProduct(new Product("Kids Bike", 100.00, 37, 0, 100, new ArrayList()));
            Inventory.AddProduct(new Product("Adult Bike", 135.00, 67, 0, 100, new ArrayList()));
            Inventory.AddProduct(new Product("Repair Kit", 15, 15, 1, 25, new ArrayList()));
            Product p1 = Inventory.LookupProduct(0);
            Product p2 = Inventory.LookupProduct(1);

            p1.AddAssociatedPart(Inventory.LookupPart(0));
            p1.AddAssociatedPart(Inventory.LookupPart(0));
            p1.AddAssociatedPart(Inventory.LookupPart(1));
            p1.AddAssociatedPart(Inventory.LookupPart(2));
            p2.AddAssociatedPart(Inventory.LookupPart(3));
            p2.AddAssociatedPart(Inventory.LookupPart(3));
            p2.AddAssociatedPart(Inventory.LookupPart(4));
            p2.AddAssociatedPart(Inventory.LookupPart(2));
        }