《【教务管理员操作流程】.docx》由会员分享,可在线阅读,更多相关《【教务管理员操作流程】.docx(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、教务管理员操作流程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();
2、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 =
3、 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 = n
4、ew 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 (Exce
5、ption 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.
6、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()
7、!= ) 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; reade
8、r.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 c
9、lassName = ; 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
10、(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(添加失败, 输入提示, MessageBoxB
11、uttons.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(); 查询修改信
12、息学生信息查询及删除信息(可以进行模糊查询)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)
13、 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 StudentI
14、d=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(删除失败, 输入提示, Mes
15、sageBoxButtons.OK, MessageBoxIcon.Exclamation); else MessageBox.Show(删除成功, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); SearchStudent(); UpdateStudentForm.cs (学生更新信息窗体)保存信息按钮代码:DialogResult result = MessageBox.Show(确实要将修改保存到数据库吗?, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information);
16、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); Searc
17、hTeacherForm.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, EventArg
18、s 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 =
19、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
20、 (result 1) MessageBox.Show(删除失败, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else MessageBox.Show(删除成功, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); SearchTeacher(); UpdateTeacherForm.cs (教师更新信息窗体)保存信息按钮代码:DialogResult result = MessageBox.Show(确实要将修改保存到数据库吗?, 输入提示,MessageBo
21、xButtons.OK, MessageBoxIcon.Information); if (result = DialogResult.OK) SqlCommandBuilder builder = new SqlCommandBuilder(dataAdapter); dataAdapter.Update(dataSet, Teacher); MessageBox.Show(保存成功, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(保存失败, 输入提示, MessageBoxButtons.OK, MessageBoxIcon.Information); 娱乐通过引用完成操作退出系统 重新登录(代码如下:) LoginForm fm1 = new LoginForm(); this.Hide(); fm1.Show();帮助说明版权说明(HelpForm.cs 帮助窗体)帮助信息(MessageBox.Show(欢迎使用帮助系统n本系统新建用户初始密码:n【123】, 帮助信息);)运行屏保(引用外部文件)