




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- LY/T 3384-2024植物新品种特异性、一致性、稳定性测试指南檵木属
- 安徽省蚌埠市2016-2017学年高二物理上学期期末考试试题文
- 安排出国差旅活动49课件
- 考研复习-风景园林基础考研试题【突破训练】附答案详解
- 2025年黑龙江省五常市辅警招聘考试试题题库及1套完整答案详解
- 2025年Z世代消费趋势下新消费品牌供应链管理优化报告
- 医院行风建设总结
- 复发性急性胰腺炎罕见病因研究2025
- AI与DeepSeek大模型赋能家具制造业数字化转型解决方案
- 乐水湖景区污水处理站及配套管网建设项目环评报告
- 教育数字化转型背景下中小学课堂教学变革研究
- 八年级英语下学期期末考试(广州专用)(解析版)
- 浙江省宁波市镇海中学2025年5月第二次模拟考试 英语试卷+答案
- 项目管理与评估试题及答案
- 护理职称课件
- 2024年安徽省淮南市田家庵区小升初数学试卷(空白卷)
- 航海英语阅读与写作能力测试考核试卷
- 环境设计人才培养方案
- 槟榔转让合同协议书
- 龙岩市2025年高中高三毕业班五月教学质量检政治试卷(含答案)
- 自动跟踪定位射流灭火系统设计与实施及验收标准化研究
评论
0/150
提交评论