Package sg.edu.nus.iss.se07.bc

Examples of sg.edu.nus.iss.se07.bc.Product


                                 */

                                String outputHeader = String.format(ProductReport.PRODUCT_REPORTHEADER_SHORT_FORMAT, header0, header1, header2, header5);
                                lstPanelProduct.add(outputHeader);
                                for (int i = 0; i < products.size(); i++) {
                                        Product item = products.get(i);
                                        int no = i + 1;
                                        String recordNo = StringUtil.createFixedWidthString(String.valueOf(no), 5);
                                        String productID = StringUtil.createFixedWidthString(item.getProductID(), 30);
                                        String productName = StringUtil.createFixedWidthString(item.getProductName(), 30);
                                        String price = StringUtil.createFixedWidthString(Float.toString(item.getProductPrice()),30);
                                        /*
                                        String description = StringUtil.createFixedWidthString(item.getProductDescription(),80);
                                        String qtyAvailable = StringUtil.createFixedWidthString(Integer.toString(item.getQuantityAvailable()),20);
                                       
                                        String barCodeNum = StringUtil.createFixedWidthString(item.getBarcodeNumber(),30);
View Full Code Here


                                        Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                        if (productDataSet != null) {
                                                Enumeration<Product> enumeration = productDataSet.elements();
                                                while (enumeration.hasMoreElements()) {
                                                        Product product = enumeration.nextElement();
                                                        if (product != null) {
                                                                String categorycode = product.getCategoryCode(product.getProductID());
                                                                if (categorycode.equalsIgnoreCase(id)) {
                                                                        dataObject.addProduct(product);
                                                                }
                                                        }
View Full Code Here

        public boolean addProduct(String categorycode, String id, String name, String description, int quantity, float price, String barcode, int reorderQty, int orderQty) throws AppException {
                boolean success = true;

                String productid = categorycode + "/" + id;
                Product dataObject = new Product(productid, name, description, quantity, price, barcode, reorderQty, orderQty);
                ProductManager dataObjectManager = new ProductManager();
                try {
                        //add product to the file
                        success = dataObjectManager.addProduct(dataObject);
                        if (success) {
                                //update caching
                                Hashtable<String, Category> categoryDataSet = DataSet.getCategoryDataSet();
                                if (categoryDataSet != null) {
                                        dataObject.setCategory(categoryDataSet.get(categorycode));
                                        if (categoryDataSet.get(categorycode) != null) {
                                                categoryDataSet.get(categorycode).addProduct(dataObject);
                                        }
                                }
View Full Code Here

        public boolean updateProduct(String id, String name, String description, Integer quantity, Float price, String barcode, Integer reorderQty, Integer orderQty) throws AppException {
                boolean success = true;

                ProductManager dataObjectManager = new ProductManager();

                Product oldDataObject = null;
                try {
                        oldDataObject = dataObjectManager.selectProduct(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }

                if (oldDataObject != null) {
                        Product newDataObject = new Product(id, name, description, quantity, price, barcode, reorderQty, orderQty);
                        try {
                                success = dataObjectManager.updateProduct(oldDataObject, newDataObject);
                                if (success) {
                                        //update caching
                                        Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                        if (productDataSet != null) {
                                                Product oldone = productDataSet.get(id);
                                                Product newone = newDataObject;
                                                newone.setCategory(oldone.getCategory());
                                                productDataSet.remove(id);
                                                productDataSet.put(id, newone);

                                                Hashtable<String, Category> categoryDataSet = DataSet.getCategoryDataSet();
                                                if (categoryDataSet.get(newone.getCategoryCode(id)) != null) {
                                                        categoryDataSet.get(newone.getCategoryCode(id)).addProduct(newone);
                                                }
                                        }


                                }
View Full Code Here

        public int getProductQty(String id) throws AppException {
                int qty = -99999;

                ProductManager dataObjectManager = new ProductManager();

                Product dataObject = null;
                try {
                        dataObject = dataObjectManager.selectProduct(id);
                } catch (AppException ex) {
                        //Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);                        return qty;
                }

                if (dataObject != null) {
                        qty = dataObject.getQuantityAvailable();
                } else {
                        //data not found
                        return qty;
                }
View Full Code Here

        public boolean increaseProductQty(String id, int amount) throws AppException {
                boolean success = true;

                ProductManager dataObjectManager = new ProductManager();

                Product dataObject = null;
                try {
                        dataObject = dataObjectManager.selectProduct(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        return false;
                }

                if (dataObject != null) {

                        int currQty = dataObject.getQuantityAvailable();
                        int newQty = currQty + amount;

                        Product newDataObject = new Product();
                        newDataObject.setProductID(dataObject.getProductID());
                        newDataObject.setProductName(dataObject.getProductName());
                        newDataObject.setProductDescription(dataObject.getProductDescription());
                        newDataObject.setQuantityAvailable(newQty);
                        newDataObject.setProductPrice(dataObject.getProductPrice());
                        newDataObject.setBarcodeNumber(dataObject.getBarcodeNumber());
                        newDataObject.setReorderQuantity(dataObject.getReorderQuantity());
                        newDataObject.setOrderQuantity(dataObject.getOrderQuantity());

                        try {
                                success = dataObjectManager.updateProduct(dataObject, newDataObject);
                                if (success) {
                                        //update caching
                                        Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                        if (productDataSet != null) {
                                                Product oldone = productDataSet.get(id);
                                                Product newone = newDataObject;
                                                newone.setCategory(oldone.getCategory());
                                                productDataSet.remove(id);
                                                productDataSet.put(id, newone);

                                                Hashtable<String, Category> categoryDataSet = DataSet.getCategoryDataSet();
                                                if (categoryDataSet.get(newone.getCategoryCode(newone.getCategoryCode(id))) != null) {
                                                        categoryDataSet.get(newone.getCategoryCode(id)).addProduct(newone);
                                                }
                                        }
                                }
                        } catch (AppException ex) {
                                Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
View Full Code Here

        public boolean decreaseProductQty(String id, int amount) throws AppException {
                boolean success = true;

                ProductManager dataObjectManager = new ProductManager();

                Product dataObject = null;
                try {
                        dataObject = dataObjectManager.selectProduct(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                }

                if (dataObject != null) {

                        int currQty = dataObject.getQuantityAvailable();
                        int newQty = currQty - amount;

                        Product newDataObject = new Product();
                        newDataObject.setProductID(dataObject.getProductID());
                        newDataObject.setProductName(dataObject.getProductName());
                        newDataObject.setProductDescription(dataObject.getProductDescription());
                        newDataObject.setQuantityAvailable(newQty);
                        newDataObject.setProductPrice(dataObject.getProductPrice());
                        newDataObject.setBarcodeNumber(dataObject.getBarcodeNumber());
                        newDataObject.setReorderQuantity(dataObject.getReorderQuantity());
                        newDataObject.setOrderQuantity(dataObject.getOrderQuantity());

                        try {
                                success = dataObjectManager.updateProduct(dataObject, newDataObject);
                                if (success) {
                                        //update caching
                                        Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                        if (productDataSet != null) {
                                                Product oldone = productDataSet.get(id);
                                                Product newone = newDataObject;
                                                newone.setCategory(oldone.getCategory());
                                                productDataSet.remove(id);
                                                productDataSet.put(id, newone);

                                                Hashtable<String, Category> categoryDataSet = DataSet.getCategoryDataSet();
                                                if (categoryDataSet.get(newone.getCategoryCode(id)) != null) {
                                                        categoryDataSet.get(newone.getCategoryCode(id)).addProduct(newone);
                                                }
                                        }
                                }
                        } catch (AppException ex) {
                                Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
View Full Code Here

                return dataObjectSet;
        }

        public Product getProductByBarcode(String barcode) throws AppException {
                Product dataObject = null;

                ProductManager productManager = new ProductManager();
                try {
                        dataObject = productManager.getProductByBarcode(barcode);
                } catch (AppException ex) {
View Full Code Here

                        success = dataObjectManager.deleteProduct(id);
                        if (success) {
                                //update caching
                                Hashtable<String, Product> productDataSet = DataSet.getProductDataSet();
                                if (productDataSet != null) {
                                        Product dataObject = productDataSet.get(id);
                                        String productCategory = dataObject.getCategoryCode(id);
                                        Hashtable<String, Category> categoryDataSet = DataSet.getCategoryDataSet();
                                        if (categoryDataSet != null) {
                                                if (categoryDataSet.get(productCategory) != null) {
                                                        categoryDataSet.get(productCategory).removeProduct(dataObject);
                                                        productDataSet.remove(id);
View Full Code Here

                                String header8 = StringUtil.createFixedWidthString("Order Quantity",30);*/

                                String outputHeader = String.format(ProductReport.PRODUCT_REPORTHEADER_SHORT_FORMAT, header0, header1, header2, header3);
                                lstProduct.add(outputHeader);
                                for (int i = 0; i < products.size(); i++) {
                                        Product item = products.get(i);
                                        int no = i + 1;
                                        String recordNo = StringUtil.createFixedWidthString(String.valueOf(no), 5);
                                        String productID = StringUtil.createFixedWidthString(item.getProductID(), 15);
                                        String productName = StringUtil.createFixedWidthString(item.getProductName(), 30);
                                        /*String price = StringUtil.createFixedWidthString(Float.toString(item.getProductPrice()),10);*/
                                        float price1 = item.getProductPrice();

                                        /*String qtyAvailable = StringUtil.createFixedWidthString(Integer.toString(item.getQuantityAvailable()),20);
                                        String description = StringUtil.createFixedWidthString(item.getProductDescription(),80);
                                        String barCodeNum = StringUtil.createFixedWidthString(item.getBarcodeNumber(),30);
                                        String reorderQty = StringUtil.createFixedWidthString(Integer.toString(item.getReorderQuantity()),30);
View Full Code Here

TOP

Related Classes of sg.edu.nus.iss.se07.bc.Product

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.