private void addPartSaveButton_Click(object sender, EventArgs e)
        {
            Part newPart;

            if (addPartOutsourcedRadioButton.Checked)
            {
                newPart = new Outsourced();
                (newPart as Outsourced).CompanyName = addPartIdentityTextBox.Text;
            }
            else
            {
                newPart = new InHouse();
                (newPart as InHouse).MachineID = int.Parse(addPartIdentityTextBox.Text);
            }
            newPart.PartID  = int.Parse(addPartIDTextBox.Text);
            newPart.Name    = addPartNameTextBox.Text;
            newPart.Price   = decimal.Parse(addPartPriceCostTextBox.Text);
            newPart.InStock = int.Parse(addPartInventoryTextBox.Text);
            newPart.Min     = int.Parse(addPartMinTextBox.Text);
            newPart.Max     = int.Parse(addPartMaxTextBox.Text);

            if (newPart.Max < newPart.Min)
            {
                MessageBox.Show("Max must be greater than or equal to Min");
            }
            else if (!(newPart.InStock >= newPart.Min) || !(newPart.InStock <= newPart.Max))
            {
                MessageBox.Show("Inventory must fall with Min and Max.");
            }
            else
            {
                EventManager.FireAddPart(newPart);
                Close();
            }
        }
예제 #2
0
        public ModifyPartScreen(InHouse inhouse)
        {
            InitializeComponent();

            modifyPartID.Text        = Convert.ToString(inhouse.PartID);
            modifyPartName.Text      = inhouse.Name;
            modifyPartInventory.Text = Convert.ToString(inhouse.InStock);
            modifyPartPrice.Text     = Convert.ToString(inhouse.Price);
            modifyPartMin.Text       = Convert.ToString(inhouse.Min);
            modifyPartMax.Text       = Convert.ToString(inhouse.Max);
            modifyPartMachineID.Text = Convert.ToString(inhouse.MachineID);
            label8.Text = "Machine ID";
            modifyPartInHouse.Checked = true;
        }
예제 #3
0
        private void addPartSave_Click(object sender, EventArgs e)
        {
            int     partID  = Int32.Parse(addPartID.Text);
            int     inStock = Int32.Parse(addPartInventory.Text);
            decimal price   = decimal.Parse(addPartPrice.Text);
            int     min     = Int32.Parse(addPartMin.Text);
            int     max     = Int32.Parse(addPartMax.Text);

            if (addPartInHouse.Checked)
            {
                int     machineID = Int32.Parse(addPartMachineID.Text);
                InHouse savePart  = new InHouse(partID, addPartName.Text, price, inStock, min, max, machineID);
                Inventory.addPart(savePart);
            }
            else
            {
                string     companyName = addPartMachineID.Text;
                Outsourced savePart    = new Outsourced(partID, addPartName.Text, price, inStock, min, max, companyName);
                Inventory.addPart(savePart);
            }
            Close();
        }
예제 #4
0
        private void modifyPart_Click(object sender, EventArgs e)
        {
            InHouse inhousePart = (InHouse)partsGrid.CurrentRow.DataBoundItem;

            new ModifyPartScreen(inhousePart).ShowDialog();
        }