Example #1
0
        private PagedResult <ExamineeViewModel> _examineeViewModelList;  //  for paging
        #endregion

        public UCtrlExaminee()
        {
            InitializeComponent();

            _examineeBLL = new ExamineeBLL();

            numYearGraduated.Maximum        = _examineeBLL.GetServerDateTime().Year + 1;
            numYearGraduated.Value          = numYearGraduated.Maximum - 1;
            dgvExaminee.AutoGenerateColumns = false;

            PopulateExamineeDatagridView();

            if (_examineeViewModelList.PageCount > MINIMUM_PAGE_NUMBER)
            {
                btnNext.Enabled = true;
            }
        }
Example #2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            FrmReport frmReport = new FrmReport();

            if (cboReport.SelectedIndex == 0)   //  exam result
            {
                ExamineeTakeBLL         examineeTakeBLL  = new ExamineeTakeBLL();
                List <ExamResultReport> examResult       = new List <ExamResultReport>();
                ReportParameter[]       reportParameters = new ReportParameter[1];

                if (rdbIn.Checked)
                {
                    examResult          = examineeTakeBLL.GetExamResultList(chkInclude.Checked, dtpIn.Value, null);
                    reportParameters[0] = new ReportParameter("ExamResultDate", "Exam result in " + dtpIn.Value.ToShortDateString());
                }
                else if (rdbFrom.Checked)
                {
                    examResult          = examineeTakeBLL.GetExamResultList(chkInclude.Checked, dtpFrom.Value, dtpTo.Value);
                    reportParameters[0] = new ReportParameter("ExamResultDate", "Exam result from " + dtpFrom.Value.ToShortDateString() + " to " + dtpTo.Value.Date.ToShortDateString());
                }

                frmReport.LoadReport("ExamResultDS", examResult, "PresentationLayer.Reports.ExamResultReport.rdlc", reportParameters);
            }
            else if (cboReport.SelectedIndex == 1)  //  examinee list
            {
                ExamineeBLL           examineeBLL      = new ExamineeBLL();
                List <ExamineeReport> examineeReport   = new List <ExamineeReport>();
                ReportParameter[]     reportParameters = new ReportParameter[1];

                if (rdbIn.Checked)
                {
                    examineeReport      = examineeBLL.GetExamineeList(dtpIn.Value, null);
                    reportParameters[0] = new ReportParameter("ExamineeDate", "Examinees registered/added in " + dtpIn.Value.ToShortDateString());
                }
                else if (rdbFrom.Checked)
                {
                    examineeReport      = examineeBLL.GetExamineeList(dtpFrom.Value, dtpTo.Value);
                    reportParameters[0] = new ReportParameter("ExamineeDate", "Examinees registered/added from " + dtpFrom.Value.ToShortDateString() + " to " + dtpTo.Value.Date.ToShortDateString());
                }

                frmReport.LoadReport("ExamineeDS", examineeReport, "PresentationLayer.Reports.ExamineeReport.rdlc", reportParameters);
            }

            frmReport.ShowDialog(this);
        }
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (InputsAreValid())
            {
                Examinee examinee = new Examinee
                {
                    LastName           = txtLastName.Text,
                    FirstName          = txtFirstName.Text,
                    MiddleName         = txtMiddleName.Text,
                    Address            = txtAddress.Text,
                    City               = txtCity.Text,
                    ContactNo          = txtContactNo.Text,
                    Email              = txtEmail.Text,
                    LastSchoolAttended = txtLastSchoolAttended.Text,
                    YearGraduated      = (int)numYearGraduated.Value,
                    ExamTakes          = 0
                }; //  create new Examinee
                   //examinee.DateTimeAdded = DateTime.Now;    //  to DAL

                ExamineeBLL examineeBLL = new ExamineeBLL();
                examineeBLL.InsertExaminee(examinee);

                txtLastName.Text           = string.Empty;
                txtFirstName.Text          = string.Empty;
                txtMiddleName.Text         = string.Empty;
                txtAddress.Text            = string.Empty;
                txtCity.Text               = string.Empty;
                txtContactNo.Text          = string.Empty;
                txtEmail.Text              = string.Empty;
                txtLastSchoolAttended.Text = string.Empty;

                lblStatus.Text = string.Empty;

                MessageBox.Show(this, "Successfully registered!\nPlease get your exam code then start your exam.\nThank you.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void SetQuestion()
        {
            _examItemCount = _examList.Single(e => e.ExamId == _examId).ItemCount;
            int examCount = _examList.Count;

            if (_questionNumber < _examItemCount)
            {
                _counter++;
                SetExaminationInfo();
                SetQuestionLabelText();
                SetChoice();
            }
            else
            {
                _subjectScoreList.Add(new SubjectScore
                {
                    SubjectName = _examList.Single(e => e.ExamId == _examId).Subject.SubjectName,
                    Score       = _examScore,
                    ItemCount   = _examItemCount
                });

                _examineeExamList[_index].Score = _examScore;   //  set score in exam taken
                _questionNumber = 0;
                _index++;
                _examScore = 0; //  reset score
                _counter   = 1; //  reset counter

                if (_index < examCount)
                {
                    _examId        = _examineeExamList[_index].ExamId;
                    _examItemCount = _examList.Single(e => e.ExamId == _examId).ItemCount;

                    SetExaminationInfo();
                    SetQuestionLabelText();
                    SetChoice();
                }
                else
                {
                    _doLoop        = false;
                    _timer.Enabled = false;

                    this.Visible = false;

                    _passingRateBLL = new PassingRateBLL();
                    _examineeTakeInfo.PassingRate = _passingRateBLL.GetCurrentPassingRate();

                    var examScoreSummary = _subjectScoreList
                                           .GroupBy(g => new
                    {
                        g.SubjectName,
                    })
                                           .Select(s => new
                    {
                        s.Key.SubjectName,
                        ItemCount  = s.Sum(ic => ic.ItemCount),
                        TotalScore = s.Sum(ts => ts.Score),
                        Result     = s.Sum(ts => ts.Score) >= Math.Ceiling(Compute.GetPercentage((double)_examineeTakeInfo.PassingRate, s.Sum(ic => ic.ItemCount))) ? true : false
                                     //,View = s.Sum(ts => ts.Score) + " >= " + Math.Ceiling(Compute.GetPercentage((double)_examineeTakeInfo.PassingRate, s.Sum(ic => ic.ItemCount)))
                    });

                    //foreach (var item in examScoreSummary)
                    //{
                    //    Console.WriteLine("Items: " + item.ItemCount + "     Score:" + item.TotalScore + "   |View:" + item.View);
                    //}

                    bool passedExam = examScoreSummary.Where(e => e.Result == false).Count() == 0;   //  if list got no failed(false) exam score
                    _examineeTakeInfo.Result = passedExam;

                    _examineeTakeBLL = new ExamineeTakeBLL();
                    _examineeTakeBLL.UpdateExamineeTake(_examineeTakeInfo);

                    _examineeBLL = new ExamineeBLL();
                    _examineeBLL.IncreaseExamineeExamTaken(_examineeTakeInfo.ExamineeId);

                    FrmCounter frmCounter = new FrmCounter("Your Exam Ends In...");
                    frmCounter.ShowDialog(this);
                    this.Close();
                }
            }
        }