Ejemplo n.º 1
0
 public static boolean addItemToDatabase(
     String name,
     String barcode,
     String description,
     long quantity,
     String location,
     String setName) {
   return itemDatabase.addEntry(barcode, name, setName, description, quantity, location);
 }
Ejemplo n.º 2
0
 /**
  * Write out the CSV version of the database for the admin.
  *
  * @param type SQLInterface.TABPERSON for the person database or "Produt" for the product database
  */
 public static void adminWriteOutDatabase(String type) {
   switch (type) {
     case (SQLInterface.TABPERSON):
       personDatabase.writeDatabaseCSV("adminPersonDatabase.csv");
       break;
     case (SQLInterface.TABITEM):
       itemDatabase.writeDatabaseCSV(type, "adminItemDatabase.csv");
       break;
     case (SQLInterface.TABGENERAL):
       itemDatabase.writeDatabaseCSV(type, "adminGeneralDatabase.csv");
       break;
     case (SQLInterface.TABCONTROLLED):
       itemDatabase.writeDatabaseCSV(type, "adminControlledDatabase.csv");
       break;
     default:
       personDatabase.writeDatabaseCSV("adminItemDatabase.csv");
   }
 }
Ejemplo n.º 3
0
 /**
  * Write the given type of database out to a CSV file at the given location.
  *
  * @param type The type of database to write. Person or Item (general or controlled)
  * @param path The location which the file will be stored at
  */
 public static void adminWriteOutDatabase(String type, String path) {
   switch (type) {
     case (SQLInterface.TABPERSON):
       personDatabase.writeDatabaseCSV(path);
       break;
     default:
       itemDatabase.writeDatabaseCSV(type, path);
   }
 }
Ejemplo n.º 4
0
 /**
  * Takes the barcode for a product and adds it to the checkout
  *
  * @param input The barcode for the product as a string
  * @return True if the product was added, false if it failed
  */
 public static boolean addToCart(String input) {
   String tempBarCode = "-1";
   if (input != null && !input.equals("")) {
     tempBarCode = input; // disallows the user from entering nothing or clicking cancel.
   } else if ((input == null) || ("".equals(input))) {
     return false;
   }
   String adding = itemDatabase.getEntryName(tempBarCode).orElse("ERROR");
   if (adding != null && !adding.equals("ERROR")) {
     System.out.println(tempBarCode + "\n" + adding);
     checkOuts.addProduct(tempBarCode, adding); // otherwise, add the product as normal.
     return true;
   }
   return false;
 }
Ejemplo n.º 5
0
 /**
  * Create a scroll pane of one of the databases
  *
  * @param type A string of either SQLInterface.TABITEM or SQLInterface.TABPERSON used to determine
  *     which database to print.
  * @return A scroll pane showing the database chosen in the parameter or the person database by
  *     default.
  * @throws IOException
  */
 public static ScrollPane printDatabase(String type) throws IOException {
   TextArea textArea;
   switch (type) {
     case (SQLInterface.TABITEM):
       textArea = new TextArea(itemDatabase.getDatabase().toString());
       break;
     case (SQLInterface.TABPERSON):
       textArea = new TextArea(personDatabase.getDatabase().toString());
       break;
     default:
       textArea = new TextArea(personDatabase.getDatabase().toString());
       break;
   }
   textArea.setEditable(false); // stop the user being able to edit this and thinking it will save.
   ScrollPane scrollPane = new ScrollPane(textArea);
   textArea.setWrapText(true);
   scrollPane.setHvalue(600);
   scrollPane.setVvalue(800);
   return scrollPane;
 }
Ejemplo n.º 6
0
 public static String getItemName(String barcode) {
   return itemDatabase.getEntryName(barcode).orElse("ERROR");
 }
Ejemplo n.º 7
0
 /**
  * set the number of a product in stock
  *
  * @param ID The name of the product you wish to set the stock count for
  * @param numberOfProducts The new stock count.
  */
 public static void setNumberOfProducts(String ID, int numberOfProducts) {
   itemDatabase.setNumber(ID, numberOfProducts);
 }
Ejemplo n.º 8
0
 /**
  * Get the number of a product left in stock
  *
  * @param ID The name of the product you wish to check stock count.
  * @return The number of the specified product in stock
  */
 public static int getProductNumber(String ID) {
   return itemDatabase.getNumber(ID);
 }
Ejemplo n.º 9
0
 /**
  * Get the barcode of a product given it's name
  *
  * @param name The name of the product to get the barcode of
  * @return The barcode of the product with the name specified.
  */
 public static String getProductBarCode(String name) {
   return itemDatabase.getBarcode(name).orElse("Item Not Found");
 }
Ejemplo n.º 10
0
 /**
  * Delete an item, requires root user/password
  *
  * @param ID The ID of the item to delete
  * @param rootID The ID of the root user attempting to delete the item.
  * @param rootPassWd The password of the root user attempting to delete the item.
  */
 public static void removeItem(String ID, String rootID, String rootPassWd) {
   if (passwordsEqual(rootID, rootPassWd)) {
     itemDatabase.deleteEntry(ID);
   }
 }
Ejemplo n.º 11
0
 /**
  * Get a list of the names of all products in the database
  *
  * @return A string array of the product names
  */
 public static ArrayList<String> getProductNames(String type) {
   return itemDatabase.getNamesOfEntries(type);
 }
Ejemplo n.º 12
0
 public static void addSet(String name, String barcode) {
   itemDatabase.addSet(barcode, name);
 }
Ejemplo n.º 13
0
 /**
  * Alter a product in the database
  *
  * @param name The new name of the product
  * @param oldName The old name of the product
  * @param barcode The new barcode of the product
  * @param oldBarcode The old barcode of the product
  */
 public static void changeDatabaseProduct(
     String name, String oldName, String barcode, String oldBarcode) {
   itemDatabase.changeItem(name, barcode, oldBarcode);
 }
Ejemplo n.º 14
0
 public static boolean addItemToDatabase(
     String name, String barcode, String type, String tagno, String set, String state) {
   return itemDatabase.addEntry(barcode, name, set, state, tagno, type);
 }
Ejemplo n.º 15
0
 /**
  * Add barcode product to the database given their name, barcode and price
  *
  * @param name The name of the product you wish to add
  * @param barcode The barcode for the product you wish to add.
  */
 public static boolean addItemToDatabase(String barcode, String name) {
   return itemDatabase.addEntry(barcode, name);
 }
Ejemplo n.º 16
0
 public static boolean itemExists(String barcode) {
   return itemDatabase.entryExists(barcode);
 }
Ejemplo n.º 17
0
 public static ArrayList<String> getTypes() {
   return itemDatabase.getTypes();
 }
Ejemplo n.º 18
0
 /**
  * Remove the specified product
  *
  * @param ID The barcode or name of the product to be removed
  * @throws IOException
  * @throws InterruptedException
  */
 public static void removeItem(String ID) throws IOException, InterruptedException {
   itemDatabase.deleteEntry(ID);
 }
Ejemplo n.º 19
0
 public static void addControlledType(String name, String barcode) {
   itemDatabase.addControlledType(barcode, name);
 }
Ejemplo n.º 20
0
 /**
  * Log a single item out of the database.
  *
  * @param ID The ID of the item to log out.
  * @param persID The ID of the person to log the item out to.
  */
 public static void logItemOut(String ID, String persID) {
   SQLInterface.addLog(ID, persID, ItemDatabase.isControlled(ID));
 }