private void SelectAssessmentSetup(ButtonItem item)
        {
            dataview.Rows.Clear();

            //cboScoreSource.Enabled = (item != null);
            //txtStartTime.Enabled = (item != null);
            //txtEndTime.Enabled = (item != null);

            if (item == null)
            {
                peTemplateName1.Text        = string.Empty;
                dataview.AllowUserToAddRows = false;
                panel1.Enabled = false;

                return;
            }
            else
            {
                JHAssessmentSetupRecord record = (item.Tag as JHAssessmentSetupRecord);
                peTemplateName1.Text        = record.Name;
                dataview.AllowUserToAddRows = true;
                panel1.Enabled = true;

                foreach (JHAEIncludeRecord each in JHAEInclude.SelectByAssessmentSetupID(record.ID))
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataview, each.Exam.ID, each.Weight, each.UseScore, each.UseEffort, "", "", each.StartTime, each.EndTime);
                    dataview.Rows.Add(row);
                }

                item.RaiseClick();
                _listener.Reset();
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (CurrentItem == null)
                {
                    return;
                }

                string msg = "確定要刪除「" + (CurrentItem.Tag as JHAssessmentSetupRecord).Name + "」評量設定?\n";
                msg += "刪除後,使用此評量設定的「課程」將會自動變成未設定評量設定狀態。";

                DialogResult dr = MsgBox.Show(msg, Application.ProductName, MessageBoxButtons.YesNo);

                if (dr == DialogResult.Yes)
                {
                    JHAssessmentSetupRecord  record     = CurrentItem.Tag as JHAssessmentSetupRecord;
                    List <JHAEIncludeRecord> deleteList = JHAEInclude.SelectByAssessmentSetupID(record.ID);
                    if (deleteList.Count > 0)
                    {
                        JHAEInclude.Delete(deleteList);
                    }
                    JHAssessmentSetup.Delete(record);
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTemplateName.Text.Trim()))
            {
                MsgBox.Show("您必須輸入名稱。");
                DialogResult = DialogResult.None;
                return;
            }

            if (ContainsTemplateName(txtTemplateName.Text.Trim()) && txtTemplateName.Text.Trim() != _orig_name)
            {
                MsgBox.Show("名稱重覆,請選擇其他名稱。");
                DialogResult = DialogResult.None;
                txtTemplateName.SelectAll();
                return;
            }

            if (txtTemplateName.Text.Trim() != _orig_name)
            {
                if (_record == null)
                {
                    JHAssessmentSetup.AfterInsert += new EventHandler <K12.Data.DataChangedEventArgs>(JHAssessmentSetup_AfterInsert);
                    _record      = new JHAssessmentSetupRecord();
                    _record.Name = txtTemplateName.Text.Trim();
                    JHAssessmentSetup.Insert(_record);
                }
                else
                {
                    _record.Name = txtTemplateName.Text.Trim();
                    JHAssessmentSetup.Update(_record);
                }

                DialogResult = DialogResult.OK;
            }
        }
Beispiel #4
0
        private void JHAssessmentSetup_AfterInsert(object sender, K12.Data.DataChangedEventArgs e)
        {
            if (e.PrimaryKeys.Count > 0)
            {
                if (cboExistTemplates.Enabled == true && cboExistTemplates.SelectedItem is JHAssessmentSetupRecord)
                {
                    JHAssessmentSetupRecord source = cboExistTemplates.SelectedItem as JHAssessmentSetupRecord;
                    bool executeRequired           = false;

                    List <JHAEIncludeRecord> aeincludes = new List <JHAEIncludeRecord>();
                    foreach (JHAEIncludeRecord each in JHAEInclude.SelectByAssessmentSetupID(source.ID))
                    {
                        JHAEIncludeRecord aeNew = new JHAEIncludeRecord();
                        aeNew.RefAssessmentSetupID = e.PrimaryKeys[0];
                        aeNew.RefExamID            = each.RefExamID;
                        aeNew.UseScore             = each.UseScore;
                        aeNew.UseText   = each.UseText;
                        aeNew.UseEffort = each.UseEffort;
                        aeNew.Weight    = each.Weight;
                        aeNew.StartTime = each.StartTime;
                        aeNew.EndTime   = each.EndTime;

                        aeincludes.Add(aeNew);
                        executeRequired = true;
                    }
                    if (executeRequired)
                    {
                        JHAEInclude.Insert(aeincludes);
                    }
                }
            }
            JHAssessmentSetup.AfterInsert -= new EventHandler <K12.Data.DataChangedEventArgs>(JHAssessmentSetup_AfterInsert);
        }
