public ActionResult ShowResult2(ViewResults viewResults, string RegNo)
        {
            
           
            Student Students = studentManager.GetAllStudentbyRegNo(RegNo);

            ViewBag.studentLists = Students;

            StudentView studentView = studentManager.GetAllDepartmentNameByRegNo(RegNo);
            ViewBag.DepartmentName = studentView;
            List<ViewResults> results = courseManager.GetAllResult(RegNo);
            ViewBag.Results = results;
            DateTime dt = DateTime.Now;
            ViewBag.Date = dt;
            return View();

        }
        public ActionResult ShowResult(ViewResults viewResults,  string RegNo)
        {
            regno1 = RegNo;
            ViewBag.PostBack = false;
            List<Student> students = studentManager.GetAllStudent();
            ViewBag.StudentList = students;
            if (RegNo != String.Empty)
            {
                ViewBag.PostBack = true;
            }
            Student Students = studentManager.GetAllStudentbyRegNo(RegNo);

            ViewBag.studentLists = Students;

            StudentView studentView=studentManager.GetAllDepartmentNameByRegNo(RegNo);
            ViewBag.DepartmentName = studentView;
            List<ViewResults> results = courseManager.GetAllResult(RegNo);
            ViewBag.Results = results;
            return new ActionAsPdf(
              "ShowResult2",
              new { viewResults = viewResults, RegNo = RegNo }

              ) { FileName = "ResultView.pdf" };
        }
        public List<ViewResults> GetAllResult(string regNo)
        {
            connection.ConnectionString = connectionString;

            //string query = "SELECT Course.Code AS CourseCode,Course.Name AS CourseName, Grade FROM Course INNER JOIN EnrollCourse ON Course.Id= EnrollCourse.CourseId LEFT JOIN  StudentResult ON EnrollCourse.CourseId= StudentResult.CourseId  WHERE EnrollCourse.RegNo= '" + regNo + "'";
            string query = "SELECT Course.Code AS CourseCode,Course.Name AS CourseName, StudentResult.Grade,StudentResult.RegNo FROM Course LEFT JOIN StudentResult ON Course.Id= StudentResult.CourseId  WHERE StudentResult.RegNo= '" + regNo + "'";


            //string query = "SELECT Course.Code AS CourseCode,Course.Name AS CourseName FROM Course INNER JOIN EnrollCourse ON Course.Id= EnrollCourse.CourseId  WHERE EnrollCourse.RegNo= '" + regNo + "'";

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            List<ViewResults> viewResults = new List<ViewResults>();
            while (reader.Read())
            {

                ViewResults viewresults = new ViewResults();
                //viewresults.Id = Convert.ToInt32(reader["Id"].ToString());
                viewresults.CourseCode = reader["CourseCode"].ToString();
                viewresults.CourseName = reader["CourseName"].ToString();
                if (!reader["Grade"].Equals(System.DBNull.Value))
                {
                    viewresults.Grade = reader.GetString(reader.GetOrdinal("Grade"));
                }
                else
                {
                    viewresults.Grade = "Not Graded Yet ";
                }
                //viewresults.Grade = reader["Grade"].ToString();
                viewResults.Add(viewresults);
            }

            reader.Close();
            connection.Close();
            return viewResults;
        }