学生学籍管理系统的设计与实现 下载本文

内容发布更新时间 : 2024/11/6 8:31:45星期一 下面是文章的全部内容请认真阅读。

MessageBox.Show(\对不起,此用户已经存在!\ return; } }

private void btnOk_Click(object sender, EventArgs e) {

//判断用户名是否已经存在

bool flag = dataOperate.seleSQL(sql); if (flag) {

MessageBox.Show(\对不起,此用户已经存在!\ return; }

//如果前两次都没有错误,就将新用户信息写入数据库 switch (cbShenFen.SelectedIndex) {

case 0: sql = \txtNum.Text + \+ txtUserName.Text + \+ txtQuestion.Text + \+ txtAnswer.Text + \

case 1: sql = \into T_Teacher_user values('\+ txtNum.Text + \+ txtUserName.Text + \+ txtQuestion.Text + \+ txtAnswer.Text + \

case 2: sql = \into T_Student_user values('\+ txtNum.Text + \+ txtUserName.Text + \+ txtQuestion.Text + \+ txtAnswer.Text + \

}

flag = dataOperate.execSQL(sql); if (flag) {

MessageBox.Show(\注册/添加用户成功!\ if (cbShenFen.SelectedIndex==2) {

InsertInfo II = new InsertInfo(); II.Show(); }

this.Close(); }

25 / 55

else {

MessageBox.Show(\注册/添加用户失败!\ } }

private void btnReset_Click(object sender, EventArgs e) {

txtNum.Text = \ txtNum.Focus();

txtUserName.Text = \ txtQuestion.Text = \ txtAnswer.Text = \ }

private void AddUser_Load(object sender, EventArgs e) {

txtNum.Focus(); }

添加详细信息

当点击信息录入界面或添加用户时,系统自动转入添加用户界面,当添加

用户成功后,继而进入学生详细信息添加界面,完成学生用户以及详细信息的添加。

实现代码如下:

private void InsertInfo_Load(object sender, EventArgs e)

EventArgs e)

{

txtNum.Text = AddUser.Num; txtName.Text = AddUser.Name; string sql = \

DataSet ds = dataOperate.getDataSet(sql, \ cbDepartment.DataSource = ds.Tables[\ cbDepartment.DisplayMember = \} private void cbDepartment_SelectedIndexChanged(object sender, {

//根据系部名称查询系部编号

string sql = \departmentID from T_Department where

27 / 55

departmentName='\

SqlDataReader sdr = dataOperate.getRow(sql); if (sdr.Read()) {

string departmentID=sdr[\ //根据系部编号查询专业信息

sql = \* from T_Major where departmentID='\+ departmentID + \

DataSet ds = dataOperate.getDataSet(sql, \ cbMajor.DataSource = ds.Tables[\ cbMajor.DisplayMember = \ } }

private void cbMajor_SelectedIndexChanged(object sender, EventArgs e)

{

//根据专业名称查询专业编号

string sql = \+ cbMajor.Text + \

SqlDataReader sdr = dataOperate.getRow(sql); if (sdr.Read()) {

string majorID=sdr[\ //根据专业编号查询班级信息

sql = \\

DataSet ds = dataOperate.getDataSet(sql, \ cbClass.DataSource = ds.Tables[\ cbClass.DisplayMember = \ } }

private void btnSubmit_Click(object sender, EventArgs e) {

string Sex=\

29 / 55