package bookshop.utils;
import java.sql.ResultSet;
import java.util.Date;
public class Users extends Execute_DB {
//定义成员变量
private int userID; //用户ID
private String usrName; //用户登录名
private String passwd; //用户登录密码
private String createTime; //用户账号创建时间
private String realName; //用户真实姓名
private String telephone; //用户电话
private String email; //用户邮箱
private int sysRole; //用户具有的权限
private String sql; //要执行的sql语句
//初始化成员变量
public Users() {
this.userID = 0;
this.usrName = "";
this.passwd = "";
this.sysRole = 0;
this.realName = "";
this.telephone = "";
this.email = "";
Date nowTime = new Date();
this.createTime = nowTime.toString();
this.sql = "";
}
//向users数据表中插入一条记录
public boolean add_user() {
System.out.println("开始插入--->");
// String sqltest = "select * from users;";
//if (super.exeSql(sqltest)) {
// System.out.println("执行成功!");
// }else System.out.println("插入失败!!!!");
// System.out.println("插入结束!---");
this.sql = "insert into users (userName ,password ,sysRole ,realName ,telephone ,email) values ('" + this.getUsrName() + "',";
this.sql += "'" + this.getPasswd() + "',";
this.sql += this.sysRole + ",";
this.sql += "'" + this.getRealName() + "',";
this.sql += "'" + this.getTelephone() + "',";
this.sql += "'" + this.getEmail() + "'";//,";
// this.sql += "'" + this.getCreateTime() + "'";
this.sql += ")";
// String sqltest = "insert into users (userName,password,sysRole,realName,telephone,email,createTime)"
// + " values ('" + this.getUsrName() + "','" + this.getPasswd() + "'," + this.getSysRole() + ",'" + this.getRealName()
// + "','" + this.getTelephone() + "','" + this.getEmail() + "','" + this.getCreateTime() + "')";
System.out.println("执行的此处了!");
// sql = "insert into users (userName,password,realName) values('zk12fsdfa3','12344abc','ZAJSH')";
// this.sql = sqltest;
boolean isInsertSuccess = super.exeSql(this.sql);
// boolean isInsertSuccess = super.exeSql(this.sql);
System.out.println(isInsertSuccess);
System.out.println("sql执行完毕!");
return isInsertSuccess;
}
//验证用户名,密码和用户身份信息是否正确
public boolean user_valid() {
this.sql = "select userName,password,sysRole from users ";
this.sql += "where userName='" + this.getUsrName() + "'";
this.sql += "and password='" + this.getPasswd() + "'";
this.sql += "and sysRole=" + this.getSysRole();
try {
ResultSet rs = super.exeSqlQuery(this.sql);
if (rs.next()) {
System.out.println(rs.getString(1));
return true;
} else {
System.out.println("验证失败!");
return false;
}
} catch (Exception ex) {
System.out.println(ex.toString());
System.out.println("查询失败!");
return false;
}
}
//判断用户名是否存在
public boolean is_exist() {
this.sql = "select * from users ";
this.sql += "where userName='" + this.getUsrName() + "'";
try {
ResultSet rs = super.exeSqlQuery(this.sql);
if (rs.next()) {
return true;
} else {
return false;
}
} catch (Exception ex) {
System.out.println(ex.toString());
return false;
}
}
//修改成员变量userID对应的用户信息
public boolean modify_info() {
this.sql = "update users set ";
this.sql += "realName='" + this.getRealName() + "',";
this.sql += "telephone='" + this.getTelephone() + "',";
this.sql += "email='" + this.getEmail() + "' where userID=" + this.userID;
boolean isUpdate = super.exeSql(this.sql);
return isUpdate;
}
//修改类成员变量userID对应的用户密码
public boolean modify_password() {
this.sql = "update users set ";
this.sql += "password='" + this.getPasswd() + "'";
this.sql += " where userID=" + this.getUserID();
boolean isUpdate = super.exeSql(this.sql);
return isUpdate;
}
//获取成员变量userID对应的用户信息
public boolean init() {
this.sql = "select * from users where userID=";
this.sql += this.getUserID();
try {
ResultSet rs = super.exeSqlQuery(this.sql);
if (rs.next()) {
this.setUsrName(rs.getString("userName"));
this.setPasswd(rs.getString("password"));
this.setRealName(rs.getString("realName"));
this.setEmail(rs.getString("email"));
this.setCreateTime(rs.getString("createTime"));
this.setSysRole(rs.getInt("sysRole"));
this.setUserID(rs.getInt("userID"));
return true;
} else {
return false;
}
} catch (Exception ex) {
System.out.println(ex.toString());
return false;
}
}
//获取userName对应的用户信息
public boolean init(String userName) {
this.sql = "select * from users where userName like '" + userName + "'";
try {
ResultSet rs = super.exeSqlQuery(this.sql);
if (rs.next()) {
this.userID = rs.getInt("userID");
System.out.println(userID);
this.setUsrName(rs.getString("userName"));
this.setPasswd(rs.getString("password"));
this.setRealName(rs.getString("realName"));
this.setEmail(rs.getString("email"));
this.setCreateTime(rs.getString("createTime"));
int sysRole1 = rs.getInt("sysRole");
this.setSysRole(sysRole1);
// this.setUserID(UserID);
System.out.println(this);
return true;
} else {
return false;
}
} catch (Exception ex) {
System.out.println(ex.toString());
return false;
}
}
//获取所有普通用户信息,返回一个ResultSet类型对象
public ResultSet show_users() {
//this.sql = "select * from users ";
// this.sql += "where sysRole=" + this.getSysRole();
this.sql = "select * from users";
ResultSet rs = null;
try {
rs = super.exeSqlQuery(this.sql);
} catch (Exception ex) {
System.out.println(ex.toString());
}
return rs;
}
/**
* @param usrName the usrName to set
*/
public void setUsrName(String usrName) {
this.usrName = usrName;
}
/**
* @param passwd the passwd to set
*/
public void setPasswd(String passwd) {
this.passwd = passwd;
}
/**
* @param createTime the createTime to set
*/
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
/**
* @param realName the realName to set
*/
public void setRealName(String realName) {
this.realName = realName;
}
/**
* @param telephone the telephone to set
*/
public void setTelephone(String telephone) {
this.telephone = telephone;
}
/**
* @param email the email to set
*/
public void setEmail(String email) {
this.email = email;
}
/**
* @return the usrNam
没有合适的资源?快使用搜索试试~ 我知道了~
数据库课程设计(文档和源代码).zip
共146个文件
jsp:84个
class:16个
java:16个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 10 浏览量
2021-12-07
20:41:19
上传
评论 1
收藏 5.28MB ZIP 举报
温馨提示
数据库课程设计(文档和源代码).zip
资源推荐
资源详情
资源评论
收起资源包目录
数据库课程设计(文档和源代码).zip (146个子文件)
Books.class 7KB
Users.class 6KB
modify_005fsort_005fsave_jsp.class 5KB
index_jsp.class 5KB
Sorts.class 4KB
Goods.class 4KB
LoginCheck.class 3KB
UserRegSave.class 3KB
Words.class 3KB
GetUserPassword.class 3KB
EncodingFilter.class 2KB
Open_DB.class 2KB
BaseConn.class 2KB
Execute_DB.class 2KB
PasswordChangeHandle.class 1KB
ConTest.class 461B
网上图书销售系统配置说明书.doc 1.04MB
网上图书销售系统.doc 1007KB
网上图书销售系统(首页).doc 27KB
小组成员成绩.doc 11KB
sqljdbc.jar 570KB
sqljdbc.jar 570KB
msbase.jar 280KB
mssqlserver.jar 66KB
msutil.jar 63KB
Users.java 10KB
Books.java 8KB
Sorts.java 6KB
Goods.java 5KB
LoginCheck.java 5KB
modify_005fsort_005fsave_jsp.java 5KB
UserRegSave.java 4KB
index_jsp.java 4KB
GetUserPassword.java 4KB
Words.java 3KB
PasswordChangeHandle.java 3KB
Execute_DB.java 2KB
Open_DB.java 2KB
BaseConn.java 1KB
EncodingFilter.java 1KB
ConTest.java 144B
book_detail.jsp 6KB
book_detail.jsp 6KB
goods_management.jsp 5KB
goods_management.jsp 5KB
search_book_result.jsp 5KB
search_book_result.jsp 5KB
my_goods_management.jsp 5KB
my_goods_management.jsp 5KB
modify_book_form.jsp 4KB
modify_book_form.jsp 4KB
add_book_form.jsp 4KB
add_book_form.jsp 4KB
user_reg_save.jsp 4KB
user_reg_save.jsp 4KB
user_detail.jsp 3KB
user_detail.jsp 3KB
book_list.jsp 3KB
book_list.jsp 3KB
books_management.jsp 3KB
books_management.jsp 3KB
add_book_save.jsp 3KB
add_book_save.jsp 3KB
recommend_book_list.jsp 3KB
recommend_book_list.jsp 3KB
sorts_management.jsp 3KB
sorts_management.jsp 3KB
index.jsp 3KB
index.jsp 3KB
user_reg.jsp 3KB
user_reg.jsp 3KB
add_goods_form.jsp 3KB
add_goods_form.jsp 3KB
add_sort_save.jsp 2KB
add_sort_save.jsp 2KB
user_login_check.jsp 2KB
user_login_check.jsp 2KB
modify_book_save.jsp 2KB
modify_book_save.jsp 2KB
delete_book.jsp 2KB
delete_book.jsp 2KB
modify_sort_from_sorts.jsp 2KB
modify_sort_from_sorts.jsp 2KB
modify_sort_save.jsp 2KB
modify_sort_save.jsp 2KB
search_book_form.jsp 2KB
search_book_form.jsp 2KB
recommend_book.jsp 2KB
recommend_book.jsp 2KB
add_goods_save.jsp 2KB
add_goods_save.jsp 2KB
delete_sorts.jsp 2KB
delete_sorts.jsp 2KB
delete_goods.jsp 2KB
delete_goods.jsp 2KB
delete_goods.jsp 2KB
delete_goods.jsp 2KB
index.jsp 1KB
index.jsp 1KB
password_change_form.jsp 1KB
共 146 条
- 1
- 2
资源评论
- qq_570243442022-07-09感谢大佬,让我及时解决了当下的问题,解燃眉之急,必须支持!
Like_Bamboo
- 粉丝: 815
- 资源: 3万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功