1、登陆界面 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Labrary { public partial class FormLogin : Form { public FormLogin() {
2、 InitializeComponent();
}
///
3、 this.tbID.Focus(); return false; } if (this.tbID.Text != "admin") { if (!UserManage.ObjUser.IsHasID(All.dbo, this.tbID.Text)) { MessageBox.Show("不存在此用户!ê?");
4、 this.tbID.Text = ""; this.tbID.Focus(); return false; } } if (this.tbID.Text != "admin") { UserManage.ObjUser user= new UserManage.ObjUser(this.tbID.Text, All.dbo);
5、if (user.PWD != this.tbPWD.Text) { MessageBox.Show("密码错误!ê?"); this.tbPWD.Text = ""; this.tbPWD.Focus(); return false; } } else {
6、 if (this.tbPWD.Text != "123456") { MessageBox.Show("密码错误! "); this.tbPWD.Text = ""; this.tbPWD.Focus(); return false; } } return true; }
7、 private void gbtnCancel_Click(object sender, EventArgs e) { this.Close(); } private void gbtnOK_Click(object sender, EventArgs e) { //如¨?果?验¨¦证¡è控?件t通ª¡§过y if (ValidControl()) { if (
8、this.tbID.Text != "admin") { All.userLogin = new UserManage.ObjUser(this.tbID.Text, All.dbo); } else { All.userLogin = new UserManage.ObjUser(All.dbo); All.userLogin.ID
9、 "admin"; All.userLogin.Name = "管理员"; } this.DialogResult = DialogResult.OK; this.Close(); } } } } 主界面 using System; using System.Collections.Generic; using System.ComponentModel; using Syst
10、em.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Labrary { public partial class FormMain : Form { public const int WM_USER = 0x0400; public const int WM_GETBUFFER_LOOP = WM_USER + 2; private RFID_dll.Reader rdr;
11、 private RFID_dll.RFID rfid;
List
12、 //this.rfid = new RFID_dll.RFID(rdr);
}
private void FormMain_Load(object sender, EventArgs e)
{
Init();
}
///
13、osition = FormStartPosition.Manual;
//多窗体在不一样时间显示
Screen[] screens = Screen.AllScreens;
if (screens.Length == 2)
{
List
14、 { if (screen.Primary == false) { listScreen.Add(screen); } } fiao.Location = listScreen[0].WorkingArea.Location; } SetMenJin
15、"PicIn"); fiao.Show(); //toolStripStatusLabel2显示登陆用户名? toolStripStatusLabel2.Text = All.userLogin.Name; this.panel1.BackgroundImage = null; //菜单栏全部显示º? this.用®?户¡ì管¨¹理¤¨ªToolStripMenuItem.Visible = true;
16、 this.系¦Ì统ª3初?始º?化¡¥CToolStripMenuItem.Visible = true; this.应®|用®?模¡ê式º?ToolStripMenuItem.Visible = true; this.图ª?书º¨¦管¨¹理¤¨ªToolStripMenuItem.Visible = true; this.退ª?办㨬卡¡§ToolStripMenuItem.Visible = true; this.借¨¨阅?ToolStripMenuItem.Visible
17、 = true; this.门?禁?ToolStripMenuItem.Visible = true; SetPurview(); this.toolStrip1.Visible = false; this.toolStrip2.Visible = false; this.toolStrip3.Visible = false; //rfid.OpenSerial(); ////是º?否¤?找¨°到Ì
18、门?禁?设¦¨¨备À?
//if (rfid.ChangeWorkModel(2))
//{
// rfid.StartInventory(this.Handle.ToInt32(),2);
//}
}
///
19、userLogin.ID == "admin") { this.应®|用®?模¡ê式º?ToolStripMenuItem.Visible = false; } else { this.用户管理¨ªToolStripMenuItem.Visible = false; this.系统初始化¡¥CToolStripMenuItem.Visible = false;
20、 this.读书管理¨ªToolStripMenuItem.Visible = false; this.退办卡¡§ToolStripMenuItem.Visible = false; this.借阅ToolStripMenuItem.Visible = false; this.门禁?ToolStripMenuItem.Visible = false; for (int i = 0; i < All.userLogin.Purview.Count; i+
21、) { string purview = All.userLogin.Purview[i]; if (purview == "1") { this.图书管理¨ªToolStripMenuItem.Visible = true; } else if (purview == "2")
22、 { this.办退卡¡§ToolStripMenuItem.Visible = true; } else if (purview == "3") { this.借阅?ToolStripMenuItem.Visible = true; } else if (purview
23、 == "4") { this.门禁ToolStripMenuItem.Visible = true; } } } } private void 用户管理¨ªToolStripMenuItem_Click(object sender, EventArgs e) { UserManage.FormUserList ful
24、 new UserManage.FormUserList(All.conn); ful.ShowDialog(); } private void 修改密码?ToolStripMenuItem_Click(object sender, EventArgs e) { UserManage.FormUserPwd fup = new UserManage.FormUserPwd(All.conn, All.userLogin); fup.ShowDialog();
25、 } private void tsbtnBookType_Click(object sender, EventArgs e) { FormBookTypeList fbtl = new FormBookTypeList(); fbtl.ShowDialog(); } private void tsbtnBookAdd_Click(object sender, EventArgs e) { FormBo
26、okAdd fba = new FormBookAdd(); fba.ShowDialog(); } private void tsbtnBookManage_Click(object sender, EventArgs e) { FormBookInfoList fbil = new FormBookInfoList(); fbil.ShowDialog(); } private void tsbtnBookStati
27、stics_Click(object sender, EventArgs e) { FormBookStatistics fbs = new FormBookStatistics(); fbs.ShowDialog(); } private void 退ª?出?XToolStripMenuItem_Click(object sender, EventArgs e) { this.Close(); } p
28、rivate 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 =
29、 new FormCardList(); fcl.ShowDialog(); } private void tsbtnAddTime_Click(object sender, EventArgs e) { string rfid = RfidOperate.GetCard(); if (rfid == "") { MessageBox.Show("请把借阅卡放到桌面读写器上!");
30、 } else { if (ObjCardInfo.IsHas(rfid)) { ObjCardInfo oci = new ObjCardInfo(rfid); FormCardInfo fci = new FormCardInfo(5, oci); fci.ShowDialog(); }
31、 else { MessageBox.Show("没有此借阅卡信息"); } } } private void tsbtnCardDelete_Click(object sender, EventArgs e) { string rfid = RfidOperate.GetCard(); if (rfid == "")
32、 { MessageBox.Show("请把借阅卡到读写器上?"); } else { if (ObjCardInfo.IsHas(rfid)) { ObjCardInfo oci = new ObjCardInfo(rfid); int count = oci.NotReturnCount();
33、 if (count == 0) { if (MessageBox.Show("是否决定退卡!ê?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { oci.Delete(); MessageBox.Show("退卡成功|!ê?");
34、 } } else { MessageBox.Show(oci.Name + "还有一本 " + count.ToString() + " 本书未归还不能退卡?"); } } else { MessageBox.Show(
35、"没有此借阅信息?"); } } } private void tsbtnJie_Click(object sender, EventArgs e) { FormBookJie fbj = new FormBookJie(1); fbj.ShowDialog(); } private void tsbtnHuan_Click(object sender, EventArgs e)
36、 { FormBookHuan fbh = new FormBookHuan(); fbh.ShowDialog(); } private void 图ª?书º¨¦管¨¹理¤¨ªToolStripMenuItem_Click(object sender, EventArgs e) { this.toolStrip1.Visible = true; this.toolStrip2.Visible = false;
37、 this.toolStrip3.Visible = false; this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\1.jpg"); } private void 退ª?办㨬卡¡§ToolStripMenuItem_Click(object sender, EventArgs e) { this.toolStrip1.Visible
38、 false; this.toolStrip2.Visible = true; this.toolStrip3.Visible = false; this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\2.jpg"); } private void 借¨¨阅?ToolStripMenuItem_Click(object sender, EventA
39、rgs e) { this.toolStrip1.Visible = false; this.toolStrip2.Visible = false; this.toolStrip3.Visible = true; this.panel1.BackgroundImage = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "\\pic\\3.jpg"); } private
40、void 门?禁?ToolStripMenuItem_Click(object sender, EventArgs e) { //MenJinInit(); //this.toolStrip1.Visible = false; //this.toolStrip2.Visible = false; //this.toolStrip3.Visible = false; //this.panel1.BackgroundImage = null;
41、 //rfid.OpenSerial(); ////是否找到门禁设备? //if (rfid.IsOpen) //{ // rfid.StartInventory(this.Handle.ToInt32()); //} } private void 注销²ToolStripMenuItem_Click(object sender, EventArgs e) {
42、 All.userLogin = null; FormLogin fl = new FormLogin(); if (fl.ShowDialog() != DialogResult.OK) { this.Close(); } else { Init(); } } private void 帮助¨
43、²ToolStripMenuItem1_Click(object sender, EventArgs e) { } private void 系统初始化¡¥CToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("是否初始化数据库?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) {
44、 All.dbo.excuteSql("delete from lendtable"); All.dbo.excuteSql("delete from bookinfo"); All.dbo.excuteSql("delete from booktype"); All.dbo.excuteSql("delete from librarycard"); All.dbo.excuteSql("delete from usertable");
45、 MessageBox.Show("初始化完成?"); } } private void 相关ToolStripMenuItem_Click(object sender, EventArgs e) { FormAbout fa = new FormAbout(); fa.ShowDialog(); } protected override void DefWndProc(ref
46、System.Windows.Forms.Message m) { if (m.Msg == WM_GETBUFFER_LOOP) { //开启 if (this.timer1.Tag.ToString() == "0") { this.timer1.Start(); this.timer1.Tag = "1";
47、 } string uid = ""; string direction = ""; bool personWithMultCard = false; rdr.GetLoopGetBufferData(m, ref uid, ref direction, ref personWithMultCard); if (uid != "0000") {
48、 //进 if (direction == "In") { this.directionFlag = 1; this.rfids.Add(uid); } //出 if (direction == "Out") {
49、 this.directionFlag = 2; this.rfids.Add(uid); } if (uid == "FFFFFFFFFFFFFFFF") { } } } base.DefWndProc(ref m); }
50、 private void timer1_Tick(object sender, EventArgs e) { if (this.directionFlag == 1) { for (int i = 0; i < this.rfids.Count; i++) { if (ObjCardInfo.IsHas(this.rfids[i])) {






