Exemplo n.º 1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            int     ProductID = (int.Parse(ID_Textbox.Text));
            string  Name      = NameTextbox.Text;
            decimal Price     = (decimal.Parse(PriceTextbox.Text));
            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
            {
                Product newProduct = new Product(ProductID, Name, Price, InStock, Min, Max);
                Inventory.removeProduct(mainScreen.currentSelectedProduct.ProductID);
                Inventory.Products.Add(newProduct);
                foreach (Part part in partsToAssociate)
                {
                    newProduct.AssociatedParts.Add(part);
                }
                mainScreen.Show();
                this.Close();
            }
        }
Exemplo n.º 2
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();
            }
        }