예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (listView.SelectedItems.Count <= 0)
            {
                return;
            }

            ListViewItem   item   = listView.SelectedItems[0];
            JHCourseRecord course = item.Tag as JHCourseRecord;

            if (MsgBox.Show(string.Format("您確定要刪除課程「{0}」的修課記錄及相關評量成績嗎?", course.Name), MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                JHStudentRecord student = JHStudent.SelectByID(PrimaryKey);

                List <JHSCETakeRecord> sces = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID);
                if (sces.Count > 0)
                {
                    JHSCETake.Delete(sces);
                    FISCA.LogAgent.LogSaver logSaver = FISCA.LogAgent.ApplicationLog.CreateLogSaverInstance();
                    string studentInfo = StudentInfoConvertor.GetInfoWithClass(student);
                    foreach (var sce in sces)
                    {
                        string desc = studentInfo + " 刪除評量成績:" + sce.Course.Name + " " + sce.Exam.Name;
                        logSaver.AddBatch("成績系統.修課及評量成績", "刪除評量成績", "student", PrimaryKey, desc);
                    }
                    logSaver.LogBatch();
                }

                List <JHSCAttendRecord> scattends = JHSCAttend.SelectByStudentIDAndCourseID(new string[] { student.ID }, new string[] { course.ID });
                if (scattends.Count > 0)
                {
                    JHSCAttend.Delete(scattends);
                    StringBuilder builder = new StringBuilder("");
                    builder.Append(StudentInfoConvertor.GetInfoWithClass(student));
                    builder.Append(" 刪除修課:" + course.Name);
                    FISCA.LogAgent.ApplicationLog.Log("成績系統.修課及評量成績", "刪除修課", "student", PrimaryKey, builder.ToString());
                }

                listView.Items.Remove(item);
            }
        }
예제 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            JHStudentRecord student = JHStudent.SelectByID(PrimaryKey);
            CreateForm      form    = new CreateForm(student);

            if (form.ShowDialog() == DialogResult.OK)
            {
                if (form.Course == null)
                {
                    return;
                }

                try
                {
                    JHSCAttendRecord scattend = new JHSCAttendRecord();
                    scattend.RefCourseID  = form.Course.ID;
                    scattend.RefStudentID = PrimaryKey;
                    JHSCAttend.Insert(scattend);
                    StringBuilder builder = new StringBuilder("");
                    builder.Append(StudentInfoConvertor.GetInfoWithClass(student));
                    builder.Append(" 加入修課:" + form.Course.Name);
                    FISCA.LogAgent.ApplicationLog.Log("成績系統.修課及評量成績", "新增修課", "student", PrimaryKey, builder.ToString());
                }
                catch (Exception ex)
                {
                    MsgBox.Show("新增修課記錄失敗。" + ex.Message);
                }

                ScoreInputForm inputform = new ScoreInputForm(student, form.Course);
                inputform.ShowDialog();

                if (!_worker.IsBusy)
                {
                    _RunningID = PrimaryKey;
                    _worker.RunWorkerAsync();
                }
            }
        }