//override selected part with new data
        private void SavePartButton_Click(object sender, EventArgs e)
        {
            int     minStock;
            int     maxStock;
            int     invInStock;
            decimal price;

            try
            {
                minStock   = int.Parse(modPartMinTextBox.Text);
                maxStock   = int.Parse(modPartMaxTextBox.Text);
                invInStock = int.Parse(modPartInventoryTextBox.Text);
                price      = decimal.Parse(modPartCostTextBox.Text);
            }
            catch
            {
                MessageBox.Show("Error: Inventory, Price, Max and Min must be numeric values.");
                return;
            }

            int    id   = int.Parse(modPartIDTextBox.Text);
            string name = modPartNameTextBox.Text;

            price      = decimal.Parse(modPartCostTextBox.Text);
            minStock   = int.Parse(modPartMinTextBox.Text);
            maxStock   = int.Parse(modPartMaxTextBox.Text);
            invInStock = int.Parse(modPartInventoryTextBox.Text);


            //exception handling
            if (minStock > maxStock)
            {
                MessageBox.Show("Error: Max must be greater than min");
                return;
            }

            if (invInStock > maxStock || invInStock < minStock)
            {
                MessageBox.Show("Error: Inventory must be between max and min inventory");
                return;
            }

            if (inhouseRadioButton.Checked)
            {
                InHousePart inPart = new InHousePart(id, name, invInStock, price, maxStock, minStock, int.Parse(modPartMacComTextBox.Text));
                Inventory.UpdatePart(id, inPart);
                inhouseRadioButton.Checked = true;
            }
            else
            {
                OutsourcedPart outPart = new OutsourcedPart(id, name, invInStock, price, maxStock, minStock, modPartMacComTextBox.Text);
                Inventory.UpdatePart(id, outPart);
                outsourcedRadioButton.Checked = true;
            }
            Close();
            MainWindow.partGridView.Update();
            MainWindow.partGridView.Refresh();
        }
        private void SavePartButton_Click(object sender, EventArgs e)
        {
            int     minStock;
            int     maxStock;
            int     invInStock;
            decimal price;

            try
            {
                minStock   = int.Parse(partMinTextBox.Text);
                maxStock   = int.Parse(partMaxTextBox.Text);
                invInStock = int.Parse(partInventoryTextBox.Text);
                price      = decimal.Parse(partCostTextBox.Text);
            }
            catch
            {
                MessageBox.Show("Error: Inventory, Price, Max and Min text fields must be numeric values.");
                return;
            }



            string name = partNameTextBox.Text;

            price      = decimal.Parse(partCostTextBox.Text);
            minStock   = int.Parse(partMinTextBox.Text);
            maxStock   = int.Parse(partMaxTextBox.Text);
            invInStock = int.Parse(partInventoryTextBox.Text);


            //exception handling
            if (minStock > maxStock)
            {
                MessageBox.Show("Error: Max must be greater than min");
                return;
            }

            if (invInStock > maxStock || invInStock < minStock)
            {
                MessageBox.Show("Error: Inventory must be between max and min inventory");
                return;
            }


            if (inhouseRadioButton.Checked)
            {
                InHousePart inPart = new InHousePart((Inventory.Parts.Count + 1), name, invInStock, price, maxStock, minStock, int.Parse(partMacComTextBox.Text));
                Inventory.AddPart(inPart);
            }
            else
            {
                OutsourcedPart outPart = new OutsourcedPart((Inventory.Parts.Count + 1), name, invInStock, price, maxStock, minStock, partMacComTextBox.Text);
                Inventory.AddPart(outPart);
            }
            Close();
        }
 //load selected data based on if part is inhouse or outsourced.
 public Modify_Part(InHousePart inPart)
 {
     InitializeComponent();
     modPartIDTextBox.Text        = inPart.PartID.ToString();
     modPartNameTextBox.Text      = inPart.Name;
     modPartInventoryTextBox.Text = inPart.Inventory.ToString();
     modPartCostTextBox.Text      = inPart.Price.Substring(1).ToString();
     modPartMaxTextBox.Text       = inPart.Max.ToString();
     modPartMinTextBox.Text       = inPart.Min.ToString();
     modPartMacComTextBox.Text    = inPart.MachineID.ToString();
 }
Пример #4
0
        public static void ExampleItems()
        {
            Product exampleProd = new Product(1, "Example Product", 5, 5.0m, 10, 5);

            Products.Add(exampleProd);

            Part exampleInPart  = new InHousePart(1, "Example In Part", 10, 5.0m, 20, 10, 1001);
            Part exampleOutPart = new OutsourcedPart(2, "Example Out Part", 30, 1.0m, 45, 10, "Test Co.");

            Parts.Add(exampleInPart);
            Parts.Add(exampleOutPart);
        }
Пример #5
0
        public Part LookupAssociatedPart(int partID)
        {
            foreach (Part part in AssociatedParts)
            {
                if (part.PartID == partID)
                {
                    return(part);
                }
            }
            InHousePart emptyInHousePart = new InHousePart();

            return(emptyInHousePart);
        }
Пример #6
0
        public static Part LookupPart(int partID)
        {
            foreach (Part part in Parts)
            {
                if (part.PartID == partID)
                {
                    return(part);
                }
            }
            Part emptyPart = new InHousePart();

            return(emptyPart);
        }
 private void ModifyPartButton_Click(object sender, EventArgs e)
 {
     if (partGridView.CurrentRow.DataBoundItem.GetType() == typeof(Inventory_Management_System.InHousePart))
     {
         InHousePart inHousePart = (InHousePart)partGridView.CurrentRow.DataBoundItem;
         new Modify_Part(inHousePart).ShowDialog();
     }
     else
     {
         OutsourcedPart outsourcedPart = (OutsourcedPart)partGridView.CurrentRow.DataBoundItem;
         new Modify_Part(outsourcedPart).ShowDialog();
     }
 }