《C#程序設(shè)計》課程設(shè)計報告學(xué)生成績管理系統(tǒng)
《《C#程序設(shè)計》課程設(shè)計報告學(xué)生成績管理系統(tǒng)》由會員分享,可在線閱讀,更多相關(guān)《《C#程序設(shè)計》課程設(shè)計報告學(xué)生成績管理系統(tǒng)(26頁珍藏版)》請在裝配圖網(wǎng)上搜索。
1、C#程序設(shè)計課程設(shè)計報告(2010 2011學(xué)年 第 2 學(xué)期)題 目: 專 業(yè): 班 級: 姓名學(xué)號: 指導(dǎo)教師: 成 績: 計算機科學(xué)與技術(shù)系年月日C#學(xué)生成績管理系統(tǒng)一、設(shè)計目的1、掌握簡單WinForm應(yīng)用程序的設(shè)計2、ADO.net的應(yīng)用。3、使用C#語言解決實際問題的能力二、設(shè)計內(nèi)容1、基本要求 (1)根據(jù)查詢條件實現(xiàn)學(xué)生信息的查詢。 (2)學(xué)生選課信息查詢、成績信息的查詢。 (3)學(xué)生信息、課程信息、成績信息的增加、刪除、修改。 (4)對基本信息完成增加、刪除、修改時,需注意表與表之間的關(guān)聯(lián)三、軟件設(shè)計過程 一、按照任務(wù)書寫表格1、 課程表2、 學(xué)生表3、 成績表另外添加了一張用
2、戶登陸表2、 軟件功能介紹1、登陸界面 點擊登陸后進入主界面,點擊退出即退出系統(tǒng)2、 主界面主界面有四個按鈕,分別是:學(xué)生信息查尋、學(xué)生信息修改、學(xué)生成績錄入和退出。前三個進入相應(yīng)的功能界面,退出則是退出系統(tǒng)。3、 學(xué)生信息查詢界面進入學(xué)生信息查尋界面??梢园凑招彰W(xué)號和專業(yè)進行查尋。按專業(yè)查詢:按姓名查詢:按學(xué)號查詢:點擊會顯示所選行學(xué)生的成績 以學(xué)號061101王林為例:返回鍵返回主菜單4、學(xué)生信息修改界面點擊任意一行,會將相應(yīng)學(xué)生的信息顯示在分別顯示在相應(yīng)的空格里,如圖:對其作出修改點擊更新當輸入的姓名在學(xué)生表里沒有時,如:點擊更新怎是加入一條學(xué)生信息選中一條學(xué)生信息,點擊刪除,會有提
3、示框提示是否刪除:點擊確定會提示刪除成功取消則是取消刪除。返回鍵返回主菜單5、 學(xué)生成績錄入界面進入學(xué)生成績錄入界面,顯示有記錄學(xué)生成績的學(xué)號、姓名、課程號及成績。錄入成績,以錄入Tom 學(xué)號061120課程號101為例:點擊確認即錄入成績點擊返回,返回主菜單。四、心得體會 這次課程設(shè)計,一開始無從下手。在聽過老師的講解后,逐漸知道了大體方向。開始慢慢地做了起來。碰到困難,尋求同學(xué)和網(wǎng)絡(luò)的幫助,在他們的幫助下,問題一一解決,最終完成了此次的課程設(shè)計。此次的課程設(shè)計讓我對C#和數(shù)據(jù)庫有更深一步的了解,把平時零散的理論知識在此次課程設(shè)計中用起來了。同時也發(fā)現(xiàn)了自己的不足之處,日后要多多實踐。五、源
4、程序 用戶登陸界面using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace _1 public partial class userLog : Form public userLog() InitializeComponent()
5、; public string connstr; public void Getway() connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; private void quit_Click(object sender, EventArgs e) this.Close(); private void log_Click(object sender, EventArgs e) Getway
6、(); string username = uname.Text.Trim(); string password = upassword.Text.Trim(); /string selectcommond = select * from Userxx where UserName =+ username+ and Userpassword = + password+; string _sql = select * from userinfo; /方?便?前期操作痢? 后來?要癮刪?除y的?記?住? using (SqlConnection conn = new SqlConnection(c
7、onnstr) conn.Open(); SqlCommand sql = new SqlCommand(_sql, conn); SqlDataReader reader = sql.ExecuteReader(); if (reader.Read() main open1 = new main(); open1.ShowDialog(); else if (uname.Text = ) MessageBox.Show(用?戶名?不?能為a空?!?, 錯洙?誤提?示?!?); else if (upassword.Text = ) MessageBox.Show(密碼?不?能為a空?!?,
8、錯洙?誤提?示?!?); else MessageBox.Show(不?存?在該?用?戶信?息!?, 錯洙?誤提?示?!?); uname.Text = ; upassword.Text = ; 主界面 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlC
9、lient;namespace _1 public partial class main : Form public main() InitializeComponent(); private void button1_Click_1(object sender, EventArgs e) StuinfoCheck stu1 = new StuinfoCheck(); stu1.ShowDialog(); private void button2_Click_1(object sender, EventArgs e) StuinfoAdd stu2 = new StuinfoAdd(); st
10、u2.ShowDialog(); private void button3_Click_1(object sender, EventArgs e) StuGraceinfo stu3 = new StuGraceinfo(); stu3.ShowDialog(); private void button4_Click_1(object sender, EventArgs e) this.Close(); 學(xué)生信息查詢using System;using System.Collections.Generic;using System.ComponentModel;using System.Dat
11、a;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using System.IO;namespace _1 public partial class StuinfoCheck : Form public StuinfoCheck() InitializeComponent(); public string SelectSno; private void StuinfoCheck_Load(object sender,
12、EventArgs e) / TODO: 這a行D代洙?碼?將?數(shù)簓據(jù)Y加載?到?表括?“studentDataSet.S”中D。您可以?根據(jù)Y需要癮移?動或移?除y它。 /this.sTableAdapter.Fill(this.studentDataSet.S); / TODO: 這a行D代洙?碼?將?數(shù)簓據(jù)Y加載?到?表括?“studentDataSet.C”中D。您可以?根據(jù)Y需要癮移?動或移?除y它。 /this.cTableAdapter.Fill(this.studentDataSet.C); /- string connstr = Data Source=.SQLEXPRESS
13、;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = SELECT Sno as 學(xué)號?,Sname as 姓?名?,Smajor as 專痢?業(yè)唉?Ssex as 性?別纄,Sbirth as 生?日?,totalpoint as 總哩?學(xué)分?,remark as 備?注痢?from S; / string _sql = select Sno as 學(xué)號?,Sname as 姓?名? from S; SqlConnectio
14、n cnn = new SqlConnection(connstr); SqlDataAdapter sda = new SqlDataAdapter(_sql, cnn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables0.DefaultView; string sql_Smajor=select distinct Smajor from S; SqlCommand cmd = new SqlCommand(sql_Smajor,cnn); cnn.Open(); / SqlData
15、Reader dr = new SqlDataReader(); SqlDataReader dr = cmd.ExecuteReader(); while(dr.Read() majorSelection.Items.Add(dr0); cnn.Close(); majorSelection.SelectedIndex=0; public DataSet Conn(string sql) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Conne
16、ct Timeout=30;User Instance=False; /string _sql = SELECT Sno as 學(xué)號?,Sname as 姓?名?,Smajor as 專痢?業(yè)唉?Ssex as 性?別纄,Sbirth as 生?日?,totalpoint as 總哩?學(xué)分?,remark as 備?注痢?from S; SqlConnection cnn = new SqlConnection(connstr); SqlDataAdapter sda = new SqlDataAdapter(sql, cnn); DataSet ds = new DataSet(); sda
17、.Fill(ds); return ds ; private void search_Click(object sender, EventArgs e) string sql = select * from S where 1=1 ; if (no.Text.Trim() != string.Empty) sql += and Sno like % + no.Text.Trim() + %; if (name.Text.Trim() != string.Empty) sql += and Sname like % + name.Text.Trim() + %; if (majorSelecti
18、on.Text.Trim() != 所有瓺專痢?業(yè)唉?) sql += and Smajor like % + majorSelection.Text + ; DataSet ds = Conn(sql); dataGridView1.DataSource = ds.Tables0.DefaultView; /private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) / / string str = dataGridView1.CurrentRow.
19、Cells0.Value.ToString(); / string _sql = SELECT Sno as 學(xué)號?,Sname as 姓?名?,Smajor as 專痢?業(yè)唉?Ssex as 性?別纄,Sbirth as 生?日?,totalpoint as 總哩?學(xué)分?,remark as 備?注痢?from S; / DataSet ds = Conn(_sql); / dataGridView1.DataSource = ds.Tables0.DefaultView; / private void dataGridView1_RowHeaderMouseClick(object sen
20、der, DataGridViewCellMouseEventArgs e) stuinfodetail formCourse = new stuinfodetail(); formCourse.SelectSno = dataGridView1.CurrentRow.Cells0.Value.ToString(); formCourse.ShowDialog(); private void exit_Click(object sender, EventArgs e) this.Close(); 成績顯示界面using System;using System.Collections.Gener
21、ic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace _1 public partial class stuinfodetail : Form public string SelectSno; public stuinfodetail() InitializeComponent(); private void
22、stuinfodetail_Load(object sender, EventArgs e) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = SELECT S.Sno as 學(xué)號?,Sname as 姓?名?,Cno as 課?程號?,Point 成績 FROM S,SC where S.Sno = SC.Sno and S.Sno= + t
23、his.SelectSno + ; SqlConnection cnn = new SqlConnection(connstr); cnn.Open(); SqlDataAdapter sda = new SqlDataAdapter(_sql, cnn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables0.DefaultView; cnn.Close(); 學(xué)生信息修改using System;using System.Collections.Generic;using System
24、.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace _1 public partial class StuinfoAdd : Form public StuinfoAdd() InitializeComponent(); private void StuinfoAdd_Load(object sender, EventArgs e) /
25、TODO: 這a行D代洙?碼?將?數(shù)簓據(jù)Y加載?到?表括?“studentDataSet.S”中D。您可以?根據(jù)Y需要癮移?動或移?除y它。 /this.sTableAdapter.Fill(this.studentDataSet.S); / TODO: 這a行D代洙?碼?將?數(shù)簓據(jù)Y加載?到?表括?“studentDataSet.C”中D。您可以?根據(jù)Y需要癮移?動或移?除y它。 /this.cTableAdapter.Fill(this.studentDataSet.C); /- string connstr = Data Source=.SQLEXPRESS;AttachDbFilena
26、me=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = SELECT Sno as 學(xué)號?,Sname as 姓?名?,Smajor as 專痢?業(yè)唉?Ssex as 性?別纄,Sbirth as 生?日?,totalpoint as 總哩?學(xué)分?,remark as 備?注痢?from S; / string _sql = select Sno as 學(xué)號?,Sname as 姓?名? from S; SqlConnection cnn = new Sql
27、Connection(connstr); SqlDataAdapter sda = new SqlDataAdapter(_sql, cnn); DataSet ds = new DataSet(); sda.Fill(ds); dataGridView1.DataSource = ds.Tables0.DefaultView; /string sql_Smajor = select distinct Smajor from S; /SqlCommand cmd = new SqlCommand(sql_Smajor, cnn); cnn.Open(); /SqlDataReader dr =
28、 new SqlDataReader(); /SqlDataReader dr = cmd.ExecuteReader(); /while (dr.Read() / / majorSeletion.Items.Add(dr0); / /cnn.Close(); /majorSeletion.SelectedIndex = 0; private void delete_Click(object sender, EventArgs e) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrat
29、ed Security=True;Connect Timeout=30;User Instance=False; DialogResult ret = MessageBox.Show(確?定要癮刪?除y該?信?息嗎e??, 刪?除y, MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if(ret = DialogResult.Cancel) return; string _sql=delete from S where Sno=+stuno.Text+; SqlConnection conn = new SqlConnectio
30、n(connstr); SqlCommand cmd = new SqlCommand(_sql,conn); try conn .Open(); int rows=cmd .ExecuteNonQuery(); if(rows = 1) MessageBox.Show(刪?除y成功|!?, 提?示?, MessageBoxButtons.OK, MessageBoxIcon.Information); StuinfoAdd_Load(null ,null ); finally conn.Close(); private void dataGridView1_RowHeaderMouseCli
31、ck(object sender, DataGridViewCellMouseEventArgs e) stuno.Text = dataGridView1.CurrentRow.Cells0.Value.ToString(); stuname.Text = dataGridView1.CurrentRow.Cells1.Value.ToString(); cname.Text = dataGridView1.CurrentRow.Cells2.Value.ToString(); stubirth.Text = dataGridView1.CurrentRow.Cells4.Value.ToS
32、tring(); credit.Text = dataGridView1.CurrentRow.Cells5.Value.ToString(); sturemark.Text = dataGridView1.CurrentRow.Cells6.Value.ToString(); if (dataGridView1.CurrentRow.Cells3.Value.ToString().Trim () = 男D) male.Checked = true; else female.Checked = true; /stubirth.Text = Convert.ToDateTime(stubirth
33、.Text.Trim().ToShortDateString(); private void updata_Click(object sender, EventArgs e) /更新?信?息 string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _title = select count(*) from S where sno= + stuno.Text + ;
34、 SqlConnection conn = new SqlConnection(connstr); SqlCommand cmd = new SqlCommand(_title, conn); /檢查是?否?有瓺該?學(xué)生?的?信?息,?有瓺則修T改?,?無T則添?加 try conn.Open(); int str = (int)cmd.ExecuteScalar();/強?制?轉(zhuǎn)羇換?,?執(zhí)行D查詢并返?回?查詢所返?回?的?結(jié)果?集中D第臺?一?行D的?第臺?一?列 /修T改?信?息 if (str = 1) _title = update S set Sname = + stuname.
35、Text + ,Smajor = + cname.Text + ,totalpoint = + int.Parse(credit.Text) + ,remark= + sturemark.Text + where Sno= + stuno.Text + ; /添?加新?信?息 else /DateTime cn = Convert.ToDateTime(stubirth.Text.Trim(); string sex = male.Checked ? 男D : 女?; _title = insert into S(Sno,Sname,Smajor,Ssex,Sbirth,totalpoint,
36、remark) values ( + stuno.Text + , + stuname.Text + , + cname.Text + , + sex + , + stubirth.Text.Trim() + , + int.Parse(credit.Text) + , + sturemark.Text + ); cmd = new SqlCommand(_title, conn); cmd.ExecuteNonQuery(); StuinfoAdd_Load(null, null); finally conn.Close(); private void exit_Click(object s
37、ender, EventArgs e) this.Close(); 學(xué)生成績錄入using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace _1 public partial class StuGraceinfo : Form pu
38、blic StuGraceinfo() InitializeComponent(); private void StuGraceinfo_Load(object sender, EventArgs e) string connstr = Data Source=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = SELECT S.Sno as 學(xué)號?,Sname as 姓?名?,Cno as 課?程號?
39、,Point as 成績 FROM S,SC where S.Sno=SC.Sno; /SELECT Sno as 學(xué)號?,Sname as 姓?名?,Smajor as 專痢?業(yè)唉?Ssex as 性?別纄,Sbirth as 生?日?,totalpoint as 總哩?學(xué)分?,remark as 備?注痢?from S SqlConnection cnn = new SqlConnection(connstr); SqlDataAdapter sda = new SqlDataAdapter(_sql, cnn); cnn.Open(); DataSet ds = new DataSet(
40、); sda.Fill(ds); dataGridView1.DataSource = ds.Tables0.DefaultView; /cnn.Close(); private void button3_Click(object sender, EventArgs e) this.Close(); private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) textBox1.Text = dataGridView1.CurrentRow.Cells1
41、.Value.ToString(); textBox3.Text = dataGridView1.CurrentRow.Cells0.Value.ToString(); textBox4.Text = dataGridView1.CurrentRow.Cells3.Value.ToString(); textBox6.Text = dataGridView1.CurrentRow.Cells2.Value.ToString(); private void button1_Click(object sender, EventArgs e) string connstr = Data Source
42、=.SQLEXPRESS;AttachDbFilename=E:1Student.mdf;Integrated Security=True;Connect Timeout=30;User Instance=False; string _sql = select count(*) from S where S.Sno= + textBox1.Text + ; string sql1 = select Cno from C where Cno= + textBox6 .Text + ; SqlConnection cnn = new SqlConnection(connstr); SqlComma
43、nd cmd = new SqlCommand(_sql,cnn); SqlCommand cmd1 = new SqlCommand(sql1, cnn); string cno=; try cnn.Open(); SqlDataReader dr = cmd1.ExecuteReader(); while (dr.Read() cno = dr0.ToString(); cnn.Close(); cnn.Open(); int cnt = (int)cmd.ExecuteScalar(); /制?轉(zhuǎn)羇化 返?回?第臺?一?行D第臺?一?列 修T改?記?錄? if (cnt = 1) _sq
44、l = update SC set Point= + textBox4.Text + ,Cno= + textBox6.Text + where Sno=+textBox1.Text +; else /添?加記?錄? _sql = insert into SC(Sno,Cno,Point) values( + textBox3.Text.Trim() + , + textBox6.Text.Trim() + , + int.Parse(textBox4.Text.Trim() + ); cmd = new SqlCommand(_sql, cnn); int i = cmd.ExecuteNonQuery(); StuGraceinfo_Load(null, null); finally cnn.Close(); 設(shè)計日志記錄每天的主要設(shè)計內(nèi)容、遇到的問題、解決方法及效果,等。DAY 1聽了老師對系統(tǒng)架構(gòu)的部分分析,對本次課程設(shè)計有了大致的了解,明確了大體框架,把任務(wù)書上的數(shù)據(jù)庫表準備好了,并簡單地完成了系統(tǒng)各個窗體的設(shè)計。DAY 2對各個窗體進行了更為細致的設(shè)計,對需要用到的事件和要修改的屬性進行適當分配,以便設(shè)計代碼時能對整體更清晰,完成了用戶登陸的代碼設(shè)計。DAY 3開始代碼設(shè)計,實現(xiàn)了學(xué)生信息查詢的功能。在這過程中,遇到了許多問題諸如數(shù)據(jù)庫的
- 溫馨提示:
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)容負責。
6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 道路運輸組織 客運設(shè)施現(xiàn)代化PPT課件
- 應(yīng)用程序的結(jié)構(gòu)工程師課件
- 正弦穩(wěn)態(tài)分析
- 汽車照明與信號系統(tǒng)1
- 攝像頭的工作原理PPT課件
- 高中英語課程標準簡介
- 目標管理實務(wù)布衣公子作品版teliss課件
- 高中英語新課程通識培訓(xùn)校本研修
- (河南專版)九年級化學(xué)上冊 第五單元 化學(xué)方程式 課題1 第2課時 化學(xué)方程式(增分課練)習(xí)題課件 (新版)新人教版
- XXXX年淥口三級聯(lián)儲推介會講稿
- 131平方根(教育精品)
- 一年級《漢語拼音復(fù)習(xí)三》課件(教育精品)
- 為品牌戰(zhàn)略奠定基礎(chǔ)
- 化妝整體服務(wù)方案課件
- 同分異構(gòu)體的書寫課件