Exemplo n.º 1
0
        private void Add_Vehicle_button_Click(object sender, EventArgs e)
        {
            if (Manufacturer_text.Text == string.Empty)
            {
                MessageBox.Show(" Manufacturer text box is empty!");
            }

            else if (Model_textBox.Text == string.Empty)
            {
                MessageBox.Show(" Modle text box is empty!");
            }
            else if (Make_Year_textBox.Text == string.Empty)
            {
                MessageBox.Show("Make Year Textbox is empty");
            }
            else if (Registration_No_textBox.Text == string.Empty)
            {
                MessageBox.Show("Registration NO text box is empty");
            }

            else if (!Int64.TryParse(Make_Year_textBox.Text, out vehicle.make))
            {
                MessageBox.Show(" Make Year textbox dosent have a number in it ");
            }
            else if (Count == 10)
            {
                MessageBox.Show("Sorry you have run out of room to store Vehicles");
            }

            else
            {
                vehicle.GetManufacturer = Manufacturer_text.Text;

                vehicle.GetModle = Model_textBox.Text;

                vehicle.GetRegistration_NO = Registration_No_textBox.Text;

                vehicle.GetMakeYear = Convert.ToInt64(Make_Year_textBox.Text);

                VehicleArry[Count] = vehicle;



                Add_Journey_Combox.Items.Add(VehicleArry[Count].GetManufacturer);
                Choose_Car_groupBox.Items.Add(VehicleArry[Count].GetManufacturer);

                Manufacturer_text.Clear();
                Model_textBox.Clear();
                Registration_No_textBox.Clear();
                Make_Year_textBox.Clear();


                Count++;
            }
        }
Exemplo n.º 2
0
        //creates a new vehicle and adds it to the vehicle list
        private void Add_Vehicle_button_Click(object sender, EventArgs e)
        {
            int makeYear;

            if (txtManufacturer.Text == string.Empty)
            {
                MessageBox.Show(" Manufacturer text box is empty!");
            }
            else if (txtModel.Text == string.Empty)
            {
                MessageBox.Show(" Model text box is empty!");
            }
            else if (Make_Year_textBox.Text == string.Empty)
            {
                MessageBox.Show("Make Year Textbox is empty");
            }
            else if (Registration_No_textBox.Text == string.Empty)
            {
                MessageBox.Show("Registration NO text box is empty");
            }
            else if (!int.TryParse(Make_Year_textBox.Text, out makeYear))
            {
                MessageBox.Show(" Make Year textbox dosent have a number in it ");
            }
            else
            {
                //creates a new vehicle and adds it to the list
                var newVehicle = new Vehicle(txtManufacturer.Text, txtModel.Text, makeYear, Registration_No_textBox.Text);
                Vehicles.Add(newVehicle);

                //refreshes comboboxes so they show the new vehicle
                cbxAddJourney.Refresh();
                cbxChooseCar.Refresh();

                //clears text boxes
                txtManufacturer.Clear();
                txtModel.Clear();
                Registration_No_textBox.Clear();
                Make_Year_textBox.Clear();
            }
        }