private void button2_Click(object sender, EventArgs e) { Form3 form3 = new 图书管理系统.Form3(); form3.Show(); this.Visible = false; }
private void Form4_Load(object sender, EventArgs e) { connection = new SqlConnection(conn); connection.Open(); sql = string.Format("select book_id1,book_id2,book_id3 from student_information where Student_ID = '{0}' ", Form1.Student_ID); SqlDataAdapter dataadapter = new SqlDataAdapter(sql, connection); dt = new DataTable(); dataadapter.Fill(dt); book_id1 = dt.Rows[0][0].ToString(); book_id2 = dt.Rows[0][1].ToString(); book_id3 = dt.Rows[0][2].ToString(); sql2 = string.Format("select book_ID, book_name,book_writer from book_information where book_ID ='{0}' or book_ID ='{1}' or book_ID ='{2}' ", book_id1, book_id2, book_id3); SqlDataAdapter dataadapter2 = new SqlDataAdapter(sql2, connection); DataSet dataset = new DataSet(); dataadapter2.Fill(dataset); try { dataGridView1.Columns[0].DataPropertyName = "book_ID"; dataGridView1.Columns[1].DataPropertyName = "book_name"; dataGridView1.Columns[2].DataPropertyName = "book_writer"; dataGridView1.DataSource = dataset.Tables[0]; } catch (Exception ex) { MessageBox.Show(ex.Message, "显示失败", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (dt.Rows[0][0].ToString() == "" || dt.Rows[0][0] == null) { MessageBox.Show("请选择图书", "欢迎使用图书馆查询借阅系统", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); Form3 form3 = new 图书管理系统.Form3(); form3.Show(); } else { book_id = (int)dataGridView1.Rows[0].Cells["Column1"].Value; connection.Close(); } }