//Calculate Detailed Result
        public bool calculateResult(Answers[] a, Questions[] q, Results r, Employee emp)
        {
            bool flag = true;
            int count = q.Length;
            int total = 0;
            string[] abc;
            ResultsDAL d = new ResultsDAL();

            int i = d.getSectionCount(r);
            DetailedReports[] re = new DetailedReports[i];
            abc = new string[i];
            int[] section = new int[i];
            abc = d.loadSection(r, i);

            int[] totalQuestions = d.totalSectionQuestions(abc, r);

            for (int j = 0; j < count; j++)
            {

                //total = total + q[j].marks;
                if (a[j].answer.Equals(q[j].solution))
                {
                    string click = q[j].section;
                    for (int k = 0; k < i; k++)
                    {
                        if (click == abc[k])
                            section[k]++;
                    }
                }
            }

            for (int k = 0; k < i; k++)
            {
                re[k] = new DetailedReports();
                re[k].employee_ID = emp.employee_Id;
                re[k].exam_ID = r.exam_ID;
                re[k].section = abc[k];
                re[k].percentage = (section[k] * 100) / totalQuestions[k];
                flag = d.addDetailedResult(re[k]);
            }
            return flag;
        }
        //
        //Calculates marks for each question and the total, stores them in Answers array, DAL call to store the answers in the Answers table, and final results in the Result table
        //
        public bool submit(Answers[] a, Questions[] q, Employee emp, Exam_Details ed)
        {
            //Calculates marks for each question (stores them in Answers array), total and percentage
            int score = 0;
            int outOf = 0;
            float per = 0;
            for (int i = 0; i < q.Length; i++)
            {
                if (a[i].answer.Equals(q[i].solution))
                    a[i].marks = q[i].marks;
                else
                    a[i].marks = 0;
                score += a[i].marks;
                outOf += q[i].marks;
            }
            per = (score *100) / outOf;

            //DAL call to store the answers in the Answers table
            bool feed = d.submitAnswers(a);

            //DAL call to store final result in the Result table
            if (feed)
            {
                Results re = new Results();
                re.employee_ID = emp.employee_Id;
                re.exam_ID = ed.exam_ID;
                re.score = score;
                re.percentage = per;
                ResultsDAL rb = new ResultsDAL();
                bool feed1 = rb.addScore(re);
                if (feed1)
                {
                    ResultStatusDAL rsd = new ResultStatusDAL();
                    ResultStatus rs = new ResultStatus();
                    rs.employee_ID = emp.employee_Id;
                    rs.exam_Type = ed.exam_Type;
                    if (re.percentage >= 50.0)
                        rs.status = "Passed";
                    else
                        rs.status = "Failed";
                    bool feed2 = rsd.updateStatus(rs);
                    if (feed2)
                        return true;
                    else
                        return false;
                }
                else
                    return false;
            }
            else
                return false;
        }