Beispiel #5
0
        private void DisplayRecord(JHCourseRecord record)
        {
            Enabled = (record != null);
            if (!Enabled)
            {
                return;
            }

            Errors.Clear();
            if (record != null)
            {
                if (record.CalculationFlag == "1")
                {
                    rdoCalcTrue.Checked = true;
                }
                //else if (record.CalculationFlag == "2")
                else if (record.CalculationFlag == "2" || record.CalculationFlag == "")
                {
                    rdoCalcFalse.Checked = true;
                }
            }
            JHAssessmentSetupRecord ass = JHAssessmentSetup.SelectByID(record.RefAssessmentSetupID);

            if (ass != null)
            {
                cboAssessmentSetup.Text = ass.Name;
            }
            else
            {
                cboAssessmentSetup.SelectedItem = NoScoreItem;
            }
        }
        private void AddToList(JHAssessmentSetupRecord record)
        {
            ButtonItem item = new ButtonItem();

            item.Text         = record.Name;
            item.Tag          = record;
            item.OptionGroup  = "AssessmentSetup";
            item.Click       += new EventHandler(AssessmentSetup_Click);
            item.DoubleClick += new EventHandler(AssessmentSetup_DoubleClick);
            ipList.Items.Add(item);
            ipList.RecalcLayout();
        }
Beispiel #7
0
        public AssessmentNameEditor(JHAssessmentSetupRecord record)
        {
            InitializeComponent();

            _record              = record;
            _orig_name           = record.Name;
            txtTemplateName.Text = record.Name;
            txtTemplateName.SelectAll();

            Text = "重新命名評分樣版";
            lblCopyExist.Enabled      = lblCopyExist.Visible = false;
            cboExistTemplates.Enabled = cboExistTemplates.Visible = false;
            Size = new Size(373, 104);
        }
Beispiel #8
0
        public AssessmentNameEditor()
        {
            InitializeComponent();

            _record    = null;
            _orig_name = string.Empty;
            Text       = "新增評量設定";

            foreach (JHAssessmentSetupRecord item in JHAssessmentSetup.SelectAll())
            {
                cboExistTemplates.Items.Add(item);
            }
            cboExistTemplates.SelectedIndex = 0;
        }
