找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4395|回复: 8
打印 上一主题 下一主题
收起左侧

基于RFID的便利超市防盗系统设计 附C#源码与PPT

[复制链接]
跳转到指定楼层
楼主
简单的C# RFID标签系统PPT内容:


首先要将需要定位监控的物资上面安装一张半有源RFID的低频激活电子标签该标签具有唯一的编码,并给具有合法拿取物品的管理人员登记和发放一个电子标签卡,用于标识管理人员的身份,然后将物资放置在双频报警主机有效监控范围内的指定位置上,并建立起物资与存放位置之间的对应关系。系统工作时,双频报警主机内的低频触发激活器连续不断发射低频激活信号,激活贵重物品上的电子标签,电子标签把信号再发射出去,有效识别范围内的读写器将收到该标签同频段发射的数据包,解析出该数据包中的标签ID号和激活器编号以及RSSI值后立刻上传到上位机电脑。当贵重物品上的标签被移出2m外,激活器发射的信号不能激活标签,相对应读写器也读取不了标签信息,声光报警装置进行报警。同时,在仓库不同的地方,安装一些有源RFID远距离读写器,用于采集低频激活电子标签被激活后发出的信息(包括电子标签本身的ID号,低频激活天线的地址码),读写器采集到数据后,通过各种传输方式,将信息上传给电脑管理中心。以便及时发现异常和采取措施。


遇到的问题和需要讨论的问题
在解决报警问题上,不知道怎样处理。当激活器发射的信号不能激活标签,相对应读写器也读取不了标签信息,声光报警装置进行报警。所以就设定当取值为空时报警器报警。
由于条件限制,读卡距离较近,还不能很好的起到实时防盗的作用。但实验表明,此设计的电路运行稳定,读写数据准确,操作时间较短,在理论上是完全可以实现的。



1、管理人员可以根据用户名和密码登录超市防盗系统

2、读写器采集到数据后,将信息上传给电脑管理中心。管理人员可以知道这箱货物的名字、生产地、生厂商编号、数量和生产日期等基本信息,并写入数据库中。

3、当激活器发射的信号不能激活标签,不能正常显示出信息。相对应读写器也读取不了标签信息,声光报警装置进行报警。



