ASP.NET實現(xiàn)圖書管理系統(tǒng)的步驟詳解
一、數(shù)據(jù)庫添加
1.用戶信息
2.圖書信息表
3.圖書借閱信息表
二、版本頁面
vs2010+sqlserver2008
三、實現(xiàn)功能
1. 用戶注冊登錄2. 兩種身份:管理員和讀者3. 讀者能夠注冊自己的賬號和密碼還有填寫自己的個人信息4. 讀者根據(jù)自己需求的借閱和歸還圖書5. 管理員可以增、減、查、改等圖書信息,修改用戶信息待完善
四、主要頁面展示
1.登錄頁面 2.用戶注冊 3.個人信息表 4.用戶歸還圖書
5.用戶借閱書籍 6.用戶檢索書籍 7.管理員頁面
五、簡單代碼
1.注冊頁面(內容判斷不在內)
try
{
//賦予sql字符串數(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();
//關閉數(shù)據(jù)庫
myconn.Close();
Response.Write("<script>alert('添加成功!!')</script>");
//保存賬號
//str = Tet_zh.Text;
//保存用戶名
Application["name"] = Tet_zh.Text;
//如果成功了成功轉入
Response.Redirect("Useradd.aspx");
}
catch (Exception ex)
{
Response.Write("<script>alert('用戶已存在??!')</script>");
}
2.個人信息頁面(內容判斷不在內)
protected void tianjia()
{
//添加用戶信息
try
{
//賦予sql字符串數(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();
//關閉數(shù)據(jù)庫
myconn.Close();
Response.Write("<script>alert('添加成功?。?)</script>");
Response.Redirect("denglu.aspx");
}
catch (Exception ex)
{
Response.Write("<script>alert('添加失?。?!')</script>"+ex.Message.ToString());
}
}
3.登錄頁面(內容判斷不在內)
//普通用戶登錄,管理員登錄雷同
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 圖書內容,"
+ "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;
//關閉數(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();
//關閉
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>");
//關閉
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>");
//關閉
myconn.Close();
set.Clear();
總結
以上所述是小編給大家介紹的ASP.NET實現(xiàn)圖書管理系統(tǒng)的步驟,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對我們網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!
上一篇:ASP.NET Core 3框架揭秘之 異步線程無法使用IServiceProvider問題
欄 目:ASP.NET
下一篇:.NET連接池的問題詳解
本文標題:ASP.NET實現(xiàn)圖書管理系統(tǒng)的步驟詳解
本文地址:http://www.jygsgssxh.com/a1/ASP_NET/10828.html
您可能感興趣的文章
- 01-11如何給asp.net core寫個簡單的健康檢查
- 01-11docker部署Asp.net core應用的完整步驟
- 01-11ASP.NET Core靜態(tài)文件的使用方法
- 01-11asp.net Core3.0區(qū)域與路由配置的方法
- 01-11ASP.Net Core中使用枚舉類而不是枚舉的方法
- 01-11.NET Core 3.0 可回收程序集加載上下文的實現(xiàn)
- 01-11Asp.net core利用MediatR進程內發(fā)布/訂閱詳解
- 01-11ASP.NET Core中間件計算Http請求時間示例詳解
- 01-11asp.net core集成JWT的步驟記錄
- 01-11ASP.NET Core MVC學習教程之路由(Routing)


閱讀排行
本欄相關
- 01-11vscode extension插件開發(fā)詳解
- 01-11VsCode插件開發(fā)之插件初步通信的方法
- 01-11如何給asp.net core寫個簡單的健康檢查
- 01-11.net core高吞吐遠程方法如何調用組件
- 01-11淺析.Net Core中Json配置的自動更新
- 01-11.NET開發(fā)人員關于ML.NET的入門學習
- 01-11.NET Core 遷移躺坑記續(xù)集之Win下莫名其
- 01-11.net core webapi jwt 更為清爽的認證詳解
- 01-11docker部署Asp.net core應用的完整步驟
- 01-11ASP.NET Core靜態(tài)文件的使用方法
隨機閱讀
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 01-10SublimeText編譯C開發(fā)環(huán)境設置
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 01-10delphi制作wav文件的方法
- 01-10C#中split用法實例總結
- 01-11ajax實現(xiàn)頁面的局部加載
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 04-02jquery與jsp,用jquery