Beispiel #9
0
        private bool ContainsTemplateName(string p)
        {
            foreach (Object obj in cboExistTemplates.Items)
            {
                if (!(obj is JHAssessmentSetupRecord))
                {
                    continue;
                }

                JHAssessmentSetupRecord item = obj as JHAssessmentSetupRecord;

                if (item.Name == p)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #10
0
        public MainFormScoreInput(JHCourseRecord courseRec)
        {
            InitializeComponent();

            _EffortMap        = new EffortMap();
            _CourseRec        = courseRec;
            CIDs              = new List <string>();
            _StudOldScoreDic  = new Dictionary <string, string>();
            _StudOldEffortDic = new Dictionary <string, string>();
            CIDs.Add(courseRec.ID);
            _SCAttendListDic         = new Dictionary <string, JHSCAttendRecord>();
            lblCourseName.Text       = courseRec.Name;
            _StudentSCAtendScoreList = new List <StudentSCAtendScore>();

            // this.MinimumSize = this.MaximumSize = this.Size;

            // 取得課程評量
            _AssessmentSetupRec = JHAssessmentSetup.SelectByID(courseRec.RefAssessmentSetupID);
        }
        private void RefreshItemPanel(string id)
        {
            JHAssessmentSetupRecord record = JHAssessmentSetup.SelectByID(id);
            ButtonItem updateItem          = null;

            foreach (ButtonItem item in ipList.Items)
            {
                JHAssessmentSetupRecord r = item.Tag as JHAssessmentSetupRecord;
                if (r.ID == id)
                {
                    updateItem = item;
                    break;
                }
            }

            if (record != null && updateItem == null) //Insert
            {
                AddToList(record);
                ipList.Refresh();
                ipList.EnsureVisible(ipList.Items[ipList.Items.Count - 1]);
            }
            else if (record != null && updateItem != null) //Update
            {
                updateItem.Tag  = record;
                updateItem.Text = record.Name;
                SelectAssessmentSetup(updateItem);
            }
            else if (record == null && updateItem != null) //Delete
            {
                updateItem.Click       -= new EventHandler(AssessmentSetup_Click);
                updateItem.DoubleClick -= new EventHandler(AssessmentSetup_DoubleClick);
                ipList.Items.Remove(updateItem);
                ipList.Refresh();
                SelectAssessmentSetup(null);
                CurrentItem = null;
                Listener.Reset();
            }
        }
Beispiel #12
0
        public ScoreInputForm(JHStudentRecord student, JHCourseRecord course)
        {
            InitializeComponent();
            InitializeListener();
            prlp = new PermRecLogProcess();
            lblCourseName.Text = course.Name;
            lblStudent.Text    = student.Name + " " + student.StudentNumber;

            _course  = course;
            _student = student;

            List <JHSCAttendRecord> scattendList = JHSCAttend.SelectByStudentIDAndCourseID(new string[] { student.ID }, new string[] { course.ID });

            if (scattendList.Count > 0)
            {
                _scattend = scattendList[0];
            }

            #region 取得評量成績
            _listener.SuspendListen();

            // 取得所有試別
            Dictionary <string, JHExamRecord> exams = JHExam.SelectAll().ToDictionary(x => x.ID);
            List <string> examIDs = new List <string>(exams.Keys);

            List <HC.JHAEIncludeRecord> aeList = new List <HC.JHAEIncludeRecord>();

            if (course.RefAssessmentSetupID != null)
            {
                JHAssessmentSetupRecord assessment = JHAssessmentSetup.SelectByID(course.RefAssessmentSetupID);
                if (assessment != null)
                {
                    foreach (JHAEIncludeRecord ae in JHAEInclude.SelectByAssessmentSetupID(assessment.ID))
                    {
                        aeList.Add(new HC.JHAEIncludeRecord(ae));
                    }
                }
                //{
                //    foreach (JHAEIncludeRecord ae in JHAEInclude.SelectAll())
                //    {
                //        if (ae.RefAssessmentSetupID == assessment.ID)
                //            aeList.Add(new HC.JHAEIncludeRecord(ae));
                //    }
                //}
            }

            List <JHSCETakeRecord> jhSCEList = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID);

            //aeList.Sort(delegate(HC.JHAEIncludeRecord x, HC.JHAEIncludeRecord y)
            //{
            //    return x.RefExamID.CompareTo(y.RefExamID);
            //});

            aeList.Sort(delegate(HC.JHAEIncludeRecord x, HC.JHAEIncludeRecord y)
            {
                int ix = examIDs.IndexOf(x.RefExamID);
                int iy = examIDs.IndexOf(y.RefExamID);
                if (ix == -1)
                {
                    ix = int.MaxValue;
                }
                if (iy == -1)
                {
                    iy = int.MaxValue;
                }
                return(ix.CompareTo(iy));
            });

            List <HC.JHSCETakeRecord> sceList = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID).AsHCJHSCETakeRecords();

            Dictionary <string, DataGridViewRow> rows = new Dictionary <string, DataGridViewRow>();
            foreach (HC.JHAEIncludeRecord ae in aeList)
            {
                DataGridViewRow row = new DataGridViewRow();
                //JHExamRecord exam = JHExam.SelectByID(ae.RefExamID);

                JHExamRecord exam = null;
                if (exams.ContainsKey(ae.RefExamID))
                {
                    exam = exams[ae.RefExamID];
                }
                row.CreateCells(dgv, (exam != null) ? exam.Name : "無此評量(" + ae.RefExamID + ")", "", "", "");
                dgv.Rows.Add(row);
                row.Cells[chExamName.Index].Tag = (exam != null) ? exam.ID : "";

                if (!ae.UseScore)
                {
                    DisableCell(row, chScore);
                }
                if (!ae.UseAssignmentScore)
                {
                    DisableCell(row, chAssignmentScore);
                }
                if (!ae.UseText)
                {
                    DisableCell(row, chText);
                }

                if (!rows.ContainsKey(ae.RefExamID))
                {
                    rows.Add(ae.RefExamID, row);
                }
            }

            //List<HC.JHSCETakeRecord> sceList = jhSCEList.AsHCJHSCETakeRecords();
            foreach (HC.JHSCETakeRecord sce in sceList)
            {
                if (rows.ContainsKey(sce.RefExamID))
                {
                    DataGridViewRow row = rows[sce.RefExamID];
                    row.Cells[chScore.Index].Value           = sce.Score.HasValue ? "" + sce.Score.Value : "";
                    row.Cells[chAssignmentScore.Index].Value = sce.AssignmentScore.HasValue ? "" + sce.AssignmentScore.Value : "";
                    row.Cells[chText.Index].Value            = sce.Text;
                    row.Tag = sce;
                }
                else
                {
                    DataGridViewRow row  = new DataGridViewRow();
                    JHExamRecord    exam = JHExam.SelectByID(sce.RefExamID);
                    row.CreateCells(dgv, (exam != null) ? exam.Name : "無此評量(" + sce.RefExamID + ")", sce.Score.HasValue ? "" + sce.Score.Value : "", sce.AssignmentScore.HasValue ? "" + sce.AssignmentScore.Value : "", sce.Text);
                    row.Tag = sce;
                    row.Cells[chExamName.Index].Tag = (exam != null) ? exam.ID : "";
                    dgv.Rows.Add(row);
                    DisableCell(row, chExamName);
                    DisableCell(row, chScore);
                    DisableCell(row, chAssignmentScore);
                    DisableCell(row, chText);
                }
            }

            #region 填入修課總成績
            if (_scattend != null)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dgv, "課程總成績", "" + _scattend.Score, "", _scattend.Text);
                DisableCell(row, chAssignmentScore);
                row.Tag = "課程總成績";
                dgv.Rows.Add(row);
            }
            #endregion

            foreach (DataGridViewRow dgv1 in dgv.Rows)
            {
                foreach (DataGridViewCell cell in dgv1.Cells)
                {
                    cell.ErrorText = "";

                    if (cell.OwningColumn == chScore || cell.OwningColumn == chAssignmentScore)
                    {
                        cell.Style.ForeColor = Color.Black;
                        if (!string.IsNullOrEmpty("" + cell.Value))
                        {
                            decimal d;
                            if (!decimal.TryParse("" + cell.Value, out d))
                            {
                                cell.ErrorText = "分數必須為數字";
                            }
                            else
                            {
                                if (d < 60)
                                {
                                    cell.Style.ForeColor = Color.Red;
                                }
                                if (d > 100 || d < 0)
                                {
                                    cell.Style.ForeColor = Color.Green;
                                }
                            }
                        }
                    }
                }
            }


            _listener.Reset();
            _listener.ResumeListen();
            #endregion
            SetLoadDataToLog();
        }
        private bool SaveTemplate()
        {
            if (HasErrors())
            {
                MsgBox.Show("請修正資料後再儲存。", Application.ProductName);
                return(false);
            }

            try
            {
                Listener.SuspendListen();

                JHAssessmentSetupRecord record = CurrentItem.Tag as JHAssessmentSetupRecord;

                //刪除原先的 AEInclude
                if (OriginAEs.Count > 0)
                {
                    JHAEInclude.Delete(OriginAEs);
                    OriginAEs.Clear();
                }

                //List<JHAEIncludeRecord> deleteList = JHAEInclude.SelectByAssessmentSetupID(record.ID);
                //if (deleteList.Count > 0)
                //    JHAEInclude.Delete(deleteList);

                //將畫面上新的 AEInclude 寫入
                List <JHAEIncludeRecord> insertList = new List <JHAEIncludeRecord>();
                foreach (DataGridViewRow each in dataview.Rows)
                {
                    if (each.IsNewRow)
                    {
                        continue;
                    }

                    JHAEIncludeRecord aeNew = new JHAEIncludeRecord();
                    aeNew.RefAssessmentSetupID = record.ID;
                    aeNew.RefExamID            = "" + each.Cells[ExamID.Index].Value;
                    aeNew.UseScore             = GetYesNoString(each.Cells[UseScore.Index].FormattedValue, false);
                    aeNew.UseText   = GetYesNoString(each.Cells[UseText.Index].FormattedValue, false);
                    aeNew.UseEffort = GetYesNoString(each.Cells[UseEffort.Index].FormattedValue, false);
                    int i;
                    aeNew.Weight    = int.TryParse("" + each.Cells[Weight.Index].Value, out i) ? i : 0;
                    aeNew.StartTime = DateToSaveFormat("" + each.Cells[StartTime.Index].Value);
                    aeNew.EndTime   = DateToSaveFormat("" + each.Cells[EndTime.Index].Value);

                    insertList.Add(aeNew);
                }
                if (insertList.Count > 0)
                {
                    JHAEInclude.Insert(insertList);
                }

                //繳交時間寫入
                record.OrdinarilyStartTime = GetDateTimeNullable(txtOStartTime.Text, PaddingMethod.First);
                record.OrdinarilyEndTime   = GetDateTimeNullable(txtOEndTime.Text, PaddingMethod.Last);
                record.TextStartTime       = GetDateTimeNullable(txtTStartTime.Text, PaddingMethod.First);
                record.TextEndTime         = GetDateTimeNullable(txtTEndTime.Text, PaddingMethod.Last);
                JHAssessmentSetup.Update(record);

                lblIsDirty.Visible = false;
                Listener.Reset();
                Listener.ResumeListen();
                return(true);
            }
            catch (Exception ex)
            {
                MsgBox.Show(ex.Message);
                return(false);
            }
        }
        private void SelectAssessmentSetup(ButtonItem item)
        {
            Listener.SuspendListen();
            dataview.Rows.Clear();

            if (item == null)
            {
                peTemplateName1.Text        = string.Empty;
                dataview.AllowUserToAddRows = false;
                panel1.Enabled = false;

                return;
            }
            else
            {
                JHAssessmentSetupRecord record = (item.Tag as JHAssessmentSetupRecord);

                peTemplateName1.Text        = record.Name;
                dataview.AllowUserToAddRows = true;
                panel1.Enabled = true;

                //填評量部分
                OriginAEs.Clear();
                foreach (JHAEIncludeRecord each in JHAEInclude.SelectByAssessmentSetupID(record.ID))
                {
                    OriginAEs.Add(each);
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dataview,
                                    each.Exam.ID,
                                    each.Weight,
                                    each.UseScore,
                                    each.UseEffort,
                                    "否",
                                    "否",
                                    each.StartTime,
                                    each.EndTime,
                                    "是"
                                    );
                    dataview.Rows.Add(row);
                }

                //填平時評量及文字評量輸入時間
                txtOStartTime.Text = txtOEndTime.Text = string.Empty;
                txtTStartTime.Text = txtTEndTime.Text = string.Empty;

                if (record.OrdinarilyStartTime.HasValue)
                {
                    txtOStartTime.Text = record.OrdinarilyStartTime.Value.ToString("yyyy/MM/dd HH:mm:ss");
                }
                if (record.OrdinarilyEndTime.HasValue)
                {
                    txtOEndTime.Text = record.OrdinarilyEndTime.Value.ToString("yyyy/MM/dd HH:mm:ss");
                }
                if (record.TextStartTime.HasValue)
                {
                    txtTStartTime.Text = record.TextStartTime.Value.ToString("yyyy/MM/dd HH:mm:ss");
                }
                if (record.TextEndTime.HasValue)
                {
                    txtTEndTime.Text = record.TextEndTime.Value.ToString("yyyy/MM/dd HH:mm:ss");
                }

                FormatDateTime(txtOStartTime, PaddingMethod.First);
                FormatDateTime(txtOEndTime, PaddingMethod.Last);
                FormatDateTime(txtTStartTime, PaddingMethod.First);
                FormatDateTime(txtTEndTime, PaddingMethod.Last);

                item.RaiseClick();
            }
            Listener.Reset();
            Listener.ResumeListen();
        }
