Esempio n. 1
0
 public static void updateQuantity(String email, String appendNo, String product_id, int qty) {
   // ResultSet rs;
   String query =
       "update cart set quantity='"
           + qty
           + "'"
           + " where email='"
           + email
           + "' and cartAppendNo='"
           + appendNo
           + "' and productId='"
           + product_id
           + "'";
   System.out.println("********" + query);
   Connection con = DB.getConnection();
   // rs=DB.readFromDB(query, connection);
   try {
     Statement stmt = (Statement) con.createStatement();
     stmt.executeUpdate(query);
   } catch (Exception e) {
     System.out.println("In Cart.java");
   }
   // DB.close(rs);
   DB.close(con);
 }
Esempio n. 2
0
 public static void removeItem(String email, String appendNo, String product_id) {
   // ResultSet rs;
   String query =
       "delete from cart  where email='"
           + email
           + "' and cartAppendNo='"
           + appendNo
           + "' and productId='"
           + product_id
           + "'";
   System.out.println("********" + query);
   Statement stmt = null;
   Connection con = DB.getConnection();
   // rs=DB.readFromDB(query, connection);
   try {
     stmt = (Statement) con.createStatement();
     stmt.executeUpdate(query);
   } catch (Exception e) {
     System.out.println("In Cart.java");
   }
   // DB.close(rs);
   try {
     stmt.close();
     DB.close(con);
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Esempio n. 3
0
  public static String checkProduct(String prodId, String mailid, String appendNo) {
    int count = 0;
    ResultSet resultSet = null;
    String query =
        "select count(*) from cart where email='"
            + mailid
            + "'and productId='"
            + prodId
            + "'and cartAppendNo='"
            + appendNo
            + "'";

    System.out.println("********" + query);
    Connection connection = DB.getConnection();
    resultSet = DB.readFromDB(query, connection);
    try {
      while (resultSet.next()) count = resultSet.getInt("count(*)");
      // System.out.println(result);

    } catch (SQLException e) {
      MyLog.myCatch("Product.java", 50, e);
      e.printStackTrace();
    }

    DB.close(resultSet);
    DB.close(connection);

    if (count != 0) return "found";
    else return "notfound";
  }
Esempio n. 4
0
  /*public static double getsubTotal(String productId)
  	{
  		double result=0;
  		ResultSet resultSet = null;
  		String query= "select price from product where productId='"+productId+"'";

  		System.out.println("********"+query);
  		Connection connection = DB.getConnection();
  		resultSet = DB.readFromDB(query, connection);
  		try {
  			while(resultSet.next())
  			result=(double)resultSet.getDouble("price");
  			//System.out.println(result);

  		} catch (SQLException e) {
              MyLog.myCatch("Course.java",50, e);
  			e.printStackTrace();
  		}
  		DB.close(resultSet);
  		DB.close(connection);
  		return result;

  	}
  */
  public static double getPrice(String productId) {
    double result = 0;
    ResultSet resultSet = null;
    String query = "select price from product where productId='" + productId + "'";

    System.out.println("********" + query);
    Connection connection = DB.getConnection();
    resultSet = DB.readFromDB(query, connection);
    try {
      while (resultSet.next()) result = (double) resultSet.getDouble("price");
      // System.out.println(result);

    } catch (SQLException e) {
      MyLog.myCatch("Course.java", 50, e);
      e.printStackTrace();
    }
    DB.close(resultSet);
    DB.close(connection);
    return result;
  }
Esempio n. 5
0
  public static String getItemDescription(String productId) {
    String result = "";
    ResultSet resultSet = null;
    String query = "select description from product where productId='" + productId + "'";

    System.out.println("********" + query);
    Connection connection = DB.getConnection();
    resultSet = DB.readFromDB(query, connection);
    try {
      while (resultSet.next()) result = resultSet.getString("description");
      // System.out.println(result);

    } catch (SQLException e) {
      MyLog.myCatch("Course.java", 50, e);
      e.printStackTrace();
    }
    DB.close(resultSet);
    DB.close(connection);
    return result;
  }
Esempio n. 6
0
  // public static double amount=0;
  // public  ArrayList<Cart> CartList=new ArrayList<Cart>();
  public static String getCurrentAppendNo(String email) {
    String result = "";
    ResultSet resultSet = null;
    String query = "select CartAppendNo from customer where email ='" + email + "'";

    System.out.println("********" + query);
    Connection connection = DB.getConnection();
    resultSet = DB.readFromDB(query, connection);
    try {
      while (resultSet.next()) result = resultSet.getString("CartAppendNo");
      System.out.println(result);

    } catch (SQLException e) {
      MyLog.myCatch("Course.java", 50, e);
      e.printStackTrace();
    }
    DB.close(resultSet);
    DB.close(connection);

    return result;
  }
Esempio n. 7
0
  public static boolean checkCurrentCart(String email, String appendNo) {
    String result = "";
    ResultSet resultSet = null;
    String query =
        "select * from cart where email ='" + email + "' and CartAppendNo='" + appendNo + "'";

    System.out.println("********" + query);
    Connection connection = DB.getConnection();
    resultSet = DB.readFromDB(query, connection);
    try {
      while (resultSet.next()) result = resultSet.getString("CartAppendNo");
      // System.out.println(result);

    } catch (SQLException e) {
      MyLog.myCatch("Course.java", 50, e);
      e.printStackTrace();
    }
    DB.close(resultSet);
    DB.close(connection);
    if (result == "") return false;
    else return true;
  }
Esempio n. 8
0
  public static ArrayList<Cart> getCart(String email, String appendNo) {
    ArrayList<Cart> CartList = new ArrayList<Cart>();
    String result = "";
    ResultSet resultSet = null;
    String query =
        "select * from cart where email ='" + email + "' and CartAppendNo='" + appendNo + "'";

    System.out.println("********" + query);
    Connection connection = DB.getConnection();
    resultSet = DB.readFromDB(query, connection);
    try {
      while (resultSet.next()) {
        Cart obj = new Cart();
        obj.DeliveryTime = "2-3 days";
        obj.productId = resultSet.getString("productId");
        obj.ItemDesc = Cart.getItemDescription(resultSet.getString("productId"));
        System.out.println(obj.ItemDesc);
        obj.price = Cart.getPrice(resultSet.getString("productId"));
        obj.quantity = resultSet.getInt("quantity");
        obj.subtotal = (obj.quantity) * (Cart.getPrice(resultSet.getString("productId")));
        System.out.println(obj.subtotal);

        // amount+=obj.subtotal;
        CartList.add(obj);
      }
      // System.out.println(result);

    } catch (SQLException e) {
      MyLog.myCatch("Course.java", 50, e);
      e.printStackTrace();
    }
    DB.close(resultSet);
    DB.close(connection);

    return CartList;
  }
Esempio n. 9
0
 public static ArrayList<Cart> findAll(String selectionModifier) {
   ArrayList<Cart> selection = new ArrayList<Cart>();
   ResultSet rs = null;
   String query = "select * " + "from cart " + selectionModifier;
   Connection connection = DB.getConnection();
   rs = DB.readFromDB(query, connection);
   try {
     while (rs.next()) {
       Cart cart = new Cart();
       cart.cartId = rs.getInt("cartId");
       cart.email = rs.getString("email");
       cart.cartAppendNo = rs.getString("cartAppendNo");
       cart.productId = rs.getString("productId");
       cart.quantity = rs.getInt("quantity");
       selection.add(cart);
     }
   } catch (SQLException e) {
     MyLog.myCatch("Product.java", 50, e);
     e.printStackTrace();
   }
   DB.close(rs);
   DB.close(connection);
   return selection;
 }
Esempio n. 10
0
  public static int insertIntoCart(String email, String productId, String appendNo, int quantity) {

    String insertSQL =
        "insert into cart"
            + "(email,productId,cartAppendNo,quantity) "
            + "values('"
            + email
            + "','"
            + productId
            + "','"
            + appendNo
            + "','"
            + quantity
            + "')";
    return DB.update(insertSQL);
  }
Esempio n. 11
0
  public int insert() {
    // TODO Auto-generated method stub
    String insertSQL =
        "insert into cart"
            + "(email,cartAppendNo,productId,quantity) "
            + "values("
            + "'"
            + email
            + "','"
            + cartAppendNo
            + "', '"
            + productId
            + "','"
            + quantity
            + "');";

    System.out.println(insertSQL);

    return DB.update(insertSQL);
  }
Esempio n. 12
0
 public int delete(String email2) {
   // TODO Auto-generated method stub
   String deleteSQL = "delete from cart " + "where email= '" + email2 + "'";
   System.out.println(deleteSQL);
   return DB.update(deleteSQL);
 }