软件工程实验报告_第1页
软件工程实验报告_第2页
软件工程实验报告_第3页
软件工程实验报告_第4页
软件工程实验报告_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

软件工程实验报告实验题目:软件工程制图实验七 一个学生选课系统的实现1、 教学目的: 培养学生运用软件工程方法开发和测试系统的能力。2、 教学成果: 能够熟练运用一种开发工具和数据库开发与测试一个学生选课系统。3、 实验要求: 1.系统管理员可以对学生、教师、选课和课程成绩进行增、删、改和查。 2.系统管理员可对学生选择课程进行查询统计,并生成柱状图并导出(每门课选择人数统计)。 3.学院管理员可对本学院教师、学生、本学院学生选课、本学院开设课程和成绩进行增删改查。 4.学院对选择课程的学生进行抽签,并按课程生成中签学生名单。 5. 教师可以登录本系统,在网站上输入课程介绍、上传课程的课件、发布、先修课程、更新和修改课程信息。 6.教师可查询选修自己课程的所有中签学生名单,并录入课程成绩生成成绩统计表(每个分数段的人数,及格率等)。 7.教师可对选修自己课程学生发送消息留言 。 8. 学生通过客户机浏览器根据学号和密码进入选课界面,在这里学生可以进行查询已选课程、指定自己的选修课程以及对自己基本信息的查询; 9.学生可以查询自己选课结果。 10.学生选课时,如果该门课程的先修课程没有学习,则不能进行选课,并给出提示“您没有学习该课程的先修课程,不能进行选课!”。 11.学生可浏览课程信息和查询成绩,下载课件。 12.学生可给任课教师发送信息和回复任课教师的留言。4、 系统概述: 本系统是一个简化版的学生管理系统,系统登录有三种身份:学生、教师、管理员。 数据流程图:E-R图:数据字典:课程信息表:名称简称键值类型长度课程号cnopvarchar30课程名cnamevarchar30教师表号tnovarchar30所属系departmentvarchar30学分gradeint上课时间ctimevarchar30上课地点clocalvarchar30先修课provarchar30学生信息表:名称简称键值类型长度学号snopvarchar30姓名snamevarchar30性别ssexvarchar30年龄oldint电话phonevarchar30系别departmentvarchar30密码secretvarchar30教师信息表:名称简称键值类型长度教师编号tnopvarchar30姓名tnamevarchar30性别tsexvarchar30职称professvarchar30电话tphonevarchar30密码secretvarchar30选课表:名称职称键值类型长度学号snopvarchar30课程号cnopvarchar30教师编号tnovarchar30成绩scoreint系统功能模块图:用例图:数据库设计(包括表名、字段名、字段类型、字段大小、字段说明)。Student:Teacher:Course:SCourse:Adnim:5、 测试用例和关键代码:登录界面:public partial class login : System.Web.UI.Page protected void Page_Load(object sender, EventArgs e) if (!IsPostBack) /判断是否是回送,比如点击同一个页面的按钮 HttpCookie myCookie1 = Request.CookiesuserName;/获取Cookie信息 if (myCookie1 != null) /如果cookie存在,则将cookie信息即用户名显示出来 string username = 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 Source= . ;Initial Catalog=StudentSelectCourse; User ID=sa; pwd=12101020427; 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 where tno= + userName + and secret= + userPwd + ; comm.CommandText = str_sql; int count = Convert.ToInt32(comm.ExecuteScalar(); if (count 0) /记录条数大于0,代表数据库有相应的用户名和密码存在 SessionuserName =userName;/设置Session,用户实现登陆 / this.Server.Transfer(Teachermain.aspx); / bool rem = CheckBox1.Checked;/判断有没有选中记住用户名 HttpCookie SingleValueCookie = new HttpCookie(userName, userName); / Response.Write(alert(登陆成功);location=javascript:history.go(-1);); Response.Cookies.Add(SingleValueCookie);/回送到客户端 Response.Redirect(/Teacher/Teachermain.aspx, true);/跳转到登陆后主页面 else Response.Write(alert(该用户不存在或用户名输入错误,请检查后重新输入!);location=javascript:history.go(-1);); / lblMessage.Text = 该用户不存在或用户名输入错误,请检查后重新输入!; 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= + userPwd + ; comm.CommandText = str_sql; int count = Convert.ToInt32(comm.ExecuteScalar(); if (count 0) /记录条数大于0,代表数据库有相应的用户名和密码存在 Sessionusername =userName;/设置Session,用户实现登陆 / bool rem = CheckBox1.Checked;/判断有没有选中记住用户名 HttpCookie SingleValueCookie = new HttpCookie(username); Response.Cookies.Add(SingleValueCookie);/回送到客户端 Response.Redirect(/Student/Studentmain.aspx, true);/跳转到登陆后主页面 else Response.Write(alert(该用户不存在或用户名输入错误,请检查后重新输入!);location=javascript:history.go(-1);); catch (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 + ; comm.CommandText = str_sql; int count = Convert.ToInt32(comm.ExecuteScalar(); if (count 0) /记录条数大于0,代表数据库有相应的用户名和密码存在 Sessionusername =userName;/设置Session,用户实现登陆 / bool rem = CheckBox1.Checked;/判断有没有选中记住用户名 HttpCookie SingleValueCookie = new HttpCookie(username) Response.Cookies.Add(SingleValueCookie);/回送到客户端 Response.Redirect(/Admin/Adminmain.aspx, true);/跳转到登陆后主页面 else Response.Write(alert(该用户不存在或用户名输入错误,请检查后重新输入!);location=javascript:history.go(-1);); catch (SqlException ex) 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 myName1Value; if (SessionuserName != null) myName1Value = SessionuserName.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); if (ckb.Checked) cno = Convert.ToString(this.GridView1.Rowsi.Cells1.Text); tno = Convert.ToString(this.GridView1.Rowsi.Cells3.Text); Response.Write(alert(选课成功!);location=javascript:history.go(-1);); string conn = Data Source= . ;Initial Catalog=StudentSelectCourse; User ID=sa; pwd=12101020427; SqlConnection connection = new SqlConnection(conn); try connection.Open();/打开数据库 string str_sql = insert into SCourse(sno,cno,tno) values( + myName1Value + , + cno + , + tno + ); SqlCommand comm = new SqlCommand(str_sql, connection);/建立COMMAND对象(即命令执行对象) comm.ExecuteNonQuery(); catch (SqlException ex) protected void Button2_Click(object sender, EventArgs e) for (int i = 0; i 0) Response.Write(alert(与已选课程冲突);location=javascript:history.go(-1);); else Response.Write(alert(与已选课程无任何冲突);location=javascript:history.go(-1);); catch (SqlException ex) 课件查看与下载:public partial class Student_StudentUploading : System.Web.UI.Page protected void 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/ + FullFileName; / 保存文件的物理路径 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.UrlEncode(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) SessionSelectedFile = ListBox1.SelectedValue.ToString(); protected void Button2_Click(object sender, EventArgs e) if (ListBox1.SelectedValue != ) if (SessionSelectedFile != ) string FullFileName = SessionSelectedFile.ToString(); DownLoadFile(FullFileName); else Response.Write(alert(请先选择要下载的文件);); 接收消息:public partial class Student_StudentAcceptMessage : System.Web.UI.Page string sno=null; protected void Page_Load(object sender, EventArgs e) if (SessionuserName != null) sno = SessionuserName.ToString(); string conn = Data Source= . ;Initial Catalog=StudentSelectCourse; User ID=sa; pwd=12101020427; SqlConnection connection = new SqlConnection(conn); try connection.Open(); string str_sql = select tname,tmessage from teachermessage,teacher,scourse where scourse.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 +发件人:+ reader0.ToString() + 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 (SessionuserName != null) myName1Value = SessionuserName.ToString(); try string conn = Data Source= . ;Initial Catalog=StudentSelectCourse; User ID=sa; pwd=12101020427; SqlConnection connection = new SqlConnection(conn); connection.Open(); string sql = select * from Student where sno=+ myName1Value+; SqlCommand cmd = new SqlCommand(sql, connection); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read() /将结果集信息添加到返回向量中 Label2.Text=reader0.ToString(); Label4.Text=reader1.ToString(); Label5.Text=reader2.ToString(); Label8.Text = reader3.ToString(); 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) / 页面首次加载 / / 返回指定目录的所有文件的名称 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(FileUpload1.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 = HttpContext.Current.Server.MapPath(Url); try if (File.Exists(FullPath) / Response.Write(alert(选课成功!);location=javascript:history.go(-1);); HttpContext.Current.Response.Write(alert(文件已存在,请重新上传。);); else FU.SaveAs(FullPath); HttpContext.Current.Response.Write(alert(文件已成功上传。);); / Response.Write(alert(选课成功!);location=javascript:history.go(-1);); catch else HttpContext.Current.Response.Write(alert(请选择上传的文件);); public void DownLoadFile(string FullFileName) / 保存文件的虚拟路径 string Url = /file/ + FullFileName; / 保存文件的物理路径 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.UrlEncode(FI.Name); Response.AddHeader(Content-Length, FI.Length.ToString(); Response.ContentType = application/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, FileAttributes.Normal); /

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论