Beispiel #15
0
        public ScoreInputForm(JHStudentRecord student, JHCourseRecord course)
        {
            InitializeComponent();
            InitializeListener();
            prlp = new PermRecLogProcess();
            lblCourseName.Text = course.Name;
            lblStudent.Text    = student.Name + " " + student.StudentNumber;

            _course  = course;
            _student = student;

            List <JHSCAttendRecord> scattendList = JHSCAttend.SelectByStudentIDAndCourseID(new string[] { student.ID }, new string[] { course.ID });

            if (scattendList.Count > 0)
            {
                _scattend = scattendList[0];
            }


            #region 取得評量成績缺考暨免試設定

            PluginMain.ScoreTextMap.Clear();
            PluginMain.ScoreValueMap.Clear();
            Framework.ConfigData cd = JHSchool.School.Configuration["評量成績缺考暨免試設定"];
            if (!string.IsNullOrEmpty(cd["評量成績缺考暨免試設定"]))
            {
                XmlElement element = Framework.XmlHelper.LoadXml(cd["評量成績缺考暨免試設定"]);

                foreach (XmlElement each in element.SelectNodes("Setting"))
                {
                    var     UseText          = each.SelectSingleNode("UseText").InnerText;
                    var     AllowCalculation = bool.Parse(each.SelectSingleNode("AllowCalculation").InnerText);
                    decimal Score;
                    decimal.TryParse(each.SelectSingleNode("Score").InnerText, out Score);
                    var Active   = bool.Parse(each.SelectSingleNode("Active").InnerText);
                    var UseValue = decimal.Parse(each.SelectSingleNode("UseValue").InnerText);

                    if (Active)
                    {
                        if (!PluginMain.ScoreTextMap.ContainsKey(UseText))
                        {
                            PluginMain.ScoreTextMap.Add(UseText, new ScoreMap
                            {
                                UseText          = UseText,
                                AllowCalculation = AllowCalculation,
                                Score            = Score,
                                Active           = Active,
                                UseValue         = UseValue,
                            });
                        }
                        if (!PluginMain.ScoreValueMap.ContainsKey(UseValue))
                        {
                            PluginMain.ScoreValueMap.Add(UseValue, new ScoreMap
                            {
                                UseText          = UseText,
                                AllowCalculation = AllowCalculation,
                                Score            = Score,
                                Active           = Active,
                                UseValue         = UseValue,
                            });
                        }
                    }
                }
            }

            #endregion

            #region 取得評量成績
            _listener.SuspendListen();

            // 取得所有試別
            Dictionary <string, JHExamRecord> exams = JHExam.SelectAll().ToDictionary(x => x.ID);
            List <string> examIDs = new List <string>(exams.Keys);

            List <HC.JHAEIncludeRecord> aeList = new List <HC.JHAEIncludeRecord>();

            if (course.RefAssessmentSetupID != null)
            {
                JHAssessmentSetupRecord assessment = JHAssessmentSetup.SelectByID(course.RefAssessmentSetupID);
                if (assessment != null)
                {
                    foreach (JHAEIncludeRecord ae in JHAEInclude.SelectByAssessmentSetupID(assessment.ID))
                    {
                        aeList.Add(new HC.JHAEIncludeRecord(ae));
                    }
                }
                //{
                //    foreach (JHAEIncludeRecord ae in JHAEInclude.SelectAll())
                //    {
                //        if (ae.RefAssessmentSetupID == assessment.ID)
                //            aeList.Add(new HC.JHAEIncludeRecord(ae));
                //    }
                //}
            }

            List <JHSCETakeRecord> jhSCEList = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID);

            //aeList.Sort(delegate(HC.JHAEIncludeRecord x, HC.JHAEIncludeRecord y)
            //{
            //    return x.RefExamID.CompareTo(y.RefExamID);
            //});

            aeList.Sort(delegate(HC.JHAEIncludeRecord x, HC.JHAEIncludeRecord y)
            {
                int ix = examIDs.IndexOf(x.RefExamID);
                int iy = examIDs.IndexOf(y.RefExamID);
                if (ix == -1)
                {
                    ix = int.MaxValue;
                }
                if (iy == -1)
                {
                    iy = int.MaxValue;
                }
                return(ix.CompareTo(iy));
            });

            List <HC.JHSCETakeRecord> sceList = JHSCETake.SelectByStudentAndCourse(student.ID, course.ID).AsHCJHSCETakeRecords();

            Dictionary <string, DataGridViewRow> rows = new Dictionary <string, DataGridViewRow>();
            foreach (HC.JHAEIncludeRecord ae in aeList)
            {
                DataGridViewRow row = new DataGridViewRow();
                //JHExamRecord exam = JHExam.SelectByID(ae.RefExamID);

                JHExamRecord exam = null;
                if (exams.ContainsKey(ae.RefExamID))
                {
                    exam = exams[ae.RefExamID];
                }
                row.CreateCells(dgv, (exam != null) ? exam.Name : "無此評量(" + ae.RefExamID + ")", "", "", "");
                dgv.Rows.Add(row);
                row.Cells[chExamName.Index].Tag = (exam != null) ? exam.ID : "";

                if (!ae.UseScore)
                {
                    DisableCell(row, chScore);
                }
                if (!ae.UseAssignmentScore)
                {
                    DisableCell(row, chAssignmentScore);
                }
                if (!ae.UseText)
                {
                    DisableCell(row, chText);
                }

                if (!rows.ContainsKey(ae.RefExamID))
                {
                    rows.Add(ae.RefExamID, row);
                }
            }

            //List<HC.JHSCETakeRecord> sceList = jhSCEList.AsHCJHSCETakeRecords();
            foreach (HC.JHSCETakeRecord sce in sceList)
            {
                if (rows.ContainsKey(sce.RefExamID))
                {
                    DataGridViewRow row = rows[sce.RefExamID];

                    if (sce.Score.HasValue)
                    {
                        if (PluginMain.ScoreValueMap.ContainsKey(decimal.Parse(sce.Score.Value + "")))
                        {
                            row.Cells[chScore.Index].Value = PluginMain.ScoreValueMap[decimal.Parse(sce.Score.Value + "")].UseText;
                        }
                        else
                        {
                            row.Cells[chScore.Index].Value = sce.Score.Value;
                        }
                    }
                    else
                    {
                        row.Cells[chScore.Index].Value = "";
                    }
                    if (sce.AssignmentScore.HasValue)
                    {
                        if (PluginMain.ScoreValueMap.ContainsKey(decimal.Parse(sce.AssignmentScore.Value + "")))
                        {
                            row.Cells[chAssignmentScore.Index].Value = PluginMain.ScoreValueMap[decimal.Parse(sce.AssignmentScore.Value + "")].UseText;
                        }
                        else
                        {
                            row.Cells[chAssignmentScore.Index].Value = sce.AssignmentScore.Value;
                        }
                    }
                    else
                    {
                        row.Cells[chAssignmentScore.Index].Value = "";
                    }
                    row.Cells[chText.Index].Value = sce.Text;
                    row.Tag = sce;
                }
                else
                {
                    DataGridViewRow row  = new DataGridViewRow();
                    JHExamRecord    exam = JHExam.SelectByID(sce.RefExamID);
                    row.CreateCells(dgv, (exam != null) ? exam.Name : "無此評量(" + sce.RefExamID + ")", sce.Score.HasValue ? "" + sce.Score.Value : "", sce.AssignmentScore.HasValue ? "" + sce.AssignmentScore.Value : "", sce.Text);
                    row.Tag = sce;
                    row.Cells[chExamName.Index].Tag = (exam != null) ? exam.ID : "";
                    dgv.Rows.Add(row);
                    DisableCell(row, chExamName);
                    DisableCell(row, chScore);
                    DisableCell(row, chAssignmentScore);
                    DisableCell(row, chText);
                }
            }

            #region 填入修課總成績
            if (_scattend != null)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dgv, "課程總成績", "" + _scattend.Score, "", _scattend.Text);
                DisableCell(row, chAssignmentScore);
                row.Tag = "課程總成績";
                dgv.Rows.Add(row);
            }
            #endregion

            foreach (DataGridViewRow dgv1 in dgv.Rows)
            {
                foreach (DataGridViewCell cell in dgv1.Cells)
                {
                    cell.ErrorText = "";

                    if (cell.OwningColumn == chScore || cell.OwningColumn == chAssignmentScore)
                    {
                        cell.Style.ForeColor = Color.Black;
                        if (!string.IsNullOrEmpty("" + cell.Value))
                        {
                            decimal d;
                            if (!decimal.TryParse("" + cell.Value, out d))
                            {
                                if (PluginMain.ScoreTextMap.Keys.Count > 0)
                                {
                                    if (!PluginMain.ScoreTextMap.ContainsKey("" + cell.Value))
                                    {
                                        cell.ErrorText = "分數必須為數字或「" + string.Join("、", PluginMain.ScoreTextMap.Keys) + "」";
                                    }
                                }
                                else
                                {
                                    cell.ErrorText = "分數必須為數字";
                                }
                            }
                            else
                            {
                                if (d < 60)
                                {
                                    cell.Style.ForeColor = Color.Red;
                                }
                                if (d > 100 || d < 0)
                                {
                                    cell.Style.ForeColor = Color.Green;
                                }
                            }
                        }
                    }
                }
            }


            _listener.Reset();
            _listener.ResumeListen();
            #endregion
            SetLoadDataToLog();
        }
