教务管理员操作流程

更新时间:2024-06-24 03:55:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

教务管理员操作流程

1、

使用Admin账号登陆——教务管理员系统

代码区域:

int count = 0;

bool isValidUser = false; if (loginType == \教务管理员\) {

string sql = string.Format(\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) {

message = \用户名或密码不存在!\; }

else 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 = \; try {

SqlCommand command=new SqlCommand(sql,DBHelper.connection); DBHelper.connection.Open();

SqlDataReader reader=command.ExecuteReader(); while(reader.Read()){

string gradeName=(string)reader[0]; 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(\GradeName='{0}'\,cboGrade.Text);

SqlCommand command = new SqlCommand(sql, DBHelper.connection); try {

DBHelper.connection.Open();

SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) {

gradeId = (int)reader[0]; }

reader.Close();

}

catch (Exception ex) {

MessageBox.Show(\操作数据库出错\); Console.WriteLine(ex.Message); } finally {

DBHelper.connection.Close(); }

sql = \ +gradeId; command.CommandText = sql; try {

DBHelper.connection.Open();

SqlDataReader reader = command.ExecuteReader();

string className = \; cboClass.Items.Clear(); while (reader.Read()) {

className = (string)reader[\]; 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 (教师信息添加窗体)

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(); } } }

新增教师信息→弹出窗口(教师信息添加)→Teacher表

保存按钮代码如下:

查询修改信息→学生信息→查询及删除信息(可以进行模糊查询)

本文来源:https://www.bwwdw.com/article/zkt3.html

Top