軟件工程實驗報告_第1頁
軟件工程實驗報告_第2頁
軟件工程實驗報告_第3頁
軟件工程實驗報告_第4頁
軟件工程實驗報告_第5頁
已閱讀5頁,還剩18頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上軟件工程實驗報告實驗題目:軟件工程制圖實驗七 一個學生選課系統(tǒng)的實現(xiàn)1、 教學目的: 培養(yǎng)學生運用軟件工程方法開發(fā)和測試系統(tǒng)的能力。2、 教學成果: 能夠熟練運用一種開發(fā)工具和數(shù)據(jù)庫開發(fā)與測試一個學生選課系統(tǒng)。3、 實驗要求: 1.系統(tǒng)管理員可以對學生、教師、選課和課程成績進行增、刪、改和查。 2.系統(tǒng)管理員可對學生選擇課程進行查詢統(tǒng)計,并生成柱狀圖并導出(每門課選擇人數(shù)統(tǒng)計)。 3.學院管理員可對本學院教師、學生、本學院學生選課、本學院開設(shè)課程和成績進行增刪改查。 4.學院對選擇課程的學生進行抽簽,并按課程生成中簽學生名單。 5. 教師可以登錄本系統(tǒng),在網(wǎng)站上輸入課

2、程介紹、上傳課程的課件、發(fā)布、先修課程、更新和修改課程信息。 6.教師可查詢選修自己課程的所有中簽學生名單,并錄入課程成績生成成績統(tǒng)計表(每個分數(shù)段的人數(shù),及格率等)。 7.教師可對選修自己課程學生發(fā)送消息留言 。 8. 學生通過客戶機瀏覽器根據(jù)學號和密碼進入選課界面,在這里學生可以進行查詢已選課程、指定自己的選修課程以及對自己基本信息的查詢; 9.學生可以查詢自己選課結(jié)果。 10.學生選課時,如果該門課程的先修課程沒有學習,則不能進行選課,并給出提示“您沒有學習該課程的先修課程,不能進行選課!”。 11.學生可瀏覽課程信息和查詢成績,下載課件。 12.學生可給任課教師發(fā)送信息和回復任課教師的

3、留言。4、 系統(tǒng)概述: 本系統(tǒng)是一個簡化版的學生管理系統(tǒng),系統(tǒng)登錄有三種身份:學生、教師、管理員。 數(shù)據(jù)流程圖:E-R圖:數(shù)據(jù)字典:課程信息表:名稱簡稱鍵值類型長度課程號cnopvarchar30課程名cnamevarchar30教師表號tnovarchar30所屬系departmentvarchar30學分gradeint上課時間ctimevarchar30上課地點clocalvarchar30先修課provarchar30學生信息表:名稱簡稱鍵值類型長度學號snopvarchar30姓名snamevarchar30性別ssexvarchar30年齡oldint電話phonevarchar3

4、0系別departmentvarchar30密碼secretvarchar30教師信息表:名稱簡稱鍵值類型長度教師編號tnopvarchar30姓名tnamevarchar30性別tsexvarchar30職稱professvarchar30電話tphonevarchar30密碼secretvarchar30選課表:名稱職稱鍵值類型長度學號snopvarchar30課程號cnopvarchar30教師編號tnovarchar30成績scoreint系統(tǒng)功能模塊圖:用例圖:數(shù)據(jù)庫設(shè)計(包括表名、字段名、字段類型、字段大小、字段說明)。Student:Teacher:Course:SCourse:

5、Adnim:5、 測試用例和關(guān)鍵代碼:登錄界面:public partial class login : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) if (!IsPostBack) /判斷是否是回送,比如點擊同一個頁面的按鈕 HttpCookie myCookie1 = Request.Cookies"userName"/獲取Cookie信息 if (myCookie1 != null) /如果cookie存在,則將cookie信息即用戶名顯示出來 string usern

6、ame = myCookie1.Value; / TextBox1.Text = username; protected void imgbtnLogin_Click(object sender, ImageClickEventArgs e) string userName = txtUserName.Text.ToString().Trim(); string userPwd = txtPwd.Text.ToString().Trim(); string userRole = rblClass.SelectedValue.Trim(); string conn = "Data So

