數(shù)據(jù)庫課程設計--運動會成績管理系統(tǒng)--用c#做_第1頁
數(shù)據(jù)庫課程設計--運動會成績管理系統(tǒng)--用c#做_第2頁
數(shù)據(jù)庫課程設計--運動會成績管理系統(tǒng)--用c#做_第3頁
數(shù)據(jù)庫課程設計--運動會成績管理系統(tǒng)--用c#做_第4頁
數(shù)據(jù)庫課程設計--運動會成績管理系統(tǒng)--用c#做_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、目錄第一章 系統(tǒng)概述11.1 開發(fā)背景.11.2 系統(tǒng)開發(fā)的目的11.3 軟件定義11.4 開發(fā)環(huán)境2第二章 需求分析.32.1 問題陳述32,2 功能需求分析32.3 數(shù)據(jù)流圖42.4 數(shù)據(jù)字典5第三章 概念結構設計.93.1 管理員E-R圖.93.2 用戶E-R圖.93.3 比賽項目E-R圖.93.4 成績表E-R圖.103.5 運動員E-R圖.103.6 總E-R圖.10第四章 邏輯結構設計.114.1 管理員表.114.2 用戶表.114.3 運動員表.124.4 比賽項目表.124.5 成績表.124.6 定義索引.13第五章 軟件功能設計.145.1 功能結構圖.145.2 功能結

2、構詳述.15第六章 代碼設計和界面設計.166.1登陸界面.166.2 添加運動員信息界面.166.3查詢信息界面.17 6.3.1查詢運動員信息.17 6.3.2查詢各個項目的第一名.17 6.3.3查詢運動員成績信息.18 6.3.4查詢運動會所有信息.186.4 刪除信息界面.196.5 錄入成績信息界面.196.6 運動員查詢界面.196.7 主要代碼.20第七章 總結與體會.29參考文獻.30 第六章 代碼設計和界面設計 本課程設計設計了兩種身份可進入運動會成績管理系統(tǒng),分別是管理員和與運動員,他們的權限也有所不同,管理員可以添加運動員信息,可以查詢運動員信息,可以查詢運動員成績信息

3、,可以查詢項目信息,可以刪除運動員,也可以刪除運動員的項目信息,還可以錄入運動員成績信息,最終顯示出每個項目的前三名。而運動員只能查看自己的個人信息和項目信息以及成績信息。此為該課程設計的主要功能。以下是各個功能的界面及主要代碼。6.1、登陸界面: 此界面功能只有運動員和管理員可進入,輸入用戶名和口令和選擇身份登錄,即可進入運動會成績管理系統(tǒng)。6.2、以管理員身份進入系統(tǒng),這是添加運動員信息界面,輸入運動員信息,點擊確定,即可添加成功,可在此查詢,也可在數(shù)據(jù)庫中查詢。6.3、查詢信息 6.3.1、查詢運動員信息 此界面須輸入運動員編號,即可查詢運動員的所有信息,如果現(xiàn)實成績?yōu)榭眨瑒t為成績尚未公

4、布,否則直接顯示成績。 6.3.2、查詢各個項目的第一名 點擊查詢,系統(tǒng)自動查詢出所有項目的第一名。6.3.3、查詢運動員成績信息 次界面功能是查詢出運動院內(nèi)成績,輸入運動員編號和所參加的醒目名稱,點擊查詢,即可查詢出該運動員在該項目中的成績,如果此成績?yōu)榭?,表示該運動員該項目成績還未公布或該項目還未開始比賽。6.3.4、查詢運動會所有信息 此界面可以查詢所有信息。6.4、刪除信息次界面有兩個功能,左邊是刪除運動員項目,此要先輸入要刪除運動員的編號和所參加的的項目名稱,點擊確定,即可刪除成功。右邊是刪除運動員,直接輸入運動員編號,點擊確定,即可刪除成功。6.5、錄入成績此界面功能是為運動員錄入

5、成績,要先輸入運動員的編號和所參加的項目名稱,輸入成績,點擊確定,即可錄入成功。所有查詢成績,都要先在此錄入,才可查詢得到成績,否則查詢到的成績都為空。6.6、運動員查詢以運動員身份進入該管理系統(tǒng),只能進行查詢,此界面跟管理員查詢界面相同,故在此不再贅述。主要代碼如下:登錄界面:private void button1_Click(object sender, EventArgs e) string username = textBox1.Text; string password = textBox2.Text; string connString = Data Source = . ; I

6、nitial Catalog=db ; User ID=crl ; Pwd=123; SqlConnection connection = new SqlConnection(connString); connection.Open();/打開數(shù)據(jù)庫 if (radioButton1.Checked = true) string sql = String.Format(select count(*) from athlete where username=0and password=1,username,password); try SqlCommand command = new SqlCo