c#源程序如下:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.SqlClient;

  10. namespace RFID
  11. {
  12.     public partial class DataConveyForm : Form
  13.     {
  14.         
  15.         public DataConveyForm()
  16.         {
  17.             InitializeComponent();
  18.         }

  19.         /*****************屏蔽窗体右上角关闭按钮******************/
  20.         private const int CP_NOCLOSE_BUTTON = 0x200;
  21.         protected override CreateParams CreateParams
  22.         {
  23.             get
  24.             {
  25.                 CreateParams myCp = base.CreateParams;
  26.                 myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
  27.                 return myCp;
  28.             }
  29.         }
  30.         /*************************************************************/



  31.         /******************退出数据传送窗口,返回到监控窗口****************************/
  32.         private void button3_Click(object sender, EventArgs e)
  33.         {
  34.             serialPort1.Close();
  35.             MonitoringForm monitoringform = new MonitoringForm();
  36.             this.Close();
  37.             monitoringform.Show();
  38.         }

  39.         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  40.         {
  41.             switch(comboBox2.SelectedIndex )
  42.             {
  43.                 case 0:
  44.                     comboBox2.Items.Clear();
  45.                     comboBox2.Items.Add("甘肃");
  46.                     comboBox2.Items.Add("辽宁");
  47.                     comboBox2.Items.Add("陕西");
  48.                     comboBox2.Items.Add("湖南");
  49.                     comboBox2.Items.Add("北京");
  50.                     break;
  51.             }
  52.         }
  53.         /***********************************************************************************************/



  54.         /******************************将学生信息插入到数据库中***************************************************/

  55.         
  56.         
  57.         
  58.         /*private void button1_Click(object sender, EventArgs e)
  59.         {
  60.             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)
  61.             {
  62.                 MessageBox.Show("学生信息输入不完整,请检查准确输入");
  63.                 return;
  64.             }
  65.             string sqlCheck = "SELECT count ( * ) FROM [StudentMsg] WHERE StudentId='" +textBox5.Text.ToString().Trim() + "'";
  66.             SqlConnection conn = new SqlConnection(connstring);
  67.             SqlCommand cmdCheck = new SqlCommand(sqlCheck, conn);
  68.             int checkCount = 0;

  69.             try
  70.             {
  71.                 conn.Open();
  72.                 checkCount = (int)cmdCheck.ExecuteScalar();
  73.             }
  74.             catch (Exception ex)
  75.             {
  76.                 MessageBox.Show(ex.Message);
  77.             }

  78.             if (checkCount > 0)
  79.             {
  80.                 conn.Close();
  81.                 MessageBox.Show("此学号在后台数据库中已经存在,学号不能重复,请重新输入,注意只能输入数字");
  82.                 return;
  83.             }

  84.             string dept = comboBox2.SelectedItem.ToString();    //学院
  85.             string spec = comboBox2.SelectedItem.ToString();    //专业
  86.             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);
  87.             using (SqlConnection conn1 = new SqlConnection(connstring))
  88.             {
  89.                 conn.Close();
  90.                 conn1.Open();
  91.                 SqlCommand comm = new SqlCommand(sql, conn1);
  92.                 int n = comm.ExecuteNonQuery();
  93.                 if (n > 0)
  94.                 {
  95.                     MessageBox.Show("添加学生信息成功!", "添加成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
  96.                     conn1.Close();
  97.                     this.textBox1.Text = "";
  98.                     this.comboBox2.Text = "";
  99.                     this.textBox3.Text = "";
  100.                     this.textBox4.Text = "";
  101.                     this.textBox6.Text = "";
  102.                 }
  103.                 else
  104.                 {
  105.                     MessageBox.Show("添加学生信息失败!", "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Information);
  106.                     conn1.Close();
  107.                 }
  108.             }
  109.         }/*
  110.         /********************************************************************************************************/


  111.         /*********************************************当前显示*************************************/
  112.         private void DataConveyForm_Load(object sender, EventArgs e)
  113.         {
  114.             try
  115.             {
  116.                 comboBox2.SelectedIndex = 0;
  117.                 comboBox2.SelectedIndex = 0;
  118.                 serialPort1.Open();
  119.             }
  120.             catch (Exception ex)
  121.             {
  122.                 MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  123.             }
  124.         }
  125.         /************************************************************************************************/


  126.         /**********************************获取物品标签号***********************************************/

  127.         private void button4_Click(object sender, EventArgs e)
  128.         {
  129.             string temp;
  130.             string data;
  131.             string data1;
  132.             try
  133.             {
  134.                 serialPort1.WriteLine("010900210200040000");

  135.             }
  136.             catch (Exception ex)
  137.             {
  138.                 MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  139.                 return;
  140.             }
  141.             temp = serialPort1.ReadLine();
  142.             System.Threading.Thread.Sleep(1000);
  143.             try
  144.             {
  145.                 serialPort1.WriteLine("010900210200040000");
  146.             }
  147.             catch (Exception ex)
  148.             {
  149.                 MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  150.                 return;
  151.             }
  152.             data = serialPort1.ReadLine();
  153.             if (data [0]=='[')
  154.             {
  155.                 data1 = data.Substring(4, 4) + data.Substring(9, 4) + data.Substring(14, 4) + data.Substring(19, 4);
  156.                 textBox3.Text = data1;
  157.             }
  158.             else
  159.             {
  160.                 MessageBox.Show("获取物品标签号失败,请注意检查!", "获取物品标签失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  161.             }
  162.         }
  163.         /***************************************************************************************/


  164.         /*********************************获取主人标签号*********************************************/
  165.         private void button5_Click(object sender, EventArgs e)
  166.         {
  167.             string temp;
  168.             string data;
  169.             string data1;
  170.             try
  171.             {
  172.                 serialPort1.WriteLine("010900210200040000");
  173.             }
  174.             catch (Exception ex)
  175.             {
  176.                 MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  177.                 return;
  178.             }
  179.             temp = serialPort1.ReadLine();
  180.             System.Threading.Thread.Sleep(1000);
  181.             try
  182.             {
  183.                 serialPort1.WriteLine("010900210200040000");
  184.             }
  185.             catch (Exception ex)
  186.             {
  187.                 MessageBox.Show(ex.Message, "串口设置操作出错!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  188.                 return;
  189.             }
  190.             data = serialPort1.ReadLine();
  191.             if (data[0] == '[')
  192.             {
  193.                 data1 = data.Substring(4, 4) + data.Substring(9, 4) + data.Substring(14, 4) + data.Substring(19, 4);
  194.                 textBox4.Text = data1;
  195.             }
  196.             else
  197.             {
  198.                 MessageBox.Show("获取主人标签号失败,请注意检查!", "获取主人标签失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  199.             }
  200.         }
  201.         private DataSet dsUser;
  202.         private void button1_Click(object sender, EventArgs e)
  203.         {
  204.             string connstring = @"Data Source=210.26.96.51;Initial Catalog=BC;User ID=sa;Pwd=95069506";
  205.             if (dsUser == null)
  206.             {
  207.                 MessageBox.Show("当前页面数据表空,请先刷新显示全部数据,然后进行操作。");
  208.                 return;
  209.             }
  210.             if (textBox1.Text.Length == 0)
  211.             {
  212.                 MessageBox.Show("商品名称不能为空,请输入准确的厂商名称!");
  213.                 return;
  214.             }
  215.             if (comboBox2.Text.Length == 0)
  216.             {
  217.                 MessageBox.Show("生产地不能为空,请输入准确的运输商名称!");
  218.                 return;
  219.             }
  220.             if (textBox6.Text.Length == 0)
  221.             {
  222.                 MessageBox.Show("系统销售商名称不能为空,请输入准确的销售商名称!");
  223.                 return;
  224.             }
  225.             if (numericUpDown1.Text.Length == 0)
  226.             {
  227.                 MessageBox.Show("订单日期名称不能为空,请输入准确的销售商名称!");
  228.                 return;
  229.             }
  230.             if (dateTimePicker1.Text.Length == 0)
  231.             {
  232.                 MessageBox.Show("订单数量不能为空,请输入准确的销售商名称!");
  233.                 return;
  234.             }
  235.             string sqlCheck = "SELECT count ( * ) FROM [Store] WHERE ProName='" + textBox1.Text.ToString().Trim() + "'";
  236.             SqlConnection conn = new SqlConnection(connstring);
  237.             SqlCommand cmdCheck = new SqlCommand(sqlCheck, conn);
  238.             int checkCount = 0;

  239.             try
  240.             {
  241.                 conn.Open();
  242.                 checkCount = (int)cmdCheck.ExecuteScalar();
  243.             }
  244.             catch (Exception ex)
  245.             {
  246.                 MessageBox.Show(ex.Message);
  247.             }


  248.             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() + "')";
  249.             try
  250.             {
  251.                 cmdCheck = new SqlCommand(sqlCheck, conn);
  252.                 cmdCheck.ExecuteNonQuery();
  253.             }
  254.             catch (Exception ex)
  255.             {
  256.                 conn.Close();
  257.                 MessageBox.Show(ex.Message);
  258.                 return;
  259.             }

  260.             sqlCheck = "SELECT '商品名'=ProName,'生产地'=Production,'生产商编号'=ProId,'购买数量'=Number,'生产日期'=DataName FROM [Store]";
  261.             try
  262.             {
  263.                 SqlDataAdapter da = new SqlDataAdapter();
  264.                 da.SelectCommand = new SqlCommand(sqlCheck, conn);

  265.                 dsUser = new DataSet("Store");
  266.                 da.Fill(dsUser, "Store");
  267.                 this.dataGridViewIndex.DataSource = dsUser.Tables["Store"];
  268.                 this.dataGridViewIndex.Refresh();
  269.                 this.dataGridViewIndex.Show();
  270.             }
  271.             catch (Exception ex)
  272.             {
  273.                 MessageBox.Show(ex.Message);
  274.             }
  275.             finally
  276.             {
  277.                 conn.Close();
  278.             }
  279.             this.textBox1.Text = "";
  280.             this.comboBox2.Text = "";
  281.             this.textBox6.Text = "";
  282.             this.numericUpDown1.Text = "";
  283.             this.dateTimePicker1.Text = "";

  284.             MessageBox.Show("数据新增完毕!");

  285.         }
  286.         private int selectRows = -1;
  287.         private string tmpProName = "";
  288.         private string tmpProduction = "";
  289.         private string tmpProId = "";
  290.         private string tmpNumber = "";
  291.         private string tmpDataName = "";
  292.         private void dataGridViewIndex_CellContentClick(object sender, DataGridViewCellEventArgs e)
  293.         {
  294.             this.selectRows = dataGridViewIndex.CurrentRow.Index;
  295.             this.textBox1.Text = dsUser.Tables["Store"].Rows[selectRows][0].ToString();
  296.             this.comboBox2.Text = dsUser.Tables["Store"].Rows[selectRows][1].ToString();
  297.             this.textBox6.Text = dsUser.Tables["Store"].Rows[selectRows][2].ToString();
  298.             this.numericUpDown1.Text = dsUser.Tables["Store"].Rows[selectRows][3].ToString();
  299.             this.dateTimePicker1.Text= dsUser.Tables["Store"].Rows[selectRows][4].ToString();
  300.             this.tmpProName = dsUser.Tables["Store"].Rows[selectRows][0].ToString();
  301.             this.tmpProduction = dsUser.Tables["Store"].Rows[selectRows][1].ToString();
  302.             this.tmpProId = dsUser.Tables["Store"].Rows[selectRows][2].ToString();
  303.             this.tmpNumber = dsUser.Tables["Store"].Rows[selectRows][3].ToString();
  304.             this.tmpDataName = dsUser.Tables["Store"].Rows[selectRows][4].ToString();
  305.         
  306.         }
  307.         /**********************************************显示*************************************************************/
  308. ……………………

  309. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码






所有资料51hei提供下载:
便利超市的防盗系统.rar (9.95 MB, 下载次数: 103)


评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:554168 发表于 2019-6-3 21:26
能免费嘛

板凳
ID:642872 发表于 2019-11-16 14:11 | 只看该作者
大佬厉害了
回复

使用道具 举报

地板
ID:638731 发表于 2019-12-2 15:43 | 只看该作者
RFID设备用那种能说下嘛?
回复

使用道具 举报

5#
ID:421595 发表于 2019-12-10 14:07 | 只看该作者
看看,学习一下
回复

使用道具 举报

6#
ID:421595 发表于 2019-12-10 14:12 | 只看该作者
楼主:能不能给出全部,好让小弟们学习学习呀
回复

使用道具 举报

7#
ID:421595 发表于 2019-12-16 08:17 | 只看该作者
学习一下
回复

使用道具 举报

8#
ID:137563 发表于 2020-2-19 15:58 | 只看该作者
不错的资料,收藏一下
回复

使用道具 举报

9#
ID:503018 发表于 2020-4-8 12:00 | 只看该作者
感谢大佬的分享
回复

使用道具 举报

10#
ID:546607 发表于 2020-5-20 15:23 | 只看该作者
用不了  别下  不听的可以下载
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表