package com.chapter15;
import java.util.*;
import java.sql.*;
import java.text.*;
public class User extends ExecuteDB
{
//定义类成员变量
private long UserID;
private String UserName;
private String UserPassword;
private String RealName;
private long DepartmentID;
private String Sex;
private String Degree;
private String BornDate;
private String UserSN;
private String Telephone;
private String Mobile;
private String Email;
private String InDate;
private String Intro;
private String Role;
private String strSql;
//初始化类成员变量
public User()
{
this.UserID=0;
this.UserName="";
this.UserPassword="";
this.RealName="";
this.DepartmentID=0;
this.Sex="";
this.Degree="";
this.BornDate = "";
this.UserSN="";
this.Telephone="";
this.Mobile="";
this.Email="";
this.InDate= "";
this.Intro="";
this.Role="0";
this.strSql="";
}
//向users数据表中添加一条新记录
public boolean add()
{
this.strSql="insert into users ";
this.strSql=this.strSql + "(";
this.strSql=this.strSql + "UserName,";
this.strSql=this.strSql + "UserPassword,";
this.strSql=this.strSql + "RealName,";
this.strSql=this.strSql + "DepartmentID,";
this.strSql=this.strSql + "Sex,";
this.strSql=this.strSql + "Degree,";
this.strSql=this.strSql + "BornDate,";
this.strSql=this.strSql + "UserSN,";
this.strSql=this.strSql + "Telephone,";
this.strSql=this.strSql + "Mobile,";
this.strSql=this.strSql + "Email,";
this.strSql=this.strSql + "InDate,";
this.strSql=this.strSql + "Intro,";
this.strSql=this.strSql + "Role";
this.strSql=this.strSql + ") ";
this.strSql=this.strSql + "values(";
this.strSql=this.strSql + "'" + this.UserName + "',";
this.strSql=this.strSql + "'" + this.UserPassword + "',";
this.strSql=this.strSql + "'" + this.RealName + "',";
this.strSql=this.strSql + "'" + this.DepartmentID + "',";
this.strSql=this.strSql + "'" + this.Sex + "',";
this.strSql=this.strSql + "'" + this.Degree + "',";
this.strSql=this.strSql + "'" + this.BornDate + "',";
this.strSql=this.strSql + "'" + this.UserSN + "',";
this.strSql=this.strSql + "'" + this.Telephone + "',";
this.strSql=this.strSql + "'" + this.Mobile + "',";
this.strSql=this.strSql + "'" + this.Email + "',";
this.strSql=this.strSql + "'" + this.InDate + "',";
this.strSql=this.strSql + "'" + this.Intro + "',";
this.strSql=this.strSql + "'" + this.Role + "'";
this.strSql=this.strSql + ")";
boolean isAdd = super.exeSql(this.strSql);
return isAdd;
}
//修改UserID对应的用户的信息
public boolean modify_info()
{
this.strSql="update users set";
this.strSql=this.strSql + " RealName=" + "'" + this.RealName + "',";
this.strSql=this.strSql + " DepartmentID=" + "'" + this.DepartmentID + "',";
this.strSql=this.strSql + " Sex=" + "'" + this.Sex + "',";
this.strSql=this.strSql + " Degree=" + "'" + this.Degree + "',";
this.strSql=this.strSql + " BornDate=" + "'" + this.BornDate + "',";
this.strSql=this.strSql + " UserSN=" + "'" + this.UserSN + "',";
this.strSql=this.strSql + " Telephone=" + "'" + this.Telephone + "',";
this.strSql=this.strSql + " Mobile=" + "'" + this.Mobile + "',";
this.strSql=this.strSql + " Email=" + "'" + this.Email + "',";
this.strSql=this.strSql + " InDate=" + "'" + this.InDate + "',";
this.strSql=this.strSql + " Intro=" + "'" + this.Intro + "'";
this.strSql=this.strSql + " where UserID='" + this.UserID + "'";
boolean isUpdate = super.exeSql(this.strSql);
return isUpdate;
}
//修改UserID对应的用户的密码
public boolean modify_UserPassword()
{
this.strSql="update users set ";
this.strSql=this.strSql + "UserPassword=" + "'" + this.UserPassword + "'";
this.strSql=this.strSql + " where UserID='" + this.UserID + "'";
boolean isUpdatekey = super.exeSql(this.strSql);
return isUpdatekey;
}
//验证用户名和密码是否正确
public boolean valid()
{
this.strSql="select UserID,UserName,Role from `users` ";
this.strSql=this.strSql + " where UserName='" + this.UserName + "'";
this.strSql=this.strSql + " and UserPassword='"+ this.UserPassword + "'";
try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
this.UserID=rs.getLong("UserID");
this.UserName=rs.getString("UserName");
this.Role = rs.getString("Role");
return true;
}
else
{
return false;
}
}
catch(Exception e)
{
return false;
}
}
//判断用户名是否存在
public boolean exist()
{
this.strSql="select * from users ";
this.strSql=this.strSql + " where UserName='" + this.UserName + "'";
try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
return true;
}
else
{
return false;
}
}
catch(Exception e)
{
return false;
}
}
//获取类成员变量UserID对应的用户信息
public boolean init()
{
this.strSql="select * from users where UserID=";
this.strSql=this.strSql + this.UserID;
try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
this.UserID=rs.getLong("UserID");
this.UserName=rs.getString("UserName");
this.UserPassword=rs.getString("UserPassword");
this.RealName=rs.getString("RealName");
this.DepartmentID=rs.getLong("DepartmentID");
this.Sex=rs.getString("Sex");
this.Degree=rs.getString("Degree");
this.BornDate=rs.getString("BornDate");
this.UserSN=rs.getString("UserSN");
this.Telephone=rs.getString("Telephone");
this.Mobile=rs.getString("Mobile");
this.Email=rs.getString("Email");
this.InDate=rs.getString("InDate");
this.Intro=rs.getString("Intro");
this.Role=rs.getString("Role");
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}
//获取类UserName对应的用户信息
public boolean init_byUserName()
{
this.strSql="select * from users where UserName like ";
this.strSql=this.strSql + "'" + this.UserName + "'";
try
{
ResultSet rs = super.exeQuery(this.strSql);
if (rs.next())
{
this.UserID=rs.getLong("UserID");
this.UserName=rs.getString("UserName");
this.UserPassword=rs.getString("UserPassword");
this.RealName=rs.getString("RealName");
this.DepartmentID=rs.getLong("DepartmentID");
this.Sex=rs.getString("Sex");
this.Degree=rs.getString("Degree");
this.BornDate=rs.getString("BornDate");
this.UserSN=rs.getString("UserSN");
this.Telephone=rs.getString("Telephone");
this.Mobile=rs.getString("Mobile");
this.Email=rs.getString("Email");
this.InDate=rs.getString("InDate");
this.Intro=rs.getString("Intro");
this.Role=rs.getString("Role");
return true;
}
else
{
return false;
}
}
catch(Exception ex)
{
return false;
}
}
//获取成员变量DepartmentID对应的部门的所有人员信息,返回一个ResultSet类型对象
public ResultSet show_department_users()
{
this.strSql="select * from users where DepartmentID ="+this.DepartmentID;
ResultSet rs = null;
try
{
rs = super.exeQuery(this.strSql);
}
catch(Exception e)
{
System.out.println(e.toString());
}
return rs;
}
//获取所有人员信息,返回一个ResultSet类型对象
public ResultSet show_users()
{
this.strSql="select UserID,UserName,RealName,DepartmentID,UserSN from users where Role = 0 order by UserSN desc";
ResultSet rs = null;
try
{
rs = super.exeQuery(this.strSql);
}
catch(Exception e)
{
System.out.println
没有合适的资源?快使用搜索试试~ 我知道了~
办公自动化系统java实现后台,jsp前台
共59个文件
jsp:36个
java:7个
class:7个
4星 · 超过85%的资源 需积分: 37 45 下载量 74 浏览量
2011-04-15
19:21:23
上传
评论 2
收藏 491KB RAR 举报
温馨提示
实现了邮件的收发功能,公告管理,人事管理,登录等功能,采用jsp+servlet+javabean实现
资源推荐
资源详情
资源评论
收起资源包目录
办公自动化系统.rar (59个子文件)
办公自动化系统
chapter15
get_password_form.html 479B
modify_info_save.jsp 2KB
download_attachment.jsp 501B
notice_detail.jsp 2KB
manager
add_department_form.html 660B
department_management.jsp 3KB
add_notice_form.html 1KB
notice_management.jsp 4KB
add_department_save.jsp 1KB
top.jsp 1KB
delete_department.jsp 1KB
main.jsp 622B
add_user_form.jsp 3KB
modify_notice_form.jsp 2KB
delete_notice.jsp 1KB
modify_user_save.jsp 2KB
department_user_list.jsp 2KB
modify_user_form.jsp 4KB
modify_department_save.jsp 2KB
delete_user.jsp 1KB
add_notice_save.jsp 2KB
modify_department_form.jsp 2KB
user_management.jsp 5KB
user_detail.jsp 3KB
modify_notice_save.jsp 3KB
add_user_save.jsp 2KB
delete_email.jsp 1KB
top.jsp 1KB
send_email_save.jsp 2KB
get_password_do.jsp 3KB
WEB-INF
web.xml 179B
classes
Email.java 5KB
User.java 12KB
ExecuteDB.java 1KB
Department.java 3KB
SplitPage.java 2KB
com
chapter15
User.class 8KB
ConnectDB.class 1KB
Email.class 4KB
Notice.class 4KB
SplitPage.class 2KB
ExecuteDB.class 1KB
Department.class 3KB
Notice.java 5KB
ConnectDB.java 952B
lib
jspSmartUpload.jar 15KB
mysql-connector-java-3.1.11-bin.jar 430KB
email_detail.jsp 3KB
main.jsp 621B
email_attachment
user_login.jsp 1KB
index.html 1KB
info_management.jsp 5KB
notice_list.jsp 4KB
modify_password_save.jsp 2KB
lib
enterprise.css 446B
send_email_form.jsp 3KB
email_management.jsp 2KB
logout.jsp 143B
notice_attachment
chapter15.sql 2KB
共 59 条
- 1
资源评论
- bottle2012-12-24还可以,受用了,具体要看怎么用!
- l3513963192012-11-27还可以 受用了
gylixy
- 粉丝: 1
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功