7、urce= . ;Initial Catalog=StudentSelectCourse; User ID=sa; pwd=" SqlConnection connection = new SqlConnection(conn); switch (userRole) case "0": try connection.Open(); SqlCommand comm = new SqlCommand(); comm.Connection = connection; string str_sql = "select count(*) from Teacher

8、where tno='" + userName + "' and secret='" + userPwd + "'" comm.CommandText = str_sql; int count = Convert.ToInt32(comm.ExecuteScalar(); if (count > 0) /記錄條數(shù)大于0,代表數(shù)據(jù)庫有相應(yīng)的用戶名和密碼存在 Session"userName" =userName;/設(shè)置Session,用戶實現(xiàn)登陸 / this.Server.Transfe

9、r("Teachermain.aspx"); / bool rem = CheckBox1.Checked;/判斷有沒有選中記住用戶名 HttpCookie SingleValueCookie = new HttpCookie("userName", userName); / Response.Write("<script>alert('登陸成功');location='javascript:history.go(-1)'</script>"); Response.Cookies

10、.Add(SingleValueCookie);/回送到客戶端 Response.Redirect("/Teacher/Teachermain.aspx", true);/跳轉(zhuǎn)到登陸后主頁面 else Response.Write("<script>alert('該用戶不存在或用戶名輸入錯誤,請檢查后重新輸入!');location='javascript:history.go(-1)'</script>"); / lblMessage.Text = "該用戶不存在或用戶名輸入錯誤,請檢查

11、后重新輸入!" catch (SqlException ex) Response.Write(ex.Message); break; case "1": try connection.Open(); SqlCommand comm = new SqlCommand(); comm.Connection = connection; string str_sql = "select count(*) from Student where sno='" + userName + "' and secret='&quo

