圖書管理系統(tǒng)源碼(C#版)

上傳人:GCG1****010 文檔編號:57134929 上傳時間:2022-02-23 格式:DOC 頁數(shù):34 大?。?57KB
收藏 版權(quán)申訴 舉報 下載
圖書管理系統(tǒng)源碼(C#版)_第1頁
第1頁 / 共34頁
圖書管理系統(tǒng)源碼(C#版)_第2頁
第2頁 / 共34頁
圖書管理系統(tǒng)源碼(C#版)_第3頁
第3頁 / 共34頁

下載文檔到電腦,查找使用更方便

0 積分

下載資源

還剩頁未讀,繼續(xù)閱讀

資源描述:

《圖書管理系統(tǒng)源碼(C#版)》由會員分享,可在線閱讀,更多相關(guān)《圖書管理系統(tǒng)源碼(C#版)(34頁珍藏版)》請在裝配圖網(wǎng)上搜索。

1、登錄界面:using System;using System。Collections。Generic;using System.ComponentModel;using System.Data;using System。Drawing;using System.Text;using System。Windows.Forms;using System。Data。SqlClient;namespace book public partial class login : Form public string password; /用來存儲密碼 public login() InitializeCom

2、ponent(); private void button2_Click(object sender, EventArgs e) Application。Exit(); private bool yanzhengshuru() password = textBox3。Text; if (Typename.Text.Trim() = ”) MessageBox.Show(請選擇登錄類型, 登錄提示, MessageBoxButtons.OK, MessageBoxIcon.Information); Typename.Focus(); return false; else if (loginid

3、。Text.Trim() = ”) MessageBox.Show(”請輸入用戶名, ”登錄提示”, MessageBoxButtons。OK, MessageBoxIcon。Information); loginid.Focus(); return false; else if (password = ”) MessageBox.Show(請輸入密碼, ”登錄提示, MessageBoxButtons.OK, MessageBoxIcon。Information); textBox3。Focus(); return false; else return true; private void

4、button1_Click(object sender, EventArgs e) userhelper.adminid= loginid.Text; /用戶賬號 password = textBox3.Text;/用戶密碼 if (yanzhengshuru()) if (Typename.Text.Trim() = 管理員”) string sql = string.Format(Select count(*) from admin where adminId=0 and adminpass=1”, loginid。Text, password); try SqlCommand comma

5、nd = new SqlCommand(sql, Dbhelper.connection); Dbhelper.connection。Open(); int count = (int)command.ExecuteScalar(); if (count 1) MessageBox.Show(用戶或密碼不存在!”); /result = false; else admin admin = new admin(); admin.Show(); catch (Exception ex) MessageBox。Show(操作數(shù)據(jù)庫出錯!”); Console。WriteLine(ex.Message)

6、; finally Dbhelper。connection.Close(); if (Typename.Text。Trim() = 借閱者) userhelper。readerid =Convert .ToString (loginid。Text); string sql = string。Format(”Select count(*) from reader where readerId=0 and readerpass=1, userhelper.readerid,textBox3。Text); try / 創(chuàng)建 Command 對象 SqlCommand command = new Sq

7、lCommand(sql, Dbhelper.connection); / 打開數(shù)據(jù)庫連接 Dbhelper。connection.Open(); / 驗證是否為合法用戶 int count = (int)command.ExecuteScalar(); if (count 1) MessageBox.Show(”用戶或密碼不存在?。?; /result = false; else reader reader = new reader(); reader.Show(); catch (Exception ex) MessageBox。Show(”操作數(shù)據(jù)庫出錯!); Console.WriteL

8、ine(ex.Message); /result = false; finally / 關(guān)閉數(shù)據(jù)庫連接 Dbhelper.connection.Close(); private void login_Load(object sender, EventArgs e) 讀者界面;using System;using System.Collections。Generic;using System。ComponentModel;using System。Data;using System。Drawing;using System.Text;using System.Windows。Forms;usin

9、g System.Data。Sql;using System.Data。SqlClient;namespace book public partial class reader : Form public reader() InitializeComponent(); private void button3_Click(object sender, EventArgs e) string id =Convert.ToString (textBox1。Text); if (id!=userhelper。readerid) MessageBox.Show(”輸入賬號與登陸賬號不相同,請重新輸入,

10、”提示,MessageBoxButtons。OK,MessageBoxIcon。Warning); textBox1.Text = ”; textBox1。Focus(); else try string sql = string.Format(update reader set islost=0where readerid=1”, 是,id); Dbhelper。connection。Open(); SqlCommand command = new SqlCommand(sql,Dbhelper.connection); int result = command。ExecuteNonQuer

11、y(); if (result 1) MessageBox.Show(”修改失敗”); else MessageBox.Show(掛失成功”); catch MessageBox。Show(error”); finally Dbhelper.connection.Close(); private void toolStripButton3_Click(object sender, EventArgs e) groupBox1.Visible = false; groupBox2.Visible = true; private void toolStripButton4_Click(object

12、 sender, EventArgs e) groupBox1.Visible = true; groupBox2。Visible = false; private void button5_Click(object sender, EventArgs e) textBox2.Text = ”; textBox4。Text = ”; textBox5。Text = ; private void Form1_Load(object sender, EventArgs e) toolStrip1.Text = string.Format(學(xué)生:0”,userhelper.readerid); pr

13、ivate void button4_Click(object sender, EventArgs e) string id =Convert。ToString (textBox2.Text); if (id!=userhelper.readerid) MessageBox。Show(輸入賬號與登陸賬號不相同,請重新輸入”,提示”,MessageBoxButtons.OK,MessageBoxIcon。Warning); textBox1。Text = ; textBox1。Focus(); else if (textBox4.Text!=textBox5.Text) MessageBox.S

14、how (”兩次密碼輸入不同); else try string sql = string。Format(update reader set readerpass=0 where readerid=1, textBox4.Text,id); Dbhelper。connection。Open(); SqlCommand command = new SqlCommand(sql,Dbhelper。connection); int result = command.ExecuteNonQuery(); if (result 1) MessageBox.Show(修改失敗”); else Messag

15、eBox。Show(”修改成功”); catch MessageBox.Show(error”); finally Dbhelper.connection。Close(); private void toolStripButton6_Click(object sender, EventArgs e) addreader addreader = new addreader(); addreader = new addreader(); private void toolStripButton1_Click(object sender, EventArgs e) readsearchbook se

16、archbook = new readsearchbook(); searchbook。Show(); private void toolStripButton2_Click(object sender, EventArgs e) borrow a = new borrow(); a.Show(); private void toolStripButton5_Click(object sender, EventArgs e) readerseacherinfo a = new readerseacherinfo(); a.Show(); private void 圖書查詢ToolStripMe

17、nuItem1_Click(object sender, EventArgs e) readsearchbook a = new readsearchbook(); a。Show(); this.Close(); private void 結(jié)束查詢ToolStripMenuItem_Click(object sender, EventArgs e) borrow a = new borrow(); a。Show(); this。Close(); private void 修改密碼ToolStripMenuItem_Click(object sender, EventArgs e) groupB

18、ox1.Visible = false; groupBox2.Visible = true; private void 掛失ToolStripMenuItem_Click(object sender, EventArgs e) groupBox1.Visible = true; groupBox2。Visible = false; private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) this。Close(); private void button2_Click(object sender, EventArgs

19、e) Application.Exit(); 管理員界面;using System;using System.Collections。Generic;using System。ComponentModel;using System。Data;using System.Drawing;using System。Text;using System.Windows.Forms;namespace book public partial class admin : Form public admin() InitializeComponent(); private void 退出ToolStripMe

20、nuItem_Click(object sender, EventArgs e) this。Close(); private void admin_Load(object sender, EventArgs e) toolStrip1。Text=string。Format (管理員:登錄,userhelper.adminid); private void toolStripButton4_Click(object sender, EventArgs e)/錄入學(xué)生信息 addreader addreader = new addreader(); addreader。Show(); this.C

21、lose(); private void 借書信息ToolStripMenuItem_Click(object sender, EventArgs e) adminborrow a = new adminborrow(); a.Show(); private void 還書信息ToolStripMenuItem_Click(object sender, EventArgs e) adminborrow a = new adminborrow(); a.Show(); private void 添加圖書ToolStripMenuItem_Click(object sender, EventArg

22、s e) addbook a = new addbook(); a。Show(); private void 刪除圖書ToolStripMenuItem_Click(object sender, EventArgs e) adminearchbook a = new adminearchbook(); a.Show(); private void 查詢圖書ToolStripMenuItem_Click(object sender, EventArgs e) adminearchbook a = new adminearchbook(); a。Show(); private void 查詢出版社

23、信息ToolStripMenuItem_Click(object sender, EventArgs e) publisher a = new publisher(); a。Show(); this。Close(); private void 修改出版社信息ToolStripMenuItem_Click(object sender, EventArgs e) publisher a = new publisher(); a.Show(); this。Close(); private void 查詢學(xué)生借閱信息ToolStripMenuItem_Click(object sender, Even

24、tArgs e) adminborrow a = new adminborrow(); a。Show(); private void toolStripButton6_Click_1(object sender, EventArgs e)/借書信息 booksborrow a = new booksborrow(); a。Show(); private void 添加ToolStripMenuItem_Click(object sender, EventArgs e) readerinfo a = new readerinfo(); a.Show(); private void 刪除ToolS

25、tripMenuItem_Click(object sender, EventArgs e) deletereader a = new deletereader(); a.Show(); 添加圖書信息界面:using System;using System。Collections。Generic;using System。ComponentModel;using System.Data;using System。Drawing;using System。Text;using System。Windows.Forms;using System。Data.SqlClient;namespace b

26、ook public partial class addbook : Form public addbook() InitializeComponent(); private void addbook_Load(object sender, EventArgs e) try string sql1 = ”select booktypename from booktype”; SqlCommand command = new SqlCommand(sql1, Dbhelper。connection); Dbhelper。connection。Open(); SqlDataReader datar

27、eader = command.ExecuteReader(); string typename = ”; while (datareader。Read() typename = (string)datareader0; comboBox2。Items。Add(typename); datareader.Close(); string sql2 = select publishername from publisher”; SqlCommand command1 = new SqlCommand(sql2, Dbhelper。connection); /Dbhelper。connection。

28、Open(); SqlDataReader datareader1 = command1。ExecuteReader(); string publishername = ; while (datareader1。Read() publishername = (string)datareader10; /MessageBox.Show(publishername); comboBox1.Items.Add(publishername); datareader1。Close(); catch MessageBox.Show(error”); finally Dbhelper.connection.

29、Close(); private void button2_Click(object sender, EventArgs e) textBox1.Text = null; textBox2.Text = null; textBox4.Text = null; comboBox2.Text = null; comboBox1。Text = null; private string typdid(string a) string id = ”; string sqltypeid = string.Format(”select booktypeid from booktype where bookt

30、ypename=0, a); try SqlCommand command=new SqlCommand (sqltypeid,Dbhelper.connection); Dbhelper.connection.Open(); id = Convert.ToString(command.ExecuteScalar()); catch MessageBox.Show(error ); finally Dbhelper.connection。Close(); return id; private string publisheid(string a) string id = ”; string s

31、qlpublisheid = string。Format(”select publisherid from publisher where publishername=0”, a); try SqlCommand command = new SqlCommand(sqlpublisheid, Dbhelper。connection); Dbhelper。connection。Open(); id = Convert.ToString(command。ExecuteScalar()); catch MessageBox。Show(error ); finally Dbhelper.connect

32、ion.Close(); return id; private void button1_Click(object sender, EventArgs e) string name =textBox1 。Text ; string writter=textBox2 。Text ; string publisher = comboBox1。Text; string type=comboBox2.Text; string price = textBox4.Text; /string id = textBox5。Text; string typeid = typdid(type); string p

33、ublisherid = publisheid(publisher); string bianhao = textBox3。Text; try if (bianhao!=”name != ” &writter != ” & publisher!= ” & type != price != ”) Dbhelper。connection。Open(); string sql = string.Format(insert into book (BOOKID,bookname,bookwritter,publisherid,booktypeid,bookprice) values (0,1,2,3,4

34、,5)”,bianhao, name,writter ,publisherid,typeid,price); SqlCommand commmand = new SqlCommand(sql,Dbhelper.connection ); int ab =commmand.ExecuteNonQuery(); if (ab != 0) MessageBox。Show(保存成功, 保存); else MessageBox。Show(”添加失敗”); return; else if (name = ” | writter = ” | publisher = ” | type= ” price= ”)

35、 MessageBox .Show(請輸入所有信息,”錯誤,MessageBoxButtons 。OK , MessageBoxIcon 。Error ); catch /(exception ex) MessageBox。Show(操作數(shù)據(jù)庫出錯”, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); finally Dbhelper.connection。Close(); private void button3_Click(object sender, EventArgs e) this。Close(); 添加讀者信息界面:usi

36、ng System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System。Windows.Forms;using System.Data.SqlClient;namespace book public partial class addreader : Form public addreader() InitializeComponent(); /退出窗口 private void but

37、ton3_Click(object sender, EventArgs e) /Application.Exit(); this。Close(); /清除所有內(nèi)容 private void button1_Click(object sender, EventArgs e) textBox1。Text = null; textBox2。Text = null; textBox4.Text = null; textBox3.Text = null; textBox5.Text = null; comboBox1。Text = null; comboBox2.Text = null; private

38、 void button2_Click(object sender, EventArgs e) /連接數(shù)據(jù)庫 /定義變量 string name =textBox1 。Text ; string age=textBox2 。Text ; string sex = comboBox1。Text; string studentId=textBox3。Text; string dept = textBox4.Text; string zhuanye= textBox5.Text; string maxnumber = comboBox2。Text; string pass = textBox6.Te

39、xt; try if (name != ” & age != & sex != ” & studentId != & dept != ” & zhuanye != ” & maxnumber!= &pass!=”) Dbhelper.connection.Open(); string sql = string.Format(”insert into reader (readerid,readerpass,readername,readersex,readerage,readerdept,readerzhuanye,maxnumber) values (0,1,2,3,4,5,6,7), stu

40、dentId, pass,name, sex, age, dept, zhuanye, maxnumber); SqlCommand commmand = new SqlCommand(sql,Dbhelper.connection ); int ab = commmand。ExecuteNonQuery(); if (ab != 0) MessageBox.Show(”保存成功”, ”保存); else MessageBox。Show(”添加失敗”); return; else if (name = ” | age = ” | sex = ” studentId = ” dept=” | zhuanye = ” maxnumber = ”) MessageBox 。Show(請輸入所有學(xué)生信息”,”錯誤”,MessageBoxButtons .OK , MessageBoxIcon .Error ); catch /(exception ex)

展開閱讀全文
溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!