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

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


        String listForReorder="List of Product below TrashHold are";
        btnCheckOut.setEnabled(false);
        try {
          if (txtPaymentAmt.getText().trim().length() != 0) {
            for (int i = 0; i < productList.size(); i++) {
              Product p = productList.get(i);
              int qty = qtyList.get(i);
              addpurchase(p, txtMemberId.getText().toString(),
                  qty);
            }
            if (appController.addTransactions(purchases, finaldeem)) {
              // Print Function must write here
              ArrayList<Product> plist = appController
                  .getProductBelowThreshold();
              if (plist != null) {
                for (int j = 0; j < plist.size(); j++) {
                  Product p = plist.get(j);
                  listForReorder += p.getProductName();
                  if (j < plist.size() - 1) {
                    listForReorder += ",";
                  }
                  MessageDialog m = new MessageDialog(mainForm,
                      "Product Below Threshold",
                      listForReorder);
                  m.setResizable(false);
                  m.setVisible(true);
                }
               
              }
    //            printReceiptDialog = new PrintReceiptDialog(mainForm,"Update Discount Detail",lstDiscount.getSelectedItem());
                MessageDialog m = new MessageDialog(mainForm,
                    "Adding Transaction",
                    "Transaction is successfully added.");
                m.setResizable(false);
                m.setVisible(true);
                  clear();
                 
                  // Print Function must write here
                                String reportfilename = appController.printTransactionReceipt(purchases, finaldeem, txtMemberId.getText(), totalAmt, deempoint, dis, grandtotal);

                                viewReport = new ViewReportPanel(mainForm, reportfilename, "Transaction Report");
                                viewReport.setVisible(true);

            }
          }else{
            MessageDialog m = new MessageDialog(mainForm,
                "Enter Payment Amount",
                "Enter Payment Amount Before CheckOut");
            m.setResizable(false);
            m.setVisible(true);
          }

        } catch (AppException ex) {
          MessageDialog m = new MessageDialog(mainForm,
              "Error in Transaction.",
              ex.getMessage());
          m.setResizable(false);
          m.setVisible(true);

        }
       
      }

    };
    btnCheckOut.addActionListener(l);

    btnCancel = new Button("Cancel");
    l = new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        mainForm.setLblTitle("");
        setVisible(false);
      }

    };
    btnCancel.addActionListener(l);

    p.add(btnCheckOut);
    p.add(btnCancel);
    return p;
  }
View Full Code Here


        public void testDataEntry() {
                ProductManager dataObjectManager = new ProductManager(productDB, productDBFormat);

                //create new product
                Product dataObject1 = new Product("CLO/1","Centenary Jumper","A really nice momento",315,(float) 21.45,"1234",10,100);
                try {
                        dataObjectManager.addProduct(dataObject1);
                } catch (AppException ex) {
                        //Logger.getLogger(TestProduct.class.getName()).log(Level.SEVERE, null, ex);
                }

                Product dataObject2 = new Product("MUG/1","Centenary Mug","A really nice mug this time",525,(float) 10.25,"9876",25,150);
                try {
                        dataObjectManager.addProduct(dataObject2);
                } catch (AppException ex) {
                        //Logger.getLogger(TestProduct.class.getName()).log(Level.SEVERE, null, ex);
                }

                Product dataObject3 = new Product("STA/1","NUS Pen","A really cute blue pen",768,(float) 5.75,"123459876",50,250);
                try {
                        dataObjectManager.addProduct(dataObject3);
                } catch (AppException ex) {
                        //Logger.getLogger(TestProduct.class.getName()).log(Level.SEVERE, null, ex);
                }
               
                Product dataObject4 = new Product("STA/2","NUS Notepad","Great notepad for those lectures",1000,(float) 3.15,"6789",25,75);
                try {
                        dataObjectManager.addProduct(dataObject3);
                } catch (AppException ex) {
                        //Logger.getLogger(TestProduct.class.getName()).log(Level.SEVERE, null, ex);
                }               
View Full Code Here

                                                        String[] stProduct = s.split(",");
                                                        qtyA = Integer.parseInt(stProduct[3]);
                                                        price = Float.parseFloat(stProduct[4]);
                                                        rQ = Integer.parseInt(stProduct[6]);
                                                        oQ = Integer.parseInt(stProduct[7]);
                                                        Product c = new Product(stProduct[0], stProduct[1], stProduct[2], qtyA, price, stProduct[5], rQ, oQ);
                                                        content.add(c);
                                                        //destroy Object Vendor
                                                        c = null;

                                                }
View Full Code Here

                                        float productPrice = productSet.get(i).getItem5().getValue();
                                        String barcodeNumber = productSet.get(i).getItem6().getValue();
                                        int reorderQuantity = productSet.get(i).getItem7().getValue();
                                        int orderQuantity = productSet.get(i).getItem8().getValue();

                                        Product product = new Product(productID, productName, productDescription, quantityAvailable, productPrice, barcodeNumber, reorderQuantity, orderQuantity);

                                        String data = product.toCSVFormat(format);
                                        FileUtil.writeContents(bw, data);
                                }
                        } else {
                                throw new AppException("[ProductDA::writeDataSet]Failed to create filename " + fileName, "[ProductDA::writeDataSet]", null);
                        }
View Full Code Here

         * @param productID
         * @return Product records in form Array List.
         * @throws AppException
         */
        public Product readData(String productID) throws AppException {
                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 AppException("[ProductDA::readData]Record not found.", "[ProductDA::readData]", null);
                                } else {

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

                                        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 AppException("[ProductDA::readData]Unable to read record no " + (String.valueOf(i + 1)), "[ProductDA::readData]", null);
                                                } else {
                                                        if (fields.length != 8) {
                                                                Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {
                                                                boolean recordValid = true;

                                                                String prodID = fields[0];
                                                                if (prodID == null) {
                                                                        prodID = "-";
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ProductID\n");
                                                                }

                                                                String productName = fields[1];
                                                                if (productName == null) {
                                                                        productName = "-";
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ProductName\n");
                                                                }

                                                                String productDescription = fields[2];
                                                                if (productDescription == null) {
                                                                        productDescription = "-";
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ProductDescription\n");
                                                                }

                                                                int quantityAvailable = 0;
                                                                try {
                                                                        quantityAvailable = Integer.parseInt(fields[3]);
                                                                } catch (NumberFormatException nfx) {
                                                                        recordValid = false;
                                                                        quantityAvailable = 0;
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: QuantityAvailable\n" +
                                                                                "Value: " + String.valueOf(quantityAvailable), nfx);
                                                                //throw new AppException(nfx.getMessage(), nfx);
                                                                }

                                                                float productPrice = -9999.9999f;
                                                                try {
                                                                        productPrice = Float.parseFloat(fields[4]);
                                                                } catch (NumberFormatException nfx) {
                                                                        recordValid = false;
                                                                        productPrice = -9999.9999f;
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ProductPrice\n" +
                                                                                "Value: " + String.valueOf(productPrice), nfx);
                                                                //throw new AppException(nfx.getMessage(), nfx);
                                                                }

                                                                String barcodeNumber = fields[5];
                                                                if (barcodeNumber == null) {
                                                                        barcodeNumber = "-";
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: BarCode Number\n");
                                                                }


                                                                int reorderQuantity = 0;
                                                                try {
                                                                        reorderQuantity = Integer.parseInt(fields[6]);
                                                                } catch (NumberFormatException nfx) {
                                                                        recordValid = false;
                                                                        productPrice = -9999.9999f;
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ReOrderQuantity\n" +
                                                                                "Value: " + String.valueOf(reorderQuantity), nfx);
                                                                //throw new AppException(nfx.getMessage(), nfx);
                                                                }


                                                                int orderQuantity = Integer.parseInt(fields[7]);
                                                                try {
                                                                        orderQuantity = Integer.parseInt(fields[7]);
                                                                } catch (NumberFormatException nfx) {
                                                                        recordValid = false;
                                                                        productPrice = -9999.9999f;
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: OrderQuantity\n" +
                                                                                "Value: " + String.valueOf(orderQuantity), nfx);
                                                                //throw new AppException(nfx.getMessage(), nfx);
                                                                }

                                                                if (!recordValid) {
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.WARNING, "Some records are found invalid. Default value are assigned.");
                                                                }

                                                                if (productID.equalsIgnoreCase(prodID)) {
                                                                        dataObject = new Product();
                                                                        dataObject.setProductID(prodID);
                                                                        dataObject.setProductName(productName);
                                                                        dataObject.setProductDescription(productDescription);
                                                                        dataObject.setQuantityAvailable(quantityAvailable);
                                                                        dataObject.setProductPrice(productPrice);
                                                                        dataObject.setBarcodeNumber(barcodeNumber);
                                                                        dataObject.setReorderQuantity(reorderQuantity);
                                                                        dataObject.setOrderQuantity(orderQuantity);
                                                                        i = lines.length;
                                                                }
                                                        }
                                                }
                                        }
View Full Code Here

                                        int sequence = 0;                                       
                                        Category dataObject = categoryDataSet.get(category.getCategoryCode());
                                        if (dataObject != null) {
                                                Enumeration<Product> enumeration = dataObject.getProducts().elements();
                                                while(enumeration.hasMoreElements()) {
                                                        Product object = enumeration.nextElement();
                                                        String id = object.getProductID();
                                                        String temp[] = StringUtil.parse(id, "/");
                                                        if (temp!=null) {                                                               
                                                                int seq = 0;
                                                                try {
                                                                        seq = Integer.parseInt(temp[1]);
View Full Code Here

                                                        String[] stProduct = s.split(",");
                                                        qtyA = Integer.parseInt(stProduct[3]);
                                                        price = Float.parseFloat(stProduct[4]);
                                                        rQ = Integer.parseInt(stProduct[6]);
                                                        oQ = Integer.parseInt(stProduct[7]);
                                                        Product c = new Product(stProduct[0], stProduct[1], stProduct[2], qtyA, price, stProduct[5], rQ, oQ);
                                                        content.add(c);
                                                        //destroy Object Vendor
                                                        c = null;

                                                }
View Full Code Here

                                        float productPrice = productSet.get(i).getItem5().getValue();
                                        String barcodeNumber = productSet.get(i).getItem6().getValue();
                                        int reorderQuantity = productSet.get(i).getItem7().getValue();
                                        int orderQuantity = productSet.get(i).getItem8().getValue();

                                        Product product = new Product(productID, productName, productDescription, quantityAvailable, productPrice, barcodeNumber, reorderQuantity, orderQuantity);

                                        String data = product.toCSVFormat(format);
                                        FileUtil.writeContents(bw, data);
                                }
                        } else {
                                throw new AppException("[ProductDA::writeDataSet]Failed to create filename " + fileName, "[ProductDA::writeDataSet]", null);
                        }
View Full Code Here

         * @param productID
         * @return Category records in form Array List.
         * @throws AppException
         */
        public Product readData(String productID) throws AppException {
                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 AppException("[ProductDA::readData]Record not found.", "[ProductDA::readData]", null);
                                } else {

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

                                        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 AppException("[ProductDA::readData]Unable to read record no " + (String.valueOf(i + 1)), "[ProductDA::readData]", null);
                                                } else {
                                                        if (fields.length != 8) {
                                                                Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + " is corrupted");
                                                        } else {
                                                                boolean recordValid = true;

                                                                String prodID = fields[0];
                                                                if (prodID == null) {
                                                                        prodID = "-";
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ProductID\n");
                                                                }

                                                                String productName = fields[1];
                                                                if (productName == null) {
                                                                        productName = "-";
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ProductName\n");
                                                                }

                                                                String productDescription = fields[2];
                                                                if (productDescription == null) {
                                                                        productDescription = "-";
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ProductDescription\n");
                                                                }

                                                                int quantityAvailable = 0;
                                                                try {
                                                                        quantityAvailable = Integer.parseInt(fields[3]);
                                                                } catch (NumberFormatException nfx) {
                                                                        recordValid = false;
                                                                        quantityAvailable = 0;
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: QuantityAvailable\n" +
                                                                                "Value: " + String.valueOf(quantityAvailable), nfx);
                                                                //throw new AppException(nfx.getMessage(), nfx);
                                                                }

                                                                float productPrice = -9999.9999f;
                                                                try {
                                                                        productPrice = Float.parseFloat(fields[4]);
                                                                } catch (NumberFormatException nfx) {
                                                                        recordValid = false;
                                                                        productPrice = -9999.9999f;
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ProductPrice\n" +
                                                                                "Value: " + String.valueOf(productPrice), nfx);
                                                                //throw new AppException(nfx.getMessage(), nfx);
                                                                }

                                                                String barcodeNumber = fields[5];
                                                                if (barcodeNumber == null) {
                                                                        barcodeNumber = "-";
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: BarCode Number\n");
                                                                }


                                                                int reorderQuantity = 0;
                                                                try {
                                                                        reorderQuantity = Integer.parseInt(fields[6]);
                                                                } catch (NumberFormatException nfx) {
                                                                        recordValid = false;
                                                                        productPrice = -9999.9999f;
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: ReOrderQuantity\n" +
                                                                                "Value: " + String.valueOf(reorderQuantity), nfx);
                                                                //throw new AppException(nfx.getMessage(), nfx);
                                                                }


                                                                int orderQuantity = Integer.parseInt(fields[7]);
                                                                try {
                                                                        orderQuantity = Integer.parseInt(fields[7]);
                                                                } catch (NumberFormatException nfx) {
                                                                        recordValid = false;
                                                                        productPrice = -9999.9999f;
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.SEVERE, "" +
                                                                                "[ProductDA::readData]Record no " + (String.valueOf(i + 1)) + "is corrupted.\n" +
                                                                                "Field: OrderQuantity\n" +
                                                                                "Value: " + String.valueOf(orderQuantity), nfx);
                                                                //throw new AppException(nfx.getMessage(), nfx);
                                                                }

                                                                if (!recordValid) {
                                                                        Logger.getLogger(ProductDA.class.getName()).log(Level.WARNING, "Some records are found invalid. Default value are assigned.");
                                                                }

                                                                if (productID.equalsIgnoreCase(prodID)) {
                                                                        dataObject = new Product();
                                                                        dataObject.setProductID(prodID);
                                                                        dataObject.setProductName(productName);
                                                                        dataObject.setProductDescription(productDescription);
                                                                        dataObject.setQuantityAvailable(quantityAvailable);
                                                                        dataObject.setProductPrice(productPrice);
                                                                        dataObject.setBarcodeNumber(barcodeNumber);
                                                                        dataObject.setReorderQuantity(reorderQuantity);
                                                                        dataObject.setOrderQuantity(orderQuantity);
                                                                        i = lines.length;
                                                                }
                                                        }
                                                }
                                        }
View Full Code Here

        }

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

                Product dataObject = new Product(id, name, description, quantity, price, barcode, reorderQty, orderQty);
                ProductManager dataObjectManager = new ProductManager();
                try {
                        success = dataObjectManager.addProduct(dataObject);
                } catch (AppException ex) {
                        //Logger.getLogger(AppController.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
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.