void StaticSerialPort_evtParseReceivedData_frmSelect(ProtocolHelper helper) { deleControlInvoke dele = delegate(object o) { ProtocolHelper p = (ProtocolHelper)o; DataRow[] rows = null; DataRow[] rowsMap = null; int totalCount = this.studentInfoTable.Rows.Count; // int totalCount = this.infoTable.Rows.Count; //rows = this.infoTable.Select("equipmentID = '" + data.equipmentID + "'"); rows = this.studentInfoTable.Select("STUDENTID = '" + p.epcID + "'"); rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + p.remoteDeviceID + "'"); string studentName = string.Empty; if (rows.Length > 0 && rowsMap.Length > 0) { string answer = p.questionValue; int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString()); studentName = (string)rows[0]["NAME"]; Carbinet _carbinet = this.groups[groupIndex]; _carbinet.setDocText(p.remoteDeviceID, studentName); //这里要处理一下同一个学生用不一个设备发送答案的情况 DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + p.epcID + "'"); if (rowsForDuplicate.Length > 0) //说明已经有过对应 { if (((string)rowsForDuplicate[0]["EQUIPEMNTID"]) != p.remoteDeviceID) //根据设备和根据学号找的记录不一样,肯定有重复 { int groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString()); Carbinet _carbinet2 = this.groups[groupIndex2]; _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], (Image)global::Carbinet.Properties.Resources.grey); _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], ""); rowsForDuplicate[0]["studenID"] = ""; } } rowsMap[0]["studenID"] = p.epcID; if (answer == "A") { rows[0]["answer"] = "A"; // _carbinet.setDocBGColor(data.equipmentID, this.clrA); _carbinet.setDocBGImage(p.remoteDeviceID, (Image)global::Carbinet.Properties.Resources.yellow); } if (answer == "B") { _carbinet.setDocBGImage(p.remoteDeviceID, (Image)global::Carbinet.Properties.Resources.orange); rows[0]["answer"] = "B"; } if (answer == "C") { rows[0]["answer"] = "C"; _carbinet.setDocBGImage(p.remoteDeviceID, (Image)global::Carbinet.Properties.Resources.blue); //_carbinet.setDocBGColor(data.equipmentID, this.clrC); } if (answer == "D") { rows[0]["answer"] = "D"; _carbinet.setDocBGImage(p.remoteDeviceID, (Image)global::Carbinet.Properties.Resources.purple); //_carbinet.setDocBGColor(data.equipmentID, this.clrD); } DataRow[] rowsA = this.studentInfoTable.Select("answer = 'A'"); DataRow[] rowsB = this.studentInfoTable.Select("answer = 'B'"); DataRow[] rowsC = this.studentInfoTable.Select("answer = 'C'"); DataRow[] rowsD = this.studentInfoTable.Select("answer = 'D'"); int iA = rowsA.Length; int iB = rowsB.Length; int iC = rowsC.Length; int iD = rowsD.Length; int iUnknown = totalCount - iA - iB - iC - iD; m_panelDrawing.Values = new decimal[] { iUnknown, iA, iB, iC, iD }; string strA = "", strB = "", strC = "", strD = "", strUnknown = ""; if (iUnknown > 0) { strUnknown = (iUnknown * 100 / totalCount).ToString() + "%"; } if (iA > 0) { strA = (iA * 100 / totalCount).ToString() + "%"; } if (iB > 0) { strB = (iB * 100 / totalCount).ToString() + "%"; } if (iC > 0) { strC = (iC * 100 / totalCount).ToString() + "%"; } if (iD > 0) { strD = (iD * 100 / totalCount).ToString() + "%"; } m_panelDrawing.Texts = new string[] { strUnknown, strA, strB, strC, strD }; } }; this.Invoke(dele, helper); }
void StaticSerialPort_evtParseReceivedData(ProtocolHelper helper) { deleControlInvoke dele = delegate(object o) { ProtocolHelper _helper = (ProtocolHelper)o; string epcID = _helper.epcID; string remoteDeviceID = _helper.remoteDeviceID; //更新考勤信息 DataRow[] rows = null; //rows = this.checkTable.Select("equipmentID = '" + data.equipmentID + "'"); //根据接收到的信息,首先将学生出勤状态置为 1,之后将控件的显示状态改为绿色 rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); string studentName = string.Empty; if (rows.Length > 0) { rows[0]["status"] = "1"; rows[0]["checkTime"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); studentName = (string)rows[0]["NAME"]; } //处理多次考勤情况 rows = this.mapConfigsTable.Select("studenID = '" + epcID + "'"); if (rows.Length > 0)//至少第二次考勤 { //此时需要将之前设为考勤状态的位置变回未考勤状态 int groupIndex = int.Parse(rows[0]["IGROUP"].ToString()); Carbinet _carbinet = this.groups[groupIndex]; _carbinet.setDocBGImage((string)rows[0]["EQUIPEMNTID"], (Image)global::Carbinet.Properties.Resources.grey); _carbinet.setDocText((string)rows[0]["EQUIPEMNTID"], ""); rows[0]["studenID"] = ""; } //rows = this.checkTable.Select("equipmentID = '" + data.equipmentID + "'"); rows = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'"); if (rows.Length > 0) { rows[0]["studenID"] = epcID; int groupIndex = int.Parse(rows[0]["IGROUP"].ToString()); //界面展示 Carbinet _carbinet = this.groups[groupIndex]; //_carbinet.setDocBGColor(data.equipmentID, Color.Green); _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.orange); _carbinet.setDocText(remoteDeviceID, studentName); rows = this.studentInfoTable.Select("status = '1'"); int checkedCount = rows.Length; int uncheckedCount = this.studentInfoTable.Rows.Count - checkedCount; Debug.WriteLine( string.Format("Form1.updateStatus -> checked = {0} unchecked = {1}" , checkedCount, uncheckedCount)); m_panelDrawing.Values = new decimal[] { uncheckedCount, checkedCount }; string strchecked = "", strUnchecked = ""; if (checkedCount > 0) { strchecked = (checkedCount / (checkedCount + uncheckedCount)).ToString() + "%"; } if (uncheckedCount > 0) { strUnchecked = (uncheckedCount / (checkedCount + uncheckedCount)).ToString() + "%"; } m_panelDrawing.ToolTips = new string[] { "缺勤:" + uncheckedCount.ToString(), "出勤:" + checkedCount.ToString() }; } }; this.Invoke(dele, helper); //throw new NotImplementedException(); }