Ejemplo n.º 1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            int Min     = (int.Parse(MinTextbox.Text));
            int Max     = (int.Parse(MaxTextbox.Text));
            int InStock = (int.Parse(InventoryTextbox.Text));

            if (Min > Max)
            {
                MessageBox.Show("Minimum cannot be larger than Maximum.", "Minimum Larger Than Maximum");
            }
            else if (InStock > Max || InStock < Min)
            {
                MessageBox.Show("Inventory number must be a value between Minimum and Maximum.", "Invalid Inventory Number");
            }
            else if (IO_Label.Text == "Company Name")
            {
                int        PartID  = (int.Parse(ID_Textbox.Text));
                string     Name    = NameTextbox.Text;
                decimal    Price   = (decimal.Parse(PriceCostTextbox.Text));
                string     IO      = IO_Textbox.Text;
                Outsourced newPart = new Outsourced(PartID, Name, Price, InStock, Min, Max, IO);
                Inventory.deletePart(mainScreen.currentSelectedPart.PartID);
                Inventory.addPart(newPart);
                mainScreen.Show();
                this.Close();
            }
            else
            {
                int     PartID  = (int.Parse(ID_Textbox.Text));
                string  Name    = NameTextbox.Text;
                decimal Price   = (decimal.Parse(PriceCostTextbox.Text));
                int     IO      = (int.Parse(IO_Textbox.Text));
                Inhouse newPart = new Inhouse(PartID, Name, Price, InStock, Min, Max, IO);
                Inventory.deletePart(mainScreen.currentSelectedPart.PartID);
                Inventory.addPart(newPart);
                mainScreen.Show();
                this.Close();
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            Inhouse    wheel = new Inhouse(1, "Wheel", 19.99m, 8, 2, 50, 3);
            Outsourced pedal = new Outsourced(2, "Pedal", 9.99m, 2, 1, 25, "ABC, LLC");
            Inhouse    chain = new Inhouse(3, "Chain", 24.99m, 7, 3, 30, 42);
            Outsourced seat  = new Outsourced(4, "Seat", 49.99m, 16, 4, 100, "Radical Labs, INC");

            Inventory.AllParts.Add(wheel);
            Inventory.AllParts.Add(pedal);
            Inventory.AllParts.Add(chain);
            Inventory.AllParts.Add(seat);

            Product redBike    = new Product(1, "Red Bicycle", 11.45m, 10, 1, 50);
            Product yellowBike = new Product(2, "Yellow Bicycle", 12.45m, 11, 1, 25);
            Product blueBike   = new Product(3, "Blue Bicycle", 14.45m, 7, 1, 20);
            Product greenBike  = new Product(4, "Green Bicycle", 17.45m, 4, 1, 7);

            Inventory.Products.Add(redBike);
            Inventory.Products.Add(yellowBike);
            Inventory.Products.Add(blueBike);
            Inventory.Products.Add(greenBike);

            redBike.AssociatedParts.Add(wheel);
            redBike.AssociatedParts.Add(pedal);
            redBike.AssociatedParts.Add(chain);

            blueBike.AssociatedParts.Add(wheel);
            blueBike.AssociatedParts.Add(seat);

            yellowBike.AssociatedParts.Add(wheel);
            yellowBike.AssociatedParts.Add(chain);
            yellowBike.AssociatedParts.Add(seat);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainScreen());
        }
Ejemplo n.º 3
0
        // Constructors ------------------------------------------------------------------------------------------------------------------------
        public ModifyPartScreen(MainScreen mainScreen)
        {
            this.mainScreen = mainScreen;
            InitializeComponent();
            ID_Textbox.Text       = mainScreen.currentSelectedPart.PartID.ToString();
            NameTextbox.Text      = mainScreen.currentSelectedPart.Name;
            PriceCostTextbox.Text = mainScreen.currentSelectedPart.Price.ToString();
            InventoryTextbox.Text = mainScreen.currentSelectedPart.InStock.ToString();
            MinTextbox.Text       = mainScreen.currentSelectedPart.Min.ToString();
            MaxTextbox.Text       = mainScreen.currentSelectedPart.Max.ToString();

            if (mainScreen.currentSelectedPart is Inhouse)
            {
                Inhouse part = (Inhouse)mainScreen.currentSelectedPart;
                InHouseRadioButton.Checked = true;
                IO_Textbox.Text            = part.MachineID.ToString();
            }
            else
            {
                Outsourced part = (Outsourced)mainScreen.currentSelectedPart;
                OutsourcedRadioButton.Checked = true;
                IO_Textbox.Text = part.CompanyName;
            }
        }