Example #1
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";
  }
Example #2
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;
  }
Example #3
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;
  }
Example #4
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;
  }
Example #5
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;
  }
Example #6
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;
  }
Example #7
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;
 }