示例#1
0
        //Saves all entered fields as a new inhouse/outsourced part object, dependent on inhouse/outsourced radio option
        private void PartSaveButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(nameTextBox.Text) || String.IsNullOrEmpty(priceTextBox.Text) || String.IsNullOrEmpty(inventoryTextBox.Text) || String.IsNullOrEmpty(minTextBox.Text) ||
                String.IsNullOrEmpty(maxTextBox.Text) || String.IsNullOrEmpty(companyMachineTextBox.Text))
            {
                MessageBox.Show("All fields must have a value. Please update and try saving again.");
                return;
            }

            if (AddPartMinBoxText > AddPartMaxBoxText)
            {
                MessageBox.Show("Your minimum value cannot be higher than your maximum value. Please enter a different value.");
                return;
            }

            if (Convert.ToInt32(inventoryTextBox.Text) < Convert.ToInt32(minTextBox.Text) || Convert.ToInt32(inventoryTextBox.Text) > Convert.ToInt32(maxTextBox.Text))
            {
                MessageBox.Show("Inventory value must not be less than minimum or greater than maximum. Please update and try saving again.");
                return;
            }

            else if (InHouseRadio.Checked)
            {
                Inhouse inHousePart = new Inhouse(Inventory.allParts.Count + 1, AddPartNameBoxText, AddPartPriceBoxText, AddPartInvBoxText, AddPartMinBoxText, AddPartMaxBoxText, int.Parse(AddPartMachComBoxText));
                Inventory.allParts.Add(inHousePart);
                this.Close();
            }

            else
            {
                Outsourced outsourcedPart = new Outsourced(Inventory.allParts.Count + 1, AddPartNameBoxText, AddPartPriceBoxText, AddPartInvBoxText, AddPartMinBoxText, AddPartMaxBoxText, AddPartMachComBoxText);
                Inventory.allParts.Add(outsourcedPart);
                this.Close();
            }
        }
示例#2
0
 private void PartModify_Click(object sender, EventArgs e)
 {
     if (partDataGridView.CurrentRow.DataBoundItem.GetType() == typeof(Inhouse))
     {
         Inhouse inPart = (Inhouse)partDataGridView.CurrentRow.DataBoundItem;
         new ModPartForm(inPart).ShowDialog();
     }
     else
     {
         Outsourced outPart = (Outsourced)partDataGridView.CurrentRow.DataBoundItem;
         new ModPartForm(outPart).ShowDialog();
     }
 }
示例#3
0
        public ModPartForm(Outsourced outPart)
        {
            InitializeComponent();

            ModPartIDBoxText      = outPart.PartID;
            ModPartNameBoxText    = outPart.Name;
            ModPartInvBoxText     = outPart.InStock;
            ModPartPriceBoxText   = outPart.Price;
            ModPartMinBoxText     = outPart.Min;
            ModPartMaxBoxText     = outPart.Max;
            ModPartMachComBoxText = outPart.CompanyName;

            OutsourcedRadio.Checked = true;
        }
