Exemple #1
0
        // Inventory
        public void InventoryProc(string Msg, RFID_CALLBACK_TYPE Type)
        {
            // Memory modules of the Data from the tags and read through it runs so Callback delegate.
            if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA)
            {

                string strMsg = Msg.Split(',')[0].ToLower();
                string intRSSI = Msg.Split(',')[1].Split('=')[1];
                string strTag = txtDocNo.Text.ToLower();
                if (strTag == strMsg)
                {
                    //lblStatus.Text = "Found";
                    this.label1.Text = Convert.ToString(Convert.ToInt32((((Convert.ToDouble(intRSSI) + (100)) * 100) / (60))));
                    this.label1.Refresh();
                    this.txtSegment3.Text = Convert.ToString(Convert.ToInt32((((Convert.ToDouble(intRSSI) + (100)) * 100) / (60))));
                    this.Refresh();
                    if (Convert.ToInt16(label1.Text) >= 80)
                    {
                        Play_Sound_NOSTOP(@"\Windows\Voicbeep.wav");
                    }
                    else
                    {
                        Play_Sound_NOSTOP(@"\Windows\Success.wav");
                    }
                    
                }
                else
                {
                    //lblStatus.Text = "0";
                    //lblStatus.Text = "Not Found";
                }


            }
            // Run from the command module to receive the results of running Callback delegate.
            else if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_REPLY)
            {
                if (Msg.Equals("OK") || Msg.Equals("Multi Read Stop") || Msg.Equals(""))
                {
                    btnStatus = "Start";
                    //if (Msg.Equals("")){
                    //lblStatus.Text = "Not Found";
                    //}
                }
                else
                {
                    MessageBox.Show(Msg);
                    btnStatus = "Start";
                    label1.Text = "0";
                    txtSegment3.Text = "0";
                    //lblStatus.Text = "Not Found";
                }
            }
        }
 // Read/Write
 public void ReadWriteProc(string Msg, RFID_CALLBACK_TYPE Type)
 {
     //if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA)
     //{
     //    textBox2.Text = Msg;
     //    Play_Sound_NOSTOP(@"\Windows\Success.wav");
     //}
     //else
     //{
     //    if (!Msg.Equals("OK"))
     //    {
     //        MessageBox.Show(Msg, "Error");
     //    }
     //}
 }
 // Lock/Kill
 public void LockKillProc(string Msg, RFID_CALLBACK_TYPE Type)
 {
 }
        // Inventory
        public void InventoryProc(string Msg, RFID_CALLBACK_TYPE Type)
        {
            // Memory modules of the Data from the tags and read through it runs so Callback delegate.
            if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA)
            {

                string strMsg = Msg.Split(',')[0].ToLower();
                string intRSSI = Msg.Split(',')[1].Split('=')[1];
                var list = new List<string>();
                //string strMsgSub = strMsg.Substring(4);
                //strMsgSub = strMsgSub.ToString().Substring(0, 10);

                string strMsgSub = strMsg;
                if (strMsg.StartsWith("3000") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }
                if (strMsg.StartsWith("1800") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }
                if (strMsgSub.Length >= 10)
                {
                    strMsgSub = strMsgSub.ToString().Substring(0, 10);
                }

                foreach (string x in lists)
                {
                    if (x.Contains(strMsgSub))
                    {
                        lblAct.Text = Convert.ToString(Convert.ToInt16(lblAct.Text) + 1);
                        strInsert.Add(Convert.ToString(x + ",1"));
                        lists.Sort();
                        lists.Remove(x);
                        Play_Sound_NOSTOP(@"\Windows\Success.wav");

                        break;
                    }
                }

                if (FunctionENG.GetTagFileLost(strMsgSub) == true)
                {
                    MessageBox.Show(strMsgSub, "Found file lost", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                }
            }
            // Run from the command module to receive the results of running Callback delegate.
            else if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_REPLY)
            {
                if (Msg.Equals("OK") || Msg.Equals("Multi Read Stop") || Msg.Equals(""))
                {
                    btnStatus = "Start";
                    //if (Msg.Equals("")){
                    //lblStatus.Text = "Not Found";
                    //}
                }
                else
                {
                    MessageBox.Show(Msg);
                    btnStatus = "Start";

                    //lblStatus.Text = "Not Found";
                }
            }
        }
