daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest May 17th, 2018 155 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. y{
  2.                 emm = Integer.parseInt(txtEMM.getText());
  3.             }
  4.             catch(Exception ex){
  5.                 lblError.setText("Error: End Month Mileage not an integer value.");
  6.                 return;
  7.             }
  8.            
  9.             try{
  10.                 price = Double.parseDouble(txtPrice.getText());
  11.                 txtEMM.getText();
  12.             }
  13.             catch(Exception ex){
  14.                 lblError.setText("Error: Price not in correct format");
  15.                 return;
  16.             }
  17.            
  18.             DBManager db = new DBManager();
  19.             HashMap<String,VehicleCategory> vehicleCats = db.loadVehicleCategories();
  20.            
  21.             for(Map.Entry<String, VehicleCategory> vEntry : vehicleCats.entrySet()){
  22.                 if(vEntry.getValue().getVehicleCatCode().equals(catCode)){
  23.                     category.setVehicleCatCode(catCode);
  24.                     category.setVehicleCatDesc(vEntry.getValue().getVehicleCatDesc());
  25.                 }
  26.             }
  27.            
  28.             if(category.getVehicleCatDesc().isEmpty()){
  29.                 lblError.setText("Error: Category must be a valid category. Set Code to one that exists.");
  30.                 return;
  31.             }
  32.            
  33.            
  34.             HashMap<String,Vehicle> vehicles = db.loadVehicles();
  35.            
  36.             for(Map.Entry<String, Vehicle> vEntry : vehicles.entrySet()){
  37.                 if(vEntry.getValue().getVehicleRegMark().equals(regMark)){
  38.                     lblError.setText("Error: Registration Mark already registered in system. Try another Registration Mark.");
  39.                     return;
  40.                 }
  41.             }
  42.            
  43.                 Vehicle newVehicle = new Vehicle(regMark, make, model, RegDate, PurchaseDate, emm, MOTDate, price, category);
  44.                 db.addVehicle(newVehicle);
  45.                 lblError.setText("Registration Successful");
  46.         }
  47.         else
  48.         {
  49.             lblError.setText("Please complete all fields");
  50.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top