//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();
        }
Пример #3
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);
        }
        public Modify_Part(OutsourcedPart outPart)
        {
            InitializeComponent();
            modPartIDTextBox.Text        = outPart.PartID.ToString();
            modPartNameTextBox.Text      = outPart.Name;
            modPartInventoryTextBox.Text = outPart.Inventory.ToString();
            modPartCostTextBox.Text      = outPart.Price.Substring(1).ToString();
            modPartMaxTextBox.Text       = outPart.Max.ToString();
            modPartMinTextBox.Text       = outPart.Min.ToString();
            modPartMacComTextBox.Text    = outPart.CompName;

            outsourcedRadioButton.Checked = true;
        }
 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();
     }
 }