Пример #1
0
 protected override void SaveMaintained()
 {
     if (isNewVehicle)
     {
         Vehicle vehicle = new Vehicle(
             Form.licensePlate.Text,
             (Model)Form.model.SelectedItem,
             (Branch)Form.branch.SelectedItem,
             (TankLevel)Form.tankLevel.SelectedItem,
             Convert.ToInt32(Form.mileage.Text),
             null)
         {
             BranchId = ((Branch)Form.branch.SelectedItem).Id,
             ModelId  = ((Model)Form.model.SelectedItem).Id
         };
         VehicleData.Insert(vehicle);
     }
     else
     {
         Vehicle vehicle = Current();
         vehicle.Model     = (Model)Form.model.SelectedItem;
         vehicle.Branch    = (Branch)Form.branch.SelectedItem;
         vehicle.TankLevel = (TankLevel)Form.tankLevel.SelectedItem;
         vehicle.Mileage   = Convert.ToInt32(Form.mileage.Text);
         VehicleData.Update(vehicle);
     }
 }
        private void InsertVehicle()
        {
            Vehicle vehicle = new Vehicle(
                this.licensePlate.Text,
                (Model)this.model.SelectedItem,
                (Branch)this.branch.SelectedItem,
                (TankLevel)this.tankLevel.SelectedItem,
                Convert.ToInt32(this.mileage.Text),
                null);

            data.Insert(vehicle);
        }