예제 #1
0
        public AddPartForm()
        {
            InitializeComponent();
            InhousePart newIPart = new InhousePart();

            OutsourcedPart newOPart = new OutsourcedPart();
        }
예제 #2
0
        private void MPSaveButton_Click(object sender, EventArgs e)
        {
            InhousePart    IP = new InhousePart();
            OutsourcedPart OP = new OutsourcedPart();

            if (Convert.ToInt32(MPInventoryTextBox.Text) < Convert.ToInt32(MPMinTextBox.Text) ||
                Convert.ToInt32(MPInventoryTextBox.Text) > Convert.ToInt32(MPMaxTextBox.Text))
            {
                MessageBox.Show("Inventory is out of range.", "Error");
                return;
            }
            if (Convert.ToInt32(MPMaxTextBox.Text) > Convert.ToInt32(MPMinTextBox.Text))
            {
                if (MPInhouseRadio.Checked)
                {
                    IP.PartID    = Int32.Parse(MPIDTextBox.Text);
                    IP.Name      = MPNameTextBox.Text;
                    IP.InStock   = Int32.Parse(MPInventoryTextBox.Text);
                    IP.Price     = Decimal.Parse(MPPriceTextBox.Text);
                    IP.Max       = Int32.Parse(MPMaxTextBox.Text);
                    IP.Min       = Int32.Parse(MPMinTextBox.Text);
                    IP.MachineID = Int32.Parse(MPMachineIDTextBox.Text);

                    Inventory.UpdatePart(Convert.ToInt32(IP.PartID), IP);
                }
                else
                {
                    OP.PartID      = Int32.Parse(MPIDTextBox.Text);
                    OP.Name        = MPNameTextBox.Text;
                    OP.InStock     = Int32.Parse(MPInventoryTextBox.Text);
                    OP.Price       = Decimal.Parse(MPPriceTextBox.Text);
                    OP.Max         = Int32.Parse(MPMaxTextBox.Text);
                    OP.Min         = Int32.Parse(MPMinTextBox.Text);
                    OP.CompanyName = (MPMachineIDTextBox.Text);

                    Inventory.UpdatePart(Convert.ToInt32(OP.PartID), OP);
                }

                Inventory.DeletePart(Inventory.CurrentPart);

                this.Hide();
                Mainscreen o = new Mainscreen();
                o.Show();
            }
            else
            {
                MessageBox.Show("Your min value is greater than the max value.", "Error");
            }
        }
예제 #3
0
        private void APSaveButton_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(APInventoryTextBox.Text) < Convert.ToInt32(APMinTextBox.Text) ||
                Convert.ToInt32(APInventoryTextBox.Text) > Convert.ToInt32(APMaxTextBox.Text))
            {
                MessageBox.Show("Inventory is out of range.", "Error");
                return;
            }
            if (Convert.ToInt32(APMaxTextBox.Text) > Convert.ToInt32(APMinTextBox.Text))
            {
                if (APInhouseRadio.Checked)
                {
                    InhousePart newIPart = new InhousePart();
                    newIPart.PartID    = Inventory.createPartID();
                    newIPart.Name      = APNameTextBox.Text;
                    newIPart.InStock   = Int32.Parse(APInventoryTextBox.Text);
                    newIPart.Price     = Decimal.Parse(APPriceTextBox.Text);
                    newIPart.Max       = Int32.Parse(APMaxTextBox.Text);
                    newIPart.Min       = Int32.Parse(APMinTextBox.Text);
                    newIPart.MachineID = Int32.Parse(APMachineIDTextBox.Text);
                    Inventory.AddPart(newIPart);
                }
                else
                {
                    OutsourcedPart newOPart = new OutsourcedPart();
                    newOPart.PartID      = Inventory.createPartID();
                    newOPart.Name        = APNameTextBox.Text;
                    newOPart.InStock     = Int32.Parse(APInventoryTextBox.Text);
                    newOPart.Price       = Decimal.Parse(APPriceTextBox.Text);
                    newOPart.Max         = Int32.Parse(APMaxTextBox.Text);
                    newOPart.Min         = Int32.Parse(APMinTextBox.Text);
                    newOPart.CompanyName = (APMachineIDTextBox.Text);
                    Inventory.AddPart(newOPart);
                }
            }

            else
            {
                MessageBox.Show("Your min value is greater than the max value.", "Error");
                return;
            }


            Close();
            Mainscreen p = new Mainscreen();

            p.Show();
        }