RFID圖書管理系統(tǒng)程序源代碼_第1頁
RFID圖書管理系統(tǒng)程序源代碼_第2頁
RFID圖書管理系統(tǒng)程序源代碼_第3頁
RFID圖書管理系統(tǒng)程序源代碼_第4頁
RFID圖書管理系統(tǒng)程序源代碼_第5頁
已閱讀5頁,還剩46頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、登陸界面 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; n amespaceLabrary public partial class FormLog in : Form public FormLogin() In itializeComp onen t(); / / 驗丨證?戲空?件t / / private bo

2、ol ValidControl() if ( this .tbID.Text =) MessageBoxShow(請?zhí)顚懹脩裘?!e ?; this .tblD.Focus(); return false ; if ( this .tbID.Text != admin) if (!UserManage. ObjUser .lsHaslD( All .dbo, this .tbID.Text) MessageBoxShow(“不存在此用戶!e ?; this .tbID.Text =; this .tbID.Focus(); return false ; if ( this .tbID.Text

3、!= admin) UserManage.ObjUser user= newUserManage.ObjUser(this .tbID.Text, All .dbo); if (user.PWD != this .tbPWD.Text) MessageBoxShow(密碼錯誤!e ?; this .tbPWD.Text =; this .tbPWD.Focus(); return false ; else if ( this .tbPWD.Text !=123456) MessageBoxShow(密碼錯誤!); this .tbPWD.Text =; this .tbPWD.Focus();

4、 return false ; return true ; private void gbtnCancel_Click( object sender,EventArgs e) this .Close(); private void gbtnOK_Click( object sender,EventArgs e) /如?果?驗丨證?進(jìn)空?件t通a?過y if (ValidControl() if ( this .tbID.Text != admin) All .userLogin =new UserManage. ObjUser( this .tbID.Text, All .dbo); else

5、 All .userLogin =new UserManage. ObjUser( All .dbo); All .userLogin.ID = admin; All .userLogin.Name =管理員 this .DialogResult = DialogResult .OK; this .Close(); 主界面 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;

6、using System.Windows.Forms; n amespaceLabrary public partial class FormMa in : Form public const int WM_USER = 0 x0400; public const int WM_GETBUFFER_LOOP = WM_USER + 2; private RFID_ _dll. Reader rdr; private RFID_ _dll. RFIDrfid; List rfids = new List (); int directionFlag = 0;1 進(jìn);岀? Form InAn dOu

7、t fiao =new FormInA ndOut(); public FormMain() In itializeComp onen t(); this .rdr =newRFID_dll. Reader(); /this.rfid = new RFID_dll.RFID(rdr); private void FormMain_Load( object sender,EventArgs e) In it(); III III初始化 III private void Init() fiao.StartPositi on =FormStartPositi on.Ma nual; II多窗體在不同

8、時間顯示 Scree n scree ns =Scree n.AllScree ns; if (screens.Length = 2) List listScreen = new List (); foreach ( Screen screen in Screen.AllScreens) if (screen.Primary = false ) listScree n.Add(scree n); fiao.Locati on = listScree n0.Worki ngArea. Locatio n; PicIn); SetMe nJin( fiao.Show(); toolStripSta

9、tusLabel2 toolStripStatusLabel2.Text = 顯示登陸用戶名? All .userLog in .Name; this .panell.Backgroundlmage =null ; II菜單欄全部顯示o? this .用?戶? 1管1 理 O aToolStripMenultem.Visible = this .系| i統(tǒng)a3初?始o(jì)?化?Y CToolStripMenultem.Visible = true ; true ; this .應(yīng)?| 用?模?試o?ToolStripMenultem.Visible =true this .圖a?書o| 管 T 理

10、O aToolStripMenultem.Visible = this .退a?辦?卡? ToolStripMenultem.Visible = true this .借閱?ToolStripMenultem.Visible = true ; this .門?禁?ToolStripMenultem.Visible = true ; true ; SetPurview(); this.toolStripl.Visible =false; this.toolStrip2.Visible =false; this.toolStrip3.Visible =false; /rfid.Ope nSeria

11、l(); /是o?否o?找八 到i?禁?設(shè)| 備a? /if (rfid.Cha ngeWorkModel(2) / / rfid.Start In ve ntory(this.Ha ndle.Tol nt32(),2); / / /權(quán)限設(shè)置 / private void SetPurview() if ( All .userLogin.ID =admin) this .應(yīng)?| 用??模? e式o?ToolStripMenultem.Visible =false ; else this .用戶管理aToolStripMenultem.Visible = false ; this .系統(tǒng)初始化?

12、Y CToolStripMenultem.Visible = false ; this .讀書管理aToolStripMenultem.Visible = false ; this .退辦卡? ToolStripMenultem.Visible = false ; this .借閱 ToolStripMenultem.Visible = false ; this .門禁?ToolStripMenultem.Visible = false ; for ( int i = 0; i All .userLogin.Purview.Count; i+) string purview = All .us

13、erLogin.Purviewi; if (purview =1) this .圖書管理aToolStripMenultem.Visible = true ; else if (purview =2) this .辦退卡? ToolStripMenul tem.Visible = true ; else if (purview =3) this .借閱?ToolStripMenultem.Visible = true ; else if (purview =4) this .門禁 ToolStripMenultem.Visible = true ; private void 用戶管理 aToo

14、lStripMenultem_Click( object sender, EventArgs e) UserManage.FormUserList ful =new UserManage. FormUserList (All .conn); ful.ShowDialog(); private void 修改密碼?ToolStripMenultem_Click(object sender, EventArgs e) UserManage.FormUserPwdfup = newUserManage. FormUserPwQ All .conn. All .userLogin); fup.Show

15、Dialog(); private void tsbtnBookType_Click( object sender, EventArgs e) FormBookTypeList fbtl = new FormBookTypeList (); fbtl.ShowDialog(); private void tsbtnBookAdd_Click( object sender,EventArgs e) FormBookAddfba = new FormBookAdd); fba.ShowDialog(); private void tsbtnBookManage_Click( object send

16、er, EventArgs e) FormBook In foList fbil = new FormBookI nfoList (); fbil.ShowDialog(); object sender, EventArgs e) private void tsbtnBookStatistics_Click( FormBookStatistics fbs = new FormBookStatistics (); fbs.ShowDialog(); private void 退a?岀?XToolStripMenultem_Click(object sender, EventArgs e) thi

17、s .Close(); private void tsbtnCardAdd_Click(object sender, EventArgs e) FormCardInfo fci = new FormCardInfo (1, new ObjCardInfo (); fci.ShowDialog(); private void tsbtnCardManage_Click(object sender,EventArgs e) FormCardList fcl = new FormCardList (); fcl.ShowDialog(); private void tsbtnAddTime_Clic

18、k(object sender, EventArgs e) string rfid = RfidOperate .GetCard(); if (rfid =) MessageBoxShow(”請把借閱卡放到桌面讀寫器上!); else if ( ObjCardInfo .IsHas(rfid) ObjCardInfo oci =new ObjCardInfo (rfid); FormCardInfo fci = new FormCardInfo (5, oci); fci.ShowDialog(); else MessageBoxShow(沒有此借閱卡信息”); private void ts

19、btnCardDelete_Click( object sender.EventArgs e) string rfid = RfidOperate .GetCard(); if (rfid =) MessageBoxShow(請把借閱卡到讀寫器上?); else if ( ObjCardInfo .1 sHas(rfid) ObjCardInfo oci = new ObjCardInfo (rfid); int count = oci.NotReturnCount(); if (cou nt = 0) if ( MessageBoxShow(“ 是否決定退卡!e ?, MessageBoxB

20、uttons.YesNo) = DialogResult .Yes) oci.Delete(); MessageBoxShow(退卡成功 | ! e ?; else MessageBoxShow(oci.Name + 還有一本+ count.ToString() + 書未歸還不能退卡?); else MessageBoxShow(沒有此借閱信息?); private void tsbtnJie_Click(object sender,EventArgs e) FormBookJie fbj = new FormBookJie(1); fbj.ShowDialog(); private void

21、 tsbtnHuan_Click( object sender,EventArgs e) FormBookHuanfbh = new FormBookHuar(); fbh.ShowDialog(); private EventArgs e) void 圖a?書o| 管 T理O aToolStripMenultem_Click( object sender, 1 this .toolStrip1.Visible =true ; this .toolStrip2.Visible =false ; this .toolStrip3.Visible =false ; this .pa nel1.Ba

22、ckgrou ndlmage =Image.From + WpicW1.jpg ); private void 退a?辦?卡? ToolStripMenultem_Click(object sen der, EventArgs e) I this .toolStrip1.Visible =false ; this .toolStrip2.Visible =true ; this .toolStrip3.Visible =false ; this .pa nel1.Backgrou ndlmage =Image.From + WpicW2.jpg ); private void 借閱?ToolS

23、tripMenultem_Click( object sender, EventArgs e) this .toolStrip1.Visible =false ; this .toolStrip2.Visible =false ; this .toolStrip3.Visible =true ; this .pa nel1.Backgrou ndlmage =Image.From + WpicW3.jpg ); private void 門?禁?ToolStripMenultem_Click(object sender,EventArgs e) /MenJinlni t(); this.too

24、lStrip1.Visible = false; this.toolStrip2.Visible = false; this.toolStrip3.Visible = false; /this.pa nel1.Backgrou ndlmage = n ull; /rfid.Ope nSerial(); /是否找到門禁設(shè)備? /if (rfid.IsOpe n) / / rfid.Start In ve ntory(this.Ha ndle.Tol nt32(); private void 注肖 2ToolStripMenultem_Click(object sender,EventArgs e

25、) All .userLogin =null ; FormLogin fl = new FormLogin(); if (fl.ShowDialog() != DialogResult .OK) this .Close(); else In it(); private void 幫助2ToolStripMenultem1_Click( object sender,EventArgs e) private void 系統(tǒng)初始化?Y CToolStripMenultem_Click( object sender, EventArgs e) if ( MessageBoxShow(是否初始化數(shù)據(jù)庫?

26、,” MessageBoxButto ns.YesNo)= DialogResult .Yes) All .dbo.excuteSql( All .dbo.excuteSql( All .dbo.excuteSql( All .dbo.excuteSql( delete from len dtable ); delete from book info); delete from booktype); delete from librarycard ); All .dbo.excuteSql( delete from usertable ); MessageBoxShow(初始化完成?); pr

27、ivate void 關(guān)于 ToolStripMenultem_Click( object sender, EventArgs e) FormAbout fa = new FormAbout(); fa.ShowDialog(); protected override void DefWndProc( ref System.Windows.Forms. Messagem) if (m.Msg = WM_GETBUFFER_LOOP) /啟動 if ( this .timer1.Tag.ToString() =0) this .timer1.Start(); this .timer1.Tag =

28、1; string uid =; stri ng directi on =; bool personWithMultCard =false ; ref rdr.GetLoopGetBufferData(m,ref uid, ref directi on, perso nWithMultCard); if (uid != 00000) / 進(jìn) if (direction =1 n) this .directionFlag = 1; this .rfids.Add(uid); /出 if (direction =Out) this .directionFlag = 2; this .rfids.A

29、dd(uid); if (uid = FFFFFFFFFFFFFFFF) base.DefWndProc( ref m); private void timer1_Tick( object sender.EventArgs e) if ( this .directionFlag = 1) for ( int i = 0; i this .rfids.Count; i+) if ( ObjCardInfo .1 sHas( this .rfidsi) ObjCardInfo oci =new ObjCardInfo (this .rfidsi); if (oci.IsOverTime() Set

30、MenJin(PicInOutTime); MenJinln it(); return ; else SetMenJin(PicIn); MenJinln it(); return ; SetMenJin(PiclnNoCard); MenJinln it(); else if ( this .directionFlag = 2) for (int i = 0; i this .rfids.Count; i+) if ( ObjBookInfo .IsHas( this .rfidsi) ObjBookInfo obi = new ObjBookInfo (this .rfidsi); if

31、(obi.LendStatus =為借岀?) this .rdr.WarningOutput(false , false , true , false , false ); SetMenJin(PicOut); MenJinln it(); return MenJinln it(); III III門禁初始化 III private void MenJinlnit() this .rfids.Clear(); this .directionFlag = 0; this .timer1.Tag =0; this .timer1.Stop(); private void SetMenJin( st

32、ring message) this .fiao.Controls.Clear(); UserControlMenJin ucmj = new UserControlMenJin (message); ucmj.Dock =DockStyle .Fill; this .fiao.Controls.Add(ucmj); private void FormMain_FormClosing( object sender,FormClosingEventArgs e) IIthis.rfid.StopI nven tory(); IIthis.rfid.CloseSerial(); 圖書統(tǒng)計 usin

33、g System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; n amespaceLabrary public partial class FormBookStatistics : Form private int boolShelf; public FormBookStatistics。 In itializeComp onen t()

34、; Bin dTreeView(); this .boolShelf = 0; Bin dListView(select RFID,BookType_ID,Name,Author,Le ndStatus,BookShelf from Book In fo); this .cboBookLendStatus.SelectedIndex = 0; private void BindTreeView() this .treeView1.Nodes.Clear(); TreeNode no deRoot = new TreeNode(); nodeRoot.Text =全部書架 1; this .tr

35、eeView1.Nodes.Add(nodeRoot); for ( int i = 0; i 4; i+) TreeNode no deChild = new TreeNode(); if (i = 0) nodeChild.Text =第一書架 1; if (i = 1) nodeChild.Text =第二書架- 1; if (i = 2) nodeChild.Text =第三書架- 1; if (i = 3) nodeChild.Text =第四書架- 1; n odeRoot.Nodes.Add( nodeChild); no deRoot.Expa nd(); private vo

36、id BindListView( string sql) thisistView1.ltems.Clear(); thisistView1.Columns.Clear(); string headerText = new string 標(biāo)簽,100,所屬分類,100,書 名,150,作者,80,借閱狀態(tài),80,所在書架,80 ; for ( int i = 0; i headerText.Length; i+) ColumnHeaderheader = new ColumnHeader(); string headerName = headerTexti.Split(: )0; int hea

37、derWidth = Convert .Tolnt32(headerTexti.Split(, )1); header.Text = headerName; header.Width = headerWidth; this .listView1.Columns.Add(header); DataTable dtb = All .dbo.getDataTable(sql); for ( int i = 0; i 0) if ( this .cboBookLendStatus.SelectedIndex = 0) BindListView(string .Format( select RFID,B

38、ookType_ID,Name,Author,Le ndStatus,BookShelf from Book Info where BookShelf=0 this .boolShelf.ToString(); if ( this .cboBookLendStatus.SelectedIndex = 1) BindListView(string .Format( select RFID,BookType_ID,Name,Author,Le ndStatus,BookShelffrom Book Info where BookShelf=0 LendStatus=1 , this .boolSh

39、elf.ToString(); if ( this .cboBookLendStatus.SelectedIndex = 2) BindListView(string .Format( select RFID,BookType_ID,Name,Author,Le ndStatus,BookShelffrom Book Info where BookShelf=0 LendStatus=0 , this .boolShelf.ToString(); 借閱卡管理 using System; using System.Collections.Generic; using System.Compone

40、ntModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; n amespaceLabrary public partial class FormCardList : Form public FormCardList() In itializeComp onen t(); SetListView(); private void SetListView() thisistView1.ltems.Clear(); List vObjCardlnfo listCard

41、 =ObjCardInfo .GetAllCard(); for ( int i = 0; i listCard) thisistView1.ltems.Clear(); for ( int i = 0; i 0) IsEnabled(true ); else IsEnabled(false ); private void tsbtnAddTime_Click(object sender,EventArgs e) if ( this .listView1.SelectedItems.Count 0) ObjCardInfo oci = this .listView1.Selectedltems

42、0.Tagas ObjCardInfo FormCardInfo fci = new FormCardInfo (5, oci); if (fci.ShowDialog() = DialogResult .OK) SetListView(); IsEnabled(false ); private void tsbtnUpdate_Click(object sender,EventArgs e) if ( this .listView1.Selectedltems.Count 0) ObjCardInfo oci = this .listView1.Selectedltems0.Tagas Ob

43、jCardInfo FormCardInfo fci = new FormCardInfo (3, oci); if (fci.ShowDialog() = DialogResult .OK) SetListView(); false ); IsE nabled( private void tsbtnQuery_Click(object sender, EventArgs e) if ( this .tstbTj.Text !=) if (lsNumber() string sql =string .Format( select rfid from librarycard where rfid

44、 like %O% order by endtime asc, this .tstbTj.Text); SetListView(ObjCardInfo .GetAllCard(sql); else string sql = string .Format( select rfid from librarycard where name like %0% order by endtime asc, this .tstbTj.Text); SetListView(ObjCardInfo .GetAllCard(sql); else SetListView(); private bool IsNumb

45、er() try Convert .ToInt64( this .tstbTj.Text); return true ; catch return false ; private void tsbtnRecord_Click( object sender,EventArgs e) if (this .listView1.Selectedltems.Count 0) FormCardRecord fcr = new FormCardRecord(this .listView1.Selectedltems0.Tagas ObjCardInfo ); fcr.ShowDialog(); privat

46、e void tsbtnDelete_Click(object sender,EventArgs e) if ( this .listView1.Selectedltems.Count 0) ObjCardInfo oci = this .listView1.Selectedltems0.Tagas ObjCardInfo ; int count = oci.NotReturnCount(); if (cou nt = 0) if ( MessageBoxShow(是非決定退卡?,MessageBoxButtons.YesNo)= DialogResult .Yes) oci.Delete()

47、; SetListView(); IsEnabled(false ); else MessageBoxShow(oci.Name + 還1 有?D + cou nt.ToStri ng() +本書未換 不能退卡! e ?; 借閱卡信息 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; n amespaceLabrary

48、 public partial class FormCard Info : Form ObjCardInfo oci; int flag; public FormCardInfo() In itializeComp onen t(); public FormCardInfo( int flag, ObjCardInfo oci) In itializeComp onen t(); this .oci = oci; this .flag = flag; SetCo ntrol(); In it(); private void Init() /續(xù)期 if ( this .flag = 5) thi

49、s .gbtnReadCard.Enabled = false ; this .tbName.Enabled = false ; this .rbtnO.Enabled =false ; this .rbtn1.Enabled =false ; this .dtpBrithday.Enabled = false ; this .tbSID.Enabled = false ; this .dtpStartTime.Enabled = false ; private void SetControl() this .tbRFID.Text =this .oci.Rfid; this .tbName.

50、Text =this .oci.Name; if ( this .oci.Sex =男) this .rbtnl.Checked =true else this .rbtnO.Checked = false ; this .dtpBrithday.Value = this .oci.Brithday; this .tbSID.Text = this .oci.SID; this .dtpStartTime.Value = this .oci.StartTime; this .dtpEndTime.Value = this .oci.EndTime; if ( this .flag != 1)

51、this .tbUser.Text = this .oci.User.Name; this .tbUser.Tag = this .oci.User; else this .tbUser.Text = All .userLogin.Name; this .tbUser.Tag = All .userLogin; private bool ValidControl() if ( this .tbRFID.Text =) MessageBoxShow(請讀卡?); this .gbtnReadCard.Focus(); return false ; if ( this .tbName.Text =

52、) MessageBoxShow(請?zhí)顚懶彰?; this .tbName.Focus(); return false ; return true ; private void GetControl() this .oci.Rfid = this .tbRFID.Text; this .oci.Name = this .tbName.Text; if ( this .rbtnO.Checked) this .oci.Sex =女?; else if ( this .rbtnl.Checked) this .oci.Sex =男 D; this .oci.Brithday = this .dt

53、pBrithday.Value; this .oci.SID = this .tbSID.Text; this .oci.StartTime = this .dtpStartTime.Value; this .oci.EndTime = this .dtpEndTime.Value; this .oci.User = this .tbUser.Tag as UserManage. ObjUser; private void gbtnCancel_Click(object sender,EventArgs e) this .Close(); private void btnReadCard_Cl

54、ick( object sender,EventArgs e) private void gbtnOK_Click( object sender,EventArgs e) if (ValidControl() GetC on trol(); if ( this .flag = 1) if ( this .oci.lsHas() MessageBoxShow(此借閱卡未退卡?); this .Close(); else this .oci.Insert(); this .DialogResult = DialogResult .OK; this .Close(); else if ( this

55、.flag = 3) this .oci.Update(); this .DialogResult = DialogResult .OK; this .Close(); else if ( this .flag = 4) else if ( this .flag = 5) this .oci.Update(); this .DialogResult = DialogResult .OK; this .Close(); private void gbtnReadCard_Click( object sender, EventArgs e) string rfidNumber = RfidOper

56、ate .GetRfid(); if (rfidNumber=) MessageBoxShow(未讀到借閱卡?); this .tbRFID.Text =; else this .tbRFID.Text = rfidNumber; 借閱記錄 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; n amespaceLabr

57、ary public partial class FormCardRecord : Form ObjCardInfo oci; public FormCardRecord。 In itializeComp onen t(); public FormCardRecord( ObjCardInfo oci) In itializeComp onen t(); this .oci = oci; this .Text = this .Text + - + this .oci.Name; SetListView(); private void SetListView() stri ng sql = st

58、ri ng .Format( select book in fo_rfid,le ndtime,retur ntime from lendtable where librarycard_rfid = 0 order by lendtime desc , this .oci.Rfid); DataTable dt = All .dbo.getDataTable(sql); for ( int i = 0; i listBookInfo = ObjBooklnfo .GetAllBooklnfo( Convert .Tolnt32( this .tscboBookType.ComboBox.Sel

59、ectedValue); for ( int i = 0; i 0) IsEnabled(true ); else IsEnabled(false ); private void IsEnabled( bool enabled) this .tsbtnBookRecord.Enabled = enabled; this .tsbtnUpdate.Enabled = enabled; private void tsbtnUpdate_Click( object sender,EventArgs e) if (this .listView1.Selectedltems.Count 0) FormB

60、ook Info fbi = new FormBook Info (3, this .listView1.Selectedltems0.Tagas ObjBooklnfo ); if (fbi.ShowDialog() = DialogResult .OK) SetListView(); private void listView1_MouseDoubleClick( object sender,MouseEventArgs e) if ( this .listView1.Selectedltems.Count 0) FormBook Info fbi = new FormBook Info

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論