生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx

上传人:b****1 文档编号:3891771 上传时间:2023-05-02 格式:DOCX 页数:25 大小:108.02KB
下载 相关 举报
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第1页
第1页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第2页
第2页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第3页
第3页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第4页
第4页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第5页
第5页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第6页
第6页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第7页
第7页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第8页
第8页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第9页
第9页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第10页
第10页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第11页
第11页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第12页
第12页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第13页
第13页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第14页
第14页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第15页
第15页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第16页
第16页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第17页
第17页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第18页
第18页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第19页
第19页 / 共25页
生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx_第20页
第20页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx

《生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx(25页珍藏版)》请在冰点文库上搜索。

生活质量系统课程设计 生活质量衡量系统Word格式文档下载.docx

该系统包括三个基本信息:

支出类型(有两种:

4.1.2用户特点

用户为非专业技术人员,对计算机系统没有详细了解,必须尽可能的提供良好的用户操作界面和使用提示。

4.1.3数据需求

4.1.4功能需求

(1)用户以合法身份登录系统,才能进行操作。

(2)用户添加支出情况

(3)用户查看支出情况

(4)用户删除支出情况

4.2概要设计

4.2.1各个子系统的设计

生活质量衡量系统包括五个子系统:

登录管理子系统,查询子系统,删除子系统,添加子系统,用户生活质量等级子系统。

五个子系统关系如下:

图1系统总体结构

系统中各个子系统都能够分别满足功能的要求,以下是各个系统的功能说明:

(1)登录管理子系统:

用户登录自己的信息,若为合法用户,则可以进入生活质量管理系统。

(2)查询子系统:

显示用户支出信息

(3)删除子系统:

删除用户不需要的支出信息

(4)添加子系统:

添加用户的支出信息

(5)生活质量等级子系统:

通过计算,查看用户所处的生活质量等级。

(生活质量等级分为:

小康,温饱,贫困)。

4.2.2数据库设计

1E-R图

图2支出E-R图

2.数据库表设计

在数据库中建立cp表包括:

(列名,数据类型,长度,是否为空,含义)。

表1cp表

列名

数据类型

长度

是否为空

含义

id

bigint

8

N

支出编码,主键,自动增长

Type

varchar

50

Y

支出类型

money

double

10

额度

data

datatime

日期

3.关系模式

支出信息(支出编码,支出类型,额度,日期)其中支出编码,为主键。

4.3详细设计

4.3.1系统流程图

图3系统流程图

4.3.3各子系统的详细设计

1.登陆管理子系统

“login.jsp”用于用户登录,输入用户名和密码。

登录失败时跳转到“error.jsp”页面,然后超链接到登录页面;

登录成功进入“index.jsp”页面,点击显示所有支出情况进入查询子系统。

2.查询子系统

“showAllCost.jsp”用于显示所有支出信息包括:

支出类型,额度,日期。

建立超链接与其他三个子系统的页面。

3.删除子系统

“deletecost.jsp”用于删除支出,输入要删除的序号点击删除。

将删除结果返回到“showAllCost.jsp”页面。

4.添加子系统

“savecost.jsp”用于填加支出,输入要添加的数据,点击添加,将添加结果返回到“showAllCost.jsp”页面。

5.生活质量等级子系统

“tongji.jsp”用于输入计算生活质量等级时间段,点击进入所对应的servlet进行处理,并用“xianshi.jsp”显示生活质量等级:

您所处的生活等级为{小康,温饱,贫困}。

4.3.2抽象数据类型的定义

所需要导入的包及建立的包

表2包定义表

包名

类名

功能

com.cost.dao

CostDao.java

增加信息

显示信息

删除信息

生活质量信息

com.cost.domain

Cost.java

图书属性

User.java

用户属性

com.cost.service

CostService.java

UserService.java

com.cost.servlet

saveCostServlet.java

DeleteCostServlet.java

ListAllCostServlet.java

LoginServlet.java

TongjiServlet.java

表3页面定义表

页面名称

savecost.jsp

添加页面

deletecost.jsp

删除页面

Tongji,jsp

填写时间段页面

error.jsp

登陆失败页面,返回登录界面

index.jsp

用户界面

login.jsp

登录页面

ShowAllCost.jsp

显示页面

success.jsp

登陆成功页面,跳转至用户界面

xianshi.jsp

显示生活质量等级页面

5设计成果

5.1运行界面及测试结果

1.用户登录界面

2登录失败页面

3.登录成功界面

4.进入查询子系统

5.添加支出信息界面及结果

6.删除支出系统及结果

7.查询生活质量等级及结果

5.2主要代码

1.页面的实现

“login.jsp”用于用户登录,它的关键代码如下:

<

body>

<

formaction="

servlet/LoginServlet"

method="

get"

>

用户名<

inputtype="

text"

name="

username"

/>

密码<

password"

<

br>

submit"

value="

登陆"

/form>

/body>

登录失败时跳转到“error.jsp”页面,然后超链接到登录页面,它的关键代码如下:

用户名密码错误。

ahref="

/cost/login.jsp"

重新登陆<

/a>

登录成功进入“index.jsp”页面,它的关键代码如下:

h2>

欢迎进入:

生活质量系统<

/h2>

servlet/ListAllCostServlet"

显示所有支出情况<

“showAllCost.jsp”用于显示所有支出信息,它的关键代码如下:

tableborder="

1"

tr>

th>

id<

/th>

<

支出类型<

额度<

日期<

/tr>

%

Listlist=(List)request.getAttribute("

allBooks"

);

for(Iteratorit=list.iterator();

it.hasNext();

){

Costcost=(Cost)it.next();

%>

td>

%=cost.getId()%>

/td>

%=cost.getType()%>

%=cost.getMoney()%>

%=cost.getData()%>

%}

savecost.jsp"

添加支出情况<

deletecost.jsp"

删除支出情况<

tongji.jsp"

生活质量等级<

/table>

“deletecost.jsp”用于删除支出,它的关键代码如下:

servlet/DeleteCostServlet"

post"

table>

请输入要删除的序号:

id"

删除"

“tongji.jsp”页面用于填写填写时间段

servlet/TongJiServlet"

请输入序号范围:

firstid"

endid"

统计"

“xianshi.jsp”用于显示生活质量等级:

center>

您所处的生活等级为:

/center>

Stringlist=(String)request.getAttribute("

allCost"

System.out.print(list);

2.工具类的实现

工具的类名为“DBConnection”,该类用于获得数据库的连接,它的实现代码如下:

publicclassDBConnection{

publicstaticConnectiongetConnection(){

finalStringdriverName="

com.microsoft.jdbc.sqlserver.SQLServerDriver"

;

finalStringurl="

jdbc:

microsoft:

sqlserver:

//localhost:

1433;

databasename=mydb"

try{

Class.forName(driverName);

}

catch(ClassNotFoundExceptione){

e.printStackTrace();

Connectioncon=DriverManager.getConnection(url,"

sa"

"

con.setAutoCommit(false);

returncon;

catch(SQLExceptione){

returnnull;

}

}

3.实体类的实现

实体类的类名有“User”和“Book”,“User”类拥有用户名称和用户密码的私有属性及各个属性的set、get方法,它的实现代码如下:

publicclassUser{

privateStringusername;

privateStringpassword;

publicStringgetUsername(){

returnusername;

publicvoidsetUsername(Stringusername){

this.username=username;

publicStringgetPassword(){

returnpassword;

publicvoidsetPassword(Stringpassword){

this.password=password;

“Cost”类拥有一些代表课程信息的私有属性以及各个属性的set、get方法,它的实现代码如下:

publicclassCost{

privateintid;

privateStringtype;

privatefloatmoney;

privateStringdate;

publicintgetId(){

returnid;

publicvoidsetId(intid){

this.id=id;

publicStringgetType(){

returntype;

publicvoidsetType(Stringtype){

this.type=type;

publicfloatgetMoney(){

returnmoney;

publicvoidsetMoney(floatmoney){

this.money=money;

publicStringgetDate(){

returndate;

publicvoidsetDate(Stringdate){

this.date=date;

4.DAO类的实现

DAO类的类名为“CostDao”,该类使用JDBC技术实现,用于和数据库交互,进行相关的增、删、改、查操作,它的实现代码如下:

publicclassCostDAO{

publicListgetAllCost(){

Connectioncon=DBConnection.getConnection();

Listlist=newArrayList();

try{

PreparedStatementps=con.prepareStatement("

select*fromi_cost"

ResultSetrs=ps.executeQuery();

while(rs.next()){

Costcost=newCost();

cost.setId(rs.getLong("

));

cost.setType(rs.getString("

type"

cost.setMoney(rs.getDouble("

money"

cost.setData(rs.getString("

data"

list.add(cost);

}

con.close();

returnlist;

}catch(SQLExceptione){

e.printStackTrace();

}

returnnull;

publicbooleansaveCost(Costcost)throwsException{

Connectionconn=DBConnection.getConnection();

StringlistSQL="

insertintoi_costvalues(?

?

)"

PreparedStatementpstmt=conn.prepareStatement(listSQL);

try{pstmt.setString(1,cost.getType());

pstmt.setDouble(2,cost.getMoney());

pstmt.setString(3,cost.getData());

pstmt.executeUpdate();

mit();

returntrue;

conn.rollback();

finally{

conn.close();

returnfalse;

publicbooleandeleteCost(intid)throwsException{

Connectionconn=DBConnection.getConnection();

StringlistSQL="

deletefromi_costwhereid=?

"

PreparedStatementpstmt=conn.prepareStatement(listSQL);

pstmt.setInt(1,id);

pstmt.executeUpdate();

finally{

conn.close();

publicStringtongJi(intfirstid,intendid)throwsException{

doublesumEating=0;

doublesumOthers=0;

select*fromecawhere"

+

"

id>

='

+firstid+"

'

"

andid'

+endid+"

ResultSetrs=pstmt.executeQuery();

Costcost=newCost();

while(rs.next()){

if(cost.getType().equals("

吃饭支出"

)){

sumEating=sumEating+cost.getMoney();

if(cost.getType().equals("

其他支出"

sumOthers=sumOthers+cost.getMoney();

}

doubleresult=sumEating/(sumEating+sumOthers);

Stringstate=null;

if(result<

0.2){

state="

小康"

returnstate;

}elseif(result>

0.5){

贫困"

}else{

温饱"

}

}

5.控制器类的实现

publicclassLoginServletextendsHttpServlet{

publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)

throwsServletException,IOException{

Useruser=newUser();

user.setUsername(request.getParameter("

user.setPassword(request.getParameter("

UserServiceuserService=newUserService();

if(userService.checkLogin(user)){

HttpSessionsession=request.getSession();

session.setAttribute("

user.getUsername());

request.getRequestDispatcher("

/index.jsp"

).forward(request,response);

else{

/error.jsp"

publicclassListAllCostServletextendsHttpServlet{

CostServicecostService=newCostService();

Listlist=costService.getAllCost();

request.setAttribute("

list);

request.getRequestDispatcher("

/showAllCost.jsp"

publicclassSaveCostServletextendsHttpServlet

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2