找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5426|回復(fù): 8
上一主題 下一主題
收起左側(cè)

基于RFID的便利超市防盜系統(tǒng)設(shè)計(jì) 附C#源碼與PPT

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
簡單的C# RFID標(biāo)簽系統(tǒng)PPT內(nèi)容:


首先要將需要定位監(jiān)控的物資上面安裝一張半有源RFID的低頻激活電子標(biāo)簽該標(biāo)簽具有唯一的編碼,并給具有合法拿取物品的管理人員登記和發(fā)放一個(gè)電子標(biāo)簽卡,用于標(biāo)識(shí)管理人員的身份,然后將物資放置在雙頻報(bào)警主機(jī)有效監(jiān)控范圍內(nèi)的指定位置上,并建立起物資與存放位置之間的對應(yīng)關(guān)系。系統(tǒng)工作時(shí),雙頻報(bào)警主機(jī)內(nèi)的低頻觸發(fā)激活器連續(xù)不斷發(fā)射低頻激活信號(hào),激活貴重物品上的電子標(biāo)簽,電子標(biāo)簽把信號(hào)再發(fā)射出去,有效識(shí)別范圍內(nèi)的讀寫器將收到該標(biāo)簽同頻段發(fā)射的數(shù)據(jù)包,解析出該數(shù)據(jù)包中的標(biāo)簽ID號(hào)和激活器編號(hào)以及RSSI值后立刻上傳到上位機(jī)電腦。當(dāng)貴重物品上的標(biāo)簽被移出2m外,激活器發(fā)射的信號(hào)不能激活標(biāo)簽,相對應(yīng)讀寫器也讀取不了標(biāo)簽信息,聲光報(bào)警裝置進(jìn)行報(bào)警。同時(shí),在倉庫不同的地方,安裝一些有源RFID遠(yuǎn)距離讀寫器,用于采集低頻激活電子標(biāo)簽被激活后發(fā)出的信息(包括電子標(biāo)簽本身的ID號(hào),低頻激活天線的地址碼),讀寫器采集到數(shù)據(jù)后,通過各種傳輸方式,將信息上傳給電腦管理中心。以便及時(shí)發(fā)現(xiàn)異常和采取措施。


遇到的問題和需要討論的問題
在解決報(bào)警問題上,不知道怎樣處理。當(dāng)激活器發(fā)射的信號(hào)不能激活標(biāo)簽,相對應(yīng)讀寫器也讀取不了標(biāo)簽信息,聲光報(bào)警裝置進(jìn)行報(bào)警。所以就設(shè)定當(dāng)取值為空時(shí)報(bào)警器報(bào)警。
由于條件限制,讀卡距離較近,還不能很好的起到實(shí)時(shí)防盜的作用。但實(shí)驗(yàn)表明,此設(shè)計(jì)的電路運(yùn)行穩(wěn)定,讀寫數(shù)據(jù)準(zhǔn)確,操作時(shí)間較短,在理論上是完全可以實(shí)現(xiàn)的。



1、管理人員可以根據(jù)用戶名和密碼登錄超市防盜系統(tǒng)

2、讀寫器采集到數(shù)據(jù)后,將信息上傳給電腦管理中心。管理人員可以知道這箱貨物的名字、生產(chǎn)地、生廠商編號(hào)、數(shù)量和生產(chǎn)日期等基本信息,并寫入數(shù)據(jù)庫中。

