ASP.NET实现图书管理系统的步骤详解(3)

5.图书借阅

1.先添加图书
 if (myread.Read())
    {
      if (tet_zt.Text == "0")
      {
        //添加借阅信息表
        myread.Close();
        string strsql5 = "insert into Bookjyxx (ISBookID,ISBookname,ISBookzt,ISname,ISid) " +
        " values (" + Tet_Bookid.Text + ",'" + tet_Name.Text + "'," + tet_zt.Text + ",'" + Tet_xm.Text + "'," + Tet_ID.Text + ")";
        mycom = new SqlCommand(strsql5, myconn);
        mycom.ExecuteNonQuery();
        //关闭
        myconn.Close();
        myread.Close();
    //////////////////////////////////////
        xiugai();
        chaxun();
      }
      if (tet_zt.Text == "1")
      {
        Response.Write("<script>alert('该书正在借阅中')</script>");
        chaxun();
      }
 2.再分别修改借阅状态
       //创建
    //先修改图书表状态信息
    string strsql7 = "update Bookxx set Bookzt='1' where BookID='" + Tet_Bookid.Text + "'";
    mycom = new SqlCommand(strsql7, myconn);
    myconn.Close();
    myconn.Open();
    mycom.ExecuteNonQuery();
    //再修改借阅状态表信息
    string strsql8 = "update Bookjyxx set ISBookzt='1' where ISBookID='" + Tet_Bookid.Text + "'";
    mycom = new SqlCommand(strsql8, myconn);
    mycom.ExecuteNonQuery();
    Response.Write("<script>alert('借阅成功!')</script>");
    //关闭
    myconn.Close();

6.图书归还

//删除他的借阅图书信息
    string strsql3="delete from bookjyxx where ISid='"+Tet_id.Text+"'";
    mycom = new SqlCommand(strsql3, myconn);
    myconn.Open();
    mycom.ExecuteNonQuery();
    //////////////////////////////
    //刷新信息
    //查询信息
    string strsql4= "select ISname as 借阅者,ISid as 借阅证号码,ISBookID as 借阅书籍编号,"
      + "ISBookname as 借阅数据名称,ISBookzt as 借阅状态,ISdate as借阅日期 from Bookjyxx where ISid='" + Tet_id.Text + "'";
    mydata = new SqlDataAdapter(strsql4, myconn);
    DataSet set = new DataSet();
    mydata.Fill(set);
    GridView1.DataSource = set.Tables[0];
    GridView1.DataBind();
    GridView1.Visible = true;
    //修改状态
    //先修改图书表状态信息
    string strsql7 = "update Bookxx set Bookzt='0' where BookID='" +tet_Bookid.Text+ "'";
    mycom = new SqlCommand(strsql7, myconn);
    mycom.ExecuteNonQuery();
    Response.Write("<script>alert('归还成功!')</script>");
    //关闭
    myconn.Close();
    set.Clear();

总结

以上所述是小编给大家介绍的ASP.NET实现图书管理系统的步骤,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对黑区网络网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!