RFID图书管理系统程序源代码

更新时间:2023-10-08 07:13:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

登陆界面

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;

using System.Windows.Forms;

namespace Labrary {

publicpartialclassFormLogin : Form {

public FormLogin() {

InitializeComponent(); }

///

/// 验¨|证?è控?件t ///

/// privatebool ValidControl() {

if (this.tbID.Text == \) {

MessageBox.Show(\请填写用户名!ê?\); this.tbID.Focus(); returnfalse; }

if (this.tbID.Text != \) {

if (!UserManage.ObjUser.IsHasID(All.dbo, this.tbID.Text)) {

MessageBox.Show(\不存在此用户!ê?\); this.tbID.Text = \; this.tbID.Focus(); returnfalse; } }

if (this.tbID.Text != \)

{

UserManage.ObjUser user= new UserManage.ObjUser(this.tbID.Text, All.dbo); if (user.PWD != this.tbPWD.Text) {

MessageBox.Show(\密码错误!ê?\); this.tbPWD.Text = \; this.tbPWD.Focus(); returnfalse; } } else

{

if (this.tbPWD.Text != \) {

MessageBox.Show(\密码错误! \); this.tbPWD.Text = \; this.tbPWD.Focus(); returnfalse; } }

returntrue; }

privatevoid gbtnCancel_Click(object sender, EventArgs e) { this.Close(); }

privatevoid gbtnOK_Click(object sender, EventArgs e) {

//如¨?果?验¨|证?è控?件t通a?§过y if (ValidControl()) {

if (this.tbID.Text != \) {

All.userLogin = new UserManage.ObjUser(this.tbID.Text, All.dbo); } else

{

All.userLogin = new UserManage.ObjUser(All.dbo); All.userLogin.ID = \;

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;

using System.Windows.Forms;

namespace Labrary {

publicpartialclassFormMain : Form {

publicconstint WM_USER = 0x0400;

publicconstint WM_GETBUFFER_LOOP = WM_USER + 2; private RFID_dll.Reader rdr; private RFID_dll.RFID rfid;

List rfids = newList(); int directionFlag = 0;//1进;出?

FormInAndOut fiao = newFormInAndOut();

public FormMain() {

InitializeComponent();

this.rdr = new RFID_dll.Reader(); //this.rfid = new RFID_dll.RFID(rdr); }

privatevoid FormMain_Load(object sender, EventArgs e) {

Init(); }

///

///初始化 /// privatevoid Init() {

fiao.StartPosition = FormStartPosition.Manual;

//多窗体在不同时间显示

Screen[] screens = Screen.AllScreens; if (screens.Length == 2) {

List listScreen = newList(); foreach (Screen screen inScreen.AllScreens) {

if (screen.Primary == false) {

listScreen.Add(screen); } }

fiao.Location = listScreen[0].WorkingArea.Location;

}

SetMenJin(\); fiao.Show();

//toolStripStatusLabel2显示登陆用户名?

toolStripStatusLabel2.Text = All.userLogin.Name;

this.panel1.BackgroundImage = null;

//菜单栏全部显示o?

this.用??户?ì管¨1理¤¨aToolStripMenuItem.Visible = true; this.系|ì统a3初?始o?化?¥CToolStripMenuItem.Visible = true;

this.应?|用??模?ê式o?ToolStripMenuItem.Visible = true;

this.图a?书o¨|管¨1理¤¨aToolStripMenuItem.Visible = true; this.退a?办?¨?卡?§ToolStripMenuItem.Visible = true; this.借¨¨阅?ToolStripMenuItem.Visible = true; this.门?禁?ToolStripMenuItem.Visible = true;

SetPurview();

this.toolStrip1.Visible = false; this.toolStrip2.Visible = false; this.toolStrip3.Visible = false;

//rfid.OpenSerial();

////是o?否¤?找¨?到ì?门?禁?设|¨¨备à? //if (rfid.ChangeWorkModel(2)) //{

// rfid.StartInventory(this.Handle.ToInt32(),2); //} }

///

///权限设置 ///

privatevoid SetPurview() {

if (All.userLogin.ID == \) {

this.应?|用??模?ê式o?ToolStripMenuItem.Visible = false; } else

{

this.用户管理¨aToolStripMenuItem.Visible = false; this.系统初始化?¥CToolStripMenuItem.Visible = false; this.读书管理¨aToolStripMenuItem.Visible = false; this.退办卡?§ToolStripMenuItem.Visible = false; this.借阅ToolStripMenuItem.Visible = false; this.门禁?ToolStripMenuItem.Visible = false;

for (int i = 0; i

string purview = All.userLogin.Purview[i]; if (purview == \) {

this.图书管理¨aToolStripMenuItem.Visible = true; } elseif (purview == \) {

this.办退卡?§ToolStripMenuItem.Visible = true; }

protectedoverridevoid DefWndProc(ref System.Windows.Forms.Message m) {

if (m.Msg == WM_GETBUFFER_LOOP) { //启动

if (this.timer1.Tag.ToString() == \) { this.timer1.Start(); this.timer1.Tag = \; }

string uid = \; string direction = \;

bool personWithMultCard = false;

rdr.GetLoopGetBufferData(m, ref uid, ref direction, ref personWithMultCard);

if (uid != \) { //进

if (direction == \) { this.directionFlag = 1; this.rfids.Add(uid); } //出

if (direction == \) { this.directionFlag = 2; this.rfids.Add(uid); }

if (uid == \) {

} }

}

base.DefWndProc(ref m);

}

privatevoid timer1_Tick(object sender, EventArgs e) {

if (this.directionFlag == 1) {

for (int i = 0; i

if (ObjCardInfo.IsHas(this.rfids[i])) {

ObjCardInfo oci = newObjCardInfo(this.rfids[i]);

if (oci.IsOverTime()) {

SetMenJin(\); MenJinInit(); return;

} else

{

SetMenJin(\); MenJinInit(); return;

} } }

SetMenJin(\); MenJinInit(); }

elseif (this.directionFlag == 2) {

for (int i = 0; i

if (ObjBookInfo.IsHas(this.rfids[i])) {

ObjBookInfo obi = newObjBookInfo(this.rfids[i]);

if (obi.LendStatus == \为借出?\) {

this.rdr.WarningOutput(false, false, true, false, false); SetMenJin(\); MenJinInit();

return;

} } }

MenJinInit(); } }

///

///门禁初始化 ///

privatevoid MenJinInit() {

this.rfids.Clear(); this.directionFlag = 0; this.timer1.Tag = \; this.timer1.Stop(); }

privatevoid SetMenJin(string message) {

this.fiao.Controls.Clear();

UserControlMenJin ucmj = newUserControlMenJin(message); ucmj.Dock = DockStyle.Fill; this.fiao.Controls.Add(ucmj); }

privatevoid FormMain_FormClosing(object sender, FormClosingEventArgs e) {

//this.rfid.StopInventory(); //this.rfid.CloseSerial(); } } }

图书统计

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data;

using System.Drawing; using System.Text;

using System.Windows.Forms;

namespace Labrary {

publicpartialclassFormBookStatistics : Form {

privateint boolShelf;

public FormBookStatistics() {

InitializeComponent();

BindTreeView();

this.boolShelf = 0;

BindListView(\BookInfo\);

this.cboBookLendStatus.SelectedIndex = 0; }

privatevoid BindTreeView() {

this.treeView1.Nodes.Clear();

TreeNode nodeRoot = newTreeNode(); nodeRoot.Text = \全部书架1\; this.treeView1.Nodes.Add(nodeRoot);

for (int i = 0; i < 4; i++) {

TreeNode nodeChild = newTreeNode(); if (i == 0) {

nodeChild.Text = \第一书架1\; } if (i == 1) {

nodeChild.Text = \第二书架¨1\; } if (i == 2)

{

nodeChild.Text = \第三书架¨1\; } if (i == 3) {

nodeChild.Text = \第四书架¨1\; }

nodeRoot.Nodes.Add(nodeChild); }

nodeRoot.Expand(); }

privatevoid BindListView(string sql) {

this.listView1.Items.Clear(); this.listView1.Columns.Clear();

string[] headerText = newstring[] { \标签,100\, \所属分类¤¨¤,100\, \书名,150\, \作者,80\, \借阅状态,80\, \所在书架,80\ };

for (int i = 0; i < headerText.Length; i++) {

ColumnHeader header = newColumnHeader();

string headerName = headerText[i].Split(',')[0];

int headerWidth = Convert.ToInt32(headerText[i].Split(',')[1]);

header.Text = headerName; header.Width = headerWidth;

this.listView1.Columns.Add(header); }

DataTable dtb = All.dbo.getDataTable(sql);

for (int i = 0; i < dtb.Rows.Count; i++) {

ObjBookInfo bookInfo = newObjBookInfo(dtb.Rows[i][\].ToString());

ListViewItem item = newListViewItem(newstring[] { bookInfo.RFID, bookInfo.BookType.Name, bookInfo.Name, bookInfo.Author, bookInfo.LendStatus, bookInfo.BookShelf });

this.listView1.Items.Add(item);

本文来源:https://www.bwwdw.com/article/7rud.html

Top