版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上软 件 学 院课程设计报告书课程名称 JavaEE 课程设计 设计题目 个人财务系统 专业班级 软件工程 学 号 xxxxxxxxx07 姓 名 xxxxx 指导教师 姜彦吉 2011 年 12 月1 设计时间2011年12月12日12月16日2 设计目的JavaEE课程设计是对所学JavaEE与中间件课程的小结,是提高学生对所学知识综合应用能力的一种方式,是集中实践性环节之一。要求同学们对课程中所学习到的知识综合运用,开发有一定规模的Java Web程序。3设计任务设计个人帐务管理系统,要求用户以合法的身份登录后可以对系统进行操作,用户可以查看,添加,删除和计算某段
2、时间内帐务的收入和支出信息等。帐务信息包括收入和支出两种,还有日期和备注。4 设计内容 4.1 设计题目个人财务管理系统 4.1.1系统功能要求用只有拥有合法身份才能登录系统,用以合法身份登录后可以产看帐务信息、添加帐务信息、删除帐务信息、分别统计某个时间段内的收入和支出总额。4.1.2 数据库存储要求 数据的存储要求:收入数额,支出数额,备注,日期4.1.3数据库的设计 表1(数据存储要求)列名称数据类型长度idbigint8incomemoneymoney8costmoneymoney8recordvarchar50timevarchar8图1(数据库存储数据)4.1.4系统构造关系登陆窗
3、口 no密码yes操作界面 查询保存计算帐目删除图2(jsp页面构造)Jsp页面传递参数调用servlet类参数计算方法servlet删除方法servlet查询方法servlet保存方法servlet删除方法dao类查询方法dao类保存方法dao类计算方法dao类图3(Java类功能调用)4.2 Jsp 页面设计4.2.1登录界面 图4(登录界面)代码如下:<form action="servlet/LoginServlet" method="post"><center>欢迎登陆个人财务统计系统!</center>&l
4、t;center> 用户名称:<input type="text" name="username" value=""><br></center><center>用户密码:<input type="text" name="password" value=""><br></center> <center><input type="submit" name
5、="subimt" value="登录"><input type="reset" name="reset" value="重置"> </center></form> 4.2.2登录成功界面 图5(登录成功查询界面) 代码如下: <% String username=(String)session.getAttribute("name"); if(username!=null)%> <center>欢迎登录:&l
6、t;%=username %></center> <% %> <form action="servlet/AccountController?arg=2" method="post"> 增加帐目明细请输入: <center> 收入数额:<input type="text" name="incomemoney"value=""><br> 支出数额:<input type="text" name=
7、"costmoney"value=""><br> 附加备注:<input type="text" name="record"value=""><br> 输入日期:<input type="text" name="time"value=""><br> <input type="submit" name="submit1" val
8、ue="保存"> <br><br> </center> </form> <form action="servlet/AccountController?arg=1" method="post"> 查询帐目明细请点击: <center><input type="submit" name="submit2" value="查询"></center><br> </
9、form> 删除帐目信息请如下: <form action="servlet/AccountController?arg=3" method="post"> 请输入要 删除帐目的日期:<center> <input type="text" name="time"> </center> <center> <input type="submit" name="submit3" value="删除&q
10、uot;></center> </form> <form action="servlet/AccountController?arg=4" method="post"> <center> 起始Id号:<input type="text" name="id1"value=""><br></center> <center> 终止Id号:<input type="text"
11、name="id2"value=""><br></center> <center> <input type="submit"name="submit4"value="计算"> </center> </form>4.2.3查询结果界面图6(查询结果界面)4.3Java方法设计4.3.1Servlet类控制增删改操作的servlet类代码设计如下:public class AccountController extends
12、 HttpServlet protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doPost(request,response);protected void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException int arg=Integer.parseInt(reques
13、t.getParameter("arg"); switch(arg) case 1:this.findAllAccount(request,response); break; case 2:this.saveAllAccount(request,response); break; case 3:this.deleteSomeAccount(request,response); break; case 4:this.caculateAccount(request,response); break; protected void caculateAccount(HttpServ
14、letRequest request, HttpServletResponse response) throws ServletException, IOException int a=0;int b=0; a=Integer.parseInt(request.getParameter("id"); b=Integer.parseInt(request.getParameter("id"); AccountDao accountDao=new AccountDao(); List list2=accountDao.caculateAccount(a,b)
15、; request.setAttribute("result",list2); RequestDispatcher rdt1=request.getRequestDispatcher("/Result1.jsp"); rdt1.forward(request, response);public void findAllAccount(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException AccountDao accoun
16、tDao=new AccountDao(); List list=accountDao.findAllAccount(); request.setAttribute("accounts", list); RequestDispatcher rdt=request.getRequestDispatcher("/Result.jsp"); rdt.forward(request, response); public void saveAllAccount(HttpServletRequest request, HttpServletResponse resp
17、onse) throws ServletException, IOException request.setCharacterEncoding("gbk"); double incomemoney=0.0; double costmoney=0.0; incomemoney=Double.parseDouble(request.getParameter("incomemoney"); costmoney=Double.parseDouble(request.getParameter("costmoney"); String recor
18、d=(String)request.getParameter("record"); String time=(String)request.getParameter("time"); MyAccount myAccount=new MyAccount(); myAccount.setIncomemoney(incomemoney); myAccount.setCostmoney(costmoney); myAccount.setRecord(record); myAccount.setTime(time); AccountDao accountDao=n
19、ew AccountDao(); try accountDao.saveAllAccount(myAccount); catch(Exception e) e.printStackTrace(); this.findAllAccount(request,response); public void deleteSomeAccount(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException request.setCharacterEncoding("gb
20、k"); String time=request.getParameter("time"); MyAccount myAccount=new MyAccount(); myAccount.setTime(time); AccountDao accountDao=new AccountDao(); try accountDao.deleteSomeAccount(myAccount); catch(Exception e) e.printStackTrace(); this.findAllAccount(request, response); 密码验证的Servle
21、t类的代码如下:public class LoginServlet extends HttpServlet public void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException doGet(req,resp);public void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException String username=req.g
22、etParameter("username"); String password=req.getParameter("password"); User user=new User(); user.setUsername(username); user.setPassword(password); HttpSession session=req.getSession(); String forward="" if(UserService.CheckLogin(user) forward="/Search.jsp" s
23、ession.setAttribute("name", username); else forward="/error.jsp" RequestDispatcher rd=req.getRequestDispatcher(forward); rd.forward(req,resp); 4.3.2Dao类密码验证的Dao类代码设计如下:public class UserService public static boolean CheckLogin(User user) if(user.getUsername().equals("lb"
24、)&&user.getPassword().equals("123") return true; return false; 帐务添加查询计算的Dao类代码设计如下:public class AccountDao private Connection conn; public List findAllAccount() conn=DBCon.getConnection(); String listSQL="select * from myaccount" List list=new ArrayList(); try PreparedSta
25、tement psmt=conn.prepareStatement(listSQL); ResultSet rs=psmt.executeQuery(); while(rs.next() MyAccount account=new MyAccount(); account.setId(rs.getInt(1); account.setIncomemoney(rs.getDouble(2); account.setCostmoney(rs.getDouble(3); account.setRecord(rs.getString(4); account.setTime(rs.getString(5
26、); list.add(account); mit(); return list; catch(Exception e) e.printStackTrace(); finally if(conn!=null) try conn.close(); catch(SQLException e) e.printStackTrace(); return list; public boolean saveAllAccount(MyAccount account)throws Exception conn=DBCon.getConnection(); String listSQL="insert
27、into myaccount values(?,?,?,?)" PreparedStatement psmt=conn.prepareStatement(listSQL); try psmt.setDouble(1, account.getIncomemoney(); psmt.setDouble(2, account.getCostmoney(); psmt.setString(3, account.getRecord(); psmt.setString(4, account.getTime(); psmt.executeUpdate(); mit(); return true;
28、catch(SQLException e) conn.rollback(); e.printStackTrace(); return false; public boolean deleteSomeAccount(MyAccount account)throws Exception conn=DBCon.getConnection(); String listSQL="delete from myaccount where time=? " PreparedStatement psmt=conn.prepareStatement(listSQL); try psmt.set
29、String(1, account.getTime(); psmt.executeUpdate(); mit(); return true; catch(SQLException e) conn.rollback(); e.printStackTrace(); return false; public List caculateAccount(int x,int y) conn=DBCon.getConnection(); double incometotal=0.0; double costtotal=0.0; int i=0; List list2=new ArrayList(); try
30、 MyAccount account=new MyAccount(); for( i=x;i<=y;i+) String listSQL1="selct incomemoney from myaccount where id=i" PreparedStatement psmt1=conn.prepareStatement(listSQL1); ResultSet rs1=psmt1.executeQuery(); psmt1.execute(); incometotal=incometotal+rs1.getDouble(2); String listSQL2=&qu
31、ot;select costmoney from myaccount where id=i" PreparedStatement psmt2=conn.prepareStatement(listSQL2); ResultSet rs2=psmt2.executeQuery(); psmt2.execute(); costtotal=costtotal+rs2.getDouble(3); mit(); account.setIncomemoney(incometotal); account.setCostmoney(costtotal); list2.add(account); return list2; catch(SQLException e) e.printStackTrace();
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025至2031年中国排档锁扣拉线行业投资前景及策略咨询研究报告
- 2025至2031年中国单纤双向组件行业投资前景及策略咨询研究报告
- 2025至2030年中国灯饰金边条数据监测研究报告
- 2025至2030年中国棒材餐具数据监测研究报告
- 2025至2030年中国密集档案柜数据监测研究报告
- 2025至2030年中国半封闭氟利昂机组数据监测研究报告
- 2025-2030年厨电产品社群运营企业制定与实施新质生产力战略研究报告
- 2025-2030年按摩器APP控制行业跨境出海战略研究报告
- 2025-2030年历史文化深度缆车游行业深度调研及发展战略咨询报告
- 2025-2030年户外用品个性化定制平台企业制定与实施新质生产力战略研究报告
- 幼儿园大班数学PPT课件2、3、4的分解与组成
- 遥感图像的分析解译(共34张PPT)
- “花卉栽培”培训教学计划
- API682机械密封冲洗方案(中文)课件
- 产品立项管理办法
- 七年级上册英语完形填空、阅读理解综合训练100题(含参考答案)
- DB35T 1345-2013兰寿系列金鱼养殖技术规范
- 祛痘产品原料配方与消费者祛痘方案选择建议
- 年产一万吨蓖麻项目可行性论证报告
- 儒林外史每回概括
- GB/T 1995-1998石油产品粘度指数计算法
评论
0/150
提交评论