Ejemplo n.º 1
0
        // Save Button click Event.
        private void SaveButton_Click(object sender, EventArgs e)
        {
            // if Min and Max is validated and Inventory is validated Clear error provider and allow save.
            if ((MinMaxValidation() == true) && (InventoryValidation() == true))
            {
                errorProvider1.Clear();
                if (isInHouse)
                {
                    // Save inhouse part.
                    Part part = new InHousePart(Convert.ToInt32(partIDTextBox.Text), partNametextBox.Text.ToString(), Convert.ToInt32(inventoryTextBox.Text), Convert.ToDouble(priceCostTextBox.Text), Convert.ToInt32(maxTextBox.Text),
                                                Convert.ToInt32(minTextBox.Text), Convert.ToInt32(compMachTextBox.Text));

                    // If isNewPart true - Add part.
                    if (isNewPart)
                    {
                        Inventory.AddPart(part);
                        MessageBox.Show("In-House Part Added!");
                    }
                    // If isNewPart is false - Swap part.
                    else
                    {
                        Inventory.SwapPart(part);
                        MessageBox.Show("Part Updated!");
                    }
                }
                // Else Save Outsourced part.
                else
                {
                    Part part = new OutSourcedPart(Convert.ToInt32(partIDTextBox.Text), partNametextBox.Text.ToString(), Convert.ToInt32(inventoryTextBox.Text), Convert.ToDouble(priceCostTextBox.Text), Convert.ToInt32(maxTextBox.Text),
                                                   Convert.ToInt32(minTextBox.Text), compMachTextBox.Text.ToString());

                    // If isNewPart true - Add part.
                    if (isNewPart)
                    {
                        Inventory.InsertPart(part);
                        MessageBox.Show("Out-Sourced Part Added!");
                    }
                    // If isNewPart is false - Swap part.
                    else
                    {
                        Inventory.SwapPart(part);
                        MessageBox.Show("Part Updated!");
                    }
                }
                this.Hide();
                IMS updatedMain = new IMS();
                updatedMain.Show();
            }
        }
Ejemplo n.º 2
0
        public PartScreen()
        {
            InitializeComponent();

            // If the current part is an Inhouse part
            // set compMachTextBox to Inhouse parts Machine ID
            // and check the inhouseRadioButton
            if (Inventory.CurrentPart is InHousePart)
            {
                InHousePart iPart = (InHousePart)Inventory.CurrentPart;
                compMachTextBox.Text       = iPart.MachineID.ToString();
                isInHouse                  = true;
                inHouseRadioButton.Checked = true;
            }
            // If the current part is an Outsourced part
            // and check the outsourcedRadioButton
            else
            {
                OutSourcedPart oPart = (OutSourcedPart)Inventory.CurrentPart;
                compMachTextBox.Text          = oPart.CompanyName;
                isInHouse                     = false;
                outsourcedRadioButton.Checked = true;
            }
        }