}
//修改用户
public boolean update(HttpServletRequest req) throws Exception {
if (getRequest(req)){
sqlStr = "update shop_user set ";
sqlStr = sqlStr + "username = '" + dataFormat.toSql(user.getUserName()) + "',";
sqlStr = sqlStr + "password = '" + dataFormat.toSql(user.getPassWord()) + "',";
sqlStr = sqlStr + "Names = '" + dataFormat.toSql(user.getNames()) + "',";
sqlStr = sqlStr + "sex = '" + dataFormat.toSql(user.getSex()) + "',";
sqlStr = sqlStr + "address = '" + dataFormat.toSql(user.getAddress()) + "',";
sqlStr = sqlStr + "phone = '" + dataFormat.toSql(user.getPhone()) + "',";
sqlStr = sqlStr + "post = '" + dataFormat.toSql(user.getPost()) + "',";
sqlStr = sqlStr + "Email = '" + dataFormat.toSql(user.getEmail()) + "' ";
sqlStr = sqlStr + " where id = '" + user.getId() + "'";
try{
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
stmt.execute(sqlStr);
return true;
} catch (SQLException e){
return false;
}
} else {
return false;
}
}
//删除用户
public boolean delete( long aid ) throws Exception {
sqlStr = "delete from shop_user where id = " + aid ;
try{
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
stmt.execute(sqlStr);
return true;
}catch (SQLException e){
System.out.println(e);
return false;
}
}
//查询指定id的用户,用于支持页面的查看详细资料请求
public boolean getUserinfo(long newid ) throws Exception {
try{
sqlStr="select * from shop_user where Id = " + newid ;
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
rs = stmt.executeQuery(sqlStr);
userlist = new Vector();
while (rs.next()){
user.setId(rs.getLong("id"));
System.out.print(rs.getLong("id"));
user.setUserName(rs.getString("username"));
user.setPassWord(rs.getString("password"));
user.setNames(rs.getString("names"));
user.setSex(rs.getString("sex"));
user.setAddress(rs.getString("address"));
user.setPhone(rs.getString("Phone"));
user.setPost(rs.getString("post"));
user.setEmail(rs.getString("email"));
user.setRegTime(rs.getString("regtime"));
user.setRegIpAddress(rs.getString("RegIpaddress"));
user.setUserPoint(rs.getInt("userpoint"));
userlist.addElement(user);
}
close();
return true;
}catch (Exception e){
System.out.print(e.getMessage());
return false;
}
}
//修改用户积分
public boolean updateUserPoint(String userid,int num)
{
String point=num+"";
String sql="EXECUTE updateUserPoint "+userid+","+point;
//String sql="update shop_user set userpoint=userpoint +"+num+" where id='"+userid+"'";
try{
DataBase db = new DataBase();
db.connect();
stmt = db.conn.createStatement ();
System.out.println(sql);
stmt.execute(sql);
return true;
} catch (SQLException e){
System.out.println(e.toString());
return false;
}
}
//取得用户的积分
public int getUserPoint(String userid)
{
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] 下一页