Exemple #5
0
        // Inventory
        public void InventoryProc(string Msg, RFID_CALLBACK_TYPE Type)
        {
            // Memory modules of the Data from the tags and read through it runs so Callback delegate.
            if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA)
            {

                string strMsg = Msg.Split(',')[0].ToLower();
                string intRSSI = Msg.Split(',')[1].Split('=')[1];
                var list = new List<string>();

                string strMsgSub = strMsg; //   .Substring(4);
                if (strMsg.StartsWith("3000") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }
                if (strMsg.StartsWith("1800") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }

                if (strMsgSub.Length >= 10)
                {
                    strMsgSub = strMsgSub.ToString().Substring(0, 10);
                }

                if (strInsert != null)
                {
                    int pos = strInsert.IndexOf(strMsgSub);

                    if (pos != -1)
                    {

                    }
                    else
                    {

                        lblAct.Text = Convert.ToString(Convert.ToInt16(lblAct.Text) + 1);
                        strInsert.Add(Convert.ToString(strMsgSub));

                        Play_Sound_NOSTOP(@"\Windows\Success.wav");
                    }

                }
                else
                {
                    strInsert.Add(Convert.ToString(strMsgSub));
                    Play_Sound_NOSTOP(@"\Windows\Success.wav");
                }
                //  string[] tmp  = list.ToArray();
                //strInsert = new List<string>(tmp);

            }
            // Run from the command module to receive the results of running Callback delegate.
            else if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_REPLY)
            {
                if (Msg.Equals("OK") || Msg.Equals("Multi Read Stop") || Msg.Equals(""))
                {
                    btnStatus = "Start";
                    //if (Msg.Equals("")){
                    //lblStatus.Text = "Not Found";
                    //}
                }
                else
                {
                    MessageBox.Show(Msg);
                    btnStatus = "Start";

                    //lblStatus.Text = "Not Found";
                }
            }
        }
        // Inventory
        public void InventoryProc(string Msg, RFID_CALLBACK_TYPE Type)
        {
            // Memory modules of the Data from the tags and read through it runs so Callback delegate.
            if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA)
            {
                string strMsg = Msg.Split(',')[0].ToLower();
                string intRSSI = Msg.Split(',')[1].Split('=')[1];
                string strMsgSub = strMsg;
                if (strMsg.StartsWith("3000") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }
                if (strMsg.StartsWith("1800") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }
                if (strMsgSub.Length >= 10)
                {
                    strMsgSub = strMsgSub.ToString().Substring(0, 10);
                }

                DataListDt.DefaultView.RowFilter = "tag_no='" + strMsgSub + "'";
                if (DataListDt.DefaultView.Count > 0) {
                    string p = Convert.ToString(Convert.ToInt32((((Convert.ToDouble(intRSSI) + (100)) * 100) / (60))));

                    int RowIndex = Convert.ToInt32(DataListDt.DefaultView[0]["RowIndex"]);
                    DataListDt.Rows[RowIndex]["percent"] = p;

                    Label lbl = new Label();
                    lbl = (Label)panel1.Controls[(RowIndex * 2) + 1];
                    lbl.Text = p;
                }
                DataListDt.DefaultView.RowFilter = "";
                Application.DoEvents();

                //if (DataListDt.Rows.Count > 0) {
                //    //panel1.Controls.Clear();
                //    btnPoint = 0;
                //    foreach (DataRow dr in DataListDt.Rows) {
                //        AddDataRow(dr["tag_no"].ToString(), dr["percent"].ToString());
                //    }
                //    Application.DoEvents();
                //}

                //string strMsgSub = strMsg;
                //if (strMsgSub.ToLower() == strTag.ToLower())
                //{
                //    //"Found";
                //    label1.Text = Convert.ToString(Convert.ToInt32((((Convert.ToDouble(intRSSI) + (100)) * 100) / (60))));
                //    if (Convert.ToInt16(label1.Text) >= Setting.intRssi)
                //    {
                //        if (Setting.blnSound)
                //        {
                //            Play_Sound_NOSTOP(@"\Windows\Fail.wav");
                //        }
                //    }
                //    else
                //    {
                //        if (Setting.blnSound)
                //        {
                //            Play_Sound_NOSTOP(@"\Windows\Success.wav");
                //        }
                //    }
                //}
                //else
                //{

                //}
            }
            // Run from the command module to receive the results of running Callback delegate.
            else if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_REPLY)
            {
                if (Msg.Equals("OK") || Msg.Equals("Multi Read Stop") || Msg.Equals(""))
                {
                    btnStatus = "Start";
                    //if (Msg.Equals("")){
                    //lblStatus.Text = "Not Found";
                    //}
                }
                else
                {
                    MessageBox.Show(Msg);
                    btnStatus = "Start";
                    //label1.Text = "0";
                    //lblStatus.Text = "Not Found";
                }
            }
        }
        // Inventory
        public void InventoryProc(string Msg, RFID_CALLBACK_TYPE Type)
        {
            // Memory modules of the Data from the tags and read through it runs so Callback delegate.
            if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA)
            {
                string strMsg = Msg.Split(',')[0].ToLower();
                string intRSSI = Msg.Split(',')[1].Split('=')[1];
                var list = new List<string>();
                string strMsgSub = strMsg;
                if (strMsg.StartsWith("3000") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }
                if (strMsg.StartsWith("1800") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }
                if (strMsgSub.Length >= 10)
                {
                    strMsgSub = strMsgSub.ToString().Substring(0, 10);
                }

                if (strMsgSub.Trim() != "")
                {
                    // strMsgSub = "1503000203";
                    //int icount = 1;
                    dt.DefaultView.RowFilter = "app_no='" + strMsgSub + "'";
                    if (dt.DefaultView.Count > 0)
                    {
                        string msg = "เลขที่แฟ้ม : " + dt.DefaultView[0]["app_no"] + "\n";
                        msg += "ผู้ยืม : " + dt.DefaultView[0]["borrowername"] + "\n";
                        msg += "วันที่ยืม : " + dt.DefaultView[0]["borrower_date"] + "\n";
                        msg += "สถานที่พบ : " + dt.DefaultView[0]["location_name"] + "";
                        MessageBox.Show(msg);

                        if (btnStatus.Equals("Stop"))
                            button1_Click(null, null);

                        return;
                    }
                    dt.DefaultView.RowFilter = "";

                    if (FunctionENG.GetTagFileLost(strMsgSub) == true)
                    {
                        MessageBox.Show(strMsgSub, "Found file lost", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                    }
                }

            }            // Run from the command module to receive the results of running Callback delegate.
            else if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_REPLY)
            {
                if (Msg.Equals("OK") || Msg.Equals("Multi Read Stop") || Msg.Equals(""))
                {
                    btnStatus = "Start";
                    //if (Msg.Equals("")){
                    //lblStatus.Text = "Not Found";
                    //}
                }
                else
                {
                    MessageBox.Show(Msg);
                    btnStatus = "Start";

                    //lblStatus.Text = "Not Found";
                }
            }
        }
        // Inventory
        public void InventoryProc(string Msg, RFID_CALLBACK_TYPE Type)
        {
            // Memory modules of the Data from the tags and read through it runs so Callback delegate.
            if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA)
            {
                string strMsg = Msg.Split(',')[0].ToLower();
                string strMsgSub = strMsg;
                try
                {
                    string intRSSI = Msg.Split(',')[1].Split('=')[1];
                    var list = new List<string>();

                    //Int32 rssi = Convert.ToInt32((((Convert.ToDouble(intRSSI) + (100)) * 100) / (60)));
                    //double chkPow = (rssi * 30) / 100;   //Power ที่อ่านได้
                    //if (Setting.Power >= chkPow) {
                    //    //ถ้าอ่านได้ค่า Power ต่ำกว่าที่ตั้งค่าไว้ ก็ไม่ต้องทำต่อ
                    //    return;
                    //}

            //                    strMsgSub = strMsg.Substring(4);
                    if (strMsg.StartsWith("3000") == true)
                    {
                        strMsgSub = strMsg.Substring(4);
                    }
                    else if (strMsg.StartsWith("1800") == true) {
                        strMsgSub = strMsg.Substring(4);
                    }

                    if (strMsgSub.Length >= 10)
                    {
                        strMsgSub = strMsgSub.ToString().Substring(0, 10);
                    }
                    if (dt.Columns.Count>0)
                    {
                        //int pos = strInsert.IndexOf(strMsgSub);

                        dt.DefaultView.RowFilter = "app_no='" + strMsgSub + "'";
                        if (dt.DefaultView.Count > 0)
                        {

                        }
                        else
                        {
                            lblAct.Text = Convert.ToString(Convert.ToInt16(lblAct.Text) + 1);
                            DataRow dr = dt.NewRow();
                            dr["app_no"] = Convert.ToString(strMsgSub);
                            dt.Rows.Add(dr);
                            //strInsert.Add(Convert.ToString(strMsgSub));

                            Play_Sound_NOSTOP(@"\Windows\Success.wav");
                        }
                        dt.DefaultView.RowFilter = "";
                    }
                    else
                    {
                        dt.Columns.Add("app_no");

                        DataRow dr = dt.NewRow();
                        dr["app_no"] = Convert.ToString(strMsgSub);

                        dt.Rows.Add(dr);
                        //strInsert.Add(Convert.ToString(strMsgSub));
                        Play_Sound_NOSTOP(@"\Windows\Success.wav");
                        lblAct.Text = "1";

                    }
                    dt.AcceptChanges();
                    dgView.DataSource = dt;

                    Application.DoEvents();

                    if (FunctionENG.GetTagFileLost(strMsgSub) == true)
                    {
                        MessageBox.Show(strMsgSub, "Found file lost", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                    }
                }
                catch
                {
                }

                if (FunctionENG.GetTagFileLost(strMsgSub) == true)
                {
                    MessageBox.Show(strMsgSub, "Found file lost", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                }
            }
            // Run from the command module to receive the results of running Callback delegate.
            else if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_REPLY)
            {
                if (Msg.Equals("OK") || Msg.Equals("Multi Read Stop") || Msg.Equals(""))
                {
                    btnStatus = "Start";
                    //if (Msg.Equals("")){
                    //lblStatus.Text = "Not Found";
                    //}
                }
                else
                {
                    MessageBox.Show(Msg);
                    btnStatus = "Start";

                    //lblStatus.Text = "Not Found";
                }
            }
        }
        // Inventory
        public void InventoryProc(string Msg, RFID_CALLBACK_TYPE Type)
        {
            // Memory modules of the Data from the tags and read through it runs so Callback delegate.
            if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA && txtfound =="false")
            {
                string strMsg = Msg.Split(',')[0].ToLower();
                string intRSSI = Msg.Split(',')[1].Split('=')[1];
                var list = new List<string>();
                string strMsgSub = strMsg;
                if (strMsg.StartsWith("3000") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }
                if (strMsg.StartsWith("1800") == true)
                {
                    strMsgSub = strMsg.Substring(4);
                }

                if (strMsgSub.Length >= 10)
                {
                    strMsgSub = strMsgSub.ToString().Substring(0, 10);
                }

                // strMsgSub = "1503000203";
                int icount = 1;
                lists.DefaultView.RowFilter = "app_no='" + strMsgSub + "'";
                if (lists.DefaultView.Count > 0) {
                    txtfound = "true";
                    if (dtFound.Columns.Count == 0)
                    {
                        getDatatableFound();
                    }

                    dtFound.DefaultView.RowFilter = "หมายเลขแฟ้ม='" + strMsgSub + "'"; //ถ้าเป็นแฟ้มที่เคยเจอแล้ว ไม่ต้องหาซ้ำอีก
                    if (dtFound.DefaultView.Count == 0)
                    {
                        string x = strMsgSub;
                        //lblStatus.Text = "Found";
                        label1.Text = Convert.ToString(Convert.ToInt32((((Convert.ToDouble(intRSSI) + (100)) * 100) / (60))));
                        if (Convert.ToInt16(label1.Text) >= Setting.intRssi)
                        {
                            if (Setting.blnSound)
                            {
                                Play_Sound_NOSTOP(@"\Windows\Fail.wav");
                            }
                        }
                        else
                        {
                            if (Setting.blnSound)
                            {
                                Play_Sound_NOSTOP(@"\Windows\Success.wav");
                            }
                        }

                        //if (Convert.ToInt32(label1.Text) >= Setting.intRssi)
                        //{
                            //ไม่ต้องเช็ค RSSI

                        if (MessageBox.Show(x, "ยืนยันการเจอแฟ้ม?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        {
                            lblAct.Text = Convert.ToString(Convert.ToInt16(lblAct.Text) + 1);
                            strInsert.Add(Convert.ToString(x + ",1"));
                            Play_Sound_NOSTOP(@"\Windows\Success.wav");
                            //#### datatable found #####

                            DataRow drFound = dtFound.NewRow();
                            drFound["ลำดับ"] = dtFound.Rows.Count + 1; ;
                            drFound["หมายเลขแฟ้ม"] = x;
                            dtFound.Rows.Add(drFound);

                            loadDatatoGrid(1);
                            //#########################
                            //break;
                            txtfound = "false";
                        }
                        else {
                            txtfound = "false";
                        }
                        //}
                    }
                    dtFound.DefaultView.RowFilter = "";
                }

                if (FunctionENG.GetTagFileLost(strMsgSub) == true)
                {
                    MessageBox.Show(strMsgSub, "Found file lost", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                }

                //foreach (DataRow x in lists.Rows)
                //{
                //    if (x["app_no"].ToString().Contains(strMsgSub))
                //    {

                //    }

                //}

            }            // Run from the command module to receive the results of running Callback delegate.
            else if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_REPLY)
            {
                if (Msg.Equals("OK") || Msg.Equals("Multi Read Stop") || Msg.Equals(""))
                {
                    btnStatus = "Start";
                    //if (Msg.Equals("")){
                    //lblStatus.Text = "Not Found";
                    //}
                }
                else
                {
                    MessageBox.Show(Msg);
                    btnStatus = "Start";

                    //lblStatus.Text = "Not Found";
                }
            }
        }
        // Inventory
        public void InventoryProc(string Msg, RFID_CALLBACK_TYPE Type)
        {
            // Memory modules of the Data from the tags and read through it runs so Callback delegate.
            if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_DATA)
            {
                string strMsg = Msg.Split(',')[0].ToLower();
                string intRSSI = Msg.Split(',')[1].Split('=')[1];
               // string strTag = txtDocNo.Text.ToLower();
                //string strSegment = txtSegment3.Text;
                //if (strSegment != "" && strSegment != string.Empty)
                //{
                //    strSegment = "-" + strSegment;
                //}
                string strHex = txtDocNo.Text; // strToHex(comboBox1.SelectedItem + txtDocNo.Text + strSegment);
                string strMsgSub = strHex;//strMsg.Substring(0, 10);//strMsg;
                //string strCheck = strMsg.IndexOf(strHex).ToString;
                int ckblenght = strHex.Length;
              //  if (1 == 0)
                if (ckblenght < 10)

                {
                   // label1.Text = "Not Found";
                   // MessageBox.Show(strHex, "Please input 10 digit", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                }
                else {

                    int first = strMsg.IndexOf(strHex) + "".Length;
                    //if (strMsgSub.ToLower() == strTag.ToLower())
                    if (first != -1)
                    {
                        //lblStatus.Text = "Found";
                        label1.Text = Convert.ToString(Convert.ToInt32((((Convert.ToDouble(intRSSI) + (100)) * 100) / (60))));
                        if (Convert.ToInt16(label1.Text) >= Setting.intRssi)
                        {
                            if (Setting.blnSound)
                            {
                                Play_Sound_NOSTOP(@"\Windows\Fail.wav");
                            }
                        }
                        else
                        {
                            if (Setting.blnSound)
                            {
                                Play_Sound_NOSTOP(@"\Windows\Success.wav");
                            }
                        }

                        if (FunctionENG.GetTagFileLost(strMsgSub) == true)
                        {
                            MessageBox.Show(strMsgSub, "Found file lost", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                        }
                    }
                    else
                    {
                        //lblStatus.Text = "0";
                        //lblStatus.Text = "Not Found";
                    }
                }
            }
            // Run from the command module to receive the results of running Callback delegate.
            else if (Type == RFID_CALLBACK_TYPE.RFIDCALLBACKTYPE_REPLY)
            {
                if (Msg.Equals("OK") || Msg.Equals("Multi Read Stop") || Msg.Equals(""))
                {
                    btnStatus = "Start";
                    //if (Msg.Equals("")){
                    //lblStatus.Text = "Not Found";
                    //}

                }
                else
                {
                    MessageBox.Show(Msg);
                    btnStatus = "Start";
                    label1.Text = "0";
                    //lblStatus.Text = "Not Found";
                }
            }
        }