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

Examples of sg.edu.nus.iss.se07.bc.category.CategoryManager


        public boolean addMember(String id, String name) throws AppException {
                boolean success = true;

                Member dataObject = new Member(id, name);
                MemberManager dataObjectManager = new MemberManager();

                try {
                        success = dataObjectManager.addMember(dataObject);
                        if (success) {
                                //update to the cache
                                Hashtable<String, Member> memberDataSet = DataSet.getMemberDataSet();
                                if (memberDataSet != null) {
                                        memberDataSet.put(id, dataObject);
View Full Code Here


        public boolean updateMember(String id, String newName) throws AppException {

                boolean success = true;

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

                if (oldDataObject != null) {
                        Member newDataObject = new Member(id, newName, oldDataObject.getMemberPoint());
                        try {
                                success = dataObjectManager.updateMember(oldDataObject, newDataObject);
                                if (success) {
                                        //update to the cache
                                        Hashtable<String, Member> memberDataSet = DataSet.getMemberDataSet();
                                        if (memberDataSet != null) {
                                                memberDataSet.remove(id);
View Full Code Here

        }

        public boolean updateMember(String id, int newPoint) throws AppException {
                boolean success = true;

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

                if (oldDataObject != null) {
                        Member newDataObject = new Member(id, oldDataObject.getMemberName(), newPoint);
                        try {
                                success = dataObjectManager.updateMember(oldDataObject, newDataObject);
                                if (success) {
                                        //update to the cache
                                        Hashtable<String, Member> memberDataSet = DataSet.getMemberDataSet();
                                        if (memberDataSet != null) {
                                                memberDataSet.remove(id);
View Full Code Here

        }

        public ArrayList<Member> listMember() throws AppException {
                ArrayList<Member> dataObjectSet = null;

                MemberManager dataObjectManager = new MemberManager();
                try {
                        dataObjectSet = dataObjectManager.listMember();
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }
View Full Code Here

        }

        public int getMemberPoint(String id) throws AppException {
                int point = -99999;

                MemberManager dataObjectManager = new MemberManager();
                Member dataObject = null;
                try {
                        dataObject = dataObjectManager.selectMember(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }
View Full Code Here

        }

        public boolean removeMember(String id, String name) throws AppException {
                boolean success = true;

                MemberManager dataObjectManager = new MemberManager();

                try {
                        success = dataObjectManager.deleteMember(id);
                        if (success) {
                                //update to the cache
                                Hashtable<String, Member> memberDataSet = DataSet.getMemberDataSet();
                                memberDataSet.remove(id);
                        }
View Full Code Here

        }

        public Member selectMember(String id) throws AppException {
                Member dataObject = null;

                MemberManager memberManager = new MemberManager();
                try {
                        dataObject = memberManager.selectMember(id);
                } catch (AppException ex) {
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
                }
View Full Code Here

                                        int productQty = productSet.get(i).getItem4().getValue();
                                        float productPrice = productSet.get(i).getItem5().getValue();
                                        String productBarcode = productSet.get(i).getItem6().getValue();
                                        int productReorderQty = productSet.get(i).getItem7().getValue();
                                        int productOrderQty = productSet.get(i).getItem8().getValue();
                                        Product product = new Product(productID, productName, productDesc, productQty, productPrice, productBarcode, productReorderQty, productOrderQty);
                                        String data = product.toCSVFormat(format);
                                        FileUtil.writeContents(bw, data);
                                }
                        } else {
                                throw new DataAccessException("[ProductDA::writeData]Failed to create filename " + fileName);
                        }
View Full Code Here

         *
         * @param productCode
         * @return Product records in form Array List.
         */
        public Product readData(String productCode) throws DataAccessException {
                Product dataObject = null;
                BufferedReader br = null;

                try {
                        br = FileUtil.getBufferedReader(fileName);
                        if (br != null) {
                                String contents = FileUtil.getContents(br);
                                if (contents == null) {
                                        return null;
                                }
                                String[] lines = StringUtil.parse(contents, format.getEndOfLineSymbols());
                                if (lines == null) {
                                        throw new DataAccessException("[ProductDA::readData]Record not found.");
                                } else {

                                        if (lines.length < 1) {
                                                throw new DataAccessException("[ProductDA::readData]Record not found.");
                                        }

                                        for (int i = 0; i < lines.length; i++) {
                                                String record = lines[i];
                                                String[] fields = StringUtil.parse(record, String.valueOf((char) format.getDelimiterChar()));
                                                if (fields == null) {
                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "[ProductDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                        throw new DataAccessException("[ProductDA::readData]Unable to read record no " + (String.valueOf(i + 1)));
                                                } else {
                                                        if (fields.length != 8) {
                                                                Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {
                                                                String id = fields[0];
                                                                String name = fields[1];
                                                                String desc = fields[2];

                                                                int qty = -1;
                                                                try {
                                                                        qty = Integer.parseInt(fields[3]);
                                                                } catch (NumberFormatException nfx) {
                                                                        throw new DataAccessException(nfx.getMessage(), nfx);
                                                                }

                                                                float price = 0f;
                                                                try {
                                                                        price = Float.parseFloat(fields[4]);
                                                                } catch (NumberFormatException nfx) {
                                                                        throw new DataAccessException(nfx.getMessage(), nfx);
                                                                }

                                                                String barcode = fields[5];

                                                                int reorderQty = -1;
                                                                try {
                                                                        reorderQty = Integer.parseInt(fields[6]);
                                                                } catch (NumberFormatException nfx) {
                                                                        throw new DataAccessException(nfx.getMessage(), nfx);
                                                                }

                                                                int orderQty = -1;
                                                                try {
                                                                        orderQty = Integer.parseInt(fields[7]);
                                                                } catch (NumberFormatException nfx) {
                                                                        throw new DataAccessException(nfx.getMessage(), nfx);
                                                                }


                                                                if (productCode.equalsIgnoreCase(id)) {
                                                                        dataObject = new Product();
                                                                        dataObject.setProductID(id);
                                                                        dataObject.setProductName(name);
                                                                        dataObject.setProductDescription(desc);
                                                                        dataObject.setQuantityAvailable(qty);
                                                                        dataObject.setProductPrice(price);
                                                                        dataObject.setBarcodeNumber(barcode);
                                                                        dataObject.setReorderQuantity(reorderQty);
                                                                        dataObject.setOrderQuantity(orderQty);
                                                                        i = lines.length;
                                                                }
                                                        }
                                                }
                                        }
View Full Code Here

                Button b = new Button("Order");
                ActionListener l = new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                          Vendor v=getSelectedVendor();
                          final Product product=getSelectedProduct();
                          if(v!=null){

                            String ConfirmMessage="Are you sure to order this "+product.getProductName()+" from "+v.getVendorName()+"with $"+ product.getProductPrice()+"\n and "+product.getOrderQuantity() ;
                            ConfirmDialog d=new ConfirmDialog(mainForm,"Order Confirmation",ConfirmMessage){

                  protected boolean performOKAction() {
                    boolean success=false;
                    try{
                     
                    if(appController.increaseProductQty(product.getProductID(),product.getReorderQuantity())==true){
                      String Message=product.getProductName()+"with $"+ product.getProductPrice()+" and "+product.getReorderQuantity()+ "\n has been ordered successfully.";
                      MessageDialog m=new MessageDialog(mainForm,"Ordering Product Successfully",Message);
                      m.setVisible(true);
                      refreshProductListPanel();
                      lstVendor.removeAll();
                      success=true;
View Full Code Here

TOP

Related Classes of sg.edu.nus.iss.se07.bc.category.CategoryManager

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.