예제 #1
0
 void PopulateFormWithCar()
 {
     var service = new CarService();
     var car = service.GetCar();
     if (car == null)
         return;
     colorTextBox.Text = car.Color;
     makeTextBox.Text = car.Make;
     modelTextBox.Text = car.Model;
     yearTextBox.Text = car.Year.ToString();
 }
예제 #2
0
 void SaveCarFromForm()
 {
     var car = new Car();
     car.Color = colorTextBox.Text;
     car.Make = makeTextBox.Text;
     car.Model = modelTextBox.Text;
     int year;
     if (int.TryParse(yearTextBox.Text, out year))
         car.Year = year;
     var service = new CarService();
     service.SaveCar(car);
 }