private void Bgw_Save_DoWork(object sender, DoWorkEventArgs e)
        {
            //開始儲存資料
            List <BodyTmperature> list = new List <BodyTmperature>();
            BodyTmperature        bt   = (BodyTmperature)e.Argument;

            list.Add(bt);

            List <string>         listID = tool._A.SaveAll(list);
            List <BodyTmperature> btList = tool._A.Select <BodyTmperature>(listID);

            bt = btList[0];

            StringBuilder sb_log = new StringBuilder();

            sb_log.AppendLine(lbHelp.Text);
            sb_log.AppendLine(string.Format("體溫「{0}」", bt.BodyTemperature));
            sb_log.AppendLine(string.Format("量測方式「{0}」", bt.MeasurementMethod));
            sb_log.AppendLine(string.Format("分類「{0}」", bt.Category));
            sb_log.AppendLine(string.Format("地點「{0}」", bt.Location));
            sb_log.AppendLine(string.Format("備註「{0}」", bt.Remark));
            FISCA.LogAgent.ApplicationLog.Log("體溫登錄", "掃碼登錄", "student", student.StudentID, sb_log.ToString());

            e.Result = bt;
        }
        public EditTmperatureForm(tool.BodyState state, int ref_id, BodyTmperature BT)
        {
            InitializeComponent();

            _state  = state;
            _ref_id = ref_id;
            _BT     = BT;
            dateTimeInput1.Value = DateTime.Now;

            BindData();

            if (_ref_id == 0)
            {
                btnSave.Enabled = false;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (student != null)
            {
                if (!bgw_Save.IsBusy)
                {
                    BodyTmperature bt;
                    if (student.bt == null)
                    {
                        bt       = new BodyTmperature();
                        bt.ObjID = int.Parse(student.StudentID);
                    }
                    else
                    {
                        bt = student.bt;
                    }

                    bt.BodyTag         = tool.BodyState.Student.ToString();
                    bt.OccurDate       = dateTimeInput1.Value;
                    bt.BodyTemperature = double.Parse(tbTmperature.Text);
                    bt.Category        = cbCategory.Text;
                    if (checkBoxX1.Checked)
                    {
                        bt.MeasurementMethod = "額溫";
                    }
                    else
                    {
                        bt.MeasurementMethod = "耳溫";
                    }

                    bt.Location = cbLocation.Text;


                    bt.Remark = tbRemark.Text;

                    bgw_Save.RunWorkerAsync(bt);
                }
                else
                {
                    MsgBox.Show("資料取得中\n請稍後");
                }
            }
            else
            {
                MsgBox.Show("未查詢到學生");
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (listView.SelectedItems.Count > 0)
            {
                DialogResult dr = MsgBox.Show("要刪除所選擇紀錄?", MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2);
                if (dr == DialogResult.Yes)
                {
                    StringBuilder sb_log = new StringBuilder();
                    sb_log.AppendLine("刪除體溫紀錄:");
                    sb_log.AppendLine(string.Format("班級「{0}」座號「{1}」姓名「{2}」", student.RefClassID != "" ? student.Class.Name : "", student.SeatNo.HasValue ? student.SeatNo.Value.ToString() : "", student.Name));

                    List <BodyTmperature> btlist = new List <BodyTmperature>();
                    foreach (ListViewItem item in listView.SelectedItems)
                    {
                        BodyTmperature bt = (BodyTmperature)item.Tag;
                        btlist.Add(bt);

                        sb_log.AppendLine(string.Format("日期「{0}」", bt.OccurDate.ToString("yyyy/MM/dd HH:mm")));
                        sb_log.AppendLine(string.Format("體溫「{0}」", bt.BodyTemperature));
                        sb_log.AppendLine(string.Format("量測方式「{0}」", bt.MeasurementMethod));
                        sb_log.AppendLine(string.Format("分類「{0}」", bt.Category));
                        sb_log.AppendLine(string.Format("地點「{0}」", bt.Location));
                        sb_log.AppendLine(string.Format("備註「{0}」", bt.Remark));
                        sb_log.AppendLine("");
                    }

                    tool._A.DeletedValues(btlist);

                    FISCA.Features.Invoke(tool.URL學生體溫記錄);
                    FISCA.LogAgent.ApplicationLog.Log("體溫登錄", "刪除", "student", student.ID, sb_log.ToString());

                    MsgBox.Show("刪除成功");
                }
                else
                {
                    MsgBox.Show("已取消");
                }
            }
            else
            {
                MsgBox.Show("請選擇紀錄");
            }
        }
Example #5
0
 private int DateTimeComparer(BodyTmperature x, BodyTmperature y)
 {
     return(y.OccurDate.CompareTo(x.OccurDate));
 }
        public override string Import(List <Campus.DocumentValidator.IRowStream> Rows)
        {
            if (mOption.Action == ImportAction.InsertOrUpdate)
            {
                List <BodyTmperature> InsertList = new List <BodyTmperature>();
                List <BodyTmperature> UpdateList = new List <BodyTmperature>();

                //學號:學生紀錄
                GetStudentByNumber(Rows);

                GetBodyTmperature();

                foreach (IRowStream Row in Rows)
                {
                    string studentNumber      = Row.GetValue("學號");
                    string body_tag           = Row.GetValue("對象");
                    string category           = Row.GetValue("類別");
                    string measurement_method = Row.GetValue("量測方式");
                    string location           = Row.GetValue("地點");
                    string remark             = Row.GetValue("備註");

                    DateTime occurDate;
                    DateTime.TryParse("" + Row.GetValue("量測日期"), out occurDate);

                    double body_temperature;
                    double.TryParse("" + Row.GetValue("體溫"), out body_temperature);

                    //學生是否存在
                    if (StudentByNumberDic.ContainsKey(studentNumber))
                    {
                        StudRecord stud = StudentByNumberDic[studentNumber];

                        //學號 + 類別 + 日期
                        string name_key = studentNumber + "_" + category + "_" + occurDate.ToString("yyyy/MM/dd");;

                        if (BodyTmperatureDic.ContainsKey(name_key))
                        {
                            //更新,取得原檔
                            BodyTmperature body_tmperature = BodyTmperatureDic[name_key];

                            //20202/3/24 - 建立修改前的副本內容
                            body_tmperature.NowClone();

                            //類別
                            body_tmperature.BodyTag           = "Student";
                            body_tmperature.Category          = category;
                            body_tmperature.BodyTemperature   = body_temperature;
                            body_tmperature.MeasurementMethod = measurement_method;
                            body_tmperature.Location          = location;
                            body_tmperature.Remark            = remark;


                            //證書日期
                            if (occurDate != null)
                            {
                                body_tmperature.OccurDate = occurDate;
                            }

                            UpdateList.Add(body_tmperature);
                        }
                        else
                        {
                            //新增
                            BodyTmperature body_tmperature = new BodyTmperature();
                            if (occurDate != null)
                            {
                                body_tmperature.OccurDate = occurDate;
                            }

                            body_tmperature.BodyTag           = "Student";
                            body_tmperature.Category          = category;
                            body_tmperature.BodyTemperature   = body_temperature;
                            body_tmperature.MeasurementMethod = measurement_method;
                            body_tmperature.Location          = location;
                            body_tmperature.Remark            = remark;

                            body_tmperature.ObjID = int.Parse(stud.id);

                            InsertList.Add(body_tmperature);
                        }
                    }
                }

                if (InsertList.Count > 0)
                {
                    tool._A.InsertValues(InsertList);

                    StringBuilder sb_log_new = new StringBuilder();
                    sb_log_new.AppendLine("新增學生體溫紀錄");

                    foreach (BodyTmperature each in InsertList)
                    {
                        if (StudentDic.ContainsKey(each.ObjID.ToString()))
                        {
                            StudRecord stud = StudentDic[each.ObjID.ToString()];
                            sb_log_new.AppendLine(string.Format("班級「{0}」座號「{1}」學生「{2}」", stud.class_name, stud.seat_no, stud.name));
                            sb_log_new.AppendLine("對象「學生」");
                            sb_log_new.AppendLine("類別「" + each.Category + "」");
                            sb_log_new.AppendLine("量測日期「" + each.OccurDate.ToString("yyyy/MM/dd") + "」");

                            sb_log_new.AppendLine("體溫「" + each.BodyTemperature + "」");
                            sb_log_new.AppendLine("量測方式「" + each.MeasurementMethod + "」");
                            sb_log_new.AppendLine("地點「" + each.Location + "」");
                            sb_log_new.AppendLine("備註「" + each.Remark + "」");
                            sb_log_new.AppendLine("");
                        }
                    }
                    FISCA.LogAgent.ApplicationLog.Log("匯入學生體溫紀錄", "新增", sb_log_new.ToString());
                }

                if (UpdateList.Count > 0)
                {
                    tool._A.UpdateValues(UpdateList);

                    StringBuilder sb_log_update = new StringBuilder();
                    sb_log_update.AppendLine("更新學生體溫紀錄");
                    foreach (BodyTmperature each in UpdateList)
                    {
                        if (StudentDic.ContainsKey(each.ObjID.ToString()))
                        {
                            StudRecord stud = StudentDic[each.ObjID.ToString()];

                            StringBuilder sb_aing = new StringBuilder();
                            bool          change  = false;

                            sb_aing.AppendLine(string.Format("班級「{0}」座號「{1}」學生「{2}」", stud.class_name, stud.seat_no, stud.name));
                            sb_aing.AppendLine(string.Format("日期「{0}」", each.OccurDate.ToString("yyyy/MM/dd")));

                            if (each.bt.BodyTemperature != each.BodyTemperature)
                            {
                                change = true;
                                sb_aing.AppendLine("體溫紀錄由「" + each.bt.BodyTemperature + "」修改為「" + each.BodyTemperature + "」");
                            }

                            if (each.bt.Location != each.Location)
                            {
                                change = true;
                                sb_aing.AppendLine("地點由「" + each.bt.Location + "」修改為「" + each.Location + "」");
                            }

                            if (each.bt.Remark != each.Remark)
                            {
                                change = true;
                                sb_aing.AppendLine("備註由「" + each.bt.Remark + "」修改為「" + each.Remark + "」");
                            }

                            if (each.bt.MeasurementMethod != each.MeasurementMethod)
                            {
                                change = true;
                                sb_aing.AppendLine("量測方式由「" + each.bt.MeasurementMethod + "」修改為「" + each.MeasurementMethod + "」");
                            }

                            sb_aing.AppendLine("");

                            if (change)
                            {
                                sb_log_update.Append(sb_aing.ToString());
                            }
                        }
                    }
                    if (sb_log_update.ToString() != "更新學生體溫紀錄")
                    {
                        FISCA.LogAgent.ApplicationLog.Log("匯入學生體溫紀錄", "更新", sb_log_update.ToString());
                    }
                }
            }

            return("");
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Check())
            {
                BodyTmperature bt = new BodyTmperature();

                if (_BT != null)
                {
                    bt = _BT;
                }
                else
                {
                    bt.ObjID   = _ref_id;
                    bt.BodyTag = _state.ToString();
                }

                bt.OccurDate       = dateTimeInput1.Value;
                bt.BodyTemperature = double.Parse(tbTmperature.Text);
                bt.Category        = cbCategory.Text;

                if (checkBoxX1.Checked)
                {
                    bt.MeasurementMethod = "額溫";
                }
                else
                {
                    bt.MeasurementMethod = "耳溫";
                }

                bt.Location = cbLocation.Text;


                bt.Remark = tbRemark.Text;

                bt.Save();

                _BT = bt;

                StringBuilder sb_log = new StringBuilder();
                sb_log.AppendLine(lbHelp.Text);
                sb_log.AppendLine(string.Format("體溫「{0}」", bt.BodyTemperature));
                sb_log.AppendLine(string.Format("量測方式「{0}」", bt.MeasurementMethod));
                sb_log.AppendLine(string.Format("分類「{0}」", bt.Category));
                sb_log.AppendLine(string.Format("地點「{0}」", bt.Location));
                sb_log.AppendLine(string.Format("備註「{0}」", bt.Remark));
                if (_state == tool.BodyState.Student)
                {
                    FISCA.LogAgent.ApplicationLog.Log("體溫登錄", "新增", "student", student.ID, sb_log.ToString());
                }
                else
                {
                    FISCA.LogAgent.ApplicationLog.Log("體溫登錄", "新增", "teacher", teacher.ID, sb_log.ToString());
                }

                if (_state == tool.BodyState.Student)
                {
                    if (tool.CheckFeature(tool.URL學生體溫記錄))
                    {
                        FISCA.Features.Invoke(tool.URL學生體溫記錄);
                    }
                }
                else
                {
                    if (tool.CheckFeature(tool.URL教師體溫記錄))
                    {
                        FISCA.Features.Invoke(tool.URL教師體溫記錄);
                    }
                }


                MsgBox.Show("儲存成功");

                this.Close();
            }
            else
            {
                MsgBox.Show("請修正錯誤");
            }
        }
Example #8
0
 private int SortSchool(BodyTmperature cpr1, BodyTmperature cpr2)
 {
     return(cpr1.OccurDate.CompareTo(cpr2.OccurDate));
 }
        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("已取消");
            }
        }