private void button1_Click(object sender, EventArgs e) { SqlConnection conn = new Opreate().conn(); conn.Open(); string strCmd; if (textBox1.Text.Equals("*")) { strCmd = "select score.sno,sname,course.cno,cname,ccategory,score.grade from student, score, course where student.sno =score.sno and score.cno = course.cno"; } else { strCmd = "select score.sno,sname,course.cno,cname,ccategory,score.grade from student,score,course where score." + comboBox1.Text + " = '" + textBox1.Text + " ' and student.sno = score.sno and score.cno = course.cno"; } //dtGrdViewSearch.Rows.Clear(); SqlDataAdapter myDataAdapter; DataSet myDataSet = new DataSet(); myDataAdapter = new SqlDataAdapter(strCmd, conn); myDataAdapter.Fill(myDataSet, "student"); dataGridView1.DataSource = myDataSet.Tables["student"]; //textBox1.Text = myDataSet.Tables["student"].; conn.Close(); }
private void searchID_Click(object sender, EventArgs e) { SqlConnection conn = new Opreate().conn(); conn.Open(); string strCmd; if (textBox1.Text.Equals("*")) { strCmd = "select * from student"; } else { strCmd = "select * from student where " + comboBox1.Text + " = '" + textBox1.Text + " '"; } //dtGrdViewSearch.Rows.Clear(); SqlDataAdapter myDataAdapter; DataSet myDataSet = new DataSet(); myDataAdapter = new SqlDataAdapter(strCmd, conn); myDataAdapter.Fill(myDataSet, "student"); //dtGrdViewSearch.DataSource = myDataSet.Tables["student"]; dataGridView1.DataSource = myDataSet.Tables["student"]; conn.Close(); }
private void skinButton1_Click(object sender, EventArgs e) { SqlConnection conn = new Opreate().conn(); conn.Open(); string strCmd; if (textBox1.Text.Equals("*")) { strCmd = "select * from Teacher_teaching"; } else { strCmd = "select * from Teacher_teaching where " + skinComboBox1.Text + " = '" + textBox1.Text + " '"; } //dtGrdViewSearch.Rows.Clear(); SqlDataAdapter myDataAdapter; DataSet myDataSet = new DataSet(); myDataAdapter = new SqlDataAdapter(strCmd, conn); myDataAdapter.Fill(myDataSet, "Teacher_teaching"); skinDataGridView1.DataSource = myDataSet.Tables["Teacher_teaching"]; conn.Close(); }
private void button1_Click(object sender, EventArgs e) { SqlConnection conn = new Opreate().conn(); conn.Open(); string strCmd; if (comboBox1.Text.Equals("")) { MessageBox.Show("请选择查询条件!"); } else if (textBox1.Text.Equals("")) { MessageBox.Show("请输入查询值!"); } else if (textBox1.Text.Equals("*")) { strCmd = "select * from course"; } else { strCmd = "select * from course where " + comboBox1.Text + "= '" + textBox1.Text + "'"; SqlDataAdapter myDataAdapter; DataSet myDataSet = new DataSet(); myDataAdapter = new SqlDataAdapter(strCmd, conn); myDataAdapter.Fill(myDataSet, "course"); dataGridView1.DataSource = myDataSet.Tables["course"]; } conn.Close(); }
private void button1_Click(object sender, EventArgs e) { SqlConnection conn = new Opreate().conn(); conn.Open(); string strCmd = ""; if (textBox1.Text.Equals("")) { // strCmd = ""; MessageBox.Show("请输入学号!"); } else { strCmd = "select * from Teacher_teaching where tno ='" + textBox1.Text + "'"; SqlDataAdapter myDataAdapter; DataSet myDataSet = new DataSet(); myDataAdapter = new SqlDataAdapter(strCmd, conn); myDataAdapter.Fill(myDataSet, "Teacher_teaching"); dataGridView1.DataSource = myDataSet.Tables["Teacher_teaching"]; } conn.Close(); }
private void skinButton7_Click(object sender, EventArgs e) { SqlConnection Conn = new Opreate().conn();//到sqlsever的连接 Conn.Open(); string Sql = "select top 1 * from teacher order by tno desc"; SqlCommand comm = new SqlCommand(Sql, Conn); //command对象 SqlDataReader dr = comm.ExecuteReader(); //定义数据读取对象 if (dr.Read()) { skinTextBox1.Text = (string)dr.GetValue(0); skinTextBox2.Text = (string)dr.GetValue(1); skinComboBox1.Text = (string)dr.GetValue(2); skinComboBox2.Text = dr.GetValue(3).ToString(); } Conn.Close(); }
private void 排课_Load(object sender, EventArgs e) { SqlConnection conn = new Opreate().conn(); conn.Open(); string strCmd = "select * from Teacher_teaching"; //dtGrdViewSearch.Rows.Clear(); SqlDataAdapter myDataAdapter; DataSet myDataSet = new DataSet(); myDataAdapter = new SqlDataAdapter(strCmd, conn); myDataAdapter.Fill(myDataSet, "Teacher_teaching"); skinDataGridView1.DataSource = myDataSet.Tables["Teacher_teaching"]; skinDataGridView1.Columns[0].ReadOnly = true; skinDataGridView1.Columns[1].ReadOnly = true; skinDataGridView1.Columns[2].ReadOnly = true; conn.Close(); }