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

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


        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 String printMemberReport() throws AppException {
                boolean success = true;
                String reportfilename = "";

                MemberReport memberReport = new MemberReport();
                try {
                        success = memberReport.generateReport();
                        if (success) {
                                reportfilename = memberReport.getFileOutputName();
                        }
                } catch (AppException ex) {
                        success = false;
                        Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
                        throw ex;
View Full Code Here

                System.out.println();
                System.out.println();

                System.out.println("List of Member");
                MemberReport memberReport = null;
                try {
                        memberReport = new MemberReport();
                        memberReport.setShowHeader(false);
                        memberReport.setShowFooter(false);
                        memberReport.generateReport();
                } catch (DataAccessException ex) {
                        Logger.getLogger(TestReport.class.getName()).log(Level.SEVERE, null, ex);
                } finally {
                        memberReport = null;
                }
View Full Code Here

        }

        public void testReport(String outputfilename, boolean header, String headertitle, boolean footer, String footertitle) {

                MemberReport dataObjectReport = new MemberReport("Member Report", memberDBFormat, memberDB, outputfilename, header, footer);
                dataObjectReport.setHeader(headertitle);
                dataObjectReport.setFooter(footertitle);
               
                try {
                        dataObjectReport.generateReport();
                } catch (AppException ex) {
                        Logger.getLogger(TestMember.class.getName()).log(Level.SEVERE, null, ex);
                }
               
                dataObjectReport = null;
View Full Code Here

        public String printMemberReport() throws AppException {
                boolean success = true;
                String reportfilename = "";

                MemberReport memberReport = new MemberReport();
                try {
                        success = memberReport.generateReport();
                        if (success) {
                                reportfilename = memberReport.getFileOutputName();
                        }
                } catch (AppException ex) {
                        success = false;
                        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

TOP

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

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.