コード例 #1
0
        public PartForm(string name, Part part)
        {
            InitializeComponent();
            modify             = true;
            error              = true;
            modifyPart         = part;
            AddPart_Label.Text = name;
            ID_Box.Text        = part.PartID.ToString();
            Name_Box.Text      = part.Name;
            Inventory_Box.Text = part.InStock.ToString();
            PriceCost_Box.Text = part.Price.ToString();
            Min_Box.Text       = part.Min.ToString();
            Max_Box.Text       = part.Max.ToString();

            if (part.GetType() == typeof(Inhouse))
            {
                Outsourced_Radio.Checked = false;
                InHouse_Radio.Checked    = true;
                Inhouse inhousePart = (Inhouse)part;
                MachineCompany_Box.Text = inhousePart.MachineID.ToString();
            }
            else
            {
                Outsourced_Radio.Checked = true;
                InHouse_Radio.Checked    = false;
                Outsourced outsourcedPart = (Outsourced)part;
                MachineCompany_Box.Text = outsourcedPart.CompanyName;
            }
        }
コード例 #2
0
        private void Save_Button_Click(object sender, EventArgs e)
        {
            try
            {
                int     min       = Int32.Parse(Min_Box.Text);
                int     max       = Int32.Parse(Max_Box.Text);
                int     inventory = Int32.Parse(Inventory_Box.Text);
                decimal price     = Decimal.Parse(PriceCost_Box.Text);

                if (InHouse_Radio.Checked)
                {
                    int machineID = Int32.Parse(MachineCompany_Box.Text);
                    if (!modify)
                    {
                        Inhouse part = new Inhouse(Name_Box.Text, price, inventory, min, max, machineID);
                        Inventory.addPart(part);
                        MainScreen.PartsTableController.Add(part.ToStringArray());
                    }
                    else
                    {
                        Inhouse part = new Inhouse(Name_Box.Text, price, inventory, min, max, machineID);
                        Part.count -= 1;
                        part.PartID = modifyPart.PartID;
                        Inventory.updatePart(Int32.Parse(ID_Box.Text), part);
                        MainScreen.PartsTableController.UpdateRow(part.ToStringArray());
                    }
                }
                else
                {
                    if (!modify)
                    {
                        Outsourced part = new Outsourced(Name_Box.Text, price, inventory, min, max, MachineCompany_Box.Text);
                        Inventory.addPart(part);
                        MainScreen.PartsTableController.Add(part.ToStringArray());
                    }
                    else
                    {
                        Outsourced part = new Outsourced(Name_Box.Text, price, inventory, min, max, MachineCompany_Box.Text);
                        Part.count -= 1;
                        part.PartID = modifyPart.PartID;
                        Inventory.updatePart(Int32.Parse(ID_Box.Text), part);
                        MainScreen.PartsTableController.UpdateRow(part.ToStringArray());
                    }
                }
                MainScreen.PartsTableController.Update();
                Close();
            }
            catch
            {
                MessageBox.Show("Unable to parse data, no information was saved.");
            }
        }
コード例 #3
0
        private void Save_Click(object sender, EventArgs e)
        {
            int invInStock = Int32.Parse(InvTextBox.Text);
            int minStock   = 0;

            try
            {
                minStock = Int32.Parse(minTextBox.Text);
            }
            catch
            {
                MessageBox.Show("Please only type numbers in min field, " + minTextBox.Text + " is not a number", "Min Field Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int maxStock = Int32.Parse(maxTextBox.Text);

            BasePart b = new BasePart();

            b.partID = Inventory.createPartID();
            b.name   = nameTextBox.Text;
            b.price  = Double.Parse(PriceTextBox.Text);
            b.min    = minStock;
            b.max    = maxStock;
            if (invInStock <= maxStock && invInStock >= minStock)
            {
                b.inStock = Int32.Parse(InvTextBox.Text);
            }

            if (inHouseRadioButton.Checked)
            {
                Inhouse newPart = new Inhouse(b, Int32.Parse(MachineCompanyIDTextBox.Text));
                Inventory.addPart(newPart);
                mainFormObject.addPartTableRow(newPart);
            }
            else
            {
                Outsourced newPart = new Outsourced(b, MachineCompanyIDTextBox.Text);
                Inventory.addPart(newPart);
                mainFormObject.addPartTableRow(newPart);
            }
            Close();
        }