Exemplo n.º 1
0
        /// <summary>
        /// 把教室的座位定义好
        /// </summary>
        /// <param name="_roomConfig"></param>
        /// <param name="_widthOfRoom">整个教室的宽度</param>
        /// <param name="_groupTop">离讲台最近的行与讲台之间的距离</param>
        /// <param name="_groupGap">group之间的距离</param>
        /// <param name="_firstGroupLeft">离教室左边的距离</param>
        private void InitialClassRoom(ClassRoomConfig _roomConfig, int _widthOfRoom, int _groupTop, int _groupGap, int _firstGroupLeft)
        {
            int heightOfDocumentFile = CHAIR_HEIGHT;

            int countOfGroup = _roomConfig.GroupCount;
            int numberOfUnit = _roomConfig.GetTotalColumn();
            int widthOfUnit  = (_widthOfRoom - (countOfGroup - 1) * _groupGap) / numberOfUnit;

            for (int groupIndex = 0; groupIndex < countOfGroup; groupIndex++)
            {
                int countOfColumnInGroup = _roomConfig.GroupList[groupIndex].ColumnCount;
                int countOfFloorInGroup  = _roomConfig.GroupList[groupIndex].RowCount;

                int currentGroupWidth = countOfColumnInGroup * widthOfUnit;

                Carbinet group = new Carbinet(this.Controls);
                group.Left = _firstGroupLeft;
                group.Top  = _groupTop;
                this.groups.Add(group);
                //初始化每一排的行
                int initialTop = 0;
                for (int iFloorIndex = 1; iFloorIndex <= countOfFloorInGroup; iFloorIndex++, initialTop = initialTop + (int)(1.7 * heightOfDocumentFile))
                {
                    group.AddFloor(this.initialFloor(group, iFloorIndex, currentGroupWidth, heightOfDocumentFile, initialTop));

                    for (int columnIndex = 1; columnIndex <= countOfColumnInGroup; columnIndex++)
                    {
                        string _equipmentID = string.Format("{0},{1},{2}", groupIndex, iFloorIndex, columnIndex);
                        group.AddDocFile(this.initialDocumentFile(_equipmentID, iFloorIndex, widthOfUnit, heightOfDocumentFile, groupIndex, iFloorIndex, columnIndex, df_Click));
                    }
                }
                _firstGroupLeft += currentGroupWidth + _groupGap;
            }
        }
        //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,也就是不选择
            }
        }
Exemplo n.º 3
0
        CarbinetFloor initialFloor(Carbinet group, int irow, int _rowWidth, int _rowHeight, int _rowTop)
        {
            CarbinetFloor row = new CarbinetFloor(group, irow, this.Controls);

            row.Width        = _rowWidth;
            row.Height       = _rowHeight;
            row.relativeTop  = _rowTop;
            row.relativeLeft = 0;

            return(row);
        }
 public CarbinetFloor(Carbinet carbinet, int floorNumber,
                      System.Windows.Forms.Control.ControlCollection controls)
 {
     this.floorNumber = floorNumber;
     this.controls    = controls;
 }
