Пример #1
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            selectedPart = (BikePart)PartListBox.SelectedItem;

            if (selectedPart == null)
            {
                return;
            }

            else
            {
                // Change Brk Even

                double brkEv = Math.Ceiling(Double.Parse(initInv.Text) / selectedPart.price);

                brkEvenCount.Text = brkEv.ToString();

                // Other

                PartNameBox.Text      = selectedPart.name;
                PartTypeDropDown.Text = selectedPart.type;
                YearsDropdown.Text    = selectedPart.years;
                MfgDropDown.Text      = selectedPart.mfg;
                ebayPriceBox.Text     = Math.Round(selectedPart.price, 2).ToString();
            }
        }
Пример #2
0
        private void addPartButton_Click(object sender, EventArgs e)
        {
            if (PartNameBox.Text.Length < 3)
            {
                MessageBox.Show("Please enter at least 3 characters for a name.");
                return;
            }

            if (PartTypeDropDown.Text.Length < 3)
            {
                MessageBox.Show("Please select a type.");
                return;
            }

            if (YearsDropdown.Text.Length < 3)
            {
                MessageBox.Show("Please select a manufacturing timeline.");
                return;
            }

            if (MfgDropDown.Text.Length < 4)
            {
                MessageBox.Show("Please select a manufacturer.");
                return;
            }

            partToAdd = new BikePart(PartNameBox.Text, PartTypeDropDown.Text, MfgDropDown.Text, YearsDropdown.Text, float.Parse(ebayPriceBox.Text));

            BikePartList.AddPart(partToAdd);

            updatePartListBox();
            PartListBox.Update();

            PartListBox.SelectedIndex = PartListBox.Items.Count - 1;

            Console.WriteLine(BikePartList.PartList.Count);
            Console.WriteLine("Part LBox: " + PartListBox.Items.Count);
        }