public void Generate()
        {
            SystemContext  context = HttpContext.RequestServices.GetService(typeof(Exam_Management_System.Models.SystemContext)) as SystemContext;
            int            academic = context.GetAcademic().Id;
            List <Year>    years = new List <Year>();
            List <Student> list = new List <Student>();
            List <Student> oldstudent = new List <Student>();
            int            roll = 1;
            int            roll2 = 1; int ct_roll2 = 1;
            int            roll3 = 1; int ct_roll3 = 1;
            int            roll4 = 1; int ct_roll4 = 1;
            int            roll5 = 1; int ct_roll5 = 1;

            using (MySqlConnection conn = context.GetConnection())
            {
                conn.Open();
                MySqlCommand cmd1 = new MySqlCommand("select * from year", conn);

                using (var reader = cmd1.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        years.Add(new Year()
                        {
                            Id   = Convert.ToInt32(reader["id"]),
                            Name = reader["year_name"].ToString(),
                        });
                    }
                }
                foreach (var year in years)
                {
                    list.Clear();
                    MySqlCommand cmd = new MySqlCommand("select * from old_student where academic_id=" + academic + " and student_year_id=" + year.Id + " order by mark desc ", conn);

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            list.Add(new Student()
                            {
                                Id         = Convert.ToInt32(reader["id"]),
                                Student_id = Convert.ToInt32(reader["student_id"]),
                                //Name = reader["student_name"].ToString(),
                                Year_id  = Convert.ToInt32(reader["student_year_id"]),
                                Major_id = Convert.ToInt32(reader["major_id"])
                            });
                        }
                    }
                    foreach (var student in list)
                    {
                        int    studentrollno_id = 0;
                        int    class_id         = 0;
                        string rollno1          = null;

                        if (student.Year_id == 1)
                        {
                            rollno1  = "1CST-" + roll;
                            class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll);
                            roll++;
                        }
                        else if (student.Year_id == 2)
                        {
                            if (student.Major_id == 2)
                            {
                                rollno1  = "2CS-" + roll2;
                                class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll2);
                                roll2++;
                            }
                            else
                            {
                                rollno1  = "2CT-" + ct_roll2;
                                class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll2);
                                ct_roll2++;
                            }
                        }
                        else if (student.Year_id == 3)
                        {
                            if (student.Major_id == 2)
                            {
                                rollno1  = "3CS-" + roll3;
                                class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll3);
                                roll3++;
                            }
                            else
                            {
                                rollno1  = "3CT-" + ct_roll3;
                                class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll3);
                                ct_roll3++;
                            }
                        }
                        else if (student.Year_id == 4)
                        {
                            if (student.Major_id == 2)
                            {
                                rollno1  = "4CS-" + roll4;
                                class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll4);
                                roll4++;
                            }
                            else
                            {
                                rollno1  = "4CT-" + ct_roll4;
                                class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll4);
                                ct_roll4++;
                            }
                        }
                        else
                        {
                            if (student.Major_id == 2)
                            {
                                rollno1  = "5CS-" + roll5;
                                class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll5);
                                roll5++;
                            }
                            else
                            {
                                rollno1  = "5CT-" + ct_roll5;
                                class_id = context.GetClassStudent(student.Year_id, student.Major_id, roll5);
                                ct_roll5++;
                            }
                        }


                        string sql = $"Insert Into studentrollno (student_id,academic_id,rollno) Values ('{student.Student_id}','{academic}','{rollno1}')";

                        using (MySqlCommand command = new MySqlCommand(sql, conn))
                        {
                            command.ExecuteNonQuery();
                            studentrollno_id = context.GetlastId();
                        }
                        string sql1 = $"Insert Into student_detail (studentrollno_id,year_id,major_id,class_id,academic_id) Values ('{studentrollno_id}','{student.Year_id}','{student.Year_id}','{class_id}','{academic}')";
                        using (MySqlCommand command1 = new MySqlCommand(sql1, conn))
                        {
                            command1.ExecuteNonQuery();
                        }
                    }
                }
                //////////////////////////////////////////////////////////////////////////////////////
            }
        }