javaEE課程設(shè)計個人財務(wù)管理系統(tǒng)_第1頁
javaEE課程設(shè)計個人財務(wù)管理系統(tǒng)_第2頁
javaEE課程設(shè)計個人財務(wù)管理系統(tǒng)_第3頁
javaEE課程設(shè)計個人財務(wù)管理系統(tǒng)_第4頁
javaEE課程設(shè)計個人財務(wù)管理系統(tǒng)_第5頁
已閱讀5頁,還剩13頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、軟 件 學(xué) 院課程設(shè)計報告書課程名稱 javaee 課程設(shè)計設(shè)計題目個人財務(wù)系統(tǒng)專業(yè)班級軟件工程學(xué)號 xxxxxxxxx07 姓名 xxxxx 指導(dǎo)教師姜彥吉2011 年 12 月1 設(shè)計時間2011 年 12 月 12 日 12 月 16日2 設(shè)計目的javaee 課程設(shè)計是對所學(xué)javaee 與中間件課程的小結(jié),是提高學(xué)生對所學(xué)知識綜合應(yīng)用能力的一種方式,是集中實踐性環(huán)節(jié)之一。要求同學(xué)們對課程中所學(xué)習(xí)到的知識綜合運用,開發(fā)有一定規(guī)模的java web程序。3 設(shè)計任務(wù)設(shè)計個人帳務(wù)管理系統(tǒng),要求用戶以合法的身份登錄后可以對系統(tǒng)進行操作,用戶可以查看,添加,刪除和計算某段時間內(nèi)帳務(wù)的收入和支出

2、信息等。帳務(wù)信息包括收入和支出兩種,還有日期和備注。4 設(shè)計內(nèi)容4.1 設(shè)計題目個人財務(wù)管理系統(tǒng)4.1.1 系統(tǒng)功能要求用只有擁有合法身份才能登錄系統(tǒng),用以合法身份登錄后可以產(chǎn)看帳務(wù)信息、添加帳務(wù)信息、刪除帳務(wù)信息、分別統(tǒng)計某個時間段內(nèi)的收入和支出總額。4.1.2 數(shù)據(jù)庫存儲要求數(shù)據(jù)的存儲要求:收入數(shù)額,支出數(shù)額,備注,日期4.1.3 數(shù)據(jù)庫的設(shè)計表 1(數(shù)據(jù)存儲要求)列名稱數(shù)據(jù)類型長度id bigint 8 incomemoney money 8 costmoney money 8 record varchar 50 time varchar 8 圖 1(數(shù)據(jù)庫存儲數(shù)據(jù))4.1.4 系統(tǒng)構(gòu)造

3、關(guān)系no yes 圖 2(jsp 頁面構(gòu)造)登陸窗口密碼保存查詢刪除計算帳目操作界面圖 3(java 類功能調(diào)用)4.2 jsp 頁面設(shè)計4.2.1 登錄界面圖 4(登錄界面)代碼如下: 歡迎登陸個人財務(wù)統(tǒng)計系統(tǒng)! 用戶名稱: jsp頁面?zhèn)鬟f參數(shù)調(diào)用 servlet 類參數(shù)保存方法 servlet 查詢方法servlet 刪除方法servlet 計算方法servlet 保存方法dao 類查詢方法dao 類刪除方法dao 類計算方法dao 類用戶密碼: 4.2.2 登錄成功界面圖 5(登錄成功查詢界面)代碼如下: 歡迎登錄: 增加帳目明細請輸入: 收入數(shù)額: 支出數(shù)額: 附加備注: 輸入日期:

4、查詢帳目明細請點擊: 刪除帳目信息請如下: 請 輸 入要刪 除 帳 目 的 日 期 : 起始id 號: 終止id 號: 4.2.3 查詢結(jié)果界面圖 6(查詢結(jié)果界面)4.3java 方法設(shè)計4.3.1servlet類控制增刪改操作的servlet類代碼設(shè)計如下:public class accountcontroller extends httpservlet protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception do

5、post(request,response); protected void dopost(httpservletrequest request, 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,respons

6、e); break; case 3:this.deletesomeaccount(request,response); break; case 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.getparam

7、eter(id); b=integer.parseint(request.getparameter(id); accountdao accountdao=new accountdao(); list list2=accountdao.caculateaccount(a,b); request.setattribute(result,list2); requestdispatcher rdt1=request.getrequestdispatcher(/result1.jsp); rdt1.forward(request, response); public void findallaccoun

8、t(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception accountdao accountdao=new accountdao(); list list=accountdao.findallaccount(); request.setattribute(accounts, list); requestdispatcher rdt=request.getrequestdispatcher(/result.jsp); rdt.forward(request,

9、response); public void saveallaccount(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception request.setcharacterencoding(gbk); double incomemoney=0.0; double costmoney=0.0; incomemoney=double.parsedouble(request.getparameter(incomemoney); costmoney=double.par

10、sedouble(request.getparameter(costmoney); string record=(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(

11、time); accountdao accountdao=new 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

12、.setcharacterencoding(gbk); 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); 密碼驗證的

13、 servlet類的代碼如下: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 user

14、name=req.getparameter(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; session.setattribute(name, username);

15、 else forward=/error.jsp; requestdispatcher rd=req.getrequestdispatcher(forward); rd.forward(req,resp); 4.3.2dao 類密碼驗證的 dao類代碼設(shè)計如下:publicclass userservice publicstaticboolean checklogin(user user) if (user.getusername().equals(lb)&user.getpassword().equals(123) returntrue ; returnfalse ; 帳務(wù)添加查詢計

16、算的dao類代碼設(shè)計如下:public class accountdao private connection conn; public list findallaccount() 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() myacc

17、ount 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); list.add(account); mit(); return list; catch(exception e) e.printstacktrace(); finally if(conn!=

18、null) try conn.close(); catch(sqlexception e) e.printstacktrace(); return list; public boolean saveallaccount(myaccount account)throws exception conn=dbcon.getconnection(); string listsql=insert into myaccount values(?,?,?,?); preparedstatement psmt=conn.preparestatement(listsql); try psmt.setdouble

19、(1, account.getincomemoney(); psmt.setdouble(2, account.getcostmoney(); psmt.setstring(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(mya

20、ccount account)throws exception conn=dbcon.getconnection(); string listsql=delete from 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.printstac

21、ktrace(); 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 myaccount account=new myaccount(); for( i=x;i=y;i+) string listsql1=selct incomemoney from myaccount where id=i; prepare

22、dstatement psmt1=conn.preparestatement(listsql1); resultset rs1=psmt1.executequery(); 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(); ps

23、mt2.execute(); costtotal=costtotal+rs2.getdouble(3); mit(); account.setincomemoney(incometotal); account.setcostmoney(costtotal); list2.add(account); return list2; catch(sqlexception e) e.printstacktrace(); return list2; 4.3.3 數(shù)據(jù)庫連接類數(shù)據(jù)庫連接代碼如下:public class dbcon public static connection getconnection

24、() string url=jdbc:microsoft:sqlserver:/localhost:1433;databasename=myaccountbase; string user=sa; string psw=sa; connection conn=null; try class.forname(com.microsoft.jdbc.sqlserver.sqlserverdriver); catch(classnotfoundexception e) e.printstacktrace(); try conn=drivermanager.getconnection(url, user, psw); conn.setautocommit(false); return conn; catch(sqlexception e) e.printstacktrace();

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論