基于delphi的學(xué)生成績管理系統(tǒng)_第1頁
基于delphi的學(xué)生成績管理系統(tǒng)_第2頁
基于delphi的學(xué)生成績管理系統(tǒng)_第3頁
基于delphi的學(xué)生成績管理系統(tǒng)_第4頁
基于delphi的學(xué)生成績管理系統(tǒng)_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上南昌航空大學(xué)信息工程學(xué)院 數(shù)據(jù)庫原理 課程實(shí)驗(yàn)報(bào)告 實(shí)驗(yàn)名稱: 學(xué)生成績信息管理系統(tǒng)實(shí)驗(yàn)時(shí)間: 2010年月2日指導(dǎo)教師: 班 級 : 學(xué) 號 : 姓 名 : 成 績 : 一、實(shí)驗(yàn)?zāi)康模?) 通過完成從用戶需求分析、系統(tǒng)概要設(shè)計(jì)、系統(tǒng)詳細(xì)設(shè)計(jì)以及數(shù)據(jù)庫的SQL操作具體實(shí)現(xiàn)等全過程,把前面的各個(gè)實(shí)驗(yàn)更好地綜合起來.(2) 進(jìn)一步理解和掌握教材中的相關(guān)內(nèi)容。(3) 掌握分析和設(shè)計(jì)一個(gè)大型數(shù)據(jù)庫系統(tǒng)的基本思路與方法。二、 實(shí)驗(yàn)要求1. 獨(dú)立完成該系統(tǒng)的數(shù)據(jù)庫設(shè)計(jì)。2. 用SQL實(shí)現(xiàn)數(shù)據(jù)庫的設(shè)計(jì),并在MS SQL Server上調(diào)試通過。3. 寫出查詢、更新以及建立觸發(fā)器SQ

2、L語句和執(zhí)行結(jié)果。4. 掌握報(bào)表的使用。三、實(shí)驗(yàn)內(nèi)容綜合前面各章內(nèi)容設(shè)計(jì)并調(diào)試一學(xué)生成績管理系統(tǒng),Delphi作為前臺開發(fā)工具,SQL Server完成后臺數(shù)據(jù)庫存管理。創(chuàng)建學(xué)生成績的統(tǒng)計(jì)(包括求班級各科成績的平均分);并實(shí)現(xiàn)對各科成績等的錄入、修改、刪除、查詢等功能;實(shí)現(xiàn)學(xué)生成績的統(tǒng)計(jì)(包括求班級各科成績的平均分);并實(shí)現(xiàn)對各科成績的排序。四、實(shí)驗(yàn)代碼及功能注釋用戶登陸界面實(shí)驗(yàn)程序:procedure TForm1.Button1Click(Sender: TObject);用戶登陸var ret:integer;beginadoconnection1.Open;with ADOStored

3、Proc1 dobeginClose;ProcedureName:='proc_login'Parameters.Clear;Parameters.Refresh;Parameters.ParamByName('username').Value:= Edit1.text;Parameters.ParamByName('password').Value:= Edit2.text;ExecProc;ret:= Parameters.ParamByName('return_value').Value;end;if ret=1 then

4、/用戶名密碼匹配beginshowmessage('登陸成功');form3.show;endelseshowmessage('你不是用戶,請注冊');end ;procedure TForm1.Button2Click(Sender: TObject);若不是用戶,觸發(fā)用戶登陸界面顯示beginform2.show;end;procedure TForm1.Button3Click(Sender: TObject);退出該管理系統(tǒng)beginform1.Close;end;說明:在這里,使用了adostoredproc1控件和adoconnection1控件,它

5、們的connectionstring屬性都要與所設(shè)計(jì)的數(shù)據(jù)庫相連,在查詢分析器中,要運(yùn)行存儲過程如下:CREATE procedure proc_loginusername varchar(20),password varchar(20)asdeclare result intselect result=count(*) from users where username=username and passwords=passwordif result=0return 0return 1GO用戶注冊界面實(shí)驗(yàn)程序:procedure TForm2.Button1Click(Sender: TOb

6、ject);新用戶注冊begin adoquery1.close; adoquery1.sql.clear; adoquery1.sql.add('insert into users(username,passwords,核對密碼,性別,出生年月,聯(lián)系地址,聯(lián)系電話,郵政編碼,電子郵箱)'+'values(:1,:2,:3,:4,:5,:6,:7,:8,:9)'); adoquery1.parameters.parambyname('1').value:=''+edit1.text+'' adoquery1.par