Exemplo n.º 5
0
        private void InitialClassRoom()
        {
            if (this.dtRoomConfig == null)
            {
                return;
            }
            this.cmbSelectedRow.SelectedIndexChanged -= this.cmbSelectedRow_SelectedIndexChanged;
            this.numCountofRow.ValueChanged          -= this.numCountofRow_ValueChanged;
            this.numCountofColumn.ValueChanged       -= this.numCountofColumn_ValueChanged;


            this.pictureBox1.Controls.Clear();

            //获取设备和位置的对应数据
            DataTable dt = this.ctl.getAllMapConfigs();

            int numberOfGroup = dtRoomConfig.Rows.Count;
            int widthOfRoom   = this.pictureBox1.Width;
            int heightOfRow   = 38;

            int totalColumns = numberOfGroup;

            DataRow[] rows4Sum = dtRoomConfig.Select("IGROUP=1");
            if (rows4Sum.Length > 0)
            {
                totalColumns = int.Parse(rows4Sum[0]["totalColumn"].ToString());
            }
            int numberOfUnit     = totalColumns + numberOfGroup - 1;
            int widthOfUnit      = widthOfRoom / numberOfUnit;
            int groupInitialLeft = 0;

            for (int i = 0; i < numberOfGroup; i++)
            {
                int numberofColumn = 1;
                int numberOfRow    = 1;

                DataRow[] rows = dtRoomConfig.Select(string.Format("IGROUP={0}", i + 1));
                if (rows.Length > 0)
                {
                    numberofColumn = int.Parse(rows[0]["ICOLUMN"].ToString());
                    numberOfRow    = int.Parse(rows[0]["IROW"].ToString());
                }
                int groupWidth = numberofColumn * widthOfUnit;

                Carbinet group = new Carbinet(this.pictureBox1.Controls);
                group.Left = groupInitialLeft;
                group.Top  = 67;
                //this.groups.Add(group);
                //初始化每一排的行
                int initialTop = 0;
                for (int irow = 1; irow <= numberOfRow; irow++, initialTop = initialTop + (int)(1.7 * heightOfRow))
                {
                    CarbinetFloor row = new CarbinetFloor(group, irow, this.pictureBox1.Controls);
                    row.Width        = groupWidth;
                    row.Height       = heightOfRow;
                    row.relativeTop  = initialTop;
                    row.relativeLeft = 0;

                    group.AddFloor(row);

                    for (int k = 1; k <= numberofColumn; k++)
                    {
                        string       _equipmentID = i.ToString() + "," + irow.ToString() + "," + k.ToString();
                        DocumentFile df           = new DocumentFile(_equipmentID, irow);
                        df.Width  = widthOfUnit;
                        df.Height = heightOfRow;
                        DataRow[] rowsMap = dt.Select(
                            string.Format("IGROUP = {0} and IROW = {1} and ICOLUMN = {2}",
                                          i.ToString(), irow.ToString(), k.ToString()));
                        if (rowsMap.Length > 0)
                        {
                            df.Text = (string)rowsMap[0]["EQUIPEMNTID"];
                        }
                        else
                        {
                            df.Text = "";
                        }
                        df.carbinetIndex = i;
                        df.floorNumber   = irow;
                        df.columnNumber  = k;
                        df.indexBase     = k.ToString();
                        //df.doc.Click += new EventHandler(doc_Click);
                        df.Click += new EventHandler(doc_Click);
                        group.AddDocFile(df);
                    }
                }
                groupInitialLeft += groupWidth + widthOfUnit;
            }
            DataRow[] rows2 = dtRoomConfig.Select("IGROUP=1");
            if (rows2.Length > 0)
            {
                int column = int.Parse(rows2[0]["ICOLUMN"].ToString());
                int row    = int.Parse(rows2[0]["IROW"].ToString());
                this.numCountofColumn.Value = (decimal)column;
                this.numCountofRow.Value    = (decimal)row;
            }

            this.cmbSelectedRow.SelectedIndexChanged += new System.EventHandler(this.cmbSelectedRow_SelectedIndexChanged);
            this.numCountofRow.ValueChanged          += new System.EventHandler(this.numCountofRow_ValueChanged);
            this.numCountofColumn.ValueChanged       += new System.EventHandler(this.numCountofColumn_ValueChanged);

            return;
            //int numberOfGroup = (int)this.numCountofGroup.Value;
            //int numberofColumn = (int)this.numCountofColumn.Value;
            //int numberOfRow = (int)this.numCountofRow.Value;


            //int numberOfUnit = numberOfGroup * numberofColumn + numberOfGroup - 1;
            //int widthOfUnit = widthOfRoom / numberOfUnit;
            //int groupInitialLeft = 0;
            //int groupWidth = numberofColumn * widthOfUnit;

            //for (int i = 0; i < numberOfGroup; i++)
            //{
            //    Carbinet group = new Carbinet(this.pictureBox1.Controls);
            //    group.Left = groupInitialLeft;
            //    group.Top = 67;
            //    //this.groups.Add(group);
            //    //初始化每一排的行
            //    int initialTop = 0;
            //    for (int irow = 1; irow <= numberOfRow; irow++, initialTop = initialTop + (int)(1.7 * heightOfRow))
            //    {
            //        CarbinetFloor row = new CarbinetFloor(group, irow, this.pictureBox1.Controls);
            //        row.Width = groupWidth;
            //        row.Height = heightOfRow;
            //        row.relativeTop = initialTop;
            //        row.relativeLeft = 0;

            //        group.AddFloor(row);

            //        for (int k = 1; k <= numberofColumn; k++)
            //        {
            //            string _equipmentID = i.ToString() + "," + irow.ToString() + "," + k.ToString();
            //            DocumentFile df = new DocumentFile(_equipmentID, irow);
            //            df.Width = widthOfUnit;
            //            df.Height = heightOfRow;
            //            DataRow[] rows = dt.Select(
            //                string.Format("IGROUP = {0} and IROW = {1} and ICOLUMN = {2}",
            //                                i.ToString(), irow.ToString(), k.ToString()));
            //            if (rows.Length > 0)
            //            {
            //                df.Text = (string)rows[0]["EQUIPEMNTID"];
            //            }
            //            else
            //            {
            //                df.Text = "";
            //            }
            //            df.carbinetIndex = i;
            //            df.floorNumber = irow;
            //            df.columnNumber = k;
            //            df.indexBase = k.ToString();
            //            //df.doc.Click += new EventHandler(doc_Click);
            //            df.Click += new EventHandler(doc_Click);
            //            group.AddDocFile(df);
            //        }

            //    }
            //    groupInitialLeft += groupWidth + widthOfUnit;
            //}
        }
        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);
            }
        }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        private void InitialClassRoom()
        {
            this.button6.Left = (this.pictureBox1.Width - this.button6.Width) / 2 + this.pictureBox1.Left;

            int numberOfGroup = dtRoomConfig.Rows.Count;
            int widthOfRoom   = this.pictureBox1.Width;
            int heightOfRow   = 38;

            int totalColumns = numberOfGroup;

            DataRow[] rows4Sum = dtRoomConfig.Select("IGROUP=1");
            if (rows4Sum.Length > 0)
            {
                totalColumns = int.Parse(rows4Sum[0]["totalColumn"].ToString());
            }
            int numberOfUnit     = totalColumns + numberOfGroup - 1;
            int widthOfUnit      = widthOfRoom / numberOfUnit;
            int groupInitialLeft = 0;

            for (int i = 0; i < numberOfGroup; i++)
            {
                int numberofColumn = 1;
                int numberOfRow    = 1;

                DataRow[] rows = dtRoomConfig.Select(string.Format("IGROUP={0}", i + 1));
                if (rows.Length > 0)
                {
                    numberofColumn = int.Parse(rows[0]["ICOLUMN"].ToString());
                    numberOfRow    = int.Parse(rows[0]["IROW"].ToString());
                }
                int groupWidth = numberofColumn * widthOfUnit;

                Carbinet group = new Carbinet(this.pictureBox1.Controls);
                group.Left = groupInitialLeft;
                group.Top  = 67;
                this.groups.Add(group);
                //初始化每一排的行
                int initialTop = 0;
                for (int irow = 1; irow <= numberOfRow; irow++, initialTop = initialTop + (int)(1.7 * heightOfRow))
                {
                    CarbinetFloor row = new CarbinetFloor(group, irow, this.pictureBox1.Controls);
                    row.Width        = groupWidth;
                    row.Height       = heightOfRow;
                    row.relativeTop  = initialTop;
                    row.relativeLeft = 0;

                    group.AddFloor(row);

                    for (int k = 1; k <= numberofColumn; k++)
                    {
                        // 如果座位与设备已经设置绑定的话,则在此处将座位与设备ID相挂钩
                        DataRow[] rowsMap = mapConfigsTable.Select(
                            string.Format("IGROUP = {0} and IROW = {1} and ICOLUMN = {2}",
                                          i.ToString(), irow.ToString(), k.ToString()));

                        string _equipmentID = i.ToString() + "," + irow.ToString() + "," + k.ToString();
                        if (rowsMap.Length > 0)
                        {
                            _equipmentID = (string)rowsMap[0]["EQUIPEMNTID"];
                        }
                        DocumentFile df = new DocumentFile(_equipmentID, irow);
                        df.Width         = widthOfUnit;
                        df.Height        = heightOfRow;
                        df.carbinetIndex = i;
                        df.floorNumber   = irow;
                        df.columnNumber  = k;
                        df.indexBase     = k.ToString();
                        df.Click        += new EventHandler(df_Click);
                        group.AddDocFile(df);
                    }
                }
                groupInitialLeft += groupWidth + widthOfUnit;
            }
        }
Exemplo n.º 9
0
        public void changeChairState(int _groupIndex, string _equipmentID, DocumentFileState _state)
        {
            Carbinet _carbinet = this.groups[_groupIndex];

            _carbinet.setColorStyle(_equipmentID, _state);
        }
Exemplo n.º 10
0
        public void changeChairState(int _groupIndex, string _equipmentID, string _text)
        {
            Carbinet _carbinet = this.groups[_groupIndex];

            _carbinet.setDocText(_equipmentID, _text);
        }
Exemplo n.º 11
0
        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);
            }
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        //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%"};
                    //}
                }
            }
        }
Exemplo n.º 14
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();
        }