Exemplo n.º 1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            Automobile car = new Automobile();                  // Create an instance of the Automobile structure.

            GetData(ref car);                                   // Get the data entered by the user.
            carList.Add(car);                                   // Add the car object to the List.
            makeTextBox.Clear();                                // Clear the TextBoxes.
            yearTextBox.Clear();
            mileageTextBox.Clear();
            makeTextBox.Focus();                                // Reset the focus.
        }
Exemplo n.º 2
0
 private void GetData(ref Automobile auto)
 {
     try
     {
         auto.make    = txtMake.Text;
         auto.year    = int.Parse(txtYear.Text);
         auto.mileage = double.Parse(txtMileage.Text);
     }//end try
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     } //end catch
 }     //end of void GetData method
Exemplo n.º 3
0
 private void GetData(ref Automobile car)
 {
     try
     {
         car.make    = makeTextBox.Text;                // Get the data from the TextBoxes.
         car.year    = int.Parse(yearTextBox.Text);
         car.mileage = double.Parse(mileageTextBox.Text);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);                    // Display the exception message.
     }
 }
Exemplo n.º 4
0
        private void addButton_Click(object sender, EventArgs e)
        {
            Automobile car = new Automobile();

            GetData(ref car);

            carList.Add(car);

            makeTextBox.Clear();
            yearTextBox.Clear();
            mileageTextBox.Clear();

            makeTextBox.Focus();
        }
Exemplo n.º 5
0
        private void GetData(ref Automobile auto)
        {
            try
            {
                auto.make    = makeTextBox.Text;
                auto.year    = int.Parse(yearTextBox.Text);
                auto.mileage = double.Parse(mileageTextBox.Text);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        }     //end of void GetData method

        private void btnAddCar_Click(object sender, EventArgs e)
        {
            Automobile car = new Automobile();

            GetData(ref car);

            carList.Add(car);

            //clear the boxes
            txtMake.Clear();
            txtYear.Clear();
            txtMileage.Clear();

            //focus the cursor
            txtMake.Focus();
        }//end of btnAddCar void method