溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

ASP.NET如何實現(xiàn)圖書管理系統(tǒng)

發(fā)布時間:2021-03-08 14:33:32 來源:億速云 閱讀:185 作者:TREX 欄目:開發(fā)技術(shù)

本篇內(nèi)容主要講解“ASP.NET如何實現(xiàn)圖書管理系統(tǒng)”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“ASP.NET如何實現(xiàn)圖書管理系統(tǒng)”吧!

一、數(shù)據(jù)庫添加

1.用戶信息

ASP.NET如何實現(xiàn)圖書管理系統(tǒng)

2.圖書信息表

ASP.NET如何實現(xiàn)圖書管理系統(tǒng)

3.圖書借閱信息表

ASP.NET如何實現(xiàn)圖書管理系統(tǒng)

二、版本頁面

vs2010+sqlserver2008

ASP.NET如何實現(xiàn)圖書管理系統(tǒng) ASP.NET如何實現(xiàn)圖書管理系統(tǒng)

三、實現(xiàn)功能

1. 用戶注冊登錄
2. 兩種身份:管理員和讀者
3. 讀者能夠注冊自己的賬號和密碼還有填寫自己的個人信息
4. 讀者根據(jù)自己需求的借閱和歸還圖書5. 管理員可以增、減、查、改等圖書信息,修改用戶信息待完善

四、主要頁面展示

1.登錄頁面 ASP.NET如何實現(xiàn)圖書管理系統(tǒng)2.用戶注冊 ASP.NET如何實現(xiàn)圖書管理系統(tǒng)3.個人信息表 ASP.NET如何實現(xiàn)圖書管理系統(tǒng)4.用戶歸還圖書

ASP.NET如何實現(xiàn)圖書管理系統(tǒng)5.用戶借閱書籍 ASP.NET如何實現(xiàn)圖書管理系統(tǒng)6.用戶檢索書籍 ASP.NET如何實現(xiàn)圖書管理系統(tǒng) 7.管理員頁面 ASP.NET如何實現(xiàn)圖書管理系統(tǒng)

五、簡單代碼

1.注冊頁面(內(nèi)容判斷不在內(nèi))

try
 {
  //賦予sql字符串?dāng)?shù)據(jù)
  string strsql1 = "insert into yhxx (zh,mima) values ('" + Tet_zh.Text + "','" + Tet_mima.Text + "')";
  //創(chuàng)建字符串對象
  mycom = new SqlCommand(strsql1, myconn);
  mycom.ExecuteNonQuery();
  //關(guān)閉數(shù)據(jù)庫
  myconn.Close();
  Response.Write("<script>alert('添加成功?。?#39;)</script>");
  //保存賬號
  //str = Tet_zh.Text;
  //保存用戶名
  Application["name"] = Tet_zh.Text;
  //如果成功了成功轉(zhuǎn)入
  Response.Redirect("Useradd.aspx");
 }
 catch (Exception ex)
 {
  Response.Write("<script>alert('用戶已存在?。?#39;)</script>");
 }

2.個人信息頁面(內(nèi)容判斷不在內(nèi))

protected void tianjia()
 {
 //添加用戶信息
 try
 {
  //賦予sql字符串?dāng)?shù)據(jù)
  
  string strsql1 = "update yhxx set xm='"+Tet_xm.Text+"',xb='"+tet_xb.Text+"',qq='"+Tet_qq.Text+"',Email='"+Tet_email.Text+"',dizhi='"+tet_home.Text+"',enjioy='"+Tet_enjoy.Text+"' where zh='"+Application["name"]+"'";
  // 創(chuàng)建字符串對象
  mycom = new SqlCommand(strsql1, myconn);
  mycom.ExecuteNonQuery();
  //關(guān)閉數(shù)據(jù)庫
  myconn.Close();
  Response.Write("<script>alert('添加成功?。?#39;)</script>");
  Response.Redirect("denglu.aspx");
 }
 catch (Exception ex)
 {
  Response.Write("<script>alert('添加失?。?!')</script>"+ex.Message.ToString());
 }
 }

