Пример #1
0
        public void SetModifyParts(Part tempPartPass)
        {
            Part tempPart = tempPartPass;

            Console.WriteLine(tempPart.GetType().ToString());

            if (tempPart.GetType().ToString() == "FirstSchoolCProj.Outsourced")
            {
                Outsourced tempPart2 = (Outsourced)tempPart;
                textBoxID.Text                = tempPart.PartID.ToString();
                textBoxInStock.Text           = tempPart.InStock.ToString();
                textBoxName.Text              = tempPart.Name.ToString();
                textBoxPrice.Text             = tempPart.Price.ToString();
                textBoxMax.Text               = tempPart.Max.ToString();
                textBoxMin.Text               = tempPart.Min.ToString();
                textBoxLast.Text              = tempPart2.CompanyName.ToString();
                radioButtonOutsourced.Checked = true;
            }
            if (tempPart.GetType().ToString() == "FirstSchoolCProj.Inhouse")
            {
                Inhouse tempPart2 = (Inhouse)tempPart;
                textBoxID.Text             = tempPart.PartID.ToString();
                textBoxInStock.Text        = tempPart.InStock.ToString();
                textBoxName.Text           = tempPart.Name.ToString();
                textBoxPrice.Text          = tempPart.Price.ToString();
                textBoxMax.Text            = tempPart.Max.ToString();
                textBoxMin.Text            = tempPart.Min.ToString();
                textBoxLast.Text           = tempPart2.MachineID.ToString();
                radioButtonInHouse.Checked = true;
            }
        }
Пример #2
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (radioButtonInHouse.Checked == true)
                {
                    Inhouse tempPart = new Inhouse();
                    int     tempId   = int.Parse(textBoxID.Text);
                    tempPart.PartID  = int.Parse(textBoxID.Text);
                    tempPart.Name    = textBoxName.Text;
                    tempPart.InStock = int.Parse(textBoxInStock.Text);
                    tempPart.Price   = int.Parse(textBoxPrice.Text);
                    tempPart.Max     = int.Parse(textBoxMax.Text);

                    int  n;
                    bool isInt = int.TryParse(textBoxMin.Text, out n);

                    if (isInt == true)
                    {
                        tempPart.Min = int.Parse(textBoxMin.Text);
                    }
                    else
                    {
                        throw new Exception("Please insert a number into min");
                    }

                    tempPart.MachineID = int.Parse(textBoxLast.Text);
                    mainObjects.myInventory.ReplaceParts(tempId, tempPart);
                    Close();
                }
                else if (radioButtonOutsourced.Checked == true)
                {
                    Outsourced tempPart = new Outsourced();
                    int        tempId   = int.Parse(textBoxID.Text);
                    tempPart.PartID  = int.Parse(textBoxID.Text);
                    tempPart.Name    = textBoxName.Text;
                    tempPart.InStock = int.Parse(textBoxInStock.Text);
                    tempPart.Price   = int.Parse(textBoxPrice.Text);
                    tempPart.Max     = int.Parse(textBoxMax.Text);
                    int  n;
                    bool isInt = int.TryParse(textBoxMin.Text, out n);

                    if (isInt == true)
                    {
                        tempPart.Min = int.Parse(textBoxMin.Text);
                    }
                    else
                    {
                        throw new Exception("Please insert a number into min");
                    }
                    tempPart.CompanyName = textBoxLast.Text;
                    mainObjects.myInventory.ReplaceParts(tempId, tempPart);
                    Close();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #3
0
        public static void InitializeInventory()
        {
            Inhouse first = new Inhouse
            {
                PartID    = 1254,
                Name      = "Wrench",
                Max       = 100,
                Min       = 10,
                Price     = 100,
                InStock   = 50,
                MachineID = 022214
            };

            Outsourced second = new Outsourced
            {
                PartID      = 2222,
                Name        = "bolt",
                Max         = 100,
                Min         = 10,
                Price       = 100,
                InStock     = 40,
                CompanyName = "Umbrella"
            };


            Product third = new Product();

            third.ProductID = 333;
            third.Name      = "Motor";
            third.Max       = 100;
            third.Min       = 10;
            third.Price     = 1000;
            third.ProductID = 33546;
            third.AddAssociatedPart(first);

            myInventory.AddPart(first);
            myInventory.AddPart(second);
            myInventory.AddProduct(third);
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (outSourcedRadioB.Checked == true)
                {
                    Outsourced tempObj = new Outsourced();
                    int        n;
                    bool       isInt = int.TryParse(textBoxMin.Text, out n);

                    if (isInt == true)
                    {
                        tempObj.Min = int.Parse(textBoxMin.Text);
                    }
                    else
                    {
                        throw new Exception("Please insert a number into min");
                    }
                    tempObj.PartID      = int.Parse(textBoxID.Text);
                    tempObj.Name        = textBoxName.Text;
                    tempObj.InStock     = int.Parse(textBoxInventoryLevel.Text);
                    tempObj.Price       = int.Parse(textBoxPrice.Text);
                    tempObj.Max         = int.Parse(textBoxMax.Text);
                    tempObj.CompanyName = textBoxMachineIdCompany.Text;



                    mainObjects.myInventory.AddPart(tempObj);



                    Close();
                }
                else if (inHouseRadioB.Checked == true)
                {
                    Inhouse tempObj = new Inhouse();
                    tempObj.PartID  = int.Parse(textBoxID.Text);
                    tempObj.Name    = textBoxName.Text;
                    tempObj.InStock = int.Parse(textBoxInventoryLevel.Text);
                    tempObj.Price   = int.Parse(textBoxPrice.Text);
                    tempObj.Max     = int.Parse(textBoxMax.Text);
                    int  n;
                    bool isInt = int.TryParse(textBoxMin.Text, out n);

                    if (isInt == true)
                    {
                        tempObj.Min = int.Parse(textBoxMin.Text);
                    }
                    else
                    {
                        throw new Exception("Please insert a number into min");
                    }

                    tempObj.MachineID = int.Parse(textBoxMachineIdCompany.Text);



                    mainObjects.myInventory.AddPart(tempObj);

                    // Form1.dataGridViewPartsMain.Refresh;

                    Close();
                }
                ;
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }