//save button.
        private void saveButton_Click(object sender, EventArgs e)
        {
            bool entryReady = true;
            bool saveSucess = false;
            int  parsedResult;
            int  j = 0;

            //if chain testing each textbox for content to see if its EntryReady
            //clear boxes when values are corrected
            if (textBox1.Text != "")
            {
                if (!(int.TryParse(textBox1.Text, out parsedResult)))
                {
                    label1.Text = "PartID must be a number";
                    label1.Show();
                    textBox1.BackColor = Color.DarkRed;
                    entryReady         = false;
                }
            }
            else
            {
                label1.Text = "Do not leave blank";
                label1.Show();
                textBox1.BackColor = Color.DarkRed;
                entryReady         = false;
            }
            if (textBox2.Text == "")
            {
                label2.Text = "Do not leave blank";
                label2.Show();
                textBox2.BackColor = Color.DarkRed;
                entryReady         = false;
            }
            if (textBox3.Text != "")
            {
                if (!(int.TryParse(textBox3.Text, out parsedResult)))
                {
                    label3.Text = "Inventory must be a number";
                    label3.Show();
                    textBox3.BackColor = Color.DarkRed;
                    entryReady         = false;
                }
            }
            else
            {
                label3.Text = "Do not leave blank";
                label3.Show();
                textBox3.BackColor = Color.DarkRed;
                entryReady         = false;
            }
            if (textBox4.Text != "")
            {
                decimal parsedDecResult;
                if (!(decimal.TryParse(textBox3.Text, out parsedDecResult)))
                {
                    label4.Text = "Price/Cost must be a number";
                    label4.Show();
                    textBox4.BackColor = Color.DarkRed;
                    entryReady         = false;
                }
            }
            else
            {
                label4.Text = "Do not leave blank";
                label4.Show();
                textBox4.BackColor = Color.DarkRed;
                entryReady         = false;
            }
            if (textBox5.Text != "")
            {
                if (!(int.TryParse(textBox5.Text, out parsedResult)))
                {
                    label5.Text = "Max must be a number";
                    label5.Show();
                    textBox5.BackColor = Color.DarkRed;
                    entryReady         = false;
                }
                else
                {
                    if (textBox7.Text != "")
                    {
                        if (int.TryParse(textBox7.Text, out parsedResult))
                        {
                            if (int.Parse(textBox5.Text) < int.Parse(textBox7.Text))
                            {
                                label5.Text = "Max must be greater than Min";
                                label5.Show();
                                textBox5.BackColor = Color.DarkRed;
                                textBox7.BackColor = Color.DarkRed;
                                entryReady         = false;
                            }
                            if (textBox3.Text != "" && textBox7.Text != "")
                            {
                                if (int.TryParse(textBox3.Text, out parsedResult) && int.TryParse(textBox7.Text, out parsedResult))
                                {
                                    if (int.Parse(textBox3.Text) < int.Parse(textBox7.Text))
                                    {
                                        label3.Text = "Inventory must be more than Min";
                                        label3.Show();
                                        textBox3.BackColor = Color.DarkRed;
                                        textBox7.BackColor = Color.DarkRed;
                                        entryReady         = false;
                                    }
                                }
                            }
                        }
                    }
                    if (textBox3.Text != "")
                    {
                        if (int.TryParse(textBox3.Text, out parsedResult))
                        {
                            if (int.Parse(textBox5.Text) < int.Parse(textBox3.Text))
                            {
                                label3.Text = "Inventory must be less than Max";
                                label3.Show();
                                textBox3.BackColor = Color.DarkRed;
                                textBox5.BackColor = Color.DarkRed;
                                entryReady         = false;
                            }
                        }
                    }
                }
            }
            else
            {
                label5.Text = "Do not leave blank";
                label5.Show();
                textBox5.BackColor = Color.DarkRed;
                entryReady         = false;
            }
            if (textBox6.Text != "")
            {
                if (!(int.TryParse(textBox6.Text, out parsedResult)) && ourInhouse == 0)
                {
                    label6.Text = "MachineID must be a number";
                    label6.Show();
                    textBox6.BackColor = Color.DarkRed;
                    entryReady         = false;
                }
            }
            else
            {
                label6.Text = "Do not leave blank";
                label6.Show();
                textBox6.BackColor = Color.DarkRed;
                entryReady         = false;
            }
            if (textBox7.Text != "")
            {
                if (!(int.TryParse(textBox7.Text, out parsedResult)))
                {
                    label7.Text = "Min must be a number";
                    label7.Show();
                    textBox7.BackColor = Color.DarkRed;
                    entryReady         = false;
                }
            }
            else
            {
                label7.Text = "Do not leave blank";
                label7.Show();
                textBox7.BackColor = Color.DarkRed;
                entryReady         = false;
            }

            //checking to see if a new part already has the same partID
            //deleting part if modifying and allowing to create in next statement
            if (entryReady == true)
            {
                for (int i = 0; i < Inventory.AllParts.Count; i++)
                {
                    j = 0;
                    if (Inventory.AllParts[i].PartID == int.Parse(textBox1.Text) && creatingNewPartID == true)
                    {
                        MessageBox.Show("Please choose another PartID. Cannot duplicate PartID.");
                        j++;
                    }
                    else if (Inventory.AllParts[i].PartID == int.Parse(textBox1.Text) && creatingNewPartID == false)
                    {
                        j = 0;
                        Inventory.deletePart(i);
                        break;
                    }
                    if (j > 0)
                    {
                        break;
                    }
                }
            }

            //creating new sub-part if new part has each Textbox filled (EntryReady)
            //and no partID conflicts for new part. Replaces part if from Modify.
            if (j == 0 && ourInhouse == 0 && entryReady == true)
            {
                var tempPart = new Inhouse(int.Parse(textBox6.Text),
                                           int.Parse(textBox1.Text), textBox2.Text,
                                           decimal.Parse(textBox4.Text), int.Parse(textBox3.Text),
                                           int.Parse(textBox7.Text), int.Parse(textBox5.Text));
                Inventory.addPart(tempPart);
                saveSucess = true;
            }
            else if (j == 0 && ourInhouse == 1 && entryReady == true)
            {
                var tempPart = new Outsourced(textBox6.Text,
                                              int.Parse(textBox1.Text), textBox2.Text,
                                              decimal.Parse(textBox4.Text), int.Parse(textBox3.Text),
                                              int.Parse(textBox5.Text), int.Parse(textBox7.Text));
                Inventory.addPart(tempPart);
                saveSucess = true;
            }
            else
            {
                MessageBox.Show("Record save unsuccessful.");
            }
            if (saveSucess)
            {
                MessageBox.Show("Record saved successfully.");
                this.Hide();
                MainScreen MScreen = new MainScreen();
                MScreen.Show();
            }
        }
        private void productSaveButton_Click(object sender, EventArgs e)
        {
            bool    entryReady = true;
            bool    saveSucess = false;
            int     parsedResult;
            decimal parsedDecResult;
            int     j = 0;

            //if chain testing each textbox for content to see if its EntryReady
            //clear boxes when values are corrected
            if (productIDTextBox.Text != "")
            {
                if (!(int.TryParse(productIDTextBox.Text, out parsedResult)))
                {
                    label1.Text = "ProductID must be a number";
                    label1.Show();
                    productIDTextBox.BackColor = Color.DarkRed;
                    entryReady = false;
                }
            }
            else
            {
                label1.Text = "Do not leave blank";
                label1.Show();
                productIDTextBox.BackColor = Color.DarkRed;
                entryReady = false;
            }
            if (productNameTextBox.Text == "")
            {
                label2.Text = "Do not leave blank";
                label2.Show();
                productNameTextBox.BackColor = Color.DarkRed;
                entryReady = false;
            }
            if (productInvTextBox.Text != "")
            {
                if (!(int.TryParse(productInvTextBox.Text, out parsedResult)))
                {
                    label3.Text = "Inventory must be a number";
                    label3.Show();
                    productInvTextBox.BackColor = Color.DarkRed;
                    entryReady = false;
                }
            }
            else
            {
                label3.Text = "Do not leave blank";
                label3.Show();
                productInvTextBox.BackColor = Color.DarkRed;
                entryReady = false;
            }
            if (productPriceTextBox.Text != "")
            {
                if (!(decimal.TryParse(productPriceTextBox.Text, out parsedDecResult)))
                {
                    label4.Text = "Price/Cost must be a number";
                    label4.Show();
                    productPriceTextBox.BackColor = Color.DarkRed;
                    entryReady = false;
                }
            }
            else
            {
                label4.Text = "Do not leave blank";
                label4.Show();
                productPriceTextBox.BackColor = Color.DarkRed;
                entryReady = false;
            }
            if (productMaxTextBox.Text != "")
            {
                if (!(int.TryParse(productMaxTextBox.Text, out parsedResult)))
                {
                    label5.Text = "Max must be a number";
                    label5.Show();
                    productMaxTextBox.BackColor = Color.DarkRed;
                    entryReady = false;
                }
                else
                {
                    if (productMinTextBox.Text != "")
                    {
                        if (int.TryParse(productMaxTextBox.Text, out parsedResult))
                        {
                            if (int.Parse(productMaxTextBox.Text) < int.Parse(productMinTextBox.Text))
                            {
                                label5.Text = "Max must be greater than Min";
                                label5.Show();
                                productMaxTextBox.BackColor = Color.DarkRed;
                                productMinTextBox.BackColor = Color.DarkRed;
                                entryReady = false;
                            }
                            if (productInvTextBox.Text != "" && productMinTextBox.Text != "")
                            {
                                if (int.Parse(productInvTextBox.Text) < int.Parse(productMinTextBox.Text))
                                {
                                    label3.Text = "Inventory must be more than Min";
                                    label3.Show();
                                    productInvTextBox.BackColor = Color.DarkRed;
                                    productMinTextBox.BackColor = Color.DarkRed;
                                    entryReady = false;
                                }
                            }
                        }
                    }
                    if (productInvTextBox.Text != "")
                    {
                        if (int.TryParse(productInvTextBox.Text, out parsedResult))
                        {
                            if (int.Parse(productMaxTextBox.Text) < int.Parse(productInvTextBox.Text))
                            {
                                label3.Text = "Inventory must be less than Max";
                                label3.Show();
                                productInvTextBox.BackColor = Color.DarkRed;
                                productMaxTextBox.BackColor = Color.DarkRed;
                                entryReady = false;
                            }
                        }
                    }
                }
            }
            else
            {
                label5.Text = "Do not leave blank";
                label5.Show();
                productMaxTextBox.BackColor = Color.DarkRed;
                entryReady = false;
            }
            if (productMinTextBox.Text != "")
            {
                if (!(int.TryParse(productMaxTextBox.Text, out parsedResult)))
                {
                    label6.Text = "Do not leave blank";
                    label6.Show();
                    productMinTextBox.BackColor = Color.DarkRed;
                    entryReady = false;
                }
            }
            else
            {
                label6.Text = "Do not leave blank";
                label6.Show();
                productMinTextBox.BackColor = Color.DarkRed;
                entryReady = false;
            }

            //checking to see if a new part already has the same partID
            //deleting part if modifying and allowing to create in next statement
            if (entryReady == true)
            {
                for (int i = 0; i < Inventory.Products.Count; i++)
                {
                    j = 0;
                    if (Inventory.Products[i].ProductID == int.Parse(productIDTextBox.Text) && creatingNewProdID == true)
                    {
                        MessageBox.Show("Please choose another Product ID. Cannot duplicate Product ID.");
                        j++;
                    }
                    else if (Inventory.Products[i].ProductID == int.Parse(productIDTextBox.Text) && creatingNewProdID == false)
                    {
                        j               = 0;
                        removeOldProd   = true;
                        removeOldProdID = i;
                        break;
                    }
                    if (j > 0)
                    {
                        break;
                    }
                }
            }

            //creating new sub-part if new part has each Textbox filled (EntryReady)
            //and no partID conflicts for new part. Replaces part if from Modify.
            if (j == 0 && entryReady == true)
            {
                Product tempProd = new Product(int.Parse(productIDTextBox.Text), productNameTextBox.Text,
                                               decimal.Parse(productPriceTextBox.Text), int.Parse(productInvTextBox.Text),
                                               int.Parse(productMinTextBox.Text), int.Parse(productMaxTextBox.Text));

                if (creatingNewProdID)
                {
                    for (int i = 0; i < Inventory.TempAssocParts.Count; i++)
                    {
                        tempProd.addAssociatedPart(Inventory.TempAssocParts[i]);
                    }
                }
                if (!(creatingNewProdID))
                {
                    for (int i = 0; i < Inventory.Products[removeOldProdID].AssociatedParts.Count; i++)
                    {
                        tempProd.addAssociatedPart(Inventory.Products[removeOldProdID].AssociatedParts[i]);
                    }
                }
                Inventory.addProduct(tempProd);
                saveSucess = true;
            }
            else
            {
                MessageBox.Show("Record save unsuccessful.");
            }
            if (saveSucess)
            {
                MessageBox.Show("Record saved successfully.");
                Inventory.TempAssocParts.Clear();
                if (removeOldProd)
                {
                    Inventory.RemoveProduct(removeOldProdID);
                }
                this.Hide();
                MainScreen MScreen = new MainScreen();
                MScreen.Show();
            }
        }