收藏 分销(赏)

javaEE专业课程设计个人财务标准管理系统.doc

上传人:精**** 文档编号:2494769 上传时间:2024-05-30 格式:DOC 页数:18 大小:137.54KB
下载 相关 举报
javaEE专业课程设计个人财务标准管理系统.doc_第1页
第1页 / 共18页
javaEE专业课程设计个人财务标准管理系统.doc_第2页
第2页 / 共18页
javaEE专业课程设计个人财务标准管理系统.doc_第3页
第3页 / 共18页
javaEE专业课程设计个人财务标准管理系统.doc_第4页
第4页 / 共18页
javaEE专业课程设计个人财务标准管理系统.doc_第5页
第5页 / 共18页
点击查看更多>>
资源描述

1、软 件 学 院课程设计汇报书课程名称 JavaEE 课程设计 设计题目 个人财务系统 专业班级 软件工程 学 号 xxxxxxxxx07 姓 名 xxxxx 指导老师 姜彦吉 年 12 月1 设计时间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系统结构关系登陆窗口 no密码yes操作界面 查询保留计算帐目删除图2(jsp页面

3、结构)Jsp页面传输参数调用servlet类参数计算方法servlet删除方法servlet查询方法servlet保留方法servlet删除方法dao类查询方法dao类保留方法dao类计算方法dao类图3(Java类功效调用)4.2 Jsp 页面设计4.2.1登录界面 图4(登录界面)代码以下:欢迎登陆个人财务统计系统! 用户名称:用户密码: 4.2.2登录成功界面 图5(登录成功查询界面) 代码以下: 欢迎登录: 增加帐目明细请输入: 收入数额: 支出数额: 附加备注: 输入日期: 查询帐目明细请点击: 删除帐目信息请以下: 请输入要 删除帐目标日期: 起始Id号: 终止Id号: 4.2.3