12、t; + userPwd + "'" comm.CommandText = str_sql; int count = Convert.ToInt32(comm.ExecuteScalar(); if (count > 0) /記錄條數(shù)大于0,代表數(shù)據(jù)庫有相應(yīng)的用戶名和密碼存在 Session"username" =userName;/設(shè)置Session,用戶實現(xiàn)登陸 / bool rem = CheckBox1.Checked;/判斷有沒有選中記住用戶名 HttpCookie SingleValueCookie = new HttpCook

13、ie("username"); Response.Cookies.Add(SingleValueCookie);/回送到客戶端 Response.Redirect("/Student/Studentmain.aspx", true);/跳轉(zhuǎn)到登陸后主頁面 else Response.Write("<script>alert('該用戶不存在或用戶名輸入錯誤,請檢查后重新輸入!');location='javascript:history.go(-1)'</script>"); ca

14、tch (SqlException ex) Response.Write(ex.Message); break; case "2": try connection.Open(); SqlCommand comm = new SqlCommand(); comm.Connection = connection; string str_sql = "select count(*) from Adnim where adnim='" + userName + "' and secret='" + userPwd +

15、"'" comm.CommandText = str_sql; int count = Convert.ToInt32(comm.ExecuteScalar(); if (count > 0) /記錄條數(shù)大于0,代表數(shù)據(jù)庫有相應(yīng)的用戶名和密碼存在 Session"username" =userName;/設(shè)置Session,用戶實現(xiàn)登陸 / bool rem = CheckBox1.Checked;/判斷有沒有選中記住用戶名 HttpCookie SingleValueCookie = new HttpCookie("userna

16、me") Response.Cookies.Add(SingleValueCookie);/回送到客戶端 Response.Redirect("/Admin/Adminmain.aspx", true);/跳轉(zhuǎn)到登陸后主頁面 else Response.Write("<script>alert('該用戶不存在或用戶名輸入錯誤,請檢查后重新輸入!');location='javascript:history.go(-1)'</script>"); catch (SqlException ex

17、) Response.Write(ex.Message); break; 學生選課:public partial class Student_StudentApply : System.Web.UI.Page string clocal = null; string ctime = null; string cno = null; /string ctime = null; string tno = null; string myName1Value; protected void Page_Load(object sender, EventArgs e) /string myName1Val

18、ue; if (Session"userName" != null) myName1Value = Session"userName".ToString(); protected void Button1_Click(object sender, EventArgs e) for (int i = 0; i < this.GridView1.Rows.Count; i+) CheckBox ckb = (CheckBox)this.GridView1.Rowsi.Cells0.FindControl("CheckBox1");

19、if (ckb.Checked) cno = Convert.ToString(this.GridView1.Rowsi.Cells1.Text); tno = Convert.ToString(this.GridView1.Rowsi.Cells3.Text); Response.Write("<script>alert('選課成功!');location='javascript:history.go(-1)'</script>"); string conn = "Data Source= . ;Initi

20、al Catalog=StudentSelectCourse; User ID=sa; pwd=" SqlConnection connection = new SqlConnection(conn); try connection.Open();/打開數(shù)據(jù)庫 string str_sql = "insert into SCourse(sno,cno,tno) values('" + myName1Value + "','" + cno + "','" + tno + "&#

21、39;)" SqlCommand comm = new SqlCommand(str_sql, connection);/建立COMMAND對象(即命令執(zhí)行對象) comm.ExecuteNonQuery(); catch (SqlException ex) protected void Button2_Click(object sender, EventArgs e) for (int i = 0; i < this.GridView1.Rows.Count; i+) CheckBox ckb = (CheckBox)this.GridView1.Rowsi.Cells0.F

22、indControl("CheckBox1"); if (ckb.Checked) cno = Convert.ToString(this.GridView1.Rowsi.Cells1.Text); ctime = Convert.ToString(this.GridView1.Rowsi.Cells6.Text); clocal = Convert.ToString(this.GridView1.Rowsi.Cells7.Text); /Label1.Text = clocal; string conn = "Data Source= . ;Initial Ca

23、talog=StudentSelectCourse; User ID=sa; pwd=" SqlConnection connection = new SqlConnection(conn); try connection.Open(); string str = " select COUNT(*) from SCourse where sno='"+myName1Value+"' and cno in(select Co from Course where Course.ctime='" + ctime + "

24、;' and Course.clocal='" + clocal + "')" SqlCommand comm = new SqlCommand(); comm.Connection = connection; comm.CommandText = str; int count = Convert.ToInt32(comm.ExecuteScalar(); if (count > 0) Response.Write("<script>alert('與已選課程沖突');location='j

25、avascript:history.go(-1)'</script>"); else Response.Write("<script>alert('與已選課程無任何沖突');location='javascript:history.go(-1)'</script>"); catch (SqlException ex) 課件查看與下載:public partial class Student_StudentUploading : System.Web.UI.Page protected vo

26、id Page_Load(object sender, EventArgs e) string AllFile = Directory.GetFiles(Server.MapPath("/file/"); foreach (string Name in AllFile) / 返回指定路徑的文件的名稱 ListBox1.Items.Add(Path.GetFileName(Name); public void DownLoadFile(string FullFileName) / 保存文件的虛擬路徑 string Url = "/file/" + Full

27、FileName; / 保存文件的物理路徑 string FullPath = HttpContext.Current.Server.MapPath(Url); / 初始化FileInfo類的實例,作為文件路徑的包裝 FileInfo FI = new FileInfo(FullPath); / 判斷文件是否存在 if (FI.Exists) / 將文件保存到本機 Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlE

28、ncode(FI.Name); Response.AddHeader("Content-Length", FI.Length.ToString(); Response.ContentType = "application/octet-stream" Response.Filter.Close(); Response.WriteFile(FI.FullName); Response.End(); protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) Session&

29、quot;SelectedFile" = ListBox1.SelectedValue.ToString(); protected void Button2_Click(object sender, EventArgs e) if (ListBox1.SelectedValue != "") if (Session"SelectedFile" != "") string FullFileName = Session"SelectedFile".ToString(); DownLoadFile(FullFi

30、leName); else Response.Write("<script>alert('請先選擇要下載的文件');</script>"); 接收消息:public partial class Student_StudentAcceptMessage : System.Web.UI.Page string sno=null; protected void Page_Load(object sender, EventArgs e) if (Session"userName" != null) sno = Sessio

31、n"userName".ToString(); string conn = "Data Source= . ;Initial Catalog=StudentSelectCourse; User ID=sa; pwd=" SqlConnection connection = new SqlConnection(conn); try connection.Open(); string str_sql = "select tname,tmessage from teachermessage,teacher,scourse where scourse.

32、sno='"+sno+"' and scourse.tno=teachermessage.tno and teachermessage.tno=teacher.tno" SqlCommand comm = new SqlCommand(str_sql, connection); SqlDataReader reader = comm.ExecuteReader(); while (reader.Read() TextBox1.Text = TextBox1.Text +"發(fā)件人:"+ reader0.ToString() + &

33、#39;n' TextBox1.Text = TextBox1.Text +"信件:"+ reader1.ToString() + 'n' catch (SqlException ex) Response.Write(ex.Message); 查看個人信息:public partial class Student_StudentInfo : System.Web.UI.Page string myName1Value; protected void Page_Load(object sender, EventArgs e) if (Session&q

34、uot;userName" != null) myName1Value = Session"userName".ToString(); try string conn = "Data Source= . ;Initial Catalog=StudentSelectCourse; User ID=sa; pwd=" SqlConnection connection = new SqlConnection(conn); connection.Open(); string sql = "select * from Student where

35、 sno='"+ myName1Value+"'" SqlCommand cmd = new SqlCommand(sql, connection); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read() /將結(jié)果集信息添加到返回向量中 Label2.Text=reader0.ToString(); Label4.Text=reader1.ToString(); Label5.Text=reader2.ToString(); Label8.Text = reader3.To

36、String(); Label6.Text = reader4.ToString(); Label7.Text = reader5.ToString(); reader.Close(); cmd.Dispose(); catch (SqlException ex) 老師頁面上傳課件;public partial class Teacher_TeacherUploading : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) / if (!IsPostBack) / 頁面首次加載 / / 返回指定目錄

37、的所有文件的名稱 string AllFile = Directory.GetFiles(Server.MapPath("/file/"); foreach (string Name in AllFile) / 返回指定路徑的文件的名稱 ListBox1.Items.Add(Path.GetFileName(Name); / protected void Button1_ServerClick(object sender, EventArgs e) string OldFileName = Path.GetFileNameWithoutExtension(FileUploa

38、d1.FileName); UpLoadFile(FileUpload1, OldFileName); public static void UpLoadFile(FileUpload FU, string NewFileName) if (FU.HasFile) / 判斷是否有文件上傳 string OldExtensionName = Path.GetExtension(FU.FileName).ToLower(); string Url = "/file/" + NewFileName + OldExtensionName; string FullPath = Htt

39、pContext.Current.Server.MapPath(Url); try if (File.Exists(FullPath) / Response.Write("<script>alert('選課成功!');location='javascript:history.go(-1)'</script>"); HttpContext.Current.Response.Write("<script>alert('文件已存在,請重新上傳。');</script>&quo

40、t;); else FU.SaveAs(FullPath); HttpContext.Current.Response.Write("<script>alert('文件已成功上傳。');</script>"); / Response.Write("<script>alert('選課成功!');location='javascript:history.go(-1)'</script>"); catch else HttpContext.Current.Respo

41、nse.Write("<script>alert('請選擇上傳的文件');</script>"); public void DownLoadFile(string FullFileName) / 保存文件的虛擬路徑 string Url = "/file/" + FullFileName; / 保存文件的物理路徑 string FullPath = HttpContext.Current.Server.MapPath(Url); / 初始化FileInfo類的實例,作為文件路徑的包裝 FileInfo FI = n

42、ew FileInfo(FullPath); / 判斷文件是否存在 if (FI.Exists) / 將文件保存到本機 Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(FI.Name); Response.AddHeader("Content-Length", FI.Length.ToString(); Response.ContentType = "applicatio

43、n/octet-stream" Response.Filter.Close(); Response.WriteFile(FI.FullName); Response.End(); public void DeleteFile(string FullFileName) / 保存文件的虛擬路徑 string Url = "/file/" + FullFileName; / 保存文件的物理路徑 string FullPath = HttpContext.Current.Server.MapPath(Url); / 去除文件的只讀屬性 File.SetAttributes(FullPath, FileAttr

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論