Exemplo n.º 1
0
 private void DataGridRecord_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     _selectedRecords = new List <tlsTtResultSecond>();
     for (int i = 0; i < DataGridRecord.SelectedItems.Count; i++)
     {
         clsATP            model  = (clsATP)DataGridRecord.SelectedItems[i];
         tlsTtResultSecond record = new tlsTtResultSecond();
         record.CheckUnitInfo  = record.Organizer = model.Atp_CheckName;
         record.CheckValueInfo = model.Atp_RLU;
         String str = model.Atp_Result;
         if (str.Equals("通过"))
         {
             str = "合格";
         }
         else if (str.Equals("超标"))
         {
             str = "不合格";
         }
         else
         {
             str = "合格";//不上传
         }
         CheckPointInfo CPoint = Global.samplenameadapter[0];
         record.CheckPlace     = CPoint.pointName;
         record.CheckPlaceCode = CPoint.orgNum;
         record.Result         = str;
         record.ResultType     = record.CheckMethod = "ATP";
         record.CheckStartDate = model.Atp_CheckData;
         record.CheckMachine   = "手持式 ATP 荧光检测仪";
         record.CheckNo        = DateTime.Now.ToString("yyyyMMddHHmmss");
         if (!str.Equals("警告"))
         {
             _selectedRecords.Add(record);
         }
     }
 }
Exemplo n.º 2
0
        private void ReadData()
        {
            try
            {
                //获取总数据数
                count = GetCount();
                int leny = 0, lenz = 0, index = 0;
                _atpLsit = new List <clsATP>();
                if (count > 0)
                {
                    //每条数据三条记录,取余
                    lenz = count % 3;
                    if (count >= 3)
                    {
                        leny = count / 3;
                    }
                    else
                    {
                        leny = count;
                    }
                    if (lenz > 0)
                    {
                        leny++;
                    }
                    for (int i = 0; i < leny; i++)
                    {
                        String cmd = Global.ATP.GetCmd(index), str = string.Empty;
                        index += 3;
                        byte[] data = ReadAndWriteToDevice(cmd);
                        if (data[0] == 0xff && data[2] == 0x31 && data[3] == 0x01)
                        {
                            i--;
                            continue;
                            //count = (data[4] << 8) | data[5];
                        }
                        List <byte[]> dataList = Global.ATP.GetByteList(data);
                        if (dataList.Count > 0)
                        {
                            for (int j = 0; j < dataList.Count; j++)
                            {
                                byte[] btlist = dataList[j];
                                clsATP model  = new clsATP()
                                {
                                    Atp_CheckName = LoginWindow._userAccount.UserName
                                };
                                String strC = string.Empty, str1 = btlist[1].ToString("X2"), str2 = btlist[2].ToString("X2"), str3 = btlist[3].ToString("X2");
                                if (!str1.Equals("00") && !str1.Equals("FE"))
                                {
                                    strC += str1;
                                }
                                if (!str2.Equals("00"))
                                {
                                    strC += str2;
                                }
                                if (!str3.Equals("00"))
                                {
                                    strC += str3;
                                }
                                if (strC.Equals(string.Empty))
                                {
                                    strC = "0";
                                }

                                model.Atp_RLU   = Int32.Parse(strC, System.Globalization.NumberStyles.HexNumber).ToString();
                                model.Atp_Upper = Convert.ToString((btlist[14] + btlist[15]), 10);
                                model.Atp_Lower = Convert.ToString((btlist[16]), 10);
                                if (int.Parse(model.Atp_RLU, 0) > int.Parse(model.Atp_Upper, 0))
                                {
                                    str = "超标";
                                }
                                else if (int.Parse(model.Atp_RLU, 0) < int.Parse(model.Atp_Lower, 0))
                                {
                                    str = "警告";
                                }
                                else if (int.Parse(model.Atp_RLU, 0) >= int.Parse(model.Atp_Lower, 0) && int.Parse(model.Atp_RLU, 0) <= int.Parse(model.Atp_Upper, 0))
                                {
                                    str = "通过";
                                }
                                model.Atp_Result    = str;
                                model.Atp_CheckData = "20" + Convert.ToString(btlist[5], 10) + "-"
                                                      + int.Parse(Convert.ToString(btlist[6], 10)).ToString("D2")
                                                      + "-" + int.Parse(Convert.ToString(btlist[7], 10)).ToString("D2");
                                //model.Atp_CheckTime = int.Parse(Convert.ToString(btlist[8], 10)).ToString("D2") + ":"
                                //    + int.Parse(Convert.ToString(btlist[9], 10)).ToString("D2")
                                //    + ":" + int.Parse(Convert.ToString(btlist[17], 10)).ToString("D2");
                                model.Atp_CheckData += " " + int.Parse(Convert.ToString(btlist[8], 10)).ToString("D2") + ":"
                                                       + int.Parse(Convert.ToString(btlist[9], 10)).ToString("D2")
                                                       + ":" + int.Parse(Convert.ToString(btlist[17], 10)).ToString("D2");
                                if (btlist[5] != 0)
                                {
                                    _atpLsit.Add(model);
                                }
                            }
                        }
                    }
                    if (_atpLsit.Count > 0)
                    {
                        _atpLsit.Sort(delegate(clsATP x, clsATP y)
                        {
                            return(y.Atp_CheckData.CompareTo(x.Atp_CheckData));
                        });
                        this.DataGridRecord.DataContext = _atpLsit;
                        _isRead = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }