




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
教务管理员操作流程1、 使用Admin账号登陆教务管理员系统代码区域:int count = 0; bool isValidUser = false; if (loginType = 教务管理员) string sql = string.Format(select count(*) from Admin where LoginId=0 AND LoginPwd=1, loginId, loginPwd); try SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); count = (int)command.ExecuteScalar(); if (count = 1) isValidUser = true; else index+; if (index = 3) Application.Exit(); isValidUser = false; catch (Exception ex) message = ex.Message; Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); if (cboType.Text = 教务管理员) AdminForm adminForm = new AdminForm(); adminForm.Show(); return true; 成功进入后可以进行AdminForm.cs (教务管理员窗体)用户管理新增用户新增学生信息(代码如下:) AddStudentForm addstudnetForm = new AddStudentForm(); addstudnetForm.MdiParent = this; addstudnetForm.Show();弹出窗口(学生信息添加)Student表AdminStudentForm.cs保存按钮代码如下: if (TianJia() try SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); int result = command.ExecuteNonQuery(); if (result != 1) MessageBox.Show(添加失败, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(添加成功, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); catch (Exception ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); private void AddStudentForm_Load(object sender, EventArgs e) string sql = select gradeName from Grade; try SqlCommand command=new SqlCommand(sql,DBHelper.connection); DBHelper.connection.Open(); SqlDataReader reader=command.ExecuteReader(); while(reader.Read() string gradeName=(string)reader0; cboGrade.Items.Add(gradeName); reader.Close(); catch(Exception ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); private void cboGrade_SelectedIndexChanged(object sender, EventArgs e) if (cboGrade.Text.Trim() != ) int gradeId = -1; string sql = string.Format(select GradeId from Grade where GradeName=0,cboGrade.Text); SqlCommand command = new SqlCommand(sql, DBHelper.connection); try DBHelper.connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.Read() gradeId = (int)reader0; reader.Close(); catch (Exception ex) MessageBox.Show(操作数据库出错); Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); sql = SELECT ClassName FROM Class WHERE GradeId= +gradeId; command.CommandText = sql; try DBHelper.connection.Open(); SqlDataReader reader = command.ExecuteReader(); string className = ; cboClass.Items.Clear(); while (reader.Read() className = (string)readerClassName; cboClass.Items.Add(className); reader.Close(); catch (Exception ex) MessageBox.Show(操作数据库出错); Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); private void txtStudentPassword_TextChanged(object sender, EventArgs e) AdminTeacherForm.cs (教师信息添加窗体) 新增教师信息弹出窗口(教师信息添加)Teacher表保存按钮代码如下:if (TianJia() try SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); int result = command.ExecuteNonQuery(); if (result != 1) MessageBox.Show(添加失败, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(添加成功, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); catch (Exception ex) MessageBox.Show(操作数据库出错, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); Console.WriteLine(ex.Message); finally DBHelper.connection.Close(); 查询修改信息学生信息查询及删除信息(可以进行模糊查询)SearchStudentForm.cs (学生查询及删除信息窗体)查询按钮代码:if (txtName.Text = ) MessageBox.Show(请输入用户名, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); txtName.Focus(); else SearchStudent(); private void tsmiDelete_Click(object sender, EventArgs e) if (listView1.SelectedItems.Count = 0) MessageBox.Show(您没有选择任何用户, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else DialogResult choice = MessageBox.Show(确定要删除该用户吗, 警告, MessageBoxButtons.OK, MessageBoxIcon.Information); if (choice = DialogResult.OK) int result = 0; try string sql = string.Format(delete Student where StudentId=0, (int)listView1.SelectedItems0.Tag); SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); result = command.ExecuteNonQuery(); catch (Exception ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); if (result 1) MessageBox.Show(删除失败, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else MessageBox.Show(删除成功, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); SearchStudent(); UpdateStudentForm.cs (学生更新信息窗体)保存信息按钮代码:DialogResult result = MessageBox.Show(确实要将修改保存到数据库吗?, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); if (result = DialogResult.OK) SqlCommandBuilder builder = new SqlCommandBuilder(dataAdapter); dataAdapter.Update(dataSet, Student); MessageBox.Show(保存成功, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(保存失败, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); SearchTeacherForm.cs (教师查询及删除信息窗体)查询按钮代码:if (txtName.Text = ) MessageBox.Show(请输入用户名, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); txtName.Focus(); else SearchTeacher(); private void btnExit_Click(object sender, EventArgs e) this.Close(); private void tsmiDelete1_Click(object sender, EventArgs e) if (listView1.SelectedItems.Count = 0) MessageBox.Show(您没有选择任何用户, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else DialogResult choice = MessageBox.Show(确定要删除该用户吗, 警告, MessageBoxButtons.OK, MessageBoxIcon.Information); if (choice = DialogResult.OK) int result = 0; try string sql = string.Format(delete Teacher where TeacherId=0, (int)listView1.SelectedItems0.Tag); SqlCommand command = new SqlCommand(sql, DBHelper.connection); DBHelper.connection.Open(); result = command.ExecuteNonQuery(); catch (Exception ex) MessageBox.Show(ex.Message); finally DBHelper.connection.Close(); if (result 1) MessageBox.Show(删除失败, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else MessageBox.Show(删除成功, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Info
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025届春季中国广核集团校园招聘模拟试卷及答案详解(各地真题)
- 2025春季粤规院科技集团招聘模拟试卷及完整答案详解一套
- 2025河南省职工医院招聘10人模拟试卷及答案详解(必刷)
- 《网络安全法》题库及答案解析
- 证券基金从业考试题目及答案解析
- 2025广西桂林医科大学第一附属医院招聘普通合同工4人模拟试卷及答案详解(易错题)
- 2025安徽宿州市立医院招聘编外人员42人模拟试卷及1套完整答案详解
- 2025河北唐山市曹妃甸区唐海中医医院招聘考前自测高频考点模拟试题完整答案详解
- 2025贵州黔南州瓮安县江界河镇招聘城镇公益性岗位人员1人考前自测高频考点模拟试题及答案详解(历年真题)
- 2025湖南湘南学院招聘事业编制人员108人考前自测高频考点模拟试题有完整答案详解
- 2025河北水发节水有限公司公开招聘工作人员16人笔试参考题库附答案解析
- 新版中华民族共同体概论课件第十二讲民族危亡与中华民族意识觉醒(1840-1919)-2025年版
- 2025-2026学年人教版(2024)九年级物理全册第十四章 内能的利用(单元同步检测练习)(含答案)
- 第1课时 10的加、减法(教学设计)-2024-2025学年一年级上册数学人教版
- 2025至2030中国聚烯烃行业项目调研及市场前景预测评估报告
- 2025四川达州宣汉县国有资产管理服务中心县属国有企业招聘劳动合同职工26人笔试历年参考题库附带答案详解
- 新教科版小学1-6年级科学需做实验目录
- 《电子商务法律法规》课程标准
- 医院关于印发《即时检验临床应用管理办法》的通知
- 三年级下册书法练习指导全册教案(湖南美术出版社)
- GB/T 17880.5-1999平头六角铆螺母
评论
0/150
提交评论