コード例 #1
0
        protected void check_Click(object sender, EventArgs e)
        {
            var code = Code.Text;

            var cand = _db.T_Candidate.FirstOrDefault(s => s.Code == code);

            if (!(cand == null))
            {
                var b_set = _db.T_BatchSet.Where(s => s.CandidateId == cand.Id).ToList();
                int count = b_set.Count();
                if (count > 1)
                {
                    var quests = b_set.Select(a => new PrevBatchGridModel
                    {
                        ID        = a.Id,
                        BatchName = ErecruitHelper.getBatchName((long)a.BatchId),
                        Code      = a.Finished == true ? ErecruitHelper.getCandidateCode((long)a.CandidateId) + "," + a.Id : ErecruitHelper.getCandidateCode((long)a.CandidateId),
                        DateTaken = a.Finished == true ? ErecruitHelper.GetDateStringFromDate((DateTime)a.TimeStarted) : "Not Finished."
                    }).Distinct().ToList();
                    batchHistory.DataSource = quests;
                    batchHistory.DataBind();
                    batchHistoryPanel.Visible = true;
                    ScoreListPanel.Visible    = false;
                    SessionHelper.NullCandidateCode(Session);
                    Session["BatchSetId"] = null;
                }
                else if (count == 1)
                {
                    batchHistoryPanel.Visible = false;
                    SessionHelper.SetCandidateCode(code, Session);
                    Session["BatchSetId"] = null;
                    Response.Redirect("ViewTestScore.aspx", false);
                }
                else
                {
                    resultLbl.Text            = String.Empty;
                    batchHistoryPanel.Visible = false;
                }
            }
            else
            {
                resultLbl.Text            = "This is not a valid candidate code";
                batchHistoryPanel.Visible = false;
            }
        }
