圖書管理系統(tǒng)源碼(C#版)
《圖書管理系統(tǒng)源碼(C#版)》由會員分享,可在線閱讀,更多相關《圖書管理系統(tǒng)源碼(C#版)(34頁珍藏版)》請在裝配圖網上搜索。
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; //用來存儲密碼 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("請選擇登錄類型", "登錄提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Typename.Focus(); return false; } else if (loginid。Text.Trim() == "”) {
4、 MessageBox.Show(”請輸入用戶名", ”登錄提示”, MessageBoxButtons。OK, MessageBoxIcon。Information); loginid.Focus(); return false; } else if (password == ”") { MessageBox.Show("請輸入密碼", ”登錄提示", 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; //用戶賬號 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ù)據庫出錯!”); 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 對象 SqlCommand command = new SqlCommand(sql, Dbhelper.connection); // 打開數(shù)據庫連接
12、 Dbhelper。connection.Open(); // 驗證是否為合法用戶 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ù)據庫出錯!"); Console.WriteLine(ex.Message); //result = false; } finally { // 關閉數(shù)據庫連接 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(”輸入賬號與登陸賬號不相同,請重新輸入",”提示",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("學生:{0}”,userhelper.readerid); } private
23、 void button4_Click(object sender, EventArgs e) { string id =Convert。ToString (textBox2.Text); if (id!=userhelper.readerid) { MessageBox。Show("輸入賬號與登陸賬號不相同,請重新輸入”,"提示”,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 結束查詢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)//錄入學生信息
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 查詢學生借閱信息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("請輸入所有信息",”錯誤",MessageBoxButtons 。OK , MessageBoxIcon 。Error ); } } c
58、atch //(exception ex) { MessageBox。Show("操作數(shù)據庫出錯”, "提示", 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、 }//清除所有內容 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ù)據庫 //定義變量 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("請輸入所有學生信息”,”錯誤”,MessageBoxButtons .OK , MessageBoxIcon .Error ); } } catch //(exception ex)
- 溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
5. 裝配圖網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 110中國人民警察節(jié)(筑牢忠誠警魂感受別樣警彩)
- 2025正字當頭廉字入心爭當公安隊伍鐵軍
- XX國企干部警示教育片觀后感筑牢信仰之基堅守廉潔底線
- 2025做擔當時代大任的中國青年PPT青年思想教育微黨課
- 2025新年工作部署會圍繞六個干字提要求
- XX地區(qū)中小學期末考試經驗總結(認真復習輕松應考)
- 支部書記上黨課筑牢清廉信念為高質量發(fā)展營造風清氣正的環(huán)境
- 冬季消防安全知識培訓冬季用電防火安全
- 2025加強政治引領(政治引領是現(xiàn)代政黨的重要功能)
- 主播直播培訓直播技巧與方法
- 2025六廉六進持續(xù)涵養(yǎng)良好政治生態(tài)
- 員工職業(yè)生涯規(guī)劃方案制定個人職業(yè)生涯規(guī)劃
- 2024年XX地區(qū)黨建引領鄉(xiāng)村振興工作總結
- XX中小學期末考試經驗總結(認真復習輕松應考)
- 幼兒園期末家長會長長的路慢慢地走