private void btnLeftAll_Click(object sender, EventArgs e) {
this.BindingContext[ds, \ btnLeftAll.Enabled = false; btnLeft.Enabled = false; btnRight.Enabled = true; btnRightAll.Enabled = true; }
private void btnLeft_Click(object sender, EventArgs e) {
if (this.BindingContext[ds, \ {
this.BindingContext[ds, \
if (this.BindingContext[ds, \ {
btnLeftAll.Enabled = false; btnLeft.Enabled = false; }
btnRight.Enabled = true; btnRightAll.Enabled = true; } }
private void btnRight_Click(object sender, EventArgs e) {
if (this.BindingContext[ds, \< this.BindingContext[ds, \
{
this.BindingContext[ds, \
if (this.BindingContext[ds, \== this.BindingContext[ds, \
{
btnRight.Enabled = false; btnRightAll.Enabled = false; }
btnLeft.Enabled = true; btnLeftAll.Enabled = true;
} }
private void btnRightAll_Click(object sender, EventArgs e) {
this.BindingContext[ds, \this.BindingContext[ds, \
btnLeft.Enabled = true; btnLeftAll.Enabled = true; btnRight.Enabled = false; btnRightAll.Enabled = false; }
private void btnDelete_Click(object sender, EventArgs e) {
=
//删除学生账户信息
int i= this.BindingContext[ds, \
string Num = ds.Tables[\ string sql = \from T_Student_user where Num='\+ Num + \
bool flag = dataOperate.execSQL(sql); if (flag) {
//删除T_Student表中的数据
sql = \ bool flag1 = dataOperate.execSQL(sql); if (flag1) {
MessageBox.Show(\删除成功!\ getInfo(); } else {
MessageBox.Show(\删除用户信息失败!\ return; } //int rowID = this.BindingContext[ds, \
//ds.Tables[\
21 / 55
//sdapt.Update(ds, \
//this.BindingContext[ds, \ //btnLeft.Enabled = false; //btnLeftAll.Enabled = false; //btnRight.Enabled = true; //btnRightAll.Enabled = true; } else {
MessageBox.Show(\删除用户账户失败!\ return; } }
private void btnClose_Click(object sender, EventArgs e) {
this.Close(); }
private void cbDepartment_SelectedIndexChanged(object sender, EventArgs e)
{
string sql = \mr.majorName from T_Major as mr,T_Department as dt where dt.departmentName='\+ cbDepartment.Text + \and mr.departmentID=dt.departmentID\
ds1 = dataOperate.getDataSet(sql, \ cbMajor.DataSource = ds1.Tables[0];
cbMajor.DisplayMember = \ }
private void cbMajor_SelectedIndexChanged(object sender, EventArgs e)
{
string sql = \mr where mr.majorName='\
ds1 = dataOperate.getDataSet(sql, \ cbClass.DataSource = ds1.Tables[0]; cbClass.DisplayMember = \ }
private void cbClass_SelectedIndexChanged(object sender, EventArgs e)
{
getInfo(); }
public void getInfo() {
con = dataOperate.createConnection(); con.Open();
string sql = \学号',st.Name as '姓名',st.Sex as '性别',st.Birthday as '出生',st.Address as '籍贯' from T_Student as st,T_Class as cs where cs.className='\
sdapt = new SqlDataAdapter(sql, con); ds = new DataSet();
sdapt.Fill(ds, \
dataGridView1.DataSource = ds;
dataGridView1.DataMember = \ dataGridView1.ReadOnly = true; } (五)
学生信息录入界面设计
其窗口界面如下图:
23 / 55
这里只能对学生进行添加,即身份只能选择Student。
实现代码如下:
private static string sql = \
public static string Num = \ public static string Name = \
private void cbShenFen_SelectedIndexChanged(object sender, EventArgs e)
{
Num = txtNum.Text;
Name = txtUserName.Text;
switch (cbShenFen.SelectedIndex) {
case 0: sql = \* from T_Administrator_user where Num='\
case 1: sql = \+ Num + \
case 2: sql = \+ Num + \
}
bool flag = dataOperate.seleSQL(sql); if (flag) {