コード例 #2
0
        protected void check_Click(object sender, EventArgs e)
        {
            var code = Code.Text;

            var cand = _db.T_Candidate.FirstOrDefault(s => s.Code == code);

            if (!(cand == null))
            {
                var b_set = _db.T_BackGroundQuestAnswers.Where(s => s.CandidateId == cand.Id).ToList();
                int count = b_set.Count();
                if (count > 1)
                {
                    var quests = b_set.Select(a => new PrevBatchGridModel
                    {
                        ID        = a.Id,
                        BatchName = ErecruitHelper.getBatchName((long)a.BatchId),
                        Code      = ErecruitHelper.getCandidateCode((long)a.CandidateId) + "," + a.BatchId,
                        DateTaken = ErecruitHelper.GetDateStringFromDate((DateTime)a.Dateadded)
                    }).Distinct().ToList();
                    batchHistory.DataSource = quests;
                    batchHistory.DataBind();
                    batchHistoryPanel.Visible = true;

                    SessionHelper.NullCandidateCode(Session);
                    Session["Batchid"] = null;
                }
                else if (count == 1)
                {
                    batchHistoryPanel.Visible = false;
                    SessionHelper.SetCandidateCode(code, Session);
                    Session["Batchid"] = b_set[0].BatchId;
                    Response.Redirect("BackgroundView.aspx", false);
                }
                else
                {
                    resultLbl.Text            = "No History";
                    batchHistoryPanel.Visible = false;
                }
            }
            else
            {
                resultLbl.Text            = "This is not a valid candidate code";
                batchHistoryPanel.Visible = false;
            }
            //if (!string.IsNullOrEmpty(code))
            //{
            //    var cand = _db.T_Candidate.FirstOrDefault(s => s.Code == code);

            //    if (cand != null)
            //    {

            //        var b_id = _db.T_BatchSet.Where(s => s.CandidateId == cand.Id).Select(x => x.BatchId);

            //        var candBatch = _db.T_Batch.FirstOrDefault(s => b_id.Contains(s.Id) && s.IsActive.Value);
            //        if (candBatch != null)
            //        {


            //            var cbSet = _db.T_BatchSet.FirstOrDefault(s => s.BatchId == candBatch.Id && s.CandidateId == cand.Id);
            //            var c_off = _db.T_Settings.FirstOrDefault(s => s.SettingsName == ErecruitHelper.Settings.CUT_OFF_MARK.ToString()).SettingsValue;
            //            if (cbSet != null && cbSet.Finished == true)
            //            {
            //                if (double.Parse(cbSet.TestScore) > double.Parse(c_off))
            //                {
            //                    SessionHelper.SetCandidateCode(code, Session);
            //                    Response.Redirect("BackgroundView.aspx", false);
            //                }
            //                else
            //                {
            //                    resultLbl.Text = "The candidate did not pass the test.";
            //                }
            //            }
            //            else
            //            {
            //                var rsltTxt = "The candidate has not concluded the test.";



            //                resultLbl.Text = rsltTxt;
            //            }

            //        }
            //        else
            //        {
            //            resultLbl.Text = "The candidate has not been assigned to a test batch.";

            //        }

            //    }
            //    else
            //    {
            //        resultLbl.Text = "This is not a valid candidate code";
            //    }
            //}
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string currentPageFileName = new FileInfo(this.Request.Url.AbsolutePath).Name;
            var    PermMgr             = new PermissionManager(Session);

            if (PermMgr.IsAdmin || PermMgr.CanManageTestResults)
            {
                var c = SessionHelper.FetchCandidateCode(Session);
                if (!string.IsNullOrEmpty(c))
                {
                    var cand = _db.T_Candidate.FirstOrDefault(s => s.Code == c);
                    if (!(cand == null))
                    {
                        var b_id = _db.T_BatchSet.Where(s => s.CandidateId == cand.Id).Select(x => x.BatchId).ToList();

                        if (b_id.Count() != 0)
                        {
                            var bs        = new T_BatchSet();
                            var candBatch = new T_Batch();

                            if (Session["BatchSetId"] != null)
                            {
                                bs        = _db.T_BatchSet.FirstOrDefault(s => s.Id == long.Parse(Session["BatchSetId"].ToString()));
                                candBatch = _db.T_Batch.FirstOrDefault(s => s.Id == bs.BatchId);
                                var b_set  = _db.T_BatchSet.Where(s => s.CandidateId == cand.Id).ToList();
                                var quests = b_set.Select(a => new PrevBatchGridModel
                                {
                                    ID        = a.Id,
                                    BatchName = ErecruitHelper.getBatchName((long)a.BatchId),
                                    Code      = a.Finished == true ? ErecruitHelper.getCandidateCode((long)a.CandidateId) + "," + a.Id : ErecruitHelper.getCandidateCode((long)a.CandidateId),
                                    DateTaken = a.Finished == true ? a.TimeStarted.ToString() : "Not Finished."
                                }).Distinct().ToList();
                                batchHistory.DataSource = quests;
                                batchHistory.DataBind();
                                batchHistoryPanel.Visible = true;
                            }
                            else
                            {
                                bs        = _db.T_BatchSet.FirstOrDefault(s => s.CandidateId == cand.Id);
                                candBatch = _db.T_Batch.FirstOrDefault(s => s.Id == bs.BatchId);
                            }

                            if (bs.Finished == true)
                            {
                                int    totalQuestions = _db.T_BatchQuestions.Count(s => s.BatchId == candBatch.Id);
                                int    correct        = _db.T_CandidateAnswers.Count(s => s.CandidateId == cand.Id && s.BatchId == candBatch.Id && s.Correct == true);
                                double percentage     = (double)correct / totalQuestions;
                                percentage = Math.Round((percentage * 100), 2);

                                var rsltTxt = "Candidate Name: " + cand.FirstName + " " + cand.LastName + "<br /><br />Got " + correct + " question(s)  out of " + totalQuestions + " questions.<br /><br />Percentage Score: " + percentage + " %";

                                name.Text = rsltTxt;
                                CID.Value = cand.Code;
                                BID.Value = candBatch.Id.ToString();
                                BindScoreGrid(cand.Id, candBatch);
                            }
                            else
                            {
                                var rsltTxt = "The candidate has not concluded the test.";

                                name.Text = rsltTxt;
                                batchHistoryPanel.Visible = false;
                                ScoreListPanel.Visible    = false;
                            }
                        }
                        else
                        {
                            resultLbl.Text            = "The candidate has not been assigned to a test batch.";
                            batchHistoryPanel.Visible = false;
                            ScoreListPanel.Visible    = false;
                        }
                    }
                    else
                    {
                        resultLbl.Text            = "This is not a valid candidate code";
                        batchHistoryPanel.Visible = false;
                        ScoreListPanel.Visible    = false;
                    }
                }
            }
            else
            {
                batchHistoryPanel.Visible = false;
                ScoreListPanel.Visible    = false;
                Response.Redirect("NoPermission.aspx", false);
            }
        }