7、mmand(sql, connection);/創(chuàng)建command對象 int num = (int)command.ExecuteScalar();/執(zhí)行查詢語句 if (num 0) MessageBox.Show(歡迎進入安徽工程大學運動會管理系統(tǒng)!, 登陸成功!, MessageBoxButtons.OK, MessageBoxIcon.Information); athlete_information athlete = new athlete_information(); athlete.Show(); this.Visible = false; else MessageBox.S

8、how(您輸入的用戶名和密碼有誤!, 登錄失?。? MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBox1.Text = ;/如果登錄失敗,設置兩個textBox為空,且光標處在textBox1的位置 textBox2.Text = ; textBox1.Focus(); radioButton1.Checked =false; / 設置radioButton為空 radioButton3.Checked = false; catch (Exception ex) MessageBox.Show(ex.Message, 操作數(shù)據(jù)庫

9、錯誤!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally connection.Close(); if (radioButton3.Checked = true) /以管理員身份進入管理系統(tǒng) string sql = String.Format(select count(*) from dba where username=0and password=1, username, password); try SqlCommand command = new SqlCommand(sql, connection);/創(chuàng)建comm

10、and對象 int num = (int)command.ExecuteScalar();/執(zhí)行查詢語句 if (num 0) MessageBox.Show(歡迎進入安徽工程大學運動會管理系統(tǒng)!, 登陸成功!, MessageBoxButtons.OK, MessageBoxIcon.Information); dba_operations operation = new dba_operations(); operation.Show(); this.Visible = false; else MessageBox.Show(您輸入的用戶名和密碼有誤!, 登錄失敗!, MessageBox

11、Buttons.OK, MessageBoxIcon.Exclamation); textBox1.Text = ;/如果登錄失敗,設置兩個textBox為空,且光標處在textBox1的位置 textBox2.Text = ; textBox1.Focus(); radioButton1.Checked = false; / 設置radioButton為空 radioButton3.Checked = false; catch (Exception ex) MessageBox.Show(ex.Message, 操作數(shù)據(jù)庫錯誤!, MessageBoxButtons.OK, MessageB

12、oxIcon.Exclamation); finally connection.Close(); if (radioButton1.Checked = false | radioButton3.Checked = false) MessageBox.Show(請選擇身份后登錄, 登錄失敗, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textBox1.Text = ;/如果登錄失敗,設置兩個textBox為空,且光標處在textBox1的位置 textBox2.Text = ; textBox1.Focus(); radioButton

13、1.Checked = false; radioButton3.Checked = false; private void button2_Click(object sender, EventArgs e) textBox1.Text = ; textBox2.Text = ; textBox1.Focus(); 添加運動運信息代碼:private void button1_Click(object sender, EventArgs e) string connString = Data Source = . ; Initial Catalog=db ; User ID=crl ; Pwd=

14、123; SqlConnection connection = new SqlConnection(connString); connection.Open();/打開數(shù)據(jù)庫 /創(chuàng)建添加運動員信息的Sql語句,一個運動員可以添加多個項目,同時對應的有多個時間 string sql = String.Format(insert into player(snum,sno,sname,sex,grade,col,items,times) + values(0,1,2,3,4,5,6,7), textBox1.Text, textBox3.Text, textBox2.Text, comboBox2.

15、Text, comboBox4.Text, comboBox1.Text, comboBox3.Text, comboBox7.Text); try SqlCommand command = new SqlCommand(sql, connection); int count = command.ExecuteNonQuery(); if (count 0) MessageBox.Show(添加運動員信息成功, 添加成功!, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(添加運動員信息失敗, 添加

16、失?。? MessageBoxButtons.OK, MessageBoxIcon.Exclamation); catch(Exception ex) MessageBox.Show(ex.Message, 操作數(shù)據(jù)庫出錯!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally connection.Close(); 查詢運動員信息:private void button3_Click(object sender, EventArgs e) string connString = Data Source = . ; Initia

17、l Catalog=db ; User ID=crl ; Pwd=123; SqlConnection connection = new SqlConnection(connString); connection.Open();/打開數(shù)據(jù)庫 string sql = String.Format(select * from player where snum=0,textBox4.Text); SqlCommand command = new SqlCommand(sql, connection); SqlDataReader datareader=command.ExecuteReader()

18、; try while (datareader.Read() textBox7.Text = datareadersnum.ToString().Trim(); textBox10.Text = datareadersname.ToString().Trim(); textBox13.Text = datareadercol.ToString().Trim(); textBox11.Text = datareadergrade.ToString().Trim(); textBox9.Text = datareadersno.ToString().Trim(); textBox12.Text =

19、 datareadersex.ToString().Trim(); textBox16.Text = datareaderscore.ToString().Trim(); richTextBox1.Text += datareaderitems.ToString().Trim()+n; richTextBox6.Text += datareadertimes.ToString().Trim()+n; catch (Exception ex) MessageBox.Show(ex.Message, 操作數(shù)據(jù)庫出錯!, MessageBoxButtons.OK, MessageBoxIcon.Ex

20、clamation); finally datareader.Close(); connection.Close(); 查詢運動員成績:private void button4_Click_1(object sender, EventArgs e) string connString = Data Source = . ; Initial Catalog=db ; User ID=crl ; Pwd=123; SqlConnection connection = new SqlConnection(connString); connection.Open();/打開數(shù)據(jù)庫 string sql

21、 = String.Format(select * from player where snum=0and items=1, textBox14.Text,comboBox5.Text); SqlCommand command = new SqlCommand(sql, connection); SqlDataReader datareader = command.ExecuteReader(); try while (datareader.Read() if (datareaderscore.ToString().Trim()=null ) label11.Text = String.For

22、mat(成績還未公布!); else textBox15.Text = datareaderscore.ToString().Trim(); catch (Exception ex) MessageBox.Show(ex.Message, 操作數(shù)據(jù)庫出錯!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally datareader.Close(); connection.Close(); 查詢各個項目第一名:private void button14_Click(object sender, EventArgs e) strin

23、g connString = Data Source = . ; Initial Catalog=db ; User ID=crl ; Pwd=123; SqlConnection connection = new SqlConnection(connString); connection.Open();/打開數(shù)據(jù)庫 string sql = String.Format(select snum,sname,score from player where score=(select distinct MAX(score)from player )and items=1500m); SqlComm

24、and command = new SqlCommand(sql, connection); SqlDataReader datareader; datareader = command.ExecuteReader(); try while (datareader.Read() textBox21.Text += datareadersnum.ToString().Trim() + ; textBox21.Text += datareadersname.ToString().Trim() + ; textBox21.Text += datareaderscore.ToString().Trim

25、() + ; catch (Exception ex) MessageBox.Show(ex.Message, 操作數(shù)據(jù)庫出錯!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally datareader.Close(); connection.Close(); 刪除運動員項目:private void button13_Click(object sender, EventArgs e) string snum = textBox20.Text; string items = comboBox17.Text; string co

26、nnString = Data Source = . ; Initial Catalog=db ; User ID=crl ; Pwd=123; SqlConnection connection = new SqlConnection(connString); connection.Open();/打開數(shù)據(jù)庫 string sql = String.Format(delete from player where snum=0and items=1,snum,items); SqlCommand command = new SqlCommand(sql, connection); / comma

27、nd.CommandText = sql; int num = (int)command.ExecuteNonQuery(); try if (num 0) MessageBox.Show(刪除運動員參賽項目成功, 刪除成功!, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(刪除運動員參賽項目失敗, 刪除失敗!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); catch (Exception ex) MessageBox.Show(ex.Me

28、ssage, 操作數(shù)據(jù)庫出錯!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally connection.Close(); 刪除運動員:private void button8_Click(object sender, EventArgs e) string snum=textBox5.Text; string connString = Data Source = . ; Initial Catalog=db ; User ID=crl ; Pwd=123; SqlConnection connection = new Sql

29、Connection(connString); connection.Open();/打開數(shù)據(jù)庫 string sql = String.Format(delete from player where snum=0,snum); SqlCommand command = new SqlCommand(sql, connection); / command.CommandText = sql; int num = (int)command.ExecuteNonQuery(); try if (num 0) MessageBox.Show(刪除運動員成功, 刪除成功!, MessageBoxBut

30、tons.OK, MessageBoxIcon.Information); else MessageBox.Show(刪除運動員失敗, 刪除失敗!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); catch (Exception ex) MessageBox.Show(ex.Message, 操作數(shù)據(jù)庫出錯!, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally connection.Close(); 錄入成績:private void button9_Click(obje

31、ct sender, EventArgs e) string score = textBox8.Text; string snum = textBox6.Text; string items = comboBox16.Text; string connString = Data Source = . ; Initial Catalog=db ; User ID=crl ; Pwd=123; SqlConnection connection = new SqlConnection(connString); connection.Open();/打開數(shù)據(jù)庫 string sql = String.Format(update player set score=0where snum=1and items=2,score,snum,items); SqlCommand command = new SqlCommand(sq

溫馨提示

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

評論

0/150

提交評論