4、查询结果界面图6(查询结果界面)4.3Java方法设计4.3.1Servlet类控制增删改操作servlet类代码设计以下:public class AccountController extends HttpServlet protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException doPost(request,response);protected void doPost(HttpServletRequest reques

5、t, HttpServletResponse response)throws ServletException, IOException int arg=Integer.parseInt(request.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

6、4:this.caculateAccount(request,response); break; protected void caculateAccount(HttpServletRequest 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 account

7、Dao=new AccountDao(); List list2=accountDao.caculateAccount(a,b); request.setAttribute(result,list2); RequestDispatcher rdt1=request.getRequestDispatcher(/Result1.jsp); rdt1.forward(request, response);public void findAllAccount(HttpServletRequest request, HttpServletResponse response) throws Servlet

8、Exception, IOException AccountDao accountDao=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, HttpServ

9、letResponse response) 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 record=(String)request.ge

10、tParameter(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=new AccountDao(); try accountDao.saveAllAccou

11、nt(myAccount); catch(Exception e) e.printStackTrace(); this.findAllAccount(request,response); public void deleteSomeAccount(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException request.setCharacterEncoding(gbk); String time=request.getParameter(time); MyAcco

12、unt myAccount=new MyAccount(); myAccount.setTime(time); AccountDao accountDao=new AccountDao(); try accountDao.deleteSomeAccount(myAccount); catch(Exception e) e.printStackTrace(); this.findAllAccount(request, response); 密码验证Servlet类代码以下:public class LoginServlet extends HttpServlet public void doGe

13、t(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException doGet(req,resp);public void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException String username=req.getParameter(username); String password=req.getParameter(password); Use

14、r user=new User(); user.setUsername(username); user.setPassword(password); HttpSession session=req.getSession(); String forward=; if(UserService.CheckLogin(user) forward=/Search.jsp; session.setAttribute(name, username); else forward=/error.jsp; RequestDispatcher rd=req.getRequestDispatcher(forward)

15、; rd.forward(req,resp); 4.3.2Dao类密码验证Dao类代码设计以下:public class UserService public static boolean CheckLogin(User user) if(user.getUsername().equals(lb)&user.getPassword().equals(123) return true; return false; 帐务添加查询计算Dao类代码设计以下:public class AccountDao private Connection conn; public List findAllAccou

16、nt() conn=DBCon.getConnection(); String listSQL=select * from myaccount; List list=new ArrayList(); try PreparedStatement psmt=conn.prepareStatement(listSQL); ResultSet rs=psmt.executeQuery(); while(rs.next() MyAccount account=new MyAccount(); account.setId(rs.getInt(1); account.setIncomemoney(rs.ge

17、tDouble(2); account.setCostmoney(rs.getDouble(3); account.setRecord(rs.getString(4); account.setTime(rs.getString(5); 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

18、 boolean saveAllAccount(MyAccount account)throws Exception conn=DBCon.getConnection(); String listSQL=insert into myaccount values(?,?,?,?); PreparedStatement psmt=conn.prepareStatement(listSQL); try psmt.setDouble(1, account.getIncomemoney(); psmt.setDouble(2, account.getCostmoney(); psmt.setString

19、(3, account.getRecord(); psmt.setString(4, account.getTime(); psmt.executeUpdate(); mit(); return true; catch(SQLException e) conn.rollback(); e.printStackTrace(); return false; public boolean deleteSomeAccount(MyAccount account)throws Exception conn=DBCon.getConnection(); String listSQL=delete from

20、 myaccount where time=? ; PreparedStatement psmt=conn.prepareStatement(listSQL); try psmt.setString(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.getConnect

21、ion(); double incometotal=0.0; double costtotal=0.0; int i=0; List list2=new ArrayList(); try 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();

22、psmt1.execute(); incometotal=incometotal+rs1.getDouble(2); String listSQL2=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(inc

23、ometotal); account.setCostmoney(costtotal); list2.add(account); return list2; catch(SQLException e) e.printStackTrace(); return list2; 4.3.3数据库连接类数据库连接代码以下:public class DBCon public static Connection getConnection() String url=jdbc:microsoft:sqlserver:/localhost:1433;databaseName=myaccountbase;Strin

24、g user=sa;String psw=sa;Connection conn=null;tryClass.forName(com.microsoft.jdbc.sqlserver.SQLServerDriver);catch(ClassNotFoundException e)e.printStackTrace();tryconn=DriverManager.getConnection(url, user, psw);conn.setAutoCommit(false);return conn;catch(SQLException e)e.printStackTrace();return nul

25、l;5 总结和展望经过此次课程设计自己JavaWeb编程加深了了解,对MVC模型工作原理和工作过程有了更深刻了解,对struts2模型及其工作过程也有了比以前更深认识,对于怎样配置web.xml和struts.xml文件也加深了记忆,Filterdispatcher过滤器作用自己也深入加深了印象。最关键是自己在这次课程设计中培养了自己独立觉问题能力和处理问题耐心。比如自己在计算收入和支出帐务和时候,刚开始自己所写算法之不能正确计算出结果,总是在返回物理视图显示0.0 0.0,在运行期间控制没有显示任何错误,原来自己在初始化时候给incometotal和costtotal全部初始化为0.0而自己

26、方法在实施查询语句后得到一个Resultset结果集自己在累加计算收入和支出综合时候,自己在if语句调减中rs.next()取非,造成没有进行累加计算,结果如论怎样全部返回0.0和0.0这两个结果。只要把去非!去掉即可得到正确计算结果并返回给物理视图。参考文件1 范立峰,林果园.JavaWeb程序设计教程.第1版, 北京:人民邮电出版社, 成绩评定成绩 老师签字目录1 设计时间12 设计目标13设计任务14 设计内容14.1 设计题目14.1.1系统功效要求14.1.2 数据库存放要求14.1.3数据库设计14.1.4系统结构关系24.2 Jsp 页面设计34.2.1登录界面34.2.2登录成功界面44.2.3查询结果界面54.3.1Servlet类64.3.2Dao类104.3.3数据库连接类145 总结和展望15参考文件15成绩评定15

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 通信科技 > 开发语言

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服