DBOperate operate = new DBOperate(); //创建操作数据库对象 private void FormCheckuser_G_Load(object sender, EventArgs e) { try { if (XG == "所有学生") { tabControl1.SelectTab("学生"); string str = "select * from student where stu_id='" + XGID + "'"; DataSet ds = operate.GetTable(str); ds.Dispose(); //学生表不用给专业赋初值,后已经将班级与专业关联 TB_stu_ID.Text = ds.Tables[0].Rows[0][0].ToString(); CBB_stu_class.Text = ds.Tables[0].Rows[0][1].ToString(); TB_stu_name.Text = ds.Tables[0].Rows[0][2].ToString(); CBB_stu_sex.Text = ds.Tables[0].Rows[0][3].ToString(); Time_stu_birth.Text = ds.Tables[0].Rows[0][4].ToString(); CBB_stu_MCCP.Text = ds.Tables[0].Rows[0][5].ToString(); TB_stu_enter.Text = ds.Tables[0].Rows[0][6].ToString(); CBB_stu_nation.Text = ds.Tables[0].Rows[0][8].ToString(); operate.StuGet_Image(XGID, pictureBox_stu); } else { tabControl1.SelectTab("老师"); string str = "select * from teacher where tea_id='" + XGID + "'"; DataSet ds = operate.GetTable(str); ds.Dispose(); TB_tea_ID.Text = ds.Tables[0].Rows[0][0].ToString();; TB_tea_name.Text = ds.Tables[0].Rows[0][1].ToString();; CBB_tea_sex.Text = ds.Tables[0].Rows[0][2].ToString();; CBB_tea_dept.Text = ds.Tables[0].Rows[0][3].ToString();; Time_tea_birth.Text = ds.Tables[0].Rows[0][4].ToString();; CBB_tea_nation.Text = ds.Tables[0].Rows[0][5].ToString();; CBB_tea_marry.Text = ds.Tables[0].Rows[0][6].ToString();; CBB_tea_MCCP.Text = ds.Tables[0].Rows[0][7].ToString();; TB_tea_phone.Text = ds.Tables[0].Rows[0][8].ToString();; Time_tea_enter.Text = ds.Tables[0].Rows[0][9].ToString();; operate.TeaGet_Image(XGID, pictureBox_tea); TB_tea_pay.Text = ds.Tables[0].Rows[0][11].ToString();; } } catch (Exception ex) { MessageBox.Show(ex.Message);//弹出消息对话框 } }