3、當(dāng)激活器發(fā)射的信號(hào)不能激活標(biāo)簽,不能正常顯示出信息。相對應(yīng)讀寫器也讀取不了標(biāo)簽信息,聲光報(bào)警裝置進(jìn)行報(bào)警。



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.         /*****************屏蔽窗體右上角關(guān)閉按鈕******************/
  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.         /******************退出數(shù)據(jù)傳送窗口,返回到監(jiān)控窗口****************************/
  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.         /******************************將學(xué)生信息插入到數(shù)據(jù)庫中***************************************************/

  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("學(xué)生信息輸入不完整,請檢查準(zhǔn)確輸入");
  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("此學(xué)號(hào)在后臺(tái)數(shù)據(jù)庫中已經(jīng)存在,學(xué)號(hào)不能重復(fù),請重新輸入,注意只能輸入數(shù)字");
  82.                 return;
  83.             }

  84.             string dept = comboBox2.SelectedItem.ToString();    //學(xué)院
  85.             string spec = comboBox2.SelectedItem.ToString();    //專業(yè)
  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("添加學(xué)生信息成功!", "添加成功", 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("添加學(xué)生信息失敗!", "添加失敗", MessageBoxButtons.OK, MessageBoxIcon.Information);
  106.                     conn1.Close();
  107.                 }
  108.             }
  109.         }/*
  110.         /********************************************************************************************************/


  111.         /*********************************************當(dāng)前顯示*************************************/
  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, "串口設(shè)置操作出錯(cuò)!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  123.             }
  124.         }
  125.         /************************************************************************************************/


  126.         /**********************************獲取物品標(biāo)簽號(hào)***********************************************/

  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, "串口設(shè)置操作出錯(cuò)!", 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, "串口設(shè)置操作出錯(cuò)!", 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("獲取物品標(biāo)簽號(hào)失敗,請注意檢查!", "獲取物品標(biāo)簽失敗", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  161.             }
  162.         }
  163.         /***************************************************************************************/


  164.         /*********************************獲取主人標(biāo)簽號(hào)*********************************************/
  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, "串口設(shè)置操作出錯(cuò)!", 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, "串口設(shè)置操作出錯(cuò)!", 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("獲取主人標(biāo)簽號(hào)失敗,請注意檢查!", "獲取主人標(biāo)簽失敗", 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("當(dāng)前頁面數(shù)據(jù)表空,請先刷新顯示全部數(shù)據(jù),然后進(jìn)行操作。");
  208.                 return;
  209.             }
  210.             if (textBox1.Text.Length == 0)
  211.             {
  212.                 MessageBox.Show("商品名稱不能為空,請輸入準(zhǔn)確的廠商名稱!");
  213.                 return;
  214.             }
  215.             if (comboBox2.Text.Length == 0)
  216.             {
  217.                 MessageBox.Show("生產(chǎn)地不能為空,請輸入準(zhǔn)確的運(yùn)輸商名稱!");
  218.                 return;
  219.             }
  220.             if (textBox6.Text.Length == 0)
  221.             {
  222.                 MessageBox.Show("系統(tǒng)銷售商名稱不能為空,請輸入準(zhǔn)確的銷售商名稱!");
  223.                 return;
  224.             }
  225.             if (numericUpDown1.Text.Length == 0)
  226.             {
  227.                 MessageBox.Show("訂單日期名稱不能為空,請輸入準(zhǔn)確的銷售商名稱!");
  228.                 return;
  229.             }
  230.             if (dateTimePicker1.Text.Length == 0)
  231.             {
  232.                 MessageBox.Show("訂單數(shù)量不能為空,請輸入準(zhǔn)確的銷售商名稱!");
  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,'生產(chǎn)地'=Production,'生產(chǎn)商編號(hào)'=ProId,'購買數(shù)量'=Number,'生產(chǎn)日期'=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("數(shù)據(jù)新增完畢!");

  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黑下載附件…………
復(fù)制代碼






所有資料51hei提供下載:
便利超市的防盜系統(tǒng).rar (9.95 MB, 下載次數(shù): 107)


評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

10#
ID:546607 發(fā)表于 2020-5-20 15:23 | 只看該作者
用不了  別下  不聽的可以下載
回復(fù)

使用道具 舉報(bào)

9#
ID:503018 發(fā)表于 2020-4-8 12:00 | 只看該作者
感謝大佬的分享
回復(fù)

使用道具 舉報(bào)

8#
ID:137563 發(fā)表于 2020-2-19 15:58 | 只看該作者
不錯(cuò)的資料,收藏一下
回復(fù)

使用道具 舉報(bào)

7#
ID:421595 發(fā)表于 2019-12-16 08:17 | 只看該作者
學(xué)習(xí)一下
回復(fù)

使用道具 舉報(bào)

6#
ID:421595 發(fā)表于 2019-12-10 14:12 | 只看該作者
樓主:能不能給出全部,好讓小弟們學(xué)習(xí)學(xué)習(xí)呀
回復(fù)

使用道具 舉報(bào)

5#
ID:421595 發(fā)表于 2019-12-10 14:07 | 只看該作者
看看,學(xué)習(xí)一下
回復(fù)

使用道具 舉報(bào)

地板
ID:638731 發(fā)表于 2019-12-2 15:43 | 只看該作者
RFID設(shè)備用那種能說下嘛?
回復(fù)

使用道具 舉報(bào)

板凳
ID:642872 發(fā)表于 2019-11-16 14:11 | 只看該作者
大佬厲害了
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:554168 發(fā)表于 2019-6-3 21:26
能免費(fèi)嘛

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表