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); }
/** * 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"); } }
/** * 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); } }
/** * 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; }
/** * 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; }
public static String getItemName(String barcode) { return itemDatabase.getEntryName(barcode).orElse("ERROR"); }
/** * 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); }
/** * 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); }
/** * 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"); }
/** * 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); } }
/** * 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); }
public static void addSet(String name, String barcode) { itemDatabase.addSet(barcode, name); }
/** * 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); }
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); }
/** * 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); }
public static boolean itemExists(String barcode) { return itemDatabase.entryExists(barcode); }
public static ArrayList<String> getTypes() { return itemDatabase.getTypes(); }
/** * 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); }
public static void addControlledType(String name, String barcode) { itemDatabase.addControlledType(barcode, name); }
/** * 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)); }