/// <summary> /// 選擇試別時觸發。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cboExamList_SelectedIndexChanged(object sender, EventArgs e) { if (cboExamList.SelectedItem == null) { return; } ExamComboBoxItem item = cboExamList.SelectedItem as ExamComboBoxItem; HC.JHAEIncludeRecord aeIncludeRecord = item.AEIncludeRecord; dgv.SuspendLayout(); #region 依 AEIncludeRecord 決定哪些 Column 要顯示 chInputScore.Visible = aeIncludeRecord.UseScore; chInputAssignmentScore.Visible = aeIncludeRecord.UseAssignmentScore; chInputText.Visible = aeIncludeRecord.UseText; #endregion GetScoresAndFill(aeIncludeRecord); LoadDvScoreColor(); dgv.ResumeLayout(); SetLoadDataToLog(); }
public CourseListViewItem(JHSchool.CourseRecord course, HC.JHAEIncludeRecord aei, List <HC.JHSCETakeRecord> sceList) { _is_finish = true; TeacherRecord teacher = course.GetFirstTeacher(); //_total = course.GetAttends().Count; _total = SCAttend.GetCourseStudentCount(course.ID); Calculate(sceList); if (aei.UseScore) { _is_finish &= (_scoreCount == _total); } if (aei.UseAssignmentScore) { _is_finish &= (_assignmentCount == _total); } if (aei.UseText) { _is_finish &= (_textCount == _total); } this.Text = course.Name; this.SubItems.Add((teacher != null) ? teacher.Name : ""); this.SubItems.Add(aei.UseScore ? ScoreField : "").ForeColor = (_scoreCount == _total) ? Color.Black : Color.Red; this.SubItems.Add(aei.UseAssignmentScore ? AssignmentField : "").ForeColor = (_assignmentCount == _total) ? Color.Black : Color.Red; this.SubItems.Add(aei.UseText ? TextField : "").ForeColor = (_textCount == _total) ? Color.Black : Color.Red; }
public void CalculateScore(HC.JHAEIncludeRecord ae, string type) { //if (ae.UseScore) Score = _score; if (type == "定期") { if (ae.UseScore) { Score = _score; } } else if (type == "定期加平時") { if (ae.UseScore && ae.UseAssignmentScore) { if (_score.HasValue && _assignment_score.HasValue) { if (Global.ScorePercentageHSDict.ContainsKey(ae.RefAssessmentSetupID)) { decimal ff = Global.ScorePercentageHSDict[ae.RefAssessmentSetupID]; decimal f = _score.Value * ff * 0.01M; decimal a = _assignment_score.Value * (100 - ff) * 0.01M; Score = f + a; } else { Score = _score.Value * 0.5M + _assignment_score.Value * 0.5M; } //Score = (_score.Value + _assignment_score.Value) / 2m; } else if (_score.HasValue) { Score = _score; } else if (_assignment_score.HasValue) { Score = _assignment_score; } } else if (ae.UseScore) { Score = _score; } else if (ae.UseAssignmentScore) { Score = _assignment_score; } } }
public static decimal?GetScore(HC.JHSCETakeRecord sce, HC.JHAEIncludeRecord ae, string source) { decimal?Score = null; if (source == "定期") { if (ae.UseScore) { Score = sce.Score; } } else if (source == "定期加平時") { if (ae.UseScore && ae.UseAssignmentScore) { if (sce.Score.HasValue && sce.AssignmentScore.HasValue) { Score = (sce.Score.Value + sce.AssignmentScore.Value) / 2m; } else if (sce.Score.HasValue) { Score = sce.Score; } else if (sce.AssignmentScore.HasValue) { Score = sce.AssignmentScore; } } else if (ae.UseScore) { Score = sce.Score; } else if (ae.UseAssignmentScore) { Score = sce.AssignmentScore; } } return(Score); }
public void CalculateScore(HC.JHAEIncludeRecord ae, string type) { //if (ae.UseScore) Score = _score; if (type == "定期") { if (ae.UseScore) { Score = _score; } } else if (type == "定期加平時") { if (ae.UseScore && ae.UseAssignmentScore) { if (_score.HasValue && _assignment_score.HasValue) { Score = (_score.Value + _assignment_score.Value) / 2m; } else if (_score.HasValue) { Score = _score; } else if (_assignment_score.HasValue) { Score = _assignment_score; } } else if (ae.UseScore) { Score = _score; } else if (ae.UseAssignmentScore) { Score = _assignment_score; } } }
private bool SaveTemplate() { if (HasErrors()) { MsgBox.Show("請修正資料後再儲存。", Application.ProductName); return(false); } try { AssessmentSetupRecord record = CurrentItem.Tag as AssessmentSetupRecord; List <JHAEIncludeRecord> list = JHAEInclude.SelectByAssessmentSetupID(record.ID); int w = JHAEInclude.Delete(list); List <AEIncludeRecordEditor> editors = new List <AEIncludeRecordEditor>(); //foreach (var item in record.GetAEIncludes()) //{ // AEIncludeRecordEditor editor = item.GetEditor(); // editor.Remove = true; // editors.Add(editor); //} //if (editors.Count > 0) // editors.SaveAll(); //editors = new List<AEIncludeRecordEditor>(); list = new List <JHAEIncludeRecord>(); foreach (DataGridViewRow each in dataview.Rows) { if (each.IsNewRow) { continue; } HC.JHAEIncludeRecord hc = new HC.JHAEIncludeRecord(new JHAEIncludeRecord()); hc.RefAssessmentSetupID = record.ID; hc.RefExamID = "" + each.Cells[ExamID.Index].Value; hc.UseScore = GetYesNoString(each.Cells[UseScore.Index].FormattedValue, false); hc.UseText = GetYesNoString(each.Cells[UseText.Index].FormattedValue, false); hc.UseAssignmentScore = GetYesNoString(each.Cells[UseAssignmentScore.Index].FormattedValue, false); int i; hc.Weight = int.TryParse("" + each.Cells[Weight.Index].Value, out i) ? i : 0; hc.StartTime = DateToSaveFormat("" + each.Cells[StartTime.Index].Value); hc.EndTime = DateToSaveFormat("" + each.Cells[EndTime.Index].Value); list.Add(hc.AsJHAEIncludeRecord()); } if (list.Count > 0) { JHAEInclude.Insert(list); } ResetDirty(); return(true); } catch (Exception ex) { //CurrentUser.ReportError(ex); MsgBox.Show(ex.Message); return(false); } }
private void SelectAssessmentSetup(ButtonItem item) { dataview.Rows.Clear(); //cboScoreSource.Enabled = (item != null); //txtStartTime.Enabled = (item != null); //txtEndTime.Enabled = (item != null); ipt01.Tag = null; if (item == null) { peTemplateName1.Text = string.Empty; dataview.AllowUserToAddRows = false; //panel1.Enabled = false; ipt01.Enabled = false; return; } else { AssessmentSetupRecord record = (item.Tag as AssessmentSetupRecord); peTemplateName1.Text = record.Name; dataview.AllowUserToAddRows = true; //panel1.Enabled = true; // 需要儲存樣版比例 if (_CheckSaveAssessmentSetup) { SaveAssessmentSetupToDB(record.ID); _CheckSaveAssessmentSetup = false; } ipt01.Text = "50"; ipt01.Enabled = true; // 取得比例 QueryHelper qh = new QueryHelper(); string selQuery = "select id,extension from exam_template where id=" + record.ID; DataTable dt = qh.Select(selQuery); string xmlStr = "<root>" + dt.Rows[0]["extension"].ToString() + "</root>"; XElement elmRoot = XElement.Parse(xmlStr); if (elmRoot != null) { if (elmRoot.Element("Extension") != null) { if (elmRoot.Element("Extension").Element("ScorePercentage") != null) { ipt01.Text = elmRoot.Element("Extension").Element("ScorePercentage").Value; } } } foreach (var ae in JHAEInclude.SelectByAssessmentSetupID(record.ID)) { HC.JHAEIncludeRecord each = new HC.JHAEIncludeRecord(ae); DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataview, each.RefExamID, each.Weight, each.UseScore, each.UseAssignmentScore, each.UseText, "", each.StartTime, each.EndTime); dataview.Rows.Add(row); } item.RaiseClick(); ResetDirty(); } }
public static decimal?GetScore(HC.JHSCETakeRecord sce, HC.JHAEIncludeRecord ae, string source) { decimal?Score = null; if (source == "定期") { if (ae.UseScore) { Score = sce.Score; } } else if (source == "平時") { if (ae.UseAssignmentScore) { if (sce.AssignmentScore.HasValue) { Score = sce.AssignmentScore.Value; } } } else if (source == "定期加平時平均") { if (ae.UseScore && ae.UseAssignmentScore) { if (sce.Score.HasValue && sce.AssignmentScore.HasValue) { // 有評量比例 if (Utilities.ScorePercentageHSDict.ContainsKey(ae.RefAssessmentSetupID)) { decimal ff = Utilities.ScorePercentageHSDict[ae.RefAssessmentSetupID]; decimal f = sce.Score.Value * ff * 0.01M; decimal a = sce.AssignmentScore.Value * (100 - ff) * 0.01M; return(f + a); } else { Score = sce.Score.Value * 0.5M + sce.AssignmentScore.Value * 0.5M; } //Score = (sce.Score.Value + sce.AssignmentScore.Value) / 2m; } else if (sce.Score.HasValue) { Score = sce.Score; } else if (sce.AssignmentScore.HasValue) { Score = sce.AssignmentScore; } } else if (ae.UseScore) { Score = sce.Score; } else if (ae.UseAssignmentScore) { Score = sce.AssignmentScore; } } return(Score); }
/// <summary> /// 取得成績並填入DataGridView /// </summary> private void GetScoresAndFill(HC.JHAEIncludeRecord aeIncludeRecord) { _dirtyCellList.Clear(); lblSave.Visible = false; #region 清空所有評量欄位及SCETakeRecord foreach (DataGridViewRow row in dgv.Rows) { row.Cells[chInputScore.Index].Value = row.Cells[chInputAssignmentScore.Index].Value = row.Cells[chInputText.Index].Value = null; (row.Tag as SCAttendTag).SCETake = null; } #endregion #region 取得成績並填入 //foreach (var record in QuerySCETake.GetSCETakeRecords(_course.ID, aeIncludeRecord.RefExamID)) //{ //} List <HC.JHSCETakeRecord> list = JHSchool.Data.JHSCETake.SelectByCourseAndExam(_course.ID, aeIncludeRecord.RefExamID).AsHCJHSCETakeRecords(); foreach (var record in list) { if (_studentRowDict.ContainsKey(record.RefStudentID)) { DataGridViewRow row = _studentRowDict[record.RefStudentID]; row.Cells[chInputScore.Index].Value = record.Score; row.Cells[chInputScore.Index].Tag = record.Score; if (record.Score.HasValue && record.Score.Value < 0) { if (PluginMain.ScoreValueMap.ContainsKey(record.Score.Value)) { row.Cells[chInputScore.Index].Value = PluginMain.ScoreValueMap[record.Score.Value].UseText; row.Cells[chInputScore.Index].Tag = PluginMain.ScoreValueMap[record.Score.Value].UseText; } } row.Cells[chInputAssignmentScore.Index].Value = record.AssignmentScore; row.Cells[chInputAssignmentScore.Index].Tag = record.AssignmentScore; if (record.AssignmentScore.HasValue && record.AssignmentScore.Value < 0) { if (PluginMain.ScoreValueMap.ContainsKey(record.AssignmentScore.Value)) { row.Cells[chInputAssignmentScore.Index].Value = PluginMain.ScoreValueMap[record.AssignmentScore.Value].UseText; row.Cells[chInputAssignmentScore.Index].Tag = PluginMain.ScoreValueMap[record.AssignmentScore.Value].UseText; } } row.Cells[chInputText.Index].Value = record.Text; row.Cells[chInputText.Index].Tag = record.Text; if (record.Score < 60) { row.Cells[chInputScore.Index].Style.ForeColor = Color.Red; } if (record.Score > 100 || record.Score < 0) { row.Cells[chInputScore.Index].Style.ForeColor = Color.Green; } else { row.Cells[chInputScore.Index].Style.ForeColor = Color.Black; } if (record.AssignmentScore < 60) { row.Cells[chInputAssignmentScore.Index].Style.ForeColor = Color.Red; } if (record.AssignmentScore > 100 || record.AssignmentScore < 0) { row.Cells[chInputAssignmentScore.Index].Style.ForeColor = Color.Green; } else { row.Cells[chInputAssignmentScore.Index].Style.ForeColor = Color.Black; } SCAttendTag tag = row.Tag as SCAttendTag; tag.SCETake = record; } else { #region 除錯用,別刪掉 //StudentRecord student = Student.Instance.Items[record.RefStudentID]; //if (student == null) // MsgBox.Show("系統編號「" + record.RefStudentID + "」的學生不存在…"); //else //{ // string className = (student.Class != null) ? student.Class.Name + " " : ""; // string seatNo = string.IsNullOrEmpty(className) ? "" : (string.IsNullOrEmpty(student.SeatNo) ? "" : student.SeatNo + " "); // string studentNumber = string.IsNullOrEmpty(student.StudentNumber) ? "" : " (" + student.StudentNumber + ")"; // MsgBox.Show(className + seatNo + student.Name + studentNumber, "這個學生有問題喔…"); //} #endregion } } #endregion }
//private string _weight; public ExamComboBoxItem(HC.JHAEIncludeRecord record) { _aeIncludeRecord = record; //_weight = record.Weight; _examRecord = record.Exam; }