//void disposeReceivedData(Data data) //{ // this.Invoke(new deleControlInvoke(this.updateStatus), data); //} //private void updateStatus(object o) //{ // Data data = (Data)o; // if (data.key == ((int)Mode.单选).ToString()) // { // 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 = '" + data.tagID + "'"); // rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + data.equipmentID + "'"); // string studentName = string.Empty; // if (rows.Length > 0 && rowsMap.Length > 0) // { // string answer = data.value; // int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString()); // studentName = (string)rows[0]["NAME"]; // Carbinet _carbinet = this.groups[groupIndex]; // _carbinet.setDocText(data.equipmentID, studentName); // //这里要处理一下同一个学生用不一个设备发送答案的情况 // DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + data.tagID + "'"); // if (rowsForDuplicate.Length > 0)//说明已经有过对应 // { // if (((string)rowsForDuplicate[0]["EQUIPEMNTID"]) != data.equipmentID)//根据设备和根据学号找的记录不一样,肯定有重复 // { // int groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString()); // Carbinet _carbinet2 = this.groups[groupIndex2]; // _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], (Image)global::Carbinet.Properties.Resources.yellow); // _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], ""); // rowsForDuplicate[0]["studenID"] = ""; // } // } // rowsMap[0]["studenID"] = data.tagID; // if (answer == "A") // { // rows[0]["answer"] = "A"; // // _carbinet.setDocBGColor(data.equipmentID, this.clrA); // _carbinet.setDocBGImage(data.equipmentID, (Image)global::Carbinet.Properties.Resources.red); // } // if (answer == "B") // { // _carbinet.setDocBGImage(data.equipmentID, (Image)global::Carbinet.Properties.Resources.orange); // rows[0]["answer"] = "B"; // } // if (answer == "C") // { // rows[0]["answer"] = "C"; // _carbinet.setDocBGImage(data.equipmentID, (Image)global::Carbinet.Properties.Resources.blue); // //_carbinet.setDocBGColor(data.equipmentID, this.clrC); // } // if (answer == "D") // { // rows[0]["answer"] = "D"; // _carbinet.setDocBGImage(data.equipmentID, (Image)global::Carbinet.Properties.Resources.pink); // //_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 }; // //if (totalCount > 0) // //{ // // m_panelDrawing.ToolTips = new string[] { // // string.Format("尚未选择:{0}%",iUnknown*100/totalCount), // // string.Format("选择A:{0}%",(iA*100/totalCount)), // // string.Format("选择B:{0}%",(iB*100/totalCount)), // // string.Format( "选择C:{0}%",(iC*100/totalCount)), // // string.Format("选择D:{0}%",(iD*100/totalCount))}; // //} // //else // //{ // // m_panelDrawing.ToolTips = new string[] { "尚未选择", // // "选择A","选择B","选择C","选择D"}; // //} // } // } //} void clearSelectStatus() { for (int i = 0; i < this.mapConfigsTable.Rows.Count; i++) { DataRow dr = this.mapConfigsTable.Rows[i]; int groupIndex = int.Parse(dr["IGROUP"].ToString()); //界面展示 if (groupIndex < this.groups.Count)//由于有多种教师效果图,因此数据库可能保存了多余的配置,而当前可能没有用到这些多余的配置 { Carbinet _carbinet = this.groups[groupIndex]; _carbinet.setDocBGImage((string)dr["EQUIPEMNTID"], global::Carbinet.Properties.Resources.grey); _carbinet.setDocText((string)dr["EQUIPEMNTID"], ""); } //_carbinet.setDocBGColor((string)dr["equipmentID"], this.clrNotKnown); } m_panelDrawing.Values = new decimal[] { this.studentInfoTable.Rows.Count, 0, 0, 0, 0 }; m_panelDrawing.Texts = new string[] { "100%", "", "", "", "" }; for (int i = 0; i < this.studentInfoTable.Rows.Count; i++) { studentInfoTable.Rows[i]["answer"] = "A";//默认都选A,也就是不选择 } }
void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { deleControlInvoke dele = delegate(object o) { IntelligentEvent p = (IntelligentEvent)o; string epcID = p.epcID; string remoteDeviceID = p.remoteDeviceID; string check_time = p.time_stamp; string studentName = string.Empty; DataRow[] rows = null; bool bRefresh_ui = false; if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0)//重复考勤 { //考勤数据不需要更新,但是显示页面需要更新 rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); if (rows.Length > 0) { rows[0]["status"] = "1"; rows[0]["checkTime"] = check_time; 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"] = ""; } bRefresh_ui = true; } if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0)//第一次考勤 { //处理该事件需要更新学生考勤数据和显示页面 //更新考勤信息 //rows = this.checkTable.Select("equipmentID = '" + data.equipmentID + "'"); //根据接收到的信息,首先将学生出勤状态置为 1,之后将控件的显示状态改为绿色 if (string.Compare(this.dtStart, check_time) <= 0) { rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); if (rows.Length > 0) { rows[0]["status"] = "1"; rows[0]["checkTime"] = check_time; studentName = (string)rows[0]["NAME"]; } bRefresh_ui = true; } } if (bRefresh_ui == true) { 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() + "%"; } } } }; this.Invoke(dele, evt); } }
void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { deleControlInvoke dele = delegate(object o) { IntelligentEvent p = (IntelligentEvent)o; string epcID = p.epcID; string remoteDeviceID = p.remoteDeviceID; string check_time = p.time_stamp; string studentName = string.Empty; string question_value = p.questionValue; DataRow[] rows = null; DataRow[] rowsMap = null; DataRow[] rowsUnknown = null; int totalCount = this.studentInfoTable.Rows.Count; //如果只是重复发送,不需要做什么 if (p.event_unit_list.IndexOf(IntelligentEventUnit.repeat_epc) >= 0) { //如果重复发送之外,还改变了设备的ID if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0) { rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'"); if (rows.Length > 0 && rowsMap.Length > 0) { string answer = question_value; int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString()); studentName = (string)rows[0]["NAME"]; Carbinet _carbinet = this.groups[groupIndex]; _carbinet.setDocText(remoteDeviceID, studentName); //这里要处理一下同一个学生用不一个设备发送答案的情况 // 根据就是每一次客户端发送信息时,服务端都要把发送过来的标签和设备重新绑定一次 // 如果之前绑定过并且和现在的不同,则说明该标签之前用别的设备发送过信息 DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + epcID + "'"); if (rowsForDuplicate.Length > 0)//说明已经有过对应,将原来设置的回答状态和学生姓名从座位上去掉 { //if (((string)rowsForDuplicate[0]["EQUIPEMNTID"]) != remoteDeviceID)//根据设备和根据学号找的记录不一样,肯定有重复 { int groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString()); Carbinet _carbinet2 = this.groups[groupIndex2]; _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], imgNormal); _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], ""); rowsForDuplicate[0]["studenID"] = ""; } } rowsMap[0]["studenID"] = epcID; //这里把设备和标签绑定到一起 _carbinet.setDocBGImage(remoteDeviceID, imgAnswered); _carbinet.setDocText(remoteDeviceID, question_value); //在座位上显示答案 } } //如果重复发送之外,还改变了问题的答案 if (p.event_unit_list.IndexOf(IntelligentEventUnit.change_answer) >= 0) { rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); if (rows.Length > 0) { rows[0]["answer"] = question_value; } //更新答题记录 rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = {1}", epcID, current_question_id)); if (rows.Length > 0) { rows[0]["answer"] = question_value; } else { dtQuestion_answer_record.Rows.Add(new object[3] { epcID, current_question_id, question_value }); } } } else if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0) { //处理该事件需要更新数据和显示页面 rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'"); if (rows.Length > 0 && rowsMap.Length > 0) { string answer = question_value; int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString()); studentName = (string)rows[0]["NAME"]; Carbinet _carbinet = this.groups[groupIndex]; //_carbinet.setDocText(remoteDeviceID, studentName);//在座位上显示学生名字 _carbinet.setDocText(remoteDeviceID, question_value); //在座位上显示答案 rowsMap[0]["studenID"] = epcID; //这里把设备和标签绑定到一起 _carbinet.setDocBGImage(remoteDeviceID, imgAnswered); rows[0]["answer"] = question_value; /* * if (answer == "A") * { * rows[0]["answer"] = "A"; * // _carbinet.setDocBGColor(data.equipmentID, this.clrA); * //_carbinet.setDocBGImage(data.equipmentID, imgA); * } * if (answer == "B") * { * //_carbinet.setDocBGImage(data.equipmentID, imgB); * rows[0]["answer"] = "B"; * } * if (answer == "C") * { * rows[0]["answer"] = "C"; * //_carbinet.setDocBGImage(data.equipmentID, imgC); * //_carbinet.setDocBGColor(data.equipmentID, this.clrC); * } * if (answer == "D") * { * rows[0]["answer"] = "D"; * //_carbinet.setDocBGImage(data.equipmentID, imgD); * //_carbinet.setDocBGColor(data.equipmentID, this.clrD); * } * //*/ //设置饼图 rowsUnknown = this.studentInfoTable.Select("answer = ''"); int iUnknown = rowsUnknown.Length; int iAnswered = totalCount - iUnknown; string strUnknown = iUnknown.ToString(); string strAnswered = iAnswered.ToString(); m_panelDrawing.Values = new decimal[] { iUnknown, iAnswered }; m_panelDrawing.Texts = new string[] { iUnknown.ToString(), iAnswered.ToString() }; } //更新答题记录 rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = '{1}'", epcID, current_question_id)); if (rows.Length > 0) { rows[0]["answer"] = question_value; } else { dtQuestion_answer_record.Rows.Add(new object[3] { epcID, current_question_id, question_value }); } } //switch (p.name) //{ // case IntelligentEvent.class_question_repeat_answer: // //考勤数据和显示页面都不需要更新, // break; // case IntelligentEvent.class_question_new_answer: // //处理该事件需要更新数据和显示页面 // rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); // rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'"); // if (rows.Length > 0 && rowsMap.Length > 0) // { // string answer = question_value; // int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString()); // studentName = (string)rows[0]["NAME"]; // Carbinet _carbinet = this.groups[groupIndex]; // _carbinet.setDocText(remoteDeviceID, studentName); // rowsMap[0]["studenID"] = epcID;//这里把设备和标签绑定到一起 // _carbinet.setDocBGImage(remoteDeviceID, imgAnswered); // ///* // if (answer == "A") // { // rows[0]["answer"] = "A"; // // _carbinet.setDocBGColor(data.equipmentID, this.clrA); // //_carbinet.setDocBGImage(data.equipmentID, imgA); // } // if (answer == "B") // { // //_carbinet.setDocBGImage(data.equipmentID, imgB); // rows[0]["answer"] = "B"; // } // if (answer == "C") // { // rows[0]["answer"] = "C"; // //_carbinet.setDocBGImage(data.equipmentID, imgC); // //_carbinet.setDocBGColor(data.equipmentID, this.clrC); // } // if (answer == "D") // { // rows[0]["answer"] = "D"; // //_carbinet.setDocBGImage(data.equipmentID, imgD); // //_carbinet.setDocBGColor(data.equipmentID, this.clrD); // } // //*/ // //设置饼图 // rowsUnknown = this.studentInfoTable.Select("answer = ''"); // int iUnknown = rowsUnknown.Length; // int iAnswered = totalCount - iUnknown; // string strUnknown = iUnknown.ToString(); // string strAnswered = iAnswered.ToString(); // m_panelDrawing.Values = new decimal[] { iUnknown, iAnswered }; // m_panelDrawing.Texts = new string[] { iUnknown.ToString(), iAnswered.ToString() }; // } // //更新答题记录 // rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = '{1}'", epcID, current_question_id)); // if (rows.Length > 0) // { // rows[0]["answer"] = question_value; // } // else // { // dtQuestion_answer_record.Rows.Add(new object[3] { epcID, current_question_id, question_value }); // } // break; // case IntelligentEvent.class_question_repeat_answer_on_another_device: // //数据不需要更新,但是显示页面需要更新 // rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); // rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'"); // if (rows.Length > 0 && rowsMap.Length > 0) // { // string answer = question_value; // int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString()); // studentName = (string)rows[0]["NAME"]; // Carbinet _carbinet = this.groups[groupIndex]; // _carbinet.setDocText(remoteDeviceID, studentName); // //这里要处理一下同一个学生用不一个设备发送答案的情况 // // 根据就是每一次客户端发送信息时,服务端都要把发送过来的标签和设备重新绑定一次 // // 如果之前绑定过并且和现在的不同,则说明该标签之前用别的设备发送过信息 // DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + epcID + "'"); // if (rowsForDuplicate.Length > 0)//说明已经有过对应 // { // //if (((string)rowsForDuplicate[0]["EQUIPEMNTID"]) != remoteDeviceID)//根据设备和根据学号找的记录不一样,肯定有重复 // { // int groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString()); // Carbinet _carbinet2 = this.groups[groupIndex2]; // _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], imgNormal); // _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], ""); // rowsForDuplicate[0]["studenID"] = ""; // } // } // rowsMap[0]["studenID"] = epcID;//这里把设备和标签绑定到一起 // _carbinet.setDocBGImage(remoteDeviceID, imgAnswered); // } // break; // case IntelligentEvent.class_question_change_answer: // rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); // if (rows.Length > 0) // { // string answer = question_value; // ///* // if (answer == "A") // { // rows[0]["answer"] = "A"; // } // if (answer == "B") // { // rows[0]["answer"] = "B"; // } // if (answer == "C") // { // rows[0]["answer"] = "C"; // } // if (answer == "D") // { // rows[0]["answer"] = "D"; // } // } // //更新答题记录 // rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = {1}", epcID, current_question_id)); // if (rows.Length > 0) // { // rows[0]["answer"] = question_value; // } // else // { // dtQuestion_answer_record.Rows.Add(new object[3] { epcID, current_question_id, question_value }); // } // break; // case IntelligentEvent.class_question_change_answer_on_another_device: // rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); // rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'"); // if (rows.Length > 0 && rowsMap.Length > 0) // { // string answer = question_value; // int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString()); // studentName = (string)rows[0]["NAME"]; // Carbinet _carbinet = this.groups[groupIndex]; // _carbinet.setDocText(remoteDeviceID, studentName); // //这里要处理一下同一个学生用不一个设备发送答案的情况 // // 根据就是每一次客户端发送信息时,服务端都要把发送过来的标签和设备重新绑定一次 // // 如果之前绑定过并且和现在的不同,则说明该标签之前用别的设备发送过信息 // DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + epcID + "'"); // if (rowsForDuplicate.Length > 0)//说明已经有过对应 // { // int groupIndex2 = int.Parse(rowsForDuplicate[0]["IGROUP"].ToString()); // Carbinet _carbinet2 = this.groups[groupIndex2]; // _carbinet2.setDocBGImage((string)rowsForDuplicate[0]["EQUIPEMNTID"], imgNormal); // _carbinet2.setDocText((string)rowsForDuplicate[0]["EQUIPEMNTID"], ""); // rowsForDuplicate[0]["studenID"] = ""; // } // rowsMap[0]["studenID"] = epcID;//这里把设备和标签绑定到一起 // _carbinet.setDocBGImage(remoteDeviceID, imgAnswered); // if (answer == "A") // { // rows[0]["answer"] = "A"; // } // if (answer == "B") // { // rows[0]["answer"] = "B"; // } // if (answer == "C") // { // rows[0]["answer"] = "C"; // } // if (answer == "D") // { // rows[0]["answer"] = "D"; // } // } // //更新答题记录 // rows = this.dtQuestion_answer_record.Select(string.Format("student_id = '{0}' and question_id = {1}", epcID, current_question_id)); // if (rows.Length > 0) // { // rows[0]["answer"] = question_value; // } // else // { // dtQuestion_answer_record.Rows.Add(new object[3] { epcID, current_question_id, question_value }); // } // break; //} }; this.Invoke(dele, evt); } }
void handle_event() { IntelligentEvent evt = MiddleWareCore.get_a_event(); if (evt != null) { deleControlInvoke dele = delegate(object o) { IntelligentEvent p = (IntelligentEvent)o; string epcID = p.epcID; string remoteDeviceID = p.remoteDeviceID; string check_time = p.time_stamp; string studentName = string.Empty; string question_value = p.questionValue; DataRow[] rows = null; DataRow[] rowsMap = null; int totalCount = this.studentInfoTable.Rows.Count; rows = this.studentInfoTable.Select("STUDENTID = '" + epcID + "'"); rowsMap = this.mapConfigsTable.Select("EQUIPEMNTID = '" + remoteDeviceID + "'"); if (rows.Length > 0 && rowsMap.Length > 0)//有该用户资料和设备资料 { string answer = question_value; int groupIndex = int.Parse(rowsMap[0]["IGROUP"].ToString()); studentName = (string)rows[0]["NAME"]; Carbinet _carbinet = this.groups[groupIndex]; //if (p.event_unit_list.IndexOf(IntelligentEventUnit.new_epc) >= 0) //{ // _carbinet.setDocText(remoteDeviceID, studentName); //} //else //{ if (p.event_unit_list.IndexOf(IntelligentEventUnit.epc_on_another_device) >= 0) { //这里要处理一下同一个学生用不一个设备发送答案的情况 DataRow[] rowsForDuplicate = this.mapConfigsTable.Select("studenID = '" + epcID + "'"); 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"] = ""; } //} _carbinet.setDocText(remoteDeviceID, studentName); rowsMap[0]["studenID"] = epcID; if (answer == "A") { rows[0]["answer"] = "A"; // _carbinet.setDocBGColor(data.equipmentID, this.clrA); _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.grey); } if (answer == "B") { _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.blue); rows[0]["answer"] = "B"; } if (answer == "C") { rows[0]["answer"] = "C"; _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.yellow); //_carbinet.setDocBGColor(data.equipmentID, this.clrC); } if (answer == "D") { rows[0]["answer"] = "D"; _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.orange); //_carbinet.setDocBGColor(data.equipmentID, this.clrD); } if (answer == "E") { rows[0]["answer"] = "E"; _carbinet.setDocBGImage(remoteDeviceID, (Image)global::Carbinet.Properties.Resources.purple); } 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'"); DataRow[] rowsE = this.studentInfoTable.Select("answer = 'E'"); int iA = rowsA.Length; int iB = rowsB.Length; int iC = rowsC.Length; int iD = rowsD.Length; int iE = rowsE.Length; //int iUnknown = totalCount - iA - iB - iC - iD - iE; m_panelDrawing.Values = new decimal[] { iA, iB, iC, iD, iE }; string strA = "", strB = "", strC = "", strD = "", strUnknown = "", strE = ""; //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() + "%"; } if (iE > 0) { strD = (iE * 100 / totalCount).ToString() + "%"; } m_panelDrawing.Texts = new string[] { strA, strB, strC, strD, strE }; } }; this.Invoke(dele, evt); } }
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 disposeReceivedData(Data data) //{ // this.Invoke(new deleControlInvoke(this.updateStatus), data); //} private void updateStatus(object o) { Data data = (Data)o; if (data.key == ((int)Mode.考勤).ToString()) { Debug.WriteLine( string.Format("Form1.updateStatus -> data = {0}" , data.toString())); //更新考勤信息 DataRow[] rows = null; //rows = this.checkTable.Select("equipmentID = '" + data.equipmentID + "'"); //根据接收到的信息,首先将学生出勤状态置为 1,之后将控件的显示状态改为绿色 rows = this.studentInfoTable.Select("STUDENTID = '" + data.tagID + "'"); 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 = '" + data.tagID + "'"); if (rows.Length > 0)//至少第二次考勤 { //if (((string)rows[0]["EQUIPEMNTID"]) == data.equipmentID)//如果两次的设备ID相同,则表示在同一台设备上考勤 //{ // return; //} //else { //此时需要将之前设为考勤状态的位置变回未考勤状态 int groupIndex = int.Parse(rows[0]["IGROUP"].ToString()); Carbinet _carbinet = this.groups[groupIndex]; _carbinet.setDocBGImage((string)rows[0]["EQUIPEMNTID"], (Image)global::Carbinet.Properties.Resources.red); _carbinet.setDocText((string)rows[0]["EQUIPEMNTID"], ""); rows[0]["studenID"] = ""; } } //rows = this.checkTable.Select("equipmentID = '" + data.equipmentID + "'"); rows = this.mapConfigsTable.Select("EQUIPEMNTID = '" + data.equipmentID + "'"); if (rows.Length > 0) { //rows[0]["sdudentID"] = data.tagID; //if (((string)rows[0]["studentName"]) == null || ((string)rows[0]["studentName"]).Length <= 0) //{ // rows[0]["studentName"] = data.tagID;//todo 这里应该检索学生信息 //} //rows[0]["status"] = "1"; rows[0]["studenID"] = data.tagID; int groupIndex = int.Parse(rows[0]["IGROUP"].ToString()); //界面展示 Carbinet _carbinet = this.groups[groupIndex]; //_carbinet.setDocBGColor(data.equipmentID, Color.Green); _carbinet.setDocBGImage(data.equipmentID, (Image)global::Carbinet.Properties.Resources.orange); _carbinet.setDocText(data.equipmentID, 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() }; //if (uncheckedCount + checkedCount > 0) //{ // m_panelDrawing.ToolTips = new string[] { "缺勤率:", // "出勤率:"}; //} //else //{ // m_panelDrawing.ToolTips = new string[] { "缺勤率:0%", // "出勤率:0%"}; //} } } }
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(); }