学生信息管理系统课程设计报告[精荐]内容摘要:

lass Context { public static User use = null。 } User类,用于记录登录者的账号和 ID号,以便于修改密码。 class User { public string userId { get。 set。 } public string userPwd { get。 set。 } } 登录模块实现 本系统的登录界面如图 41 所示,输入 用户名 和密码, 选择登录身份, 点击 登录 ,判断用户名和密码是否正确,正确可进入 相应的 系统主界面,否则提示错误信息。 点击 退出 ,退出登录窗口。 图 41 登录界面 9 图 42 空的用户名和密码 图 43 错误的用户名和密码 ( 1) 登录按钮的代码为: private void btnOK_Click(object sender, EventArgs e) {string connectionStr = Data Source=39。 .39。 Initial Catalog=39。 StudentMessageManagement39。 Integrated Security=39。 true39。 SqlConnection connection = new SqlConnection(connectionStr)。 if ( != amp。 amp。 != ) { ()。 SqlCommand mand = new SqlCommand()。 = connection。 if () { = (select count(*) from Administrator where AdId=39。 {0}39。 and AdPwd=39。 {1}39。 , , )。 int count = (int)()。 //查询表中的记录个数 if (count 0) {User user = new User()。 =。 =。 = user。 Administrator ad = new Administrator()。 =。 ()。 ()。 } else (用户名或密码错误 , 提 示 , , )。 } if () 10 { = (select count(*) from Teacher where TeaId=39。 {0}39。 and TeaPwd=39。 {1}39。 , , )。 int count = (int)()。 if (count 0) {User user = new User()。 =。 =。 = user。 Teacher tea = new Teacher()。 =。 ()。 ()。 } else (用户 名 或密码错误 , 提示 , , )。 } ()。 } else (用户名或密码不能为空 , 提示 , , )。 } ( 2) 取消按钮的代码为: private void btnExit_Click(object sender, EventArgs e) {()。 } 学生信息查询 模块实现 ,选择学生管理功能,可以看到界面如下: 图 44 学生信息界面 11 ,点击查询的下拉框,选择“按。 查询”,即可显示学生信息。 : 图 45 学生查询 图 46 学生查询显示 : private void boBox1_SelectedIndexChanged(object sender, EventArgs e) {string connectionStr = Data Source=39。 .39。 Initial Catalog=39。 StudentMessageManagement39。 Integrated Security=39。 true39。 SqlConnection connection = new SqlConnection(connectionStr)。 string sql =。 switch () {case 按学号查询 :sql = (select * from Student,Class,Grade,Major where = and = and = and StuNo like 39。 %{0}%39。 ,())。 break。 case 按 姓 名 查 询 :sql = (select * from Student,Class,Grade,Major where = and = and = and StuName like 39。 %{0}%39。 ,())。 break。 case 按 班 级 查 询 :sql = (select * from Student,Class,Grade,Major where = and = and = and 12 ClassName like 39。 %{0}%39。 ,)。 break。 case 按 专 业 查 询 :sql = (select * from Student,Class,Grade,Major where = and = and = and MajorName like 39。 %{0}%39。 ,)。 break。 case 按 性 别 查 询 :sql = (select * from Student,Class,Grade,Major where = and = and = and Sex like 39。 %{0}%39。 , )。 break。 case 按 年 龄 查 询 :sql = (select * from Student,Class,Grade,Major where = and = and = and Age like 39。 %{0}%39。 ,())。 break。 case 按 年 级 查 询 :sql = (select * from Student,Class,Grade,Major where = and = and = and GradeName like 39。 %{0}%39。 ,)。 break。 case 按家庭住址查询 :sql = (select * from Student,Class,Grade,Major where = and = and = and Address like 39。 %{0}%39。 ,())。 break。 case 按 备 注 查 询 :sql = (select * from Student,Class,Grade,Major where = and = and = and Extra like 39。 %{0}%39。 ,())。 break。 } SqlCommand mand = new SqlCommand(sql,connection)。 ()。 SqlDataReader reader = ()。 ()。 while (()) {ListViewItem lv = new ListViewItem()。 = reader[StuNO].ToString()。 (reader[StuName].ToString())。 (reader[Age].ToString())。 (reader[Sex].ToString())。 (reader[ClassName].ToString())。 (reader[GradeName].ToString())。 (reader[MajorName].ToString())。 (reader[Phone].ToString())。 (reader[Address].ToString())。 (reader[Extra].ToString())。 (lv)。 } ()。 ()。 } 13 学生信息添加 模块实现 ,点击添加按钮。 带有红 *标记的为必填项。 图 47 添加成功 图 48 错误提示 14 ,则提示: 图 49 输入学号重复提示 : private void btnAdd_Click(object sender, EventArgs e) {if (() == || () == || () == || () == || () == ) { (您输入的学生基本信息不完整(至少输入学号,姓名,班级,年级,专业)。 , 提示, , )。 } else{ String connectionStr = Data Source=39。 .39。 Initial Catalog=39。 StudentMessageManagement39。 Integrated Security=39。 true39。 SqlConnection connection = new SqlConnection(connectionStr)。 ()。 SqlCommand mand = new SqlCommand()。 = connection。 = (Select MajorId from Major where MajorName=39。 {0}39。 , )。 int majorId = (int)()。 = (Select GradeId from Grade where GradeName=39。 {0}39。 , )。 int gradeId = (int)()。 = (Select ClassId from Class where ClassName=39。 {0}39。 , )。 int classId = (int)()。 15 = (select count(*) from Student where StuNo=39。 {0}39。 , ())。 int count = (int)()。 if (count 0) { (您输入的学生学号已存在,请重新输入。 , 提示 , , )。 } else{String sql = (insert into Student(StuNo,StuName,Age,Sex,ClassId,GradeId,MajorId,Phone,Address,Extra) +values (39。 {0}39。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。