日期:2014-05-17 浏览次数:21057 次
private void AdminPlacement_Load(object sender, EventArgs e)
{
pobjconn.Open();
SqlCommand pobjcom = new SqlCommand();
pobjcom.CommandText = "select CourseName,ElectivesID from View_1";
pobjcom.Connection = pobjconn;
pobjcom.ExecuteNonQuery();
SqlDataAdapter pobjdat = new SqlDataAdapter(pobjcom);
pobjdat.Fill(table);
comboBox1.DataSource = table;
comboBox1.DisplayMember = "CourseName";
comboBox1.ValueMember = "ElectivesID";
pobjconn.Close();
}
private void button1_Click_1(object sender, EventArgs e)
{
table1.Clear();
pobjconn.Open();
SqlCommand pobjcom = new SqlCommand();
pobjcom.CommandText = "select CourseName as 选修课,TeacherName as 教师,StuName as 学生 from AdminPlacement where ElectivesID=@ElectivesID";
pobjcom.Parameters.Add("@ElectivesID", SqlDbType.Int).Value = comboBox1.SelectedValue;
pobjcom.Connection = pobjconn;
pobjcom.ExecuteNonQuery();
SqlDataAdapter pobjdat1 = new SqlDataAdapter(pobjcom);
pobjdat1.Fill(table1);
dataGridView1.DataSource = table1;
dataGridView1.AllowUserToAddRows = false;
for (int j = 0; j < dataGridView1.Columns.Count; j++)
dataGridView1.Columns[j].SortMode = DataGridViewColumnSortMode.NotSortable;
pobjconn.Close();
textBox1.Text = dataGridView1.Rows.Count.ToString();