Esempio n. 1
0
 //Metodo verifica la entidad vehículo que este correcta,
 //que para cuando se elimine no cause error
 public void eliminarVehiculo(ENT.Vehiculo vehiculo)
 {
     DAL.Vehiculo DalVehiculo = new DAL.Vehiculo();
     try
     {
         if (vehiculo.Id <= 0)
         {
             throw new Exception("Debes seleccionar un vehículo, para eliminarlo");
         }
         DalVehiculo.borrarVehiculo(vehiculo);
         if (DalVehiculo.Error)
         {
             throw new Exception("Error al eliminar el vehículo " + DalVehiculo.ErrorMsg);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
 //Metodo verica que los datos que recibe por parametro
 //esten correctos para pasarlos a DAL y insertarlos
 public void agregarVehiculo(ENT.Vehiculo vehiculo)
 {
     DAL.Vehiculo DalVehiculo = new DAL.Vehiculo();
     try
     {
         if (vehiculo.Anno <= 0)
         {
             throw new Exception("Año de vehículo requerido");
         }
         if (vehiculo.Cilindraje <= 0)
         {
             throw new Exception("Cilindraje del vihículo requerido");
         }
         if (vehiculo.NumeroChazis <= 0)
         {
             throw new Exception("Numero de chazis del vehículo requerido");
         }
         if (vehiculo.Placa == string.Empty)
         {
             throw new Exception("Placa del vehículo requerida");
         }
         if (vehiculo.TipoCombustible == string.Empty)
         {
             throw new Exception("Tipo de combustible del vehículo invalido");
         }
         if (vehiculo.NumeroMotor <= 0)
         {
             throw new Exception("Error numero de motor del vehículo requerido");
         }
         if (vehiculo.Estado == string.Empty)
         {
             throw new Exception("Estado del vehículo requerido");
         }
         if (vehiculo.Cliente.Id <= 0)
         {
             throw new Exception("Debes seleccionar un cliente para guardar el vehículo");
         }
         if (vehiculo.Marca.Id <= 0)
         {
             throw new Exception("Debes seleccionar una marca para guardar este vehiculo");
         }
         if (vehiculo.Tipo.Id <= 0)
         {
             throw new Exception("Debes seleccionar un tipo de vehículo");
         }
         if (vehiculo.Id <= 0)
         {
             DalVehiculo.agregarVehiculo(vehiculo);
             if (DalVehiculo.Error)
             {
                 throw new Exception("Error al guardar el vehículo " + DalVehiculo.ErrorMsg);
             }
         }
         else
         {
             DalVehiculo.editarVehiculo(vehiculo);
             if (DalVehiculo.Error)
             {
                 throw new Exception("Error al editar el vehículo " + DalVehiculo.ErrorMsg);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }