Beispiel #1
0
        //
        //On Form Load: Displays Welcome Message, displays today's schedule, if any
        //
        private void EmpHome_Load(object sender, EventArgs e)
        {
            emp = b.getEmployee(emp);
            welcomeLabel.Text = "Welcome " + emp.first_Name + " " + emp.last_Name;

            ResultsBS r = new ResultsBS();
            int count = r.getExamCountForEmployee(emp);
            Exam_Details[] er = new Exam_Details[count];
            er = r.getExamIDsForEmployee(emp, count);
            er = eb.getSchedule(er);
            int[] index = eb.checkTodaysSchedule(er);
            Results[] res = new Results[index.Length];
            for (int i = 0; i < index.Length; i++)
            {
                res[i] = new Results();
                res[i].employee_ID = emp.employee_Id;
                res[i].exam_ID = er[index[i]].exam_ID;
            }

            //bool[] feed = new bool[index.Length];
            res = r.checkIfAppeared(res);

            int total = 0;
            for (int i = res.Length - 1; i >= 0; i--)
            {
                if (res[i].score == -1)
                {
                    total++;
                    ed.exam_ID = res[i].exam_ID;
                }
            }

            if (total == 0)
            {
                examIDLabel.Text = "Sorry.";
                examTypeLabel.Text = "You dont have any test scheduled today.";
                dateLabel.Text = "";
                durationLabel.Text = "";
                noteLabel.Text = "";
                skipTutorial.Enabled = false;
                takeTutorial.Enabled = false;
            }
            else
            {
                ed = eb.getExamDetails(ed);
                Exam_Types et1 = new Exam_Types();
                et1.exam_Type = ed.exam_Type;
                et1 = et.getExamType(et1);

                examIDLabel.Text += ed.exam_ID;
                examTypeLabel.Text +=" " +et1.exam_Type + " (" + et1.subject + " Level " + et1.level_Number+")";
                dateLabel.Text += ed.datetime.Date.ToShortDateString(); ;
                durationLabel.Text += +ed.duration;
                total--;
                if (total >= 1)
                    noteLabel.Text += "You have " + total + " more exams scheduled today.";
                else
                    noteLabel.Text = "";
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     ResultsBS r = new ResultsBS();
     int count = r.getConductedExamsCount();
     if (count > 0)
     {
         Results[] rs = new Results[count];
         rs = r.loadConductedExamID(rs);
         for (int j = 0; j < count; j++)
         {
             examIDCombo.Items.Add(rs[j].exam_ID);
         }
     }
     else
         System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('No Exams present in the database.')</SCRIPT>");
 }
Beispiel #3
0
 //
 //On form Load: Loads the conducted exam IDs
 //
 private void CheckDetailed_Load(object sender, EventArgs e)
 {
     ResultsBS r = new ResultsBS();
     int count = r.getConductedExamsCount();
     if (count > 0)
     {
         Results[] rs = new Results[count];
         rs = r.loadConductedExamID(rs);
         for (int j = 0; j < count; j++)
         {
             examIDCombo.Items.Add(rs[j].exam_ID);
         }
     }
     else
         MessageBox.Show("No Exams yet conducted","Error",MessageBoxButtons.OK);
 }
Beispiel #4
0
        //
        //Updates & displays time. On time up, submits the paper
        //
        private void Timer_Tick(object sender, EventArgs e)
        {
            if (timeLeft > 0)
            {
                // Updates & Display the new time left
                timeLeft = timeLeft - 1;
                min = timeLeft / 60;
                sec = timeLeft - 60 * min;
                timerLabel.Text = min + " minutes: " + sec + " seconds";
            }
            else
            {
                //If the user runs out of time, stops the timer, shows a MessageBox
                Timer.Stop();
                timerLabel.Text = "Time's up!";
                MessageBox.Show("You have run out of time! You didn't finish in time. Sorry.", "Time up !", MessageBoxButtons.OK);

                //Stores the answer
                ans = (string)orderTextBox.Text;
                ab.storeAnswer(a, index, ans);

                //Calculates score, stores answers and result in database
                bool feed = ab.submit(a, q, emp, ed);
                if (feed == true)
                {

                    //Add Detailed Result
                    Results re = new Results();
                    DetailedReports dr = new DetailedReports();
                    re.employee_ID = emp.employee_Id;
                    re.exam_ID = ed.exam_ID;
                    //re.score = score;
                    ResultsBS rb = new ResultsBS();
                    bool flag = rb.calculateResult(a, q, re, emp);

                    //Navigates to Results Form
                    Result rs = new Result(emp, ed, q, a);
                    rs.MdiParent = this.MdiParent;
                    rs.Dock = DockStyle.Fill;
                    this.Close();
                    rs.Show();
                }
                else
                    MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error");
            }
        }
Beispiel #5
0
        //
        //On click on Submit button: Stores the selected answer, Confirms choice to submit, submits and navigates to Result Form
        //
        private void submit_Click(object sender, EventArgs e)
        {
            //Stores the selected answer
            ans = (string)orderTextBox.Text;
            ab.storeAnswer(a, index, ans);

            //Confirms choice to submit
            DialogResult r = MessageBox.Show("Are you sure you want to submit?", "Submit Test", MessageBoxButtons.YesNo);
            if (r == DialogResult.Yes)
            {
                //Calculates score, stores answers, and result
                bool feed = ab.submit(a, q, emp, ed);
                if (feed == true)
                {
                    //Add Detailed Result
                    Results re = new Results();
                    DetailedReports dr = new DetailedReports();
                    re.employee_ID = emp.employee_Id;
                    re.exam_ID = ed.exam_ID;
                    //re.score = score;
                    ResultsBS rb = new ResultsBS();
                    bool flag = rb.calculateResult(a, q, re, emp);

                    //Navigates to Results Form
                    Result rs = new Result(emp, ed, q, a);
                    rs.MdiParent = this.MdiParent;
                    rs.Dock = DockStyle.Fill;
                    this.Close();
                    rs.Show();
                }
                else
                    MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error");
            }
        }
        //
        //On Form Load
        //
        private void SelectResult_Load(object sender, EventArgs e)
        {
            // to allign the Legend(Group Box) to
            // the center of form
            int centerForm;
            int centerGroup;
            int groupStartPosition;

            centerForm = this.Width / 2;
            centerGroup = selectExamLegend.Width / 2;
            groupStartPosition = centerForm - centerGroup;
            selectExamLegend.Left = groupStartPosition;

            ResultsBS r = new ResultsBS();
            int count = r.getConductedExamsCount();
            if (count > 0)
            {
                Results[] rs = new Results[count];
                rs = r.loadConductedExamID(rs);
                for (int i = 0; i < count; i++)
                {
                    examIDCombo.Items.Add(rs[i].exam_ID);
                }
            }
            else
                MessageBox.Show("No Exams yet conducted");
        }
        protected void timer1_tick(object sender, EventArgs e)
        {
            if (0 > DateTime.Compare(DateTime.Now, DateTime.Parse(Session["timeout"].ToString())))
            {
                timerLabel.Text = string.Format("Time Left: 00:{0}:{1}", ((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).TotalMinutes).ToString(), ((Int32)DateTime.Parse(Session["timeout"].ToString()).Subtract(DateTime.Now).Seconds).ToString());
            }
            else
            {
                //If the user runs out of time, stops the timer, shows a MessageBox
                //Timer.Stop();
                timerLabel.Text = "Time's up!";
                //MessageBox.Show("You have run out of time! You didn't finish in time. Sorry.", "Time up !", MessageBoxButtons.OK);
                System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('You have run out of time! You didn't finish in time. Sorry.')</SCRIPT>");

                //Stores the selected ans
                string ans = "";
                if (option1RadioButton.Checked)
                    ans = "1";
                else if (option2RadioButton.Checked)
                    ans = "2";
                else if (option3RadioButton.Checked)
                    ans = "3";
                else if (option4RadioButon.Checked)
                    ans = "4";
                a[index].answer = ans;
                //a = ab.storeAnswer(a, index, ans);

                //Calculates score, stores answers and result in database
                bool feed = ab.submit(a, q, emp, ed);
                if (feed == true)
                {

                    //Add Detailed Result
                    Results re = new Results();
                    DetailedReports dr = new DetailedReports();
                    re.employee_ID = emp.employee_Id;
                    re.exam_ID = ed.exam_ID;
                    //re.score = score;
                    ResultsBS rb = new ResultsBS();
                    bool flag = rb.calculateResult(a, q, re, emp);

                    /*Navigates to Results Form
                    Result rs = new Result(emp, ed, q, a);
                    rs.MdiParent = this.MdiParent;
                    rs.Dock = DockStyle.Fill;
                    this.Close();
                    rs.Show();*/
                }
            }
        }
        protected void submit_Click(object sender, EventArgs e)
        {
            //Stores the selected ans
            string ans = "";
            //Response.Write(option1RadioButton.Checked.ToString());
            if (option1RadioButton.Checked)
                //Response.Write("Hello 1");
                //(Session["answeres"] as Answers[])[index].answer = "1";
                a[index].answer = "1";
            else if (option2RadioButton.Checked)
                a[index].answer = "2";
            else if (option3RadioButton.Checked)
                a[index].answer = "3";
            else if (option4RadioButon.Checked)
                a[index].answer = "4";
            //a = ab.storeAnswer(a, index, ans);
            //answ.Text = a[index].answer;
            //Response.Write("Hello" + answ.Text + "  " + a[index].answer);

            Session.Remove("answers");
            Session["answers"] = a;

            string confirmValue = Request.Form["confirm_value"];
            if (confirmValue == "Yes")
            {

                Session["questions"] = q;
                Session["answers"] = a;
                Session["employee"] = emp;
                Session["exam"] = ed;

                bool feed = ab.submit(a, q, emp, ed);
                if (feed == true)
                {
                    //Add Detailed Result
                    Results re = new Results();
                    DetailedReports dr = new DetailedReports();
                    re.employee_ID = emp.employee_Id;
                    re.exam_ID = ed.exam_ID;
                    //re.score = score;
                    ResultsBS rb = new ResultsBS();
                    bool flag = rb.calculateResult(a, q, re, emp);

                    /*Navigates to Results Form
                    Result rs = new Result(emp, ed, q, a);
                    rs.MdiParent = this.MdiParent;
                    rs.Dock = DockStyle.Fill;
                    this.Close();
                    rs.Show();*/

                    Response.Redirect("~/Result.aspx");
                }
                else
                    System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Some error occured. Sorry for the inconvenience.')</SCRIPT>");
                //MessageBox.Show("Some error occured. Sorry for the inconvenience.", "Error");
            }
        }
        //
        //On click of Add button, validates and adds applicants
        //
        private void add_Click(object sender, EventArgs e)
        {
            if (employeeIDCombo.SelectedIndex == -1 || examIDCombo.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a valid entry.", "Error");
            }
            else
            {
                //Creates Results objects
                Results r = new Results();
                string id = employeeIDCombo.Text.ToString();
                int pos = id.IndexOf(":");
                r.employee_ID = id.Substring(0, pos);
                r.exam_ID = examIDCombo.Text.ToString();

                //Gets exam type of exam ID
                Exam_Details ed = new Exam_Details();
                ed.exam_ID = r.exam_ID;
                ed = edb.getExamDetails(ed);

                //Gets number of attempts for exam type
                Exam_Types et = new Exam_Types();
                Exam_TypeBS etb = new Exam_TypeBS();
                et.exam_Type = ed.exam_Type;
                et = etb.getExamType(et);

                //Creates ResultStatus objects
                ResultStatus rs = new ResultStatus();
                rs.employee_ID = r.employee_ID;
                rs.exam_Type = ed.exam_Type;

                //Gets the attempts_no and status
                ResultStatusBS rsb = new ResultStatusBS();
                rs = rsb.getResultStatus(rs);

                ResultsBS rb = new ResultsBS();

                //Unscheduled
                if (rs.status == "Unscheduled")
                {
                    rs.attempt_No = 1;
                    rs.status = "Scheduled";
                    string feedback = rsb.addResultStatus(rs);
                    if (feedback == "Error")
                    {
                        MessageBox.Show("Some error occured. Sorry for the inconvenience.");
                    }
                    else
                    {
                        string feed = rb.addApplicant(r);
                        if (feed == "Error")
                        {
                            MessageBox.Show("Some error occured. Sorry for the inconvenience.");
                            rsb.deleteResultStatus(rs);
                        }
                        else
                        {
                            //Succesfully scheduled
                            MessageBox.Show(feed + feedback, "Scheduled", MessageBoxButtons.OK);
                            examIDCombo.SelectedIndex = employeeIDCombo.SelectedIndex = 0;
                        }
                    }
                }
                //Scheduled
                else if (rs.status == "Scheduled")
                {
                    MessageBox.Show("Employee " + rs.employee_ID + " already has an exam scheduled for exam type " + rs.exam_Type + ".", "Already Scheduled", MessageBoxButtons.OK);
                }
                //Passed
                else if (rs.status == "Passsed")
                {
                    MessageBox.Show("Employee " + rs.employee_ID + " has passed an exam of exam type " + rs.exam_Type + ".", "Passed", MessageBoxButtons.OK);
                }
                //Failed
                else if (rs.status == "Failed")
                {
                    ///Exhausted Attempts
                    if (rs.attempt_No == et.no_Of_Attempts)
                    {
                        MessageBox.Show("Employee " + rs.employee_ID + " has used up the maximum number of attempts for exam type " + rs.exam_Type + ".", "Exhausted Attempts", MessageBoxButtons.OK);
                    }
                    //Attempts left
                    else
                    {
                        rs.Attempt_No++;
                        rs.status = "Scheduled";

                        string feedback = rsb.updateResultStatus(rs);
                        if (feedback == "Error")
                        {
                            MessageBox.Show("Some error occured. Sorry for the inconvenience.");
                        }
                        else
                        {
                            string feed = rb.addApplicant(r);
                            if (feed == "Error")
                            {
                                MessageBox.Show("Some error occured. Sorry for the inconvenience.");
                                rs.attempt_No--;
                                rsb.updateResultStatus(rs);
                            }
                            else
                            {
                                //Succesfully scheduled
                                MessageBox.Show(feed + feedback, "Scheduled", MessageBoxButtons.OK);
                                examIDCombo.SelectedIndex = employeeIDCombo.SelectedIndex = 0;
                            }
                        }
                    }
                }
            }
        }