Beispiel #1
0
 private void modifyPartButton_Click(object sender, EventArgs e)
 {
     if (partsDataGridView.CurrentRow.DataBoundItem.GetType() == typeof(Inhouse))
     {
         Inhouse inhouse = (Inhouse)partsDataGridView.CurrentRow.DataBoundItem;
         new Modify_Part(inhouse).ShowDialog();
     }
     else
     {
         Outsourced outsourced = (Outsourced)partsDataGridView.CurrentRow.DataBoundItem;
         new Modify_Part(outsourced).ShowDialog();
     }
     partsDataGridView.Update();
     partsDataGridView.Refresh();
 }
Beispiel #2
0
 public Modify_Part(Outsourced outsourced)
 {
     InitializeComponent();
     outsourcedModifyPartRadio.Checked = true;
     inHouseModifyPartRadio.Checked    = false;
     modifyPartIDText.Enabled          = false;
     modifyPartIDText.Text             = outsourced.PartID.ToString();
     modifyPartNameText.Text           = outsourced.Name;
     modifyPartInventoryText.Text      = outsourced.InStock.ToString();
     modifyPartPriceText.Text          = outsourced.Price.ToString();
     modifyPartMaxText.Text            = outsourced.Max.ToString();
     modifyPartMinText.Text            = outsourced.Min.ToString();
     modifyPartCompanyNameLabel.Text   = "Company Name";
     modifyPartCompanyNameText.Text    = outsourced.CompanyName.ToString();
 }
Beispiel #3
0
        private void createDummyData()
        {
            Part part1 = new Inhouse(123908, "Sprocket", 3.50m, 34, 2, 45, 9870);
            Part part2 = new Outsourced(234892, "Spring", 0.50m, 245, 2, 450, "Zhung Chow");
            Part part3 = new Outsourced(769523, "Chain", 1.55m, 105, 2, 500, "Zhung Chow");

            Inventory.AllParts.Add(part1);
            Inventory.AllParts.Add(part2);
            Inventory.AllParts.Add(part3);
            Product product1 = new Product(1129000, "Assembly", 23.50m, 30, 1, 45);

            product1.addAssociatedPart(part1);
            product1.addAssociatedPart(part2);
            Inventory.Products.Add(product1);

            Product product2 = new Product(1136001, "Lower Assembly", 13.75m, 25, 1, 50);

            product1.addAssociatedPart(part1);
            product1.addAssociatedPart(part3);
            Inventory.Products.Add(product2);
        }
Beispiel #4
0
        private void addPartSaveButton_Click(object sender, EventArgs e)
        {
            string  name = addPartNameText.Text;
            int     min;
            int     max;
            int     inStock;
            decimal price;
            int     machineID   = 0;
            string  companyName = "";

            // II J. Exception handling requirements:
            // "Detect non-numeric values in textboxes that expect numeric values
            try
            {
                min     = int.Parse(addPartMinText.Text);
                max     = int.Parse(addPartMaxText.Text);
                inStock = int.Parse(addPartInventoryText.Text);
                price   = decimal.Parse(addPartPriceText.Text);
                if (inHouseAddPartRadio.Checked)
                {
                    machineID = int.Parse(addPartCompanyNameText.Text);
                }
                if (outsourcedAddPartRadio.Checked)
                {
                    companyName = addPartCompanyNameText.Text;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Please check your input to make sure that all are valid numbers\\dollar amounts\n{ex.ToString()}");
                return;
            }

            // "Min should be less than Max; and Inv should be between those values"
            if (min > max)
            {
                MessageBox.Show("Max must be greater than Min");
                return;
            }
            if (inStock > max || inStock < min)
            {
                if (inStock > max)
                {
                    MessageBox.Show("Inventory cannot be greater than Max");
                    return;
                }
                else
                {
                    MessageBox.Show("Inventory cannot be less than Min");
                    return;
                }
            }


            if (inHouseAddPartRadio.Checked)
            {
                Inhouse part = new Inhouse(generateUniqueNumber(), name, price, inStock, min, max, machineID);
                Inventory.addPart(part);
                MessageBox.Show($"{name} added correctly.");
                Close();
            }

            if (outsourcedAddPartRadio.Checked)
            {
                Outsourced part = new Outsourced(generateUniqueNumber(), name, price, inStock, min, max, companyName);
                Inventory.addPart(part);
                MessageBox.Show($"{name} added correctly.");
                Close();
            }
        }