3.登錄頁面(內(nèi)容判斷不在內(nèi))

 //普通用戶登錄,管理員登錄雷同
 try
 {
  string sql = "select * from yhxx where zh='"+Tet_zh.Text+"' and mima='"+Tet_mm.Text+"' and yhlb='"+tet_dz.Text+"'";
  //創(chuàng)建命令對象
  SqlCommand com = new SqlCommand(sql,myconn);
  //創(chuàng)建讀取對象
  SqlDataReader dr = com.ExecuteReader();
  //成功彈出提示框
  //MessageBox.Show("讀取成功!!");
  if (dr.Read())
  {
  dr.Close();
  myconn.Close();
  Application["name1"] = Tet_zh.Text;
  Response.Redirect("index.aspx");
  }
  else
  {
  Response.Write("<script>alert('用戶名或密碼有誤??!')</script>");
  }

 }
 catch (Exception ex)
 {
  Response.Write("<script>alert('登錄失?。?!')</script>");
 }

4.圖書檢索

try
 {
  //打開數(shù)據(jù)庫
  myconn.Open();
 }
 catch (Exception ex)
 {
  Response.Write("<script>alert('數(shù)據(jù)庫打開失敗')</script>");
 }
 try
 {
  //創(chuàng)建數(shù)據(jù)字符串
  if (tet_name.Text == "")
  {
  Response.Write("<script>alert('名稱不能為空!')</script>");
  }
  else
  {
  string strsql3 = "select BookID as 圖書編號,BookName as 圖書名稱,"
    + "Booklb as 圖書類別,Bookzz as 圖書作者,Booklr as 圖書內(nèi)容,"
    + "Bookfm as 圖書封面,Bookjg as 圖書價格,Bookzt as 圖書借閱狀態(tài) "
    + " from Bookxx where BookName='" + tet_name.Text + "'";
  mycom = new SqlCommand(strsql3, myconn);
  //打開數(shù)據(jù)庫
  //myconn.Open();
  //
  myread = mycom.ExecuteReader();
  GridView1.DataSource = myread;
  GridView1.DataBind();
  GridView1.Visible = true;
  //關(guān)閉數(shù)據(jù)
  myread.Close();
  myconn.Close();
  }
 }
 catch (Exception ex)
 {
  Response.Write("<script>alert('查詢失敗!')</script>" + ex.Message.ToString());
 }

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();
  //關(guān)閉
  myconn.Close();
  myread.Close();
 //////////////////////////////////////
  xiugai();
  chaxun();
  }
  if (tet_zt.Text == "1")
  {
  Response.Write("<script>alert('該書正在借閱中')</script>");
  chaxun();
  }
 2.再分別修改借閱狀態(tài)
  //創(chuàng)建
 //先修改圖書表狀態(tài)信息
 string strsql7 = "update Bookxx set Bookzt='1' where BookID='" + Tet_Bookid.Text + "'";
 mycom = new SqlCommand(strsql7, myconn);
 myconn.Close();
 myconn.Open();
 mycom.ExecuteNonQuery();
 //再修改借閱狀態(tài)表信息
 string strsql8 = "update Bookjyxx set ISBookzt='1' where ISBookID='" + Tet_Bookid.Text + "'";
 mycom = new SqlCommand(strsql8, myconn);
 mycom.ExecuteNonQuery();
 Response.Write("<script>alert('借閱成功!')</script>");
 //關(guān)閉
 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 借閱數(shù)據(jù)名稱,ISBookzt as 借閱狀態(tài),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;
 //修改狀態(tài)
 //先修改圖書表狀態(tài)信息
 string strsql7 = "update Bookxx set Bookzt='0' where BookID='" +tet_Bookid.Text+ "'";
 mycom = new SqlCommand(strsql7, myconn);
 mycom.ExecuteNonQuery();
 Response.Write("<script>alert('歸還成功!')</script>");
 //關(guān)閉
 myconn.Close();
 set.Clear();

總結(jié)

到此,相信大家對“ASP.NET如何實現(xiàn)圖書管理系統(tǒng)”有了更深的了解,不妨來實際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI