C#MySQL圖書管理系統(tǒng)_第1頁
C#MySQL圖書管理系統(tǒng)_第2頁
C#MySQL圖書管理系統(tǒng)_第3頁
C#MySQL圖書管理系統(tǒng)_第4頁
C#MySQL圖書管理系統(tǒng)_第5頁
已閱讀5頁,還剩27頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

院專年2014學(xué)生姓名 號(hào) 師 開發(fā)環(huán)境:Windows10-開發(fā)工具:VisualStudio013數(shù)據(jù)庫工具管理員表圖書信息表借閱信息表用戶信息表adminInfo否管理員否否bookInfo否圖書編號(hào)否否否否是是是借閱人的是0borrowed否借閱信息是操作人是是圖書是0是是UserInfo否用戶否否是csmainCenter.cs:stringsql="server=localhost;userid=root;password=123456;database=C#librarycenter";MySqlConnectionconnnewMySqlConnection(sql);MySqlDataAdapterdata1=MySqlCommandcmd1=newMySqlCommand("SELECTbookName'圖書名',bookAuthoras'作者',bookPriceas'圖書價(jià)格',bookPress'出版社',bookTypeas',(CASEisBorrowedWHEN0THENELSE'已借閱'END)as'借閱情況'FROM`c#librarycenter`.bookinfo",data1.SelectCommandcmd1;//設(shè)置為已實(shí)例化SqlDataAdapter的查詢命令DataTabledt=newDataTable();data1.Fill(dt);//把數(shù)據(jù)填充到dataGridView1.DataSourcedt;//將數(shù)據(jù)集綁定datagridview,完成顯示dataGridView1.AllowUserToAddRows=false;loginlogin=label1.Text="這里是SMART-LIBRARY!用戶:"+}privatevoidbutton1_Click(objectsender,EventArgse){Stringso=textBox1.Text;Stringsql="server=localhost;userid=root;password=123456;database=C#librarycenter";MySqlConnectionconnnewMySqlConnection(sql);MySqlDataAdapterdata1=MySqlCommandcmd1=newMySqlCommand("SELECTbookName'圖書名',bookAuthoras'作者',bookPriceas'圖書價(jià)格',bookPress'出版社',bookTypeas',(CASEisBorrowedWHEN0THENELSEEND)as'FROM`c#librarycenter`.bookinfowherebookNamelike'%"+so+"%'",conn);//sql語句data1.SelectCommand=cmd1;//設(shè)置為已實(shí)例化SqlDataAdapter//DataSetds1newDataSet();//實(shí)例化datasetDataTabledt=newDataTable();data1.Fill(dt);//把數(shù)據(jù)填充到dataGridView1.DataSourcedt;//將數(shù)據(jù)集綁定datagridview,完成顯示dataGridView1.AllowUserToAddRows=false;}主要實(shí)現(xiàn)代碼-privatevoiddataGridView1_CellContentClick(objectsender,DataGridViewCellEventArgse){intr=stringh=this.dataGridView1.Rows[r].Cells[1].Value.ToString();strings=loginlogin=newlogin();StringuserId="";DateTimedt=DateTime.Now;StringborrowedTime=dt.ToString("yyyy-MM-stringsql="server=localhost;userid=root;password=123456;database=C#librarycenter";MySqlConnectionconn=StringupdateBorrow1="selectuserIdfromuserInfowhere=MySqlCommandmysqlcommand=newMySqlCommand(updateBorrow1,conn);MySqlDataReadermdr=mysqlcommand.ExecuteReader();if(mdr.Read()){userId=}StringupdateBorrow2="updatebookInfosetisBorrowed='1',borrowId='"+userId+"',borrowedTime='"+borrowedTime+"'wherebookId='"+h+"'";MySqlCommandmysqlcommand2=newMySqlCommand(updateBorrow2,conn);inti=mysqlcommand2.ExecuteNonQuery();if(i!=-{MessageBox.Show(login.username+"\r\n恭喜你借"+"<<"+s>>\r\n}{MessageBox.Show("}StringupdateBorrow3="insertintoborrowed(userId,userName,bookId,editTime,bookName,edit)values('"+userIdlogin.usernamehborrowedTime"','"+s+"','借書')";MySqlCommandmysqlcommand3=newMySqlCommand(updateBorrow3,conn);}主要實(shí)現(xiàn)代碼–privatevoiddataGridView1_CellContentClick(objectsender,DataGridViewCellEventArgse){intr=stringh=this.dataGridView1.Rows[r].Cells[1].Value.ToString();strings=this.dataGridView1.Rows[r].Cells[2].Value.ToString();DateTimedt=DateTime.Now;StringreturnedTime=dt.ToString("yyyy-MM-StringuserId=stringsql="server=localhost;userid=root;password=123456;database=C#librarycenter";MySqlConnectionconn=newMySqlConnection(sql);StringupdateBorrow1="updatebookInfosetisBorrowed='0',borrowId=null,borrowedTime=nullwherebookId='"+h+"'";MySqlCommandmysqlcommand2=newMySqlCommand(updateBorrow1,conn);inti=mysqlcommand2.ExecuteNonQuery();if(i!=-{MessageBox.Show(login.username+"\r\n<<"+s+"\r\n}{MessageBox.Show("}StringupdateBorrow="selectuserIdfromuserInfowhereuserName='"+login.username+"'";MySqlCommandmysqlcommand=newMySqlCommand(updateBorrow,conn);MySqlDataReadermdr=mysqlcommand.ExecuteReader();if{userId=}StringupdateBorrow2="insertintoborrowed(userId,userName,bookId,editTime,bookName,edit)values('"+userIdlogin.usernamehreturnedTime"','"+s+"','還書')";MySqlCommandmysqlcommand3=newMySqlCommand(updateBorrow2,conn);}主要實(shí)現(xiàn)代碼–privatevoidbutton1_Click(objectsender,EventArgs{loginlogin=newlogin();Stringpw=textBox1.Text;Stringnpw=Stringun=login.username;StringuserPassword="";StringuserId="";if(male.Checked==true)ans="male";if(female.Checked==true)ans="female";Stringsql="server=localhost;userid=root;password=123456;database=C#librarycenter";MySqlConnectionconn=newMySqlConnection(sql);Stringyanzheng="SELECTuserPasswordFROMuserinfowhere=MySqlCommandyz=newMySqlCommand(yanzheng,conn);MySqlDataReadermdr2=yz.ExecuteReader();if{userPassword=}if(textBox2.Text.Trim()!={if(pw=={Stringeditsql1="selectuserIdfromuserInfowhereuserName=+login.username+"'MySqlCommandcmd1=newMySqlCommand(editsql1,conn);MySqlDataReadermdr=cmd1.ExecuteReader();if(mdr.Read()){userId=mdr.GetString(0);}else{}Stringeditsql2="updateuserInfosetuserPassword='"+npw+"',userSex='"+ans+"'whereuserId='"+userId+"'";MySqlCommandcmd2=newMySqlCommand(editsql2,conn);inti=cmd2.ExecuteNonQuery();if(i=={MessageBox.Show(login.username"\r\n您的信息修改成功!\r\n}{MessageBox.Show("修改失敗,請(qǐng)聯(lián)系管理員}}{MessageBox.Show("}}{MessageBox.Show("}}borrowedinfo.cs:label1.Text=login.usernameStringsql="server=localhost;userid=root;password=123456;database=C#librarycenter";MySqlConnectionconnnewMySqlConnection(sql);StringuserId=MySqlCommandcmd=newMySqlCommand("selectuserIdfromborrowedwhereuserName='"+login.username+"'",conn);MySqlDataReadermdr=cmd.ExecuteReader();if(mdr.Read()){userId=mdr.GetString(0);}MySqlDataAdapterdata1=MySqlCommandcmd1=newMySqlCommand("selectbookId'圖書編號(hào)',bookNameas',editTimeas',editasfromborrowedwhereuserId='"+userId+"'",conn);//sql語句data1.SelectCommand=cmd1;//設(shè)置為已實(shí)例化SqlDataAdapter//DataSetds1newDataSet();//實(shí)例化datasetDataTabledt=newDataTable();data1.Fill(dt);//把數(shù)據(jù)填充到dataGridView1.DataSourcedt;//將數(shù)據(jù)集綁定datagridview,完成顯示dataGridView1.AllowUserToAddRows=false;}主要實(shí)現(xiàn)代碼–privatevoid關(guān)于ToolStripMenuItem_Click(objectsender,EventArgs{MessageBox.Show("制作者:MatthewHan\r\n完成時(shí)間:2017-6-}privatevoid退出系統(tǒng)ToolStripMenuItem_Click(objectsender,{}privatevoid圖書管理ToolStripMenuItem_Click(objectsender,{editMaineditMain=neweditMain();editMain.FormBorderStyle=FormBorderStyle.None;editMain.Dock=DockStyle.Fill;editMain.TopLevel=false;}privatevoid添加圖書ToolStripMenuItem_Click(objectsender,{edit2edit2=newedit2();}privatevoid用戶管理ToolStripMenuItem_Click(objectsender,{edit3edit3=newedit3();edit3.FormBorderStyle=FormBorderStyle.None;edit3.Dock=DockStyle.Fill;edit3.TopLevel=false;}editMain.cs&edit1.cs:privatevoiddataGridView1_CellContentClick(objectsender,DataGridViewCellEventArgse){intr=stringbn=this.dataGridView1.Rows[r].Cells[1].Value.ToString();stringba=this.dataGridView1.Rows[r].Cells[2].Value.ToString();stringbp1=this.dataGridView1.Rows[r].Cells[3].Value.ToString();stringbp2=this.dataGridView1.Rows[r].Cells[4].Value.ToString();stringbt=this.dataGridView1.Rows[r].Cells[5].Value.ToString();editMaineditMain=neweditMain();editMain.bookname=editMain.bookauthor=ba.ToString();editMain.bookprice=bp1.ToString();editMain.bookpress=bp2.ToString();editMain.booktype=bt.ToString();edit1edit1=newedit1();}publicedit1(){editMaineditMain=neweditMain();label6.Text=editMain.bookname;textBox1.Text=editMain.bookauthor;textBox2.Text=editMain.bookprice;textBox3.Text=editMain.bookpress;textBox4.Text=editMain.booktype;}privatevoidbutton1_Click(objectsender,EventArgs{Stringbn=editMain.bookname;Stringba=textBox1.Text;Stringbp1=textBox2.Text;Stringbp2=textBox3.Text;Stringbt=textBox4.Text;Stringsql="server=localhost;userid=root;password=123456;database=C#librarycenter";MySqlConnectionconn=newMySqlConnection(sql);Stringsql2="updatebookInfosetbookAuthor='"+ba+"',bookPrice='"+bp1+"',bookPress='"+bp2+"',bookType='"+bt+"'wherebookName='"+bn+"'MySqlCommandcmd=newMySqlCommand(sql2,inti=cmd.ExecuteNonQuery();if(i==1)MessageBox.Show("}主要實(shí)現(xiàn)代碼–privatevoidbutton1_Click(objectsender,EventArgse){Stringbn=textBox5.Text;Stringba=textBox1.Text;Stringbp1=textBox2.Text;Stringbp2=Stringbt=Stringsql="server=localhost;userid=root;

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論