




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、校園卡掌上管理系統(tǒng) -編碼與測試報(bào)告 制作人: 曹 靜 崔 文 傅小江 李國明 1、編碼1.1部分代碼1.1.1數(shù)據(jù)庫實(shí)施階段任務(wù)(1)建立數(shù)據(jù)庫(校園卡管理系統(tǒng))create database campuscard;建立數(shù)據(jù)表1) 用戶信息表的建立 create table tb_admin (id int(10) not null primary key, username varchar(32) not null, password varchar(32) not null,type smallint(1) not null,createdate date not null ); 2)
2、校園卡信息表的建立 create table tb_card ( id int(10) not null primary key, stuid varchar(10) not null,cardid varchar(13) not null, password varchar(32) not null,balance double(5) not null,status int(1) not null,createdate date not null );3) 消費(fèi)信息表的建立 create table tb_consumption (id int(10) not null primary ke
3、y, cardid varchar(13) not null, money doublae(5) not null,address varchar(32) not null,createdate date not null );4) 轉(zhuǎn)賬信息表的建立 create table tb_recharge (id int(10) not null primary key, cardid varchar(13) not null, money doublae(5) not null,createdate date not null );5) 學(xué)生信息表的建立 create table tb_stude
4、nt (id int(10) not null primary key,stuid varchar(10) not null,name varchar(32) not null, cardid varchar(18) not null,bankcard varchar(19) not null,createdate date not null );1.1.2實(shí)體類cardusers類源代碼package usergui;public class cardusers public string userid;/用戶編號(hào) public string username;/用戶名; public st
5、ring usersex; public string userpwd; public string usertype; public cardusers(string userid) this.userid = userid; public cardusers(string userid, string username, string usersex, string userpwd, string usertype) throws pwdshortexception if(userpwd.length()<6) throw (new pwdshortexception(); else
6、 this.userid = userid; this.username = username; this.usersex = usersex; this.userpwd = userpwd; this.usertype = usertype; public string getuserid() return userid; public void setuserid(string userid) this.userid = userid; public string getusername() return username; public void setusername(string u
7、sername) this.username = username; public string getuserpwd() return userpwd; public void setuserpwd(string userpwd) throws pwdshortexception if(userpwd.length()<6) throw(new pwdshortexception(); else this.userpwd = userpwd; public string getusersdx() return usersex; public void setusersdx(string
8、 usersdx) this.usersex = usersex; public string getusertype() return usertype; public void setusertype(string usertype) this.usertype = usertype; override public string tostring() return "用戶編號(hào)=" + userid + ", 姓名=" + username + ", 性別=" + usersex + ", 密碼=" + use
9、rpwd + ", 身份=" + usertype ; carduserecords類源代碼package operationgui;public class carduserecords private long cardno; private string useitems; private double money; private string usetime; public carduserecords(long cardno, string item, double money, string time) this.cardno = cardno; this.u
10、seitems = item; this.money = money; this.usetime = time; public long getcardno() return cardno; public string getuseitems() return useitems; public string getusetime() return usetime; public double getmoney() return money; override public string tostring() return "卡號(hào)=" + cardno + ", 名
11、目=" + useitems + ", 費(fèi)用=" + money + ", 時(shí)間=" + usetime; schoolcard類源代碼package cardgui;import javax.swing.joptionpane;public class schoolcard public int cardno;/卡號(hào) static int nextcardno=111003200;/起始卡號(hào) private string userid;/卡所屬的用戶編號(hào) private string password; private double bala
12、nce; private boolean isusing; public schoolcard() this.cardno=nextcardno+; public schoolcard(string userid, string password) this(); this.userid = userid; this.password = password; this.balance=0; this.isusing=true; public static void setnextcardno(int newstartno) /設(shè)置起始卡號(hào) schoolcard.nextcardno = new
13、startno; public int getcardno() return cardno; public string getuserid() /差卡的用戶號(hào) return userid; public void setuserid(string uid) /設(shè)置卡的用戶號(hào) this.userid = uid; public double getbalance() /查詢余額 return balance; public string getpassword() return password; public void setpassword(string upwd) throws uses
14、tateexception if(check() this.password = upwd; else throw (new usestateexception(); public void deposit(double money) throws usestateexception if(check() this.balance=balance+money; else throw (new usestateexception(); public void consume(double money) throws usestateexception if(check() if(this.bal
15、ance>=money) this.balance=balance-money; else joptionpane.showmessagedialog(null,"卡上余額不夠消費(fèi),請先充值!"); else throw (new usestateexception(); public boolean getcardstate() return isusing; public void setstate(boolean state) this.isusing = state; public boolean check() if(this.isusing) return
16、 true; else return false; override public string tostring() return "卡號(hào)=" + cardno + ", 用戶號(hào)=" + userid + ", 密碼=" + password + ", 余額=" + balance + ", 是否可用=" + isusing ; 1.1.3實(shí)現(xiàn)數(shù)據(jù)庫連接 package operationgui;import java.sql.*;public class dbaccess private c
17、onnection conn=null; private statement stmt=null; public resultset rs=null; private preparedstatement prestmt=null; private string driver="sun.jdbc.odbc.jdbcodbcdriver" private string url="jdbc:odbc:cardconn"/自定義數(shù)據(jù)源名 private string user="jane" private string pwd="1
18、23456" public string notes="數(shù)據(jù)庫操作提示" /實(shí)例方法:實(shí)現(xiàn)數(shù)據(jù)庫連接 public void dbconn() try class.forname(driver); conn=drivermanager.getconnection(url, user, pwd); stmt=conn.createstatement(); catch (classnotfoundexception ec) system.out.println(ec); catch (sqlexception es) system.out.println(es); c
19、atch (exception ex) system.out.println(ex); /實(shí)現(xiàn)數(shù)據(jù)庫查詢并返回查詢記錄 public resultset dbselect(string selstring) try rs=stmt.executequery(selstring); catch (sqlexception es) system.out.println(es); notes="數(shù)據(jù)庫查詢出現(xiàn)異常" return rs; /數(shù)據(jù)庫更新 public string dbupdate(string updatestring) try prestmt=conn.prep
20、arestatement(updatestring); prestmt.executeupdate(); notes="記錄更新成功" catch (sqlexception es) system.out.println(es); notes="數(shù)據(jù)庫更新出現(xiàn)異常" return notes; /插入數(shù)據(jù) public string dbinsert(string insertstring) try prestmt=conn.preparestatement(insertstring); prestmt.executeupdate(); notes=&q
21、uot;插入記錄成功" catch (sqlexception es) system.out.println(es); notes="數(shù)據(jù)庫插入出現(xiàn)異常" return notes; /刪除 public string dbdelete(string delstring) try prestmt=conn.preparestatement(delstring); prestmt.executeupdate(); notes="刪除成功" catch (sqlexception es) system.out.println(es); notes=
22、"數(shù)據(jù)庫刪除現(xiàn)異常" return notes; /關(guān)閉數(shù)據(jù)庫 public void dbclose() if(conn!=null) try rs.close(); stmt.close(); conn.close(); catch (exception e) 1.2 系統(tǒng)主界面的截圖。校園卡管理界面校園卡管理主要功能是對校園卡信息進(jìn)行查詢,開戶銷戶等功能的操作。圖1登錄界面1.3系統(tǒng)部分功能界面的截圖。圖2 個(gè)人信息查詢界面圖3 修改密碼界面圖4 開戶界面圖5銷戶界面圖6 丟失界面圖7 補(bǔ)辦界面圖8 校園卡信息查詢界面2、測試2.1測試分析用戶登錄界面/確定
23、按鈕代碼private void jbtnokactionperformed(java.awt.event.actionevent evt) if(jradiobuttonp.isselected() chtype="普通用戶" else chtype="管理員" db.dbconn(); sql="select * from cardusers" db.dbselect(sql); try while(db.rs.next() system.out.println("b");/如果用戶號(hào),密碼,身份相符 if(t
24、xtuid.gettext().equals(db.rs.getstring("userid") && string.valueof(txtpwd.getpassword().equals(db.rs.getstring("userpwd") && chtype.equals(db.rs.getstring("usertype") /顯示用戶名,并新建當(dāng)前用戶對象,存儲(chǔ)有關(guān)信息。 currentuser=new cardusers(txtuid.gettext(); currentuser.userpw
25、d= string.valueof(txtpwd.getpassword(); currentuser.userid=txtuid.gettext(); currentuser.usertype=chtype; currentuser.username=db.rs.getstring("username"); jlbnote.settext("歡迎你:"+currentuser.username+"!");system.out.println("b"); new schoolcardmaingui(currentu
26、ser).setvisible(true);system.out.println("c");/主界面 this.dispose(); db.dbclose(); else jlbnote.settext("賬號(hào),密碼,身份不符,請檢查輸入信息是否正確!"); catch (sqlexception e) system.err.print(e.tostring(); db.dbclose(); 主界面用戶信息錄入界面/添加用戶代碼 private void jbtnaddactionperformed(java.awt.event.actionevent
27、evt) try connection con=drivermanager.getconnection("jdbc:odbc:cardconn","jane","123456"); java.sql.statement sql=con.createstatement(resultset.type_scroll_sensitive,resultset.concur_updatable); resultset rs=sql.executequery("select * from cardusers"); while(r
28、s.next() if(rs.getstring(1).equals(jtxtuserid.gettext() break; if(rs.isafterlast()=false) joptionpane.showmessagedialog(this,"已經(jīng)添加此用戶!"); else m.removeallelements(); checkvaliddate ck=new checkvaliddate(jtxtuserid); if(ck.check(0) string uid=jtxtuserid.gettext(); string uname=jtxtusername.
29、gettext(); string upwd=jtxtpwd.gettext(); try user=new cardusers(uid,uname,usex,upwd,utype); /userlist.add(user); m=new defaultlistmodel(); catch(pwdshortexception e) userlist.add(user); for(int j=0;j<userlist.size();j+) m.addelement(userlist.get(j); jlistuser.setmodel(m); /*數(shù)據(jù)庫操作* sqls="ins
30、ert into cardusers values ('"+uid+"','"+uname+"','"+usex+"','"+upwd+"','"+utype+"')" dbo.dboperation(sqls, 2); catch (sqlexception ex) logger.getlogger(dbusereditnew.class.getname().log(level.severe, null,
31、 ex); 修改密碼 /確定按鈕響應(yīng)事件代碼 private void jbtnokactionperformed(java.awt.event.actionevent evt) checkvaliddate ck=new checkvaliddate(txtpwdnew); if(ck.check(0) && txtpwdnew.gettext().length()>=6) if(txtpwdnew.gettext().equals(txtpwdna.gettext() db.dbconn(); string sql="update cardusers set
32、 userpwd='"+txtpwdnew.gettext()+"'where userid='"+currentuser.userid+"'" db.dbupdate(sql); db.dbclose(); jlbnote.settext("修改密碼成功!"); / joptionpane.showmessagedialog(this, "chenggong", "tishi",joptionpane.warning_message); else jl
33、bnote.settext("兩次輸入密碼不一致!"); 2.2黑盒測試void mima()char a7,b="533159"int i,j;for (j=1;j<=3;j+)/for循環(huán)來控制密碼登陸次數(shù),次數(shù)為三次printf("tt請輸入密碼:");for (i=0;i<6;i+)ai=getch();if(ai=8) i=i-2;printf("b b");elseif (ai=13)break;printf("*");ai='0'printf("n");if (strcmp(a,b)=0)/比較兩個(gè)字符串的大小,兩個(gè)字符串相同時(shí)返回0.printf("密碼正確n");break;elseprintf("tt輸入密碼錯(cuò)誤!請重新輸入:n");本程序代碼功
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 婚前個(gè)人資產(chǎn)分割與婚后共同財(cái)產(chǎn)規(guī)劃協(xié)議
- 再婚夫婦共同財(cái)產(chǎn)管理與婚內(nèi)忠誠協(xié)議書
- 建筑行業(yè)人力資源配置與績效評估合同
- 健身房教練職業(yè)發(fā)展路徑規(guī)劃合同
- 餐飲業(yè)衛(wèi)生安全標(biāo)準(zhǔn)補(bǔ)充協(xié)議
- 智能家居系統(tǒng)升級(jí)改造與售后保障服務(wù)合同
- 風(fēng)力發(fā)電設(shè)備維護(hù)與風(fēng)力資源利用補(bǔ)充合同
- 社區(qū)衛(wèi)生服務(wù)中心公共衛(wèi)生信息平臺(tái)建設(shè)與運(yùn)營服務(wù)協(xié)議
- 校招銷售崗筆試題目及答案
- 校招線上測試題庫及答案
- 《光的直線傳播》教學(xué)設(shè)計(jì) 省賽一等獎(jiǎng)
- 人工智能的誕生簡述課件
- 子宮破裂的護(hù)理查房
- 人力資源管理師二級(jí)理論知識(shí)要點(diǎn)
- 出貨檢驗(yàn)報(bào)告
- 科研成果研制任務(wù)書
- 完整版:美制螺紋尺寸對照表(牙數(shù)、牙高、螺距、小徑、中徑外徑、鉆孔)
- 市政道路綜合整治工程施工部署方案
- 無機(jī)材料科學(xué)基礎(chǔ)-第3章-晶體結(jié)構(gòu)與晶體中的缺陷
- 泄漏擴(kuò)散模型及其模擬計(jì)算
- 橋梁工程施工工藝標(biāo)準(zhǔn)圖集
評論
0/150
提交評論