圖書管理系統(tǒng)源碼(C#版)
《圖書管理系統(tǒng)源碼(C#版)》由會(huì)員分享,可在線閱讀,更多相關(guān)《圖書管理系統(tǒng)源碼(C#版)(34頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(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 pass
2、word; //用來存儲(chǔ)密碼 public login() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { Application。Exit(); } private bool yanzhengshuru() { password = textBox3。Text; i
3、f (Typename.Text.Trim() == ””) { MessageBox.Show("請(qǐng)選擇登錄類型", "登錄提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Typename.Focus(); return false; } else if (loginid。Text.Trim() == "”) {
4、 MessageBox.Show(”請(qǐng)輸入用戶名", ”登錄提示”, MessageBoxButtons。OK, MessageBoxIcon。Information); loginid.Focus(); return false; } else if (password == ”") { MessageBox.Show("請(qǐng)輸入密碼", ”登錄提示", MessageBoxButtons.OK, MessageBo
5、xIcon。Information); textBox3。Focus(); return false; } else { return true; } } private void button1_Click(object sender, EventArgs e) { userhelper.adminid= loginid.T
6、ext; //用戶賬號(hào) 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, p
7、assword); try { SqlCommand command = new SqlCommand(sql, Dbhelper.connection); Dbhelper.connection。Open(); int count = (int)command.ExecuteScalar(); if (count 〈 1)
8、 { MessageBox.Show("用戶或密碼不存在!”); //result = false; } else { admin admin = new admin(); admin.S
9、how(); } } catch (Exception ex) { MessageBox。Show("操作數(shù)據(jù)庫(kù)出錯(cuò)!”); Console。WriteLine(ex.Message); } finally
10、 { Dbhelper。connection.Close(); } } if (Typename.Text。Trim() == "借閱者") { userhelper。readerid =Convert .ToString (loginid。Text); string sql = string。Format(”Select count(
11、*) from reader where readerId=’{0}’ and readerpass='{1}’", userhelper.readerid,textBox3。Text); try { // 創(chuàng)建 Command 對(duì)象 SqlCommand command = new SqlCommand(sql, Dbhelper.connection); // 打開數(shù)據(jù)庫(kù)連接
12、 Dbhelper。connection.Open(); // 驗(yàn)證是否為合法用戶 int count = (int)command.ExecuteScalar(); if (count 〈 1) { MessageBox.Show(”用戶或密碼不存在!"); //result = fa
13、lse; } else { reader reader = new reader(); reader.Show(); } } catch (Exception ex)
14、 { MessageBox。Show(”操作數(shù)據(jù)庫(kù)出錯(cuò)!"); Console.WriteLine(ex.Message); //result = false; } finally { // 關(guān)閉數(shù)據(jù)庫(kù)連接 Dbhe
15、lper.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; us
16、ing System.Text; using System.Windows。Forms; using System.Data。Sql; using System.Data。SqlClient; namespace book { public partial class reader : Form { public reader() { InitializeComponent(); } private void button3_Click(object sender, EventA
17、rgs e) { string id =Convert.ToString (textBox1。Text); if (id!=userhelper。readerid) { MessageBox.Show(”輸入賬號(hào)與登陸賬號(hào)不相同,請(qǐng)重新輸入",”提示",MessageBoxButtons。OK,MessageBoxIcon。Warning); textBox1.Text = ””; textBox
18、1。Focus(); } else try { string sql = string.Format("update reader set islost=’{0}’where readerid=’{1}'”, '是',id); Dbhelper。connection。Open(); SqlCommand command = new SqlComman
19、d(sql,Dbhelper.connection); int result = command。ExecuteNonQuery(); if (result 〈 1) { MessageBox.Show(”修改失敗”); } else MessageBox.Show("掛失成功”); }
20、 catch { MessageBox。Show("error”); } finally { Dbhelper.connection.Close(); } } private void toolStripButton3_Click(object sender, EventArgs e)
21、 { groupBox1.Visible = false; groupBox2.Visible = true; } private void toolStripButton4_Click(object sender, EventArgs e) { groupBox1.Visible = true; groupBox2。Visible = false; } private void button5_Click(object sen
22、der, EventArgs e) { textBox2.Text = ””; textBox4。Text = "”; textBox5。Text = ""; } private void Form1_Load(object sender, EventArgs e) { toolStrip1.Text = string.Format("學(xué)生:{0}”,userhelper.readerid); } private
23、 void button4_Click(object sender, EventArgs e) { string id =Convert。ToString (textBox2.Text); if (id!=userhelper.readerid) { MessageBox。Show("輸入賬號(hào)與登陸賬號(hào)不相同,請(qǐng)重新輸入”,"提示”,MessageBoxButtons.OK,MessageBoxIcon。Warning); text
24、Box1。Text = ""; textBox1。Focus(); } else if (textBox4.Text!=textBox5.Text) { MessageBox.Show (”兩次密碼輸入不同"); } else try { string sql = string。Format("update reader set readerp
25、ass='{0}’ where readerid=’{1}’", textBox4.Text,id); Dbhelper。connection。Open(); SqlCommand command = new SqlCommand(sql,Dbhelper。connection); int result = command.ExecuteNonQuery(); if (result 〈 1)
26、 { MessageBox.Show("修改失敗”); } else MessageBox。Show(”修改成功”); } catch { MessageBox.Show("error”); } finally {
27、 Dbhelper.connection。Close(); } } private void toolStripButton6_Click(object sender, EventArgs e) { addreader addreader = new addreader(); addreader = new addreader(); } private void toolStripButton1_Cl
28、ick(object sender, EventArgs e) { readsearchbook searchbook = new readsearchbook(); searchbook。Show(); } private void toolStripButton2_Click(object sender, EventArgs e) { borrow a = new borrow(); a.Show(); }
29、 private void toolStripButton5_Click(object sender, EventArgs e) { readerseacherinfo a = new readerseacherinfo(); a.Show(); } private void 圖書查詢ToolStripMenuItem1_Click(object sender, EventArgs e) { readsearchbook a = new readsear
30、chbook(); 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
31、 sender, EventArgs e) { groupBox1.Visible = false; groupBox2.Visible = true; } private void 掛失ToolStripMenuItem_Click(object sender, EventArgs e) { groupBox1.Visible = true; groupBox2。Visible = false; } priva
32、te void 退出ToolStripMenuItem_Click(object sender, EventArgs e) { this。Close(); } private void button2_Click(object sender, EventArgs e) { Application.Exit(); } } } 管理員界面; using System; using System.Collections。Generic; using Sys
33、tem。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 退出ToolStripMenuItem
34、_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é)生信息
35、 { addreader addreader = new addreader(); addreader。Show(); this.Close(); } private void 借書信息ToolStripMenuItem_Click(object sender, EventArgs e) { adminborrow a = new adminborrow(); a.Show(); }
36、 private void 還書信息ToolStripMenuItem_Click(object sender, EventArgs e) { adminborrow a = new adminborrow(); a.Show(); } private void 添加圖書ToolStripMenuItem_Click(object sender, EventArgs e) { addbook a = new addbook();
37、 a。Show(); } private void 刪除圖書ToolStripMenuItem_Click(object sender, EventArgs e) { adminearchbook a = new adminearchbook(); a.Show(); } private void 查詢圖書ToolStripMenuItem_Click(object sender, EventArgs e) { admin
38、earchbook a = new adminearchbook(); a。Show(); } private void 查詢出版社信息ToolStripMenuItem_Click(object sender, EventArgs e) { publisher a = new publisher(); a。Show(); this。Close(); } private void 修改出版社信息Tool
39、StripMenuItem_Click(object sender, EventArgs e) { publisher a = new publisher(); a.Show(); this。Close(); } private void 查詢學(xué)生借閱信息ToolStripMenuItem_Click(object sender, EventArgs e) { adminborrow a = new adminborrow();
40、 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) { reader
41、info a = new readerinfo(); a.Show(); } private void 刪除ToolStripMenuItem_Click(object sender, EventArgs e) { deletereader a = new deletereader(); a.Show(); }}} 添加圖書信息界面: using System; using System。Collections。Generic; using Sys
42、tem。ComponentModel; using System.Data; using System。Drawing; using System。Text; using System。Windows.Forms; using System。Data.SqlClient; namespace book { public partial class addbook : Form { public addbook() { InitializeComponent(); } priv
43、ate void addbook_Load(object sender, EventArgs e) { try { string sql1 = ”select booktypename from booktype”; SqlCommand command = new SqlCommand(sql1, Dbhelper。connection); Dbhelper。connection。Open();
44、 SqlDataReader datareader = command.ExecuteReader(); string typename = ”"; while (datareader。Read()) { typename = (string)datareader[0]; comboBox2。Items。Add(typename); }
45、datareader.Close(); string sql2 = "select publishername from publisher”; SqlCommand command1 = new SqlCommand(sql2, Dbhelper。connection); //Dbhelper。connection。Open(); SqlDataReader datareader1 = command1。ExecuteReader(); string
46、 publishername = ""; while (datareader1。Read()) { publishername = (string)datareader1[0]; //MessageBox.Show(publishername); comboBox1.Items.Add(publishername); } datarea
47、der1。Close(); } catch { MessageBox.Show("error”); } finally { Dbhelper.connection.Close(); } } private void button2_Click(object sender, EventArgs e) {
48、 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.Forma
49、t(”select booktypeid from booktype where booktypename=’{0}'", a); try { SqlCommand command=new SqlCommand (sqltypeid,Dbhelper.connection); Dbhelper.connection.Open(); id = Convert.ToString(command.ExecuteScalar()); } catch
50、 { MessageBox.Show("error "); } finally { Dbhelper.connection。Close(); } return id; } private string publisheid(string a) { string id = ”"; string
51、sqlpublisheid = string。Format(”select publisherid from publisher where publishername='{0}’”, a); try { SqlCommand command = new SqlCommand(sqlpublisheid, Dbhelper。connection); Dbhelper。connection。Open(); id = Convert.ToStri
52、ng(command。ExecuteScalar()); } catch { MessageBox。Show("error "); } finally { Dbhelper.connection.Close(); }return id; } private void button1_Click(object sender
53、, 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;
54、 string typeid = typdid(type); string publisherid = publisheid(publisher); string bianhao = textBox3。Text; try { if (bianhao!=”"&&name != ”" &&writter != "” && publisher!= ”" && type != "" && price != "”) {
55、 Dbhelper。connection。Open(); string sql = string.Format("insert into book (BOOKID,bookname,bookwritter,publisherid,booktypeid,bookprice) values ('{0}',’{1}’,’{2}',’{3}','{4}’,{5})”,bianhao, name,writter ,publisherid,typeid,price); SqlCommand commmand = new SqlCom
56、mand(sql,Dbhelper.connection ); int ab =commmand.ExecuteNonQuery(); if (ab != 0) { MessageBox。Show("保存成功", "保存"); } else { MessageBox。Show(”添加失敗”);
57、 return; } } else if (name == ”” || writter == ”" || publisher == ”” || type== ”" || price== ””) { MessageBox .Show("請(qǐng)輸入所有信息",”錯(cuò)誤",MessageBoxButtons 。OK , MessageBoxIcon 。Error ); } } c
58、atch //(exception ex) { MessageBox。Show("操作數(shù)據(jù)庫(kù)出錯(cuò)”, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { Dbhelper.connection。Close(); } } private void button3_Click(object
59、sender, EventArgs e) { this。Close(); } } } 添加讀者信息界面: 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;
60、 namespace book { public partial class addreader : Form { public addreader() { InitializeComponent(); }//退出窗口 private void button3_Click(object sender, EventArgs e) { //Application.Exit(); this。Close();
61、 }//清除所有內(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 =
62、null; comboBox2.Text = null; } private void button2_Click(object sender, EventArgs e) { //連接數(shù)據(jù)庫(kù) //定義變量 string name =textBox1 。Text ; string age=textBox2 。Text ; string sex = comboBox1。Text; string studentId=textB
63、ox3。Text; string dept = textBox4.Text; string zhuanye= textBox5.Text; string maxnumber = comboBox2。Text; string pass = textBox6.Text; try { if (name != ”" && age != "" && sex != ”” && studentId != "" && de
64、pt != ”" && 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}’,'
65、{3}’,{4},'{5}’,'{6}',{7})", studentId, pass,name, sex, age, dept, zhuanye, maxnumber); SqlCommand commmand = new SqlCommand(sql,Dbhelper.connection ); int ab = commmand。ExecuteNonQuery(); if (ab != 0) { MessageBox.S
66、how(”保存成功”, ”保存"); } else { MessageBox。Show(”添加失敗”); return; } } else if (name == ”” || age == ”” || sex == ”" || studentId == "” || dept=="” || zhuanye == "” || maxnumber == ”") { MessageBox 。Show("請(qǐng)輸入所有學(xué)生信息”,”錯(cuò)誤”,MessageBoxButtons .OK , MessageBoxIcon .Error ); } } catch //(exception ex)
- 溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 市教育局冬季運(yùn)動(dòng)會(huì)安全工作預(yù)案
- 2024年秋季《思想道德與法治》大作業(yè)及答案3套試卷
- 2024年教師年度考核表個(gè)人工作總結(jié)(可編輯)
- 2024年xx村兩委涉案資金退還保證書
- 2024年憲法宣傳周活動(dòng)總結(jié)+在機(jī)關(guān)“弘揚(yáng)憲法精神推動(dòng)發(fā)改工作高質(zhì)量發(fā)展”專題宣講報(bào)告會(huì)上的講話
- 2024年XX村合作社年報(bào)總結(jié)
- 2024-2025年秋季第一學(xué)期初中歷史上冊(cè)教研組工作總結(jié)
- 2024年小學(xué)高級(jí)教師年終工作總結(jié)匯報(bào)
- 2024-2025年秋季第一學(xué)期初中物理上冊(cè)教研組工作總結(jié)
- 2024年xx鎮(zhèn)交通年度總結(jié)
- 2024-2025年秋季第一學(xué)期小學(xué)語文教師工作總結(jié)
- 2024年XX村陳規(guī)陋習(xí)整治報(bào)告
- 2025年學(xué)校元旦迎新盛典活動(dòng)策劃方案
- 2024年學(xué)校周邊安全隱患自查報(bào)告
- 2024年XX鎮(zhèn)農(nóng)村規(guī)劃管控述職報(bào)告