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

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

private void cbClass_SelectedIndexChanged(object sender, EventArgs e)

{

string sql = \学号',s.Name as '姓名',s.Sex as '性别',s.Birthday as '出生',s.Address as '地址' from T_Student as s,T_Class as c where className='\

DataSet ds = dataOperate.getDataSet(sql, \ dgvStuInfo.DataSource = ds;

dgvStuInfo.DataMember = \ }

(七) 修改学生信息界面设计

其窗口界面如下:

35 / 55

通过学号和姓名,查找出具体学生的信息,经确认可以修改后,点击查询按钮,将查询出该条件下的用户的信息;此时,按钮的文本值将变成“修改”,点击“修改”,基本信息将从不可编辑变成可编辑状态,并且,按钮的文本又变成“保存”;将要修改的值修改好后,点击保存,数据库将根据提交的数据修改用户信息;信息修改成功后,所有信息又回到不可编辑状态。

实现代码如下:

private string Department = \

private void btnBrowse_Click(object sender, EventArgs e) {

if (btnBrowse.Text == \查询\ {

string sql = \* from T_Student where Num='\+ txtNum.Text + \

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

txtName1.Text = sdr[\ string Sex=sdr[\ if (Sex == \男\ {

rbtnMan.Checked = true; } else {

rbtnWomen.Checked = true; }

txtBirthday.Text = sdr[\ txtAddress.Text = sdr[\ string classID = sdr[\

37 / 55

//根据班级编号classID查询班级信息 sql classID='\

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

cbClass.Text = sdr[\ string majorID = sdr[\ //根据专业编号majorID查询专业信息 sql = \majorID + \

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

cbMajor.Text = sdr[\ string sdr[\

//查询部门信息

departmentID

=

=

\

*

from

T_Class

where

sql = \* from T_Department where departmentID='\

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

cbDepartment.Text sdr[\

Department sdr[\

btnBrowse.Text = \修改\ } } } } else {

MessageBox.Show(\对不起,无此记录!\ Empty();

39 / 55

=

=