private void FormCheckscore_Load(object sender, EventArgs e) { cbbClass.SelectedIndex = 0; cbbSemester.SelectedIndex = 0; cbbClass.SelectedIndex = 0; if (FormMain.Power == "学生") { Text = "当前学生编号:" + FormMain.User; cbbClass.Enabled = false; cbbstudent.Enabled = false; cbbstudent.Text = FormMain.User; dataGridView1.ReadOnly = true; string sqlstr1 = "select * from Coures where Cour_Semester='" + cbbSemester.SelectedItem.ToString() + "'"; operate.BindDropdownlist(sqlstr1, cbbCourse, 1);//绑定下拉列表(课程) cbbCourse.SelectedIndex = -1; } else { if (FormMain.Power == "教师") { Text = "当前教师编号:" + FormMain.User; } string StuId = dataGridView1.SelectedCells[1].Value.ToString(); //得到编号(学生或者教师编号) operate.StuGet_Image(StuId, pictureBox1); //显示图片信息 this.dataGridView1.Columns[1].FillWeight = 120; string str1 = "select stu_name from Student"; operate.BindDropdownlist(str1, cbbstudent, 0); cbbCourse.SelectedIndex = -1; } }
//选中的树节点改变事件 private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { string str = e.Node.Text;//得到选中的节点字符串 //|| str ==" 教导主任" || str == "总务主任" || str == "副校长" || str == "校长" if (FormMain.Power == "管理员") { if (str == "所有教师") { string sqlstr = "select Tea_id as '教师编号', Tea_name as '教师姓名',Tea_Dept '部门',Tea_Birthday as '生日',Tea_Nation as '民族',Tea_Marriage as '婚否',Tea_MCCP as '政治面貌',Tea_Phone as '电话',Tea_Accession as '就职日期',Tea_Pay as '薪资' from Teacher"; operate.BindDataGridView(dataGridView1, sqlstr);//将查询信息绑定到DATAGRIDVIEW1中 dataGridView1.Columns[0].Width = 60; dataGridView1.Columns[1].Width = 100; return; } else { string sqlstr2 = "select Tea_id as '教师编号', Tea_name as '教师姓名',Tea_Dept '部门',Tea_Birthday as '生日',Tea_Nation as '民族',Tea_Marriage as '婚否',Tea_MCCP as '政治面貌',Tea_Phone as '电话',Tea_Accession as '就职日期',Tea_Pay as '薪资' from Teacher where Tea_Dept='" + str + "'"; operate.BindDataGridView(dataGridView1, sqlstr2);//将查询信息绑定到DATAGRIDVIEW1中 return; } } else //teacher { if (str == "所有教师") { ADD.Enabled = false; change.Enabled = false; delete.Enabled = false; string sqlstr = "select Tea_id as '教师编号', Tea_name as '教师姓名',Tea_Dept '部门',Tea_Birthday as '生日',Tea_Nation as '民族',Tea_Marriage as '婚否',Tea_MCCP as '政治面貌',Tea_Phone as '电话',Tea_Accession as '就职日期',Tea_Pay as '薪资' from Teacher where Tea_id='" + FormMain.User + "'"; operate.BindDataGridView(dataGridView1, sqlstr);//将查询信息绑定到DATAGRIDVIEW1中 } else if (str == "所有学生") { ADD.Enabled = true; change.Enabled = true; delete.Enabled = false; string sqlstr = "SELECT [stu_id] as '学生编号',[stu_class] as '学生班级',[stu_name] as '学生姓名',[stu_sex] as '学生性别',[stu_birthday] as '学生生日',[stu_MCCP] as '政治面貌',[stu_Enterscore] as '入学成绩',[stu_nativeplace] as '籍贯' FROM [dbo].[Student]"; operate.BindDataGridView(dataGridView1, sqlstr); //将查询信息绑定到DATAGRIDVIEW1中 string StuId = dataGridView1.SelectedCells[0].Value.ToString(); //得到编号(学生编号) operate.StuGet_Image(StuId, pictureBox1); //显示图片信息 Text = "当前学生编号:" + dataGridView1.SelectedCells[0].Value.ToString(); } } }
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);//弹出消息对话框 } }