简单的C# RFID标签系统PPT内容:
首先要将需要定位监控的物资上面安装一张半有源RFID的低频激活电子标签该标签具有唯一的编码,并给具有合法拿取物品的管理人员登记和发放一个电子标签卡,用于标识管理人员的身份,然后将物资放置在双频报警主机有效监控范围内的指定位置上,并建立起物资与存放位置之间的对应关系。系统工作时,双频报警主机内的低频触发激活器连续不断发射低频激活信号,激活贵重物品上的电子标签,电子标签把信号再发射出去,有效识别范围内的读写器将收到该标签同频段发射的数据包,解析出该数据包中的标签ID号和激活器编号以及RSSI值后立刻上传到上位机电脑。当贵重物品上的标签被移出2m外,激活器发射的信号不能激活标签,相对应读写器也读取不了标签信息,声光报警装置进行报警。同时,在仓库不同的地方,安装一些有源RFID远距离读写器,用于采集低频激活电子标签被激活后发出的信息(包括电子标签本身的ID号,低频激活天线的地址码),读写器采集到数据后,通过各种传输方式,将信息上传给电脑管理中心。以便及时发现异常和采取措施。
遇到的问题和需要讨论的问题
在解决报警问题上,不知道怎样处理。当激活器发射的信号不能激活标签,相对应读写器也读取不了标签信息,声光报警装置进行报警。所以就设定当取值为空时报警器报警。
由于条件限制,读卡距离较近,还不能很好的起到实时防盗的作用。但实验表明,此设计的电路运行稳定,读写数据准确,操作时间较短,在理论上是完全可以实现的。
1、管理人员可以根据用户名和密码登录超市防盗系统
2、读写器采集到数据后,将信息上传给电脑管理中心。管理人员可以知道这箱货物的名字、生产地、生厂商编号、数量和生产日期等基本信息,并写入数据库中。
3、当激活器发射的信号不能激活标签,不能正常显示出信息。相对应读写器也读取不了标签信息,声光报警装置进行报警。
c#源程序如下:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- namespace RFID
- {
- public partial class DataConveyForm : Form
- {
-
- public DataConveyForm()
- {
- InitializeComponent();
- }
- /*****************屏蔽窗体右上角关闭按钮******************/
- private const int CP_NOCLOSE_BUTTON = 0x200;
- protected override CreateParams CreateParams
- {
- get
- {
- CreateParams myCp = base.CreateParams;
- myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
- return myCp;
- }
- }
- /*************************************************************/
- /******************退出数据传送窗口,返回到监控窗口****************************/
- private void button3_Click(object sender, EventArgs e)
- {
- serialPort1.Close();
- MonitoringForm monitoringform = new MonitoringForm();
- this.Close();
- monitoringform.Show();
- }
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch(comboBox2.SelectedIndex )
- {
- case 0:
- comboBox2.Items.Clear();
- comboBox2.Items.Add("甘肃");
- comboBox2.Items.Add("辽宁");
- comboBox2.Items.Add("陕西");
- comboBox2.Items.Add("湖南");
- comboBox2.Items.Add("北京");
- break;
- }
- }
- /***********************************************************************************************/
- /******************************将学生信息插入到数据库中***************************************************/
-
-
-
- /*private void button1_Click(object sender, EventArgs e)
- {
- if (textBox1.Text.Length == 0 | comboBox2.Text.Length == 0 | textBox3.Text.Length == 0 | textBox4.Text.Length == 0 | textBox5.Text.Length == 0 | textBox6.Text.Length == 0|comboBox2.Text.Length ==0|comboBox2.Text.Length ==0)
- {
- MessageBox.Show("学生信息输入不完整,请检查准确输入");
- return;
- }
- string sqlCheck = "SELECT count ( * ) FROM [StudentMsg] WHERE StudentId='" +textBox5.Text.ToString().Trim() + "'";
- SqlConnection conn = new SqlConnection(connstring);
- SqlCommand cmdCheck = new SqlCommand(sqlCheck, conn);
- int checkCount = 0;
- try
- {
- conn.Open();
- checkCount = (int)cmdCheck.ExecuteScalar();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- if (checkCount > 0)
- {
- conn.Close();
- MessageBox.Show("此学号在后台数据库中已经存在,学号不能重复,请重新输入,注意只能输入数字");
- return;
- }
- string dept = comboBox2.SelectedItem.ToString(); //学院
- string spec = comboBox2.SelectedItem.ToString(); //专业
- string sql = String.Format("INSERT INTO StudentMsg(Department,StudentId,Name,Sex,Grade,DormitoryId,Speciality,ObjectId,HostId)VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", dept, textBox5.Text, textBox1.Text, sex, comboBox2.Text, textBox6.Text, spec, textBox3.Text, textBox4.Text);
- using (SqlConnection conn1 = new SqlConnection(connstring))
- {
- conn.Close();
- conn1.Open();
- SqlCommand comm = new SqlCommand(sql, conn1);
- int n = comm.ExecuteNonQuery();
- if (n > 0)
- {
- MessageBox.Show("添加学生信息成功!", "添加成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
- conn1.Close();
- this.textBox1.Text = "";
- this.comboBox2.Text = "";
- this.textBox3.Text = "";
- this.textBox4.Text = "";
- this.textBox6.Text = "";
- }
- else
- {
- MessageBox.Show("添加学生信息失败!", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Information);
- conn1.Close();
- }
- }
- }/*
- /********************************************************************************************************/
- /*********************************************当前显示*************************************/
- private void DataConveyForm_Load(object sender, EventArgs e)
- {
- try
- {
- comboBox2.SelectedIndex = 0;
- comboBox2.SelectedIndex = 0;
- serialPort1.Open();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- }
- /************************************************************************************************/
- /**********************************获取物品标签号***********************************************/
- private void button4_Click(object sender, EventArgs e)
- {
- string temp;
- string data;
- string data1;
- try
- {
- serialPort1.WriteLine("010900210200040000");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- temp = serialPort1.ReadLine();
- System.Threading.Thread.Sleep(1000);
- try
- {
- serialPort1.WriteLine("010900210200040000");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- data = serialPort1.ReadLine();
- if (data [0]=='[')
- {
- data1 = data.Substring(4, 4) + data.Substring(9, 4) + data.Substring(14, 4) + data.Substring(19, 4);
- textBox3.Text = data1;
- }
- else
- {
- MessageBox.Show("获取物品标签号失败,请注意检查!", "获取物品标签失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- }
- /***************************************************************************************/
- /*********************************获取主人标签号*********************************************/
- private void button5_Click(object sender, EventArgs e)
- {
- string temp;
- string data;
- string data1;
- try
- {
- serialPort1.WriteLine("010900210200040000");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- temp = serialPort1.ReadLine();
- System.Threading.Thread.Sleep(1000);
- try
- {
- serialPort1.WriteLine("010900210200040000");
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- return;
- }
- data = serialPort1.ReadLine();
- if (data[0] == '[')
- {
- data1 = data.Substring(4, 4) + data.Substring(9, 4) + data.Substring(14, 4) + data.Substring(19, 4);
- textBox4.Text = data1;
- }
- else
- {
- MessageBox.Show("获取主人标签号失败,请注意检查!", "获取主人标签失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- }
- private DataSet dsUser;
- private void button1_Click(object sender, EventArgs e)
- {
- string connstring = @"Data Source=210.26.96.51;Initial Catalog=BC;User ID=sa;Pwd=95069506";
- if (dsUser == null)
- {
- MessageBox.Show("当前页面数据表空,请先刷新显示全部数据,然后进行操作。");
- return;
- }
- if (textBox1.Text.Length == 0)
- {
- MessageBox.Show("商品名称不能为空,请输入准确的厂商名称!");
- return;
- }
- if (comboBox2.Text.Length == 0)
- {
- MessageBox.Show("生产地不能为空,请输入准确的运输商名称!");
- return;
- }
- if (textBox6.Text.Length == 0)
- {
- MessageBox.Show("系统销售商名称不能为空,请输入准确的销售商名称!");
- return;
- }
- if (numericUpDown1.Text.Length == 0)
- {
- MessageBox.Show("订单日期名称不能为空,请输入准确的销售商名称!");
- return;
- }
- if (dateTimePicker1.Text.Length == 0)
- {
- MessageBox.Show("订单数量不能为空,请输入准确的销售商名称!");
- return;
- }
- string sqlCheck = "SELECT count ( * ) FROM [Store] WHERE ProName='" + textBox1.Text.ToString().Trim() + "'";
- SqlConnection conn = new SqlConnection(connstring);
- SqlCommand cmdCheck = new SqlCommand(sqlCheck, conn);
- int checkCount = 0;
- try
- {
- conn.Open();
- checkCount = (int)cmdCheck.ExecuteScalar();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- sqlCheck = "INSERT INTO [Store] VALUES ('" + textBox1.Text.ToString().Trim() + "','" + comboBox2.Text.ToString().Trim() + "','" + textBox6.Text.ToString().Trim() + "','" + numericUpDown1.Text.ToString().Trim() + "','" + dateTimePicker1.Text.ToString().Trim() + "')";
- try
- {
- cmdCheck = new SqlCommand(sqlCheck, conn);
- cmdCheck.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- conn.Close();
- MessageBox.Show(ex.Message);
- return;
- }
- sqlCheck = "SELECT '商品名'=ProName,'生产地'=Production,'生产商编号'=ProId,'购买数量'=Number,'生产日期'=DataName FROM [Store]";
- try
- {
- SqlDataAdapter da = new SqlDataAdapter();
- da.SelectCommand = new SqlCommand(sqlCheck, conn);
- dsUser = new DataSet("Store");
- da.Fill(dsUser, "Store");
- this.dataGridViewIndex.DataSource = dsUser.Tables["Store"];
- this.dataGridViewIndex.Refresh();
- this.dataGridViewIndex.Show();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- finally
- {
- conn.Close();
- }
- this.textBox1.Text = "";
- this.comboBox2.Text = "";
- this.textBox6.Text = "";
- this.numericUpDown1.Text = "";
- this.dateTimePicker1.Text = "";
- MessageBox.Show("数据新增完毕!");
- }
- private int selectRows = -1;
- private string tmpProName = "";
- private string tmpProduction = "";
- private string tmpProId = "";
- private string tmpNumber = "";
- private string tmpDataName = "";
- private void dataGridViewIndex_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- this.selectRows = dataGridViewIndex.CurrentRow.Index;
- this.textBox1.Text = dsUser.Tables["Store"].Rows[selectRows][0].ToString();
- this.comboBox2.Text = dsUser.Tables["Store"].Rows[selectRows][1].ToString();
- this.textBox6.Text = dsUser.Tables["Store"].Rows[selectRows][2].ToString();
- this.numericUpDown1.Text = dsUser.Tables["Store"].Rows[selectRows][3].ToString();
- this.dateTimePicker1.Text= dsUser.Tables["Store"].Rows[selectRows][4].ToString();
- this.tmpProName = dsUser.Tables["Store"].Rows[selectRows][0].ToString();
- this.tmpProduction = dsUser.Tables["Store"].Rows[selectRows][1].ToString();
- this.tmpProId = dsUser.Tables["Store"].Rows[selectRows][2].ToString();
- this.tmpNumber = dsUser.Tables["Store"].Rows[selectRows][3].ToString();
- this.tmpDataName = dsUser.Tables["Store"].Rows[selectRows][4].ToString();
-
- }
- /**********************************************显示*************************************************************/
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
便利超市的防盗系统.rar
(9.95 MB, 下载次数: 107)
|