Exemplo n.º 1
0
        /// <summary>
        /// Add To List
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddToList(object sender, EventArgs e)
        {
            totalTimes++;//总次数

            TagView1 msg    = (TagView1)sender;
            bool     exists = false;

            foreach (ListViewItem lvi in lvCodes.Items)
            {
                if (lvi == null)
                {
                    continue;
                }
                if (msg.Userdata != "")
                {
                    if (msg.Userdata == lvi.SubItems[3].Text)
                    {
                        exists = true;
                        int ic = Convert.ToInt32(lvi.SubItems[0].Text);
                        ic += 1;
                        lvi.SubItems[0].Text = ic.ToString();
                        MessageBox.Show(ic.ToString());
                        if (msg.RSSI != "")
                        {
                            lvi.SubItems[4].Text = msg.RSSI;
                        }
                        break;
                    }
                }
                else if (msg.Epc != "" && msg.ID == "")
                {
                    if (lvi.SubItems[2].Text == msg.Epc)
                    {
                        exists = true;
                        int ic = Convert.ToInt32(lvi.SubItems[0].Text);
                        ic += 1;
                        lvi.SubItems[0].Text = ic.ToString();
                        if (msg.RSSI != "")
                        {
                            lvi.SubItems[4].Text = msg.RSSI;
                        }
                        break;
                    }
                }
                else
                {
                    if (lvi.SubItems[1].Text == msg.ID)
                    {
                        exists = true;
                        int ic = Convert.ToInt32(lvi.SubItems[0].Text);
                        ic += 1;
                        lvi.SubItems[0].Text = ic.ToString();
                        break;
                    }
                }
            }

            if (!exists)
            {
                try
                {
                    string[] arrayCodigo    = null;
                    string[] arrayResultado = null;
                    string   codigo         = null;
                    string   nombre         = null;
                    Dao.Dao  dao            = new Dao.Dao();


                    arrayCodigo = msg.Epc.Split(' ');
                    codigo      = arrayCodigo[2] + arrayCodigo[3][0] + arrayCodigo[3][1];
                    int lectura = (int)Int64.Parse(codigo, System.Globalization.NumberStyles.HexNumber);


                    string res = dao.getPersonaByUHFComedor(lectura.ToString());
                    arrayResultado = res.Split(',');
                    nombre         = arrayResultado[1];
                    ListViewItem lvi = new ListViewItem(new string[] { "1", msg.ID, nombre, msg.Epc, msg.Userdata, msg.RSSI.ToString() });
                    //strmsg = msg.Userdata
                    lvCodes.Items.Add(lvi);
                    lvCodes.EnsureVisible(lvCodes.Items.Count - 1);
                    readSnd.Set();
                    stopSearching();


                    FrInfo frInfo = new FrInfo(res);
                    frInfo.ShowDialog();

                    totalTags  = 1;
                    totalTimes = 1;
                }
                catch (Exception ex) {
                    MessageBox.Show("Lectura de tarjeta incorrecta!\n Tarjeta dañada o ajena al establecimiento");
                    stopSearching();
                }
            }
            totalTags    = lvCodes.Items.Count;//
            lblStat.Text = "Credenciales:" + lvCodes.Items.Count;
        }
Exemplo n.º 2
0
        private void CreateAndShowForm()
        {
            FrInfo frInfo = new FrInfo(this.res);

            frInfo.ShowDialog();
        }