7、ameters.parambyname('2').value:=''+edit2.text+'' adoquery1.parameters.parambyname('3').value:=''+edit3.text+'' adoquery1.parameters.parambyname('4').value:=''+combobox1.text+'' adoquery1.parameters.parambyname('5').value

8、:=''+combobox1.text+' '+combobox1.text+'' adoquery1.parameters.parambyname('6').value:=''+edit4.text+'' adoquery1.parameters.parambyname('7').value:=''+edit5.text+'' adoquery1.parameters.parambyname('8').value:=''

9、;+edit6.text+'' adoquery1.parameters.parambyname('9').value:=''+edit7.text+'' adoquery1.execsql;end;說明:在該數(shù)據(jù)庫中,建了一個(gè)名為users的用戶表,存儲用戶的信息。只有是用戶在登陸時(shí),才能進(jìn)入主界面,當(dāng)不是用戶在登陸時(shí),必須先進(jìn)行新用戶注冊,才能進(jìn)入主系統(tǒng)。 系統(tǒng)主界面學(xué)生基本信息查詢精確查詢程序:procedure TForm3.Button1Click(Sender: TObject);beginwith adoquery1

10、 dobegin if radiobutton1.Checked then /通過單選按鈕的選擇來判斷是要進(jìn)行精確查詢還是模糊查詢 begin adoquery1.Close ; adoquery1.SQL.Clear ; adoquery1.SQL.Add('select * from 學(xué)生表 where 學(xué)號='''+edit1.text+'''' ); adoquery1.Open; end;end;說明:由于學(xué)生表中,學(xué)號為主鍵,因此要查此表中學(xué)生基本信息,只要輸入主鍵值即可得一條記錄,即實(shí)現(xiàn)精確查詢。模糊查詢程序:pro

11、cedure TForm3.Button3Click(Sender: TObject);begin with adoquery1 do begin if radiobutton2.Checked then begin if (edit2.Text <>'')or (edit3.Text <>'')or(edit4.Text <>'')or(edit5.Text <>'') or(edit6.Text <>'')then begin adoquery1.Cl

12、ose; adoquery1.SQL.Clear; adoquery1.SQL.Add('select * from 學(xué)生表'); adoquery1.SQL.Add('where(學(xué)號 like '''+'%'+edit2.text+'%'+''')'); adoquery1.SQL.Add('or(姓名 like '''+'%'+edit3.text+'%'+''')'); adoqu

13、ery1.SQL.Add('or(所在系別 like '''+'%'+edit4.text+'%'+''')'); adoquery1.SQL.Add('or(所在專業(yè) like '''+'%'+edit5.text+'%'+''')'); adoquery1.SQL.Add('or(所在班級 like '''+'%'+edit6.text+'%&#

14、39;+''')'); adoquery1.Open ; end else begin application.MessageBox('沒有查詢條件','提示',mb_ok); exit; end; end; end;end;說明:當(dāng)輸入的信息不是主鍵時(shí),由于滿足該輸入條件的記錄可能不只一個(gè),因此得到的是一個(gè)模糊查詢的結(jié)果。學(xué)生成績查詢方法與學(xué)生基本信息查詢一致。學(xué)生基本信息錄入實(shí)驗(yàn)程序:procedure TForm4.Button1Click(Sender: TObject);begin adoquery1.close; ad

15、oquery1.sql.clear; adoquery1.sql.add('insert into 學(xué)生表(學(xué)號,姓名,民族,出生年月,籍貫,性別,所在系別,所在專業(yè),所在班級,政治面貌,家庭住址,郵政編碼,聯(lián)系電話)'+'values(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13)'); adoquery1.parameters.parambyname('1').value:=''+edit1.text+'' adoquery1.parameters.parambyname

16、('2').value:=''+edit2.text+'' adoquery1.parameters.parambyname('3').value:=''+edit3.text+'' adoquery1.parameters.parambyname('4').value:=''+combobox1.text+' '+combobox2.text+'' adoquery1.parameters.parambyname('5'

17、;).value:=''+edit4.text+'' adoquery1.parameters.parambyname('6').value:=''+combobox3.text+'' adoquery1.parameters.parambyname('7').value:=''+combobox4.text+'' adoquery1.parameters.parambyname('8').value:=''+edit5.text+&#

18、39;' adoquery1.parameters.parambyname('9').value:=''+edit6.text+'' adoquery1.parameters.parambyname('10').value:=''+edit7.text+'' adoquery1.parameters.parambyname('11').value:=''+edit8.text+'' adoquery1.parameters.parambynam

19、e('12').value:=''+edit9.text+'' adoquery1.parameters.parambyname('13').value:=''+edit10.text+'' adoquery1.execsql;end;在SQL Server中查看錄入結(jié)果錄入前:錄入后:說明:從錄入前與錄入后表的比較看到,實(shí)現(xiàn)了學(xué)號為aaa學(xué)生基本信息的錄入。求學(xué)生平均成績、成績排序并顯示實(shí)驗(yàn)程序:procedure TForm3.Button4Click(Sender: TObject);begi

20、n with adoquery1 dobegin if radiobutton3.Checked then與學(xué)生基本信息查詢一樣,這里為成績精確查詢 beginadoquery1.Close ; adoquery1.SQL.Clear ; adoquery1.SQL.Add('select * from 成績信息表 where 學(xué)號='''+edit9.text+'''' ); adoquery1.Open; end; if radiobutton4.Checked then與學(xué)生基本信息查詢一樣,這里為成績模糊查詢 begin

21、if (edit10.text <>'')or (edit11.Text <>'')or(edit12.Text <>'')or(edit13.Text <>'') or(edit14.Text <>'')then begin adoquery1.Close; adoquery1.SQL.Clear; adoquery1.SQL.Add('select * from 成績信息表'); adoquery1.SQL.Add('where

22、(學(xué)號 like '''+'%'+edit10.text+'%'+''')'); adoquery1.SQL.Add('or(姓名 like '''+'%'+edit11.text+'%'+''')'); adoquery1.SQL.Add('or(所在系別 like '''+'%'+edit12.text+'%'+''')&

23、#39;); adoquery1.SQL.Add('or(所在專業(yè) like '''+'%'+edit13.text+'%'+''')'); adoquery1.SQL.Add('or(所在班級 like '''+'%'+edit14.text+'%'+''')'); adoquery1.Open ; end else begin application.MessageBox('沒有查詢條件

24、9;,'提示',mb_ok); exit; end; end; if radiobutton9.Checked then求每個(gè)學(xué)生的課程平均成績 begin adoquery1.Close ; sql.Clear ; sql.Add('select 學(xué)號,姓名,AVG(成績) as 平均成績 from 成績信息表 where 所在班級='''' group by 學(xué)號,姓名'); adoquery1.Open ; end; if radiobutton11.Checked then將學(xué)生成績按從低到高排序 begin adoque

25、ry1.Close ; sql.Clear ; sql.Add('select 學(xué)號,姓名,avg(成績) as 平均成績 from 成績信息表 group by 學(xué)號,姓名 order by 平均成績'); adoquery1.open; end;end;end;求平均成績界面與平均成績排序后界面:說明:使用到了數(shù)據(jù)庫的自帶函數(shù)avg() 來求平均成績,按平均成績排序時(shí),只要在已經(jīng)做好的平均成績顯示程序上加上order by 語句即可。學(xué)生基本信息刪除與修改實(shí)驗(yàn)程序:procedure TForm3.Button6Click(Sender: TObject);begin wi

26、th adoquery1 do begin if radiobutton7.Checked then begin adoquery1.Close ; adoquery1.SQL.Clear ; adoquery1.SQL.Add('update 學(xué)生表 set '+combobox1.text+'='''+edit19.text+''''); /edit19 編輯框用來輸入要更改的字段名 adoquery1.SQL.Add('where 學(xué)號='''+edit18.text+''''); adoquery1.execsql; end; if radiobutton8.Checked then begin adoquer

溫馨提示

  • 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論