public List <Rollno> GetOldRollNo()
        {
            SystemContext context     = HttpContext.RequestServices.GetService(typeof(Exam_Management_System.Models.SystemContext)) as SystemContext;
            int           academic_id = context.GetAcademicSecond().Id;
            List <Rollno> list        = new List <Rollno>();

            using (MySqlConnection conn = context.GetConnection())
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("SELECT * FROM student,studentrollno,student_detail where student.id=studentrollno.student_id and studentrollno.id=student_detail.studentrollno_id and studentrollno.academic_id=" + academic_id, conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        list.Add(new Rollno()
                        {
                            Id   = Convert.ToInt32(reader["id"]),
                            Roll = reader["rollno"].ToString(),
                            Name = reader["student_name"].ToString(),
                        });
                    }
                }
            }
            return(list);
        }
        public void PostOldStudent(Student student)
        {
            SystemContext context    = HttpContext.RequestServices.GetService(typeof(Exam_Management_System.Models.SystemContext)) as SystemContext;
            int           academic   = context.GetAcademicSecond().Id;
            int           student_id = context.GetStudentId(student.Rollno, academic);
            int           mark       = context.GetMark(student_id);

            using (MySqlConnection conn = context.GetConnection())
            {
                conn.Open();
                string sql1 = $"Insert Into old_student (student_year_id,address,phone,father_phone,mother_phone,email,academic_id,major_id,student_id,mark) Values ('{student.Year_id}','{student.Address}','{student.Phone}','{student.Father_phone}','{student.Mother_phone}','{student.Email}','{student.Academic_id}','{student.Major_id}','{student_id}','{mark}')";
                using (MySqlCommand command1 = new MySqlCommand(sql1, conn))
                {
                    command1.ExecuteNonQuery();
                }
            }
            // return Redirect("/Student/AddOldStudent");
        }
        public List <Student> GetStudentYear(string id)
        {
            SystemContext  context     = HttpContext.RequestServices.GetService(typeof(Exam_Management_System.Models.SystemContext)) as SystemContext;
            int            academic_id = context.GetAcademic().Id;
            int            secondaca   = context.GetAcademicSecond().Id;
            List <Student> list        = new List <Student>();

            using (MySqlConnection conn = context.GetConnection())
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand("select * from studentrollno,student,old_student,result,major,year where result.studentrollno_id=studentrollno.id and studentrollno.student_id=student.id and old_student.student_id=student.id and studentrollno.rollno='" + id + "' and old_student.major_id=major.id and old_student.student_year_id=year.id order by result.academic_id", conn);

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        list.Add(new Student()
                        {
                            Id           = Convert.ToInt32(reader["id"]),
                            Rollno       = reader["rollno"].ToString(),
                            Name         = reader["student_name"].ToString(),
                            Major        = reader["major_name"].ToString(),
                            Major_id     = Convert.ToInt32(reader["major_id"]),
                            Year         = reader["year_name"].ToString(),
                            Year_id      = Convert.ToInt32(reader["student_year_id"]),
                            Pass         = Convert.ToInt32(reader["pass"]),
                            Father_name  = reader["father_name"].ToString(),
                            Mother_name  = reader["mother_name"].ToString(),
                            Img          = reader["img"].ToString(),
                            Phone        = reader["phone"].ToString(),
                            Father_phone = reader["father_phone"].ToString(),
                            Mother_phone = reader["mother_phone"].ToString(),
                            Email        = reader["email"].ToString(),
                            Address      = reader["address"].ToString(),
                        });
                    }
                }
            }
            return(list);
        }