示例#4
0
        private void PartSaveButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(nameTextBox.Text) || String.IsNullOrEmpty(priceTextBox.Text) || String.IsNullOrEmpty(inventoryTextBox.Text) || String.IsNullOrEmpty(minTextBox.Text) ||
                String.IsNullOrEmpty(maxTextBox.Text) || String.IsNullOrEmpty(machineIDTextBox.Text))
            {
                MessageBox.Show("All fields must have a value. Please update and try saving again.");
                return;
            }

            if (ModPartMaxBoxText < ModPartMinBoxText)
            {
                MessageBox.Show("This part's minimum value is currently higher than the maximum value. Please update and retry.");
            }

            if (Convert.ToInt32(inventoryTextBox.Text) < Convert.ToInt32(minTextBox.Text) || Convert.ToInt32(inventoryTextBox.Text) > Convert.ToInt32(maxTextBox.Text))
            {
                MessageBox.Show("Inventory value must not be less than minimum or greater than maximum. Please update and try saving again.");
                return;
            }

            if (InHouseRadio.Checked == true)
            {
                Inhouse inHouse = new Inhouse(ModPartIDBoxText, ModPartNameBoxText, ModPartPriceBoxText, ModPartInvBoxText, ModPartMinBoxText, ModPartMaxBoxText, int.Parse(ModPartMachComBoxText));
                Inventory.DeletePart(inHouse);
                Inventory.AddPart(inHouse);
                //Inventory.UpdateInhousePart(ModPartIDBoxText, inHouse);
                this.Close();
            }

            //else if (OutsourcedRadio.Checked == true)
            //{
            //    Outsourced outSourced = new Outsourced(ModPartIDBoxText, ModPartNameBoxText, ModPartPriceBoxText, ModPartInvBoxText, ModPartMinBoxText, ModPartMaxBoxText, ModPartMachComBoxText);
            //    Inventory.UpdateOutsourcedPart(ModPartIDBoxText, outSourced);
            //    this.Close();
            //}
            else if (OutsourcedRadio.Checked == true)
            {
                Outsourced outSourced = new Outsourced(ModPartIDBoxText, ModPartNameBoxText, ModPartPriceBoxText, ModPartInvBoxText, ModPartMinBoxText, ModPartMaxBoxText, ModPartMachComBoxText);
                Inventory.DeletePart(outSourced);
                Inventory.AddPart(outSourced);
                this.Close();
            }



            MainForm.RefreshParts();
        }
示例#5
0
 public static void DeletePart(Part part)
 {
     for (int i = 0; i < allParts.Count; ++i)
     {
         if (allParts[i].PartID == part.PartID)
         {
             if (allParts[i].GetType() == typeof(Outsourced))
             {
                 Outsourced existingOutPart = (Outsourced)allParts[i];
                 allParts.Remove(existingOutPart);
             }
             else
             {
                 Inhouse existingInPart = (Inhouse)allParts[i];
                 allParts.Remove(existingInPart);
             }
         }
     }
 }
示例#6
0
        public static void PopulateSampleLists()
        {
            Product product1 = new Product(1, "Bicycle", 125.00m, 7, 5, 15);
            Product product2 = new Product(2, "Tricycle", 200.00m, 3, 2, 5);
            Product product3 = new Product(3, "Unicycle", 250.00m, 2, 1, 3);
            Product product4 = new Product(4, "Tandem Bicycle", 399.99m, 3, 3, 5);

            Part part1 = new Inhouse(1, "Tire", 30.50m, 33, 50, 100, 9001);
            Part part2 = new Inhouse(2, "Handlebars", 22.99m, 46, 25, 50, 9001);
            Part part3 = new Inhouse(3, "Seat", 33.00m, 50, 50, 100, 9002);
            Part part4 = new Inhouse(4, "Reflector", 2.50m, 756, 500, 2000, 9002);
            Part part5 = new Outsourced(5, "Chain", 3.00m, 17, 15, 30, "Bikes 'R' Us");
            Part part6 = new Outsourced(6, "Crank", 10.00m, 29, 20, 35, "Bikes 'R' Us");
            Part part7 = new Outsourced(7, "Pedal", 5.55m, 20, 15, 100, "Bikeville USA");
            Part part8 = new Outsourced(8, "Brake", 45.00m, 40, 35, 90, "Bikeville USA");

            products.Add(product1);
            products.Add(product2);
            products.Add(product3);
            products.Add(product4);

            allParts.Add(part1);
            allParts.Add(part2);
            allParts.Add(part3);
            allParts.Add(part4);
            allParts.Add(part5);
            allParts.Add(part6);
            allParts.Add(part7);
            allParts.Add(part8);

            product1.associatedParts.Add(part1);
            product1.associatedParts.Add(part2);
            product2.associatedParts.Add(part3);
            product2.associatedParts.Add(part4);
            product3.associatedParts.Add(part5);
            product3.associatedParts.Add(part6);
            product4.associatedParts.Add(part7);
            product4.associatedParts.Add(part8);
        }