private void Bgw_Load_DoWork(object sender, DoWorkEventArgs e)
        {
            categoryList   = new List <string>();
            tmperatureList = new List <string>();
            studentDic     = new Dictionary <string, SuperStudent>();
            //查詢分類
            DataTable dt = tool._Q.Select(@"select category from $body_temperature.student_tmperature group by category ");

            foreach (DataRow row in dt.Rows)
            {
                string category = "" + row["category"];
                categoryList.Add(category);
            }

            //查詢地點
            dt = tool._Q.Select(@"select location from $body_temperature.student_tmperature group by location ");
            foreach (DataRow row in dt.Rows)
            {
                string location = "" + row["location"];
                tmperatureList.Add(location);
            }

            //一般生
            dt = tool._Q.Select(string.Format(@"select student.id as student_id,student.name as student_name ,
student.student_number,student.freshman_photo,student.seat_no,class.class_name,class.id as ref_class_id
from student join class on student.ref_class_id=class.id where student.status='1'"));
            foreach (DataRow row in dt.Rows)
            {
                student = new SuperStudent(row);
                if (!studentDic.ContainsKey(student.StudentNumber))
                {
                    studentDic.Add(student.StudentNumber, student);
                }
            }
        }
        private void dataGridViewX1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1 && e.ColumnIndex != -1)
            {
                //叫出資料進行修改
                if (dataGridViewX1.Rows[e.RowIndex].Tag != null)
                {
                    SuperStudent       stud = (SuperStudent)dataGridViewX1.Rows[e.RowIndex].Tag;
                    EditTmperatureForm erf  = new EditTmperatureForm(tool.BodyState.Student, int.Parse(stud.StudentID), stud.bt);
                    erf.ShowDialog();

                    //修正後
                    dataGridViewX1.Rows[e.RowIndex].Cells[3].Value = erf._BT.BodyTemperature;
                    dataGridViewX1.Rows[e.RowIndex].Cells[4].Value = "已手動修改";
                }
            }
        }
 private void btnSelect_Click(object sender, EventArgs e)
 {
     //查詢學號學生
     studentNumber = tbSelect.Text.Trim();
     if (!studentDic.ContainsKey(studentNumber))
     {
         if (!bgw_Select.IsBusy)
         {
             bgw_Select.RunWorkerAsync();
         }
         else
         {
             MsgBox.Show("資料取得中\n請稍後");
         }
     }
     else
     {
         student = studentDic[studentNumber];
         NextPer();
     }
 }
        private void Bgw_Save_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (!e.Cancelled)
            {
                if (e.Error == null)
                {
                    BodyTmperature bt = (BodyTmperature)e.Result;

                    DataGridViewRow row = dataGridViewX1.Rows[studentRowIndex];
                    row.Tag = student;

                    row.Cells[3].Value = tbTmperature.Text;
                    double checkTmp = double.Parse(tbTmperature.Text);
                    if (checkTmp >= 37)
                    {
                        row.Cells[3].Style.ForeColor = Color.Red;
                    }

                    if (student.bt != null)
                    {
                        row.Cells[4].Value = "體溫重掃修正";
                    }
                    else
                    {
                        //若是額溫,以37.5為發燒定義
                        if (checkBoxX1.Checked)
                        {
                            if (checkTmp >= 37.5)
                            {
                                row.Cells[3].Style.ForeColor = Color.Red;
                                row.Cells[4].Value           = "體溫偏高,建議重新量測";
                            }
                            else
                            {
                                row.Cells[4].Value = "儲存成功";
                            }
                        }
                        else
                        {
                            if (checkTmp >= 38)
                            {
                                row.Cells[3].Style.ForeColor = Color.Red;
                                row.Cells[4].Value           = "體溫偏高,建議重新量測";
                            }
                            else
                            {
                                row.Cells[4].Value = "儲存成功";
                            }
                        }
                    }

                    if (tool.CheckFeature(tool.URL學生體溫記錄))
                    {
                        FISCA.Features.Invoke(tool.URL學生體溫記錄);
                    }
                    student.bt = bt;

                    //恢復預設
                    pictureBox1.Image = null;
                    lbHelp.Text       = "班級\n座號\n學生";
                    tbSelect.Text     = "";
                    tbTmperature.Text = "";
                    student           = null;

                    //回到學號
                    tbSelect.Focus();
                }
                else
                {
                    MsgBox.Show("發生錯誤:\n" + e.Error.Message);
                }
            }
            else
            {
                MsgBox.Show("已取消");
            }
        }