Esempio n. 1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (NameTextBox.Text == "" || PriceCostTextBox.Text == "" || InventoryTextBox.Text == "" || MaxTextBox.Text == "" || MinTextBox.Text == "" || SourceTextBox.Text == "")
                {
                    MessageBox.Show("Please enter values for all fields", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Convert.ToInt32(MinTextBox.Text) > Convert.ToInt32(MaxTextBox.Text))
                {
                    MessageBox.Show("Your Min cannot exceed your Max", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Convert.ToInt32(InventoryTextBox.Text) > Convert.ToInt32(MaxTextBox.Text))
                {
                    MessageBox.Show("Your Inv cannot exceed your Max", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (InHouseRadioButton.Checked)
                    {
                        InHouse newPart = new InHouse
                                              (NameTextBox.Text,
                                              Convert.ToDouble(PriceCostTextBox.Text),
                                              Convert.ToInt32(InventoryTextBox.Text),
                                              Convert.ToInt32(MinTextBox.Text),
                                              Convert.ToInt32(MaxTextBox.Text),
                                              Convert.ToInt32(SourceTextBox.Text));

                        Inventory.AddPart(newPart); //method to add to the part list
                    }
                    else
                    {
                        Outsourced newPart = new Outsourced
                                                 (NameTextBox.Text,
                                                 Convert.ToDouble(PriceCostTextBox.Text),
                                                 Convert.ToInt32(InventoryTextBox.Text),
                                                 Convert.ToInt32(MinTextBox.Text),
                                                 Convert.ToInt32(MaxTextBox.Text),
                                                 SourceTextBox.Text);

                        Inventory.AddPart(newPart);
                    }
                    BackToMainScreen();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
 private void FillOut(Outsourced P)
 {
     SourceTextBox.Text = P.CompanyName;
 }
Esempio n. 3
0
 private void FillO(Outsourced P)
 {
     P.CompanyName = SourceTextBox.Text;
 }
Esempio n. 4
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (NameTextBox.Text == "" || PriceCostTextBox.Text == "" || InventoryTextBox.Text == "" || MaxTextBox.Text == "" || MinTextBox.Text == "" || SourceTextBox.Text == "")
                {
                    MessageBox.Show("Please enter values for all fields", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Convert.ToInt32(MinTextBox.Text) > Convert.ToInt32(MaxTextBox.Text))
                {
                    MessageBox.Show("Your Min cannot exceed your Max", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Convert.ToInt32(InventoryTextBox.Text) > Convert.ToInt32(MaxTextBox.Text))
                {
                    MessageBox.Show("Your Inv cannot exceed your Max", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    //5 takes the modified part and saves it to the same index
                    Inventory.CurrentPart.PartID  = Convert.ToInt32(IDTextBox.Text);
                    Inventory.CurrentPart.Name    = NameTextBox.Text;
                    Inventory.CurrentPart.InStock = Convert.ToInt32(InventoryTextBox.Text);
                    Inventory.CurrentPart.Price   = Convert.ToDouble(PriceCostTextBox.Text);
                    Inventory.CurrentPart.Max     = Convert.ToInt32(MaxTextBox.Text);
                    Inventory.CurrentPart.Min     = Convert.ToInt32(MinTextBox.Text);

                    if (Inventory.CurrentPart.GetType() == typeof(Outsourced))
                    {
                        if (!IsOutsourced)
                        {
                            var tempPart = new InHouse(Inventory.CurrentPart.PartID, Inventory.CurrentPart.Name, Inventory.CurrentPart.Price, Inventory.CurrentPart.InStock, Inventory.CurrentPart.Min, Inventory.CurrentPart.Max, 0); //make a method for the mID to input into the constructor
                            FillI(tempPart);
                            Inventory.UpdatePart(Inventory.CurrentPartIndex, tempPart);
                        }
                        else
                        {
                            FillO((Outsourced)Inventory.CurrentPart);
                            Inventory.UpdatePart(Inventory.CurrentPartIndex, Inventory.CurrentPart);
                        }
                    }
                    else
                    {
                        if (IsOutsourced)
                        {
                            var tempPart = new Outsourced(Inventory.CurrentPart.PartID, Inventory.CurrentPart.Name, Inventory.CurrentPart.Price, Inventory.CurrentPart.InStock, Inventory.CurrentPart.Min, Inventory.CurrentPart.Max, "dummy");
                            FillO(tempPart);
                            Inventory.UpdatePart(Inventory.CurrentPartIndex, tempPart);
                        }
                        else
                        {
                            FillI((InHouse)Inventory.CurrentPart);
                            Inventory.UpdatePart(Inventory.CurrentPartIndex, Inventory.CurrentPart);
                        }
                    }
                    BackToMainScreen();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }