Package com.charitas.model

Examples of com.charitas.model.Product


        PreparedStatement statement = connection.prepareStatement(sql);
        statement.setInt(1, i);
        ResultSet resultSet = statement.executeQuery();
        //List<Product> list = new ArrayList<>();
       
        Product prod = null;
        if (resultSet.next()){
           
            Category cat  = new Category();
            cat.setId(resultSet.getInt("category_id"));
            cat.setName(resultSet.getString("category_name"));
           
            prod = new Product();
            prod.setCategory(cat);
            prod.setDescription(resultSet.getString("description"));
            prod.setExpiredDate(resultSet.getDate("expireddate"));
            prod.setId(resultSet.getInt("product_id"));
            prod.setName(resultSet.getString("name"));
            prod.setPrice(resultSet.getDouble("price"));
           
            //list.add(prod);
        }
        return prod;
    }
View Full Code Here


        while (result.next()){
            Category cat = new Category();
            cat.setId(result.getInt("category_id"));
            cat.setName(result.getString("category_name"));
           
            Product prod = new Product();
            prod.setCategory(cat);
            prod.setDescription(result.getString("description"));
            prod.setPrice(result.getDouble("price"));
            prod.setExpiredDate(result.getDate("expiredDate"));
            prod.setId(result.getInt("product_id"));
            prod.setName(result.getString("name"));
           
            list.add(prod);
        }
               
        return list;
View Full Code Here

            Calendar cal = Calendar.getInstance();
           
            Category cat1 = new Category();
            cat1.setId(1);
           
            Product prod1 =new Product();
            prod1.setCategory(cat1);
            prod1.setDescription("tes prod");
            prod1.setExpiredDate(cal.getTime());
            prod1.setName("permen");
            prod1.setPrice(7500);
            productDAO.save(prod1);
                   
            Product product = new Product();
            List<Product> allData = productDAO.findAll();
           
            for(int i = 0; i < allData.size(); i++ ){
                Category cat = new Category();
               
                product = allData.get(i);
                cat = product.getCategory();
                       
                System.out.println("Id produk = " + product.getId() + "  " + product.getName() + "  " + cat.getId()+ "  " + cat.getName());
            }
            /*
            try {       
                CategoryDAO categoryDAO = new CategoryDAOImpl(DatabaseConnection.getInstance().getConnection());
               
View Full Code Here

    //private ProductDAO productDAO;
    private CategoryDAO categoryDAO;

    private void packData() {
        if (product == null) {
            product = new Product();
        }
        product.setName(TxtName.getText());
        product.setDescription(TextAreaDescription.getText());
        product.setExpiredDate(DateChooserExpired.getDate());
        product.setCategory(categorys.get(ComboBoxCategory.getSelectedIndex()));
View Full Code Here

        for (int i = 0; products != null && i < products.size(); i++ ){
           
            SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
           
           
            Product product = products.get(i);
            DecimalFormat decimalFormat = new DecimalFormat("#,###.00");
           
           
            data[i][0] = product.getId();
            data[i][1] = product.getName();
            data[i][2] = product.getCategory().getName();
            data[i][3] = decimalFormat.format(product.getPrice());
                    //product.getPrice();
            data[i][4] =  sdf.format(product.getExpiredDate());
                    //product.getExpiredDate();
            data[i][5] = product.getDescription();
           
        }
       
        String[] Judul = {"id","nama","category", "price","expireed","desc"};
               
View Full Code Here

    private void ButtonAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonAddActionPerformed
        // TODO add your handling code here:
        if (dialog == null ){
            dialog = new DialogProduct(SwingUtil.getParentJFrame(this), true);
        }
        dialog.setProduct(new Product());
        dialog.setVisible(true);
        if ( dialog.getMode() == DialogProduct.SAVE_MODE ){
            Product product = dialog.getProduct();
            try{
            if (product.getId() <=0 ){               
                productDAO.save(product);               
            }else{
                productDAO.update(product.getId(), product);
            }
           
            } catch(SQLException ex){
                JOptionPane.showMessageDialog(this, ex.getMessage(),"Sql Exception",JOptionPane.ERROR_MESSAGE);
            }
View Full Code Here

            if (dialog == null){
                    dialog = new DialogProduct(SwingUtil.getParentJFrame(this), true);
                }
            int id = (Integer) TableProduct.getValueAt(TableProduct.getSelectedRow(), 0);

            Product product = null;
           
            try {
               
                product = productDAO.findById(id);
            } catch (SQLException ex) {
                Logger.getLogger(InternalFrameProduct.class.getName()).log(Level.SEVERE, null, ex);
                JOptionPane.showMessageDialog(this, ex.getMessage(),"Sql Exception", JOptionPane.ERROR_MESSAGE);
                return ;
            }
            dialog.setProduct(product);
            dialog.setVisible(true);
           
            if(dialog.getMode() == DialogProduct.SAVE_MODE){
                product = dialog.getProduct();
                try {
                    productDAO.update(product.getId(), product );
                } catch (SQLException ex) {
                    Logger.getLogger(InternalFrameProduct.class.getName()).log(Level.SEVERE, null, ex);
                }
               
            }
View Full Code Here

TOP

Related Classes of com.charitas.model.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.