Beispiel #16
0
        /// <summary>
        /// 驗證課程
        /// </summary>
        /// <param name="courses"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        internal static bool ValidateCourses(List <JHCourseRecord> courses, UserConfig config)
        {
            MessageView view = new MessageView(MessageItemType.Course);

            view.ButtonVisible = false;
            view.Title         = string.Format("{0} 學年度 第 {1} 學期 {2}", config.SchoolYear, config.Semester, config.Exam.Name);

            #region 留下有效的科目課程
            List <JHCourseRecord> validCourses = new List <JHCourseRecord>();
            foreach (JHCourseRecord course in courses)
            {
                if (course.Subject != config.SourceSubject &&
                    !config.TargetSubjects.Contains(course.Subject))
                {
                    continue;
                }
                validCourses.Add(course);
            }
            #endregion

            List <JHCourseRecord> temp = new List <JHCourseRecord>();

            #region 檢查有沒有評量設定
            foreach (JHCourseRecord course in validCourses)
            {
                if (string.IsNullOrEmpty(course.RefAssessmentSetupID))
                {
                    view.Add(course.ID, course.Name, "沒有評量設定");
                }
                else
                {
                    temp.Add(course);
                }
            }
            validCourses = new List <JHCourseRecord>(temp);
            temp.Clear();
            #endregion

            #region 評量設定必須是一樣的
            List <string> asIDs = new List <string>();
            foreach (JHCourseRecord course in validCourses)
            {
                if (!asIDs.Contains(course.RefAssessmentSetupID))
                {
                    asIDs.Add(course.RefAssessmentSetupID);
                }
            }
            if (asIDs.Count > 1)
            {
                Dictionary <string, JHAssessmentSetupRecord> asDict = new Dictionary <string, JHAssessmentSetupRecord>();
                foreach (JHAssessmentSetupRecord asRecord in JHAssessmentSetup.SelectAll())
                {
                    asDict.Add(asRecord.ID, asRecord);
                }

                foreach (JHCourseRecord course in validCourses)
                {
                    view.Add(course.ID, course.Name, "評量設定為「" + asDict[course.RefAssessmentSetupID].Name + "」,所有科目需要有相同的評量設定");
                }
            }
            #endregion

            if (view.HasMessage)
            {
                view.ShowDialog();
                return(false);
            }

            #region 評量設定裡沒有選擇的試別
            if (asIDs.Count == 1)
            {
                bool found = false;
                foreach (JHAEIncludeRecord ae in JHAEInclude.SelectByAssessmentSetupID(asIDs[0]))
                {
                    if (ae.RefExamID == config.Exam.ID)
                    {
                        found = true;
                        break;
                    }
                }
                if (found == false)
                {
                    JHAssessmentSetupRecord asRecord = JHAssessmentSetup.SelectByID(asIDs[0]);
                    foreach (JHCourseRecord course in validCourses)
                    {
                        view.Add(course.ID, course.Name, "評量設定「" + asRecord.Name + "」,沒有「" + config.Exam.Name + "」試別");
                    }
                }
            }
            #endregion

            if (view.HasMessage)
            {
                view.ShowDialog();
                return(false);
            }

            return(true);
        }