コード例 #1
0
        public AddPart(Inhouse inPart)
        {
            InitializeComponent();

            textBoxAddPartID        = inPart.PartID;
            textBoxAddPartName      = inPart.Name;
            textBoxAddPartInv       = inPart.InStock;
            textBoxAddPartPriceCost = inPart.Price;
            textBoxAddPartMin       = inPart.Min;
            textBoxAddPartMax       = inPart.Max;
            textBoxAddPartMachineID = inPart.MachineID.ToString();
            if (Inventory.CurrentPart is Inhouse)
            {
                Inhouse e = (Inhouse)Inventory.CurrentPart;
                BoxAddPartMachineID.Text = e.MachineID.ToString();
                isInHouse = true;
                radioAddPartInHouse.Checked = true;
            }
            else
            {
                Outsourced e = (Outsourced)Inventory.CurrentPart;
                BoxAddPartMachineID.Text = e.CompanyName;
                isInHouse = false;
                radioAddPartOutsourced.Checked = true;
            }
        }
コード例 #2
0
        //Save Button
        private void buttonModifyPartSave_Click(object sender, EventArgs e)
        {
            //Exception
            if (textBoxModifyPartMax < textBoxModifyPartMin)
            {
                MessageBox.Show("Minimum must not exceed maximum");
                return;
            }
            if (textBoxModifyPartInv < textBoxModifyPartMin || textBoxModifyPartInv > textBoxModifyPartMax)
            {
                MessageBox.Show("Inventory must be between minimum and maximum");
                return;
            }
            if (radioModifyPartInHouse.Checked)
            {
                Inhouse inhouse = new Inhouse(Convert.ToInt32(BoxModifyPartID.Text), BoxModifyPartName.Text, Convert.ToDouble(BoxModifyPartPriceCost.Text),
                                              Convert.ToInt32(BoxModifyPartInv.Text), Convert.ToInt32(BoxModifyPartMin.Text), Convert.ToInt32(BoxModifyPartMax.Text),
                                              Convert.ToInt32(BoxModifyPartMachineID.Text));
                Inventory.UpdateInHouse(Convert.ToInt32(BoxModifyPartID.Text), inhouse);
                radioModifyPartInHouse.Checked = true;
            }
            else
            {
                Outsourced outsourced = new Outsourced(Convert.ToInt32(BoxModifyPartID.Text), BoxModifyPartName.Text, Convert.ToDouble(BoxModifyPartPriceCost.Text),
                                                       Convert.ToInt32(BoxModifyPartInv.Text), Convert.ToInt32(BoxModifyPartMin.Text), Convert.ToInt32(BoxModifyPartMax.Text),
                                                       BoxModifyPartMachineID.Text);
                Inventory.UpdateOutsourced(Convert.ToInt32(BoxModifyPartID.Text), outsourced);
                radioModifyPartOutsourced.Checked = true;
            }
            this.Hide();
            MainScreen f1 = new MainScreen();

            f1.Show();
        }
コード例 #3
0
        public ModifyPart(Inhouse inPart)
        {
            InitializeComponent();

            textBoxModifyPartID        = inPart.PartID;
            textBoxModifyPartName      = inPart.Name;
            textBoxModifyPartInv       = inPart.InStock;
            textBoxModifyPartPriceCost = inPart.Price;
            textBoxModifyPartMax       = inPart.Max;
            textBoxModifyPartMin       = inPart.Min;
            textBoxModifyPartMachineID = inPart.MachineID.ToString();
        }
コード例 #4
0
 //Part Modify Button
 private void buttonModifyPart_Click(object sender, EventArgs e)
 {
     this.Hide();
     if (dataGridViewParts.CurrentRow.DataBoundItem.GetType() == typeof(DeanKellyInventorySystem.Inhouse))
     {
         Inhouse inPart = (Inhouse)dataGridViewParts.CurrentRow.DataBoundItem;
         new ModifyPart(inPart).ShowDialog();
     }
     else
     {
         Outsourced outPart = (Outsourced)dataGridViewParts.CurrentRow.DataBoundItem;
         new ModifyPart(outPart).ShowDialog();
     }
 }
コード例 #5
0
        //UpdatePart
        //public static void UpdatePart(Part part)
        //{

        //    AllParts.RemoveAt(CurrentPartID);
        //    AllParts.Insert(CurrentPartID, part);
        //}
        public static void UpdateInHouse(int partID, Inhouse inPart)
        {
            for (int i = 0; i < AllParts.Count; i++)
            {
                if (AllParts[i].GetType() == typeof(DeanKellyInventorySystem.Inhouse))
                {
                    Inhouse newPart = (Inhouse)AllParts[i];

                    if (newPart.PartID == partID)
                    {
                        newPart.Name      = inPart.Name;
                        newPart.InStock   = inPart.InStock;
                        newPart.Price     = inPart.Price;
                        newPart.Min       = inPart.Min;
                        newPart.Max       = inPart.Max;
                        newPart.MachineID = inPart.MachineID;
                    }
                }
            }
        }
コード例 #6
0
        //
        //Save Button
        private void buttonAddPartSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Exception Min must not exceed Max
                if (textBoxAddPartMax < textBoxAddPartMin)
                {
                    MessageBox.Show("Minimum must not exceed maximum");
                    return;
                }
            }
            catch (FormatException formatException)
            {
                MessageBox.Show("Please enter a numeric value for Min and Max.");
            }
            try
            {
                //Exception Inventory must be between min and max
                if (textBoxAddPartInv < textBoxAddPartMin || textBoxAddPartInv > textBoxAddPartMax)
                {
                    MessageBox.Show("Inventory must be between minimum and maximum");
                    return;
                }
            }
            catch (FormatException formatException)
            {
                MessageBox.Show("Please enter a numeric value for Inv.");
            }
            try
            {
                if (radioAddPartInHouse.Checked)
                {
                    Inhouse inHouse = new Inhouse((Inventory.AllParts.Count + 1), textBoxAddPartName, textBoxAddPartPriceCost, textBoxAddPartInv,
                                                  textBoxAddPartMin, textBoxAddPartMax, int.Parse(textBoxAddPartMachineID));
                    Inventory.AddPart(inHouse);
                }
                else
                {
                    //Exception Min must not exceed Max
                    if (textBoxAddPartMax < textBoxAddPartMin)
                    {
                        MessageBox.Show("Minimum must not exceed maximum");
                        return;
                    }
                    //Exception Inventory must be between min and max
                    if (textBoxAddPartInv < textBoxAddPartMin || textBoxAddPartInv > textBoxAddPartMax)
                    {
                        MessageBox.Show("Inventory must be between minimum and maximum");
                        return;
                    }
                    Outsourced outsourced = new Outsourced((Inventory.AllParts.Count + 1), textBoxAddPartName, textBoxAddPartPriceCost, textBoxAddPartInv,
                                                           textBoxAddPartMin, textBoxAddPartMax, textBoxAddPartMachineID);
                    Inventory.AddPart(outsourced);
                }
            }
            catch (FormatException formatException)
            {
                MessageBox.Show("Price must be a numeric value");
            }
            this.Hide();
            MainScreen f1 = new MainScreen();

            f1.Show();
        }