//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(); }