public IEnumerable <copy_correction> AllUncheckedQuestions(copy_correction copy)
        {
            string query = @"SELECT 
                                session,
                                class_id,
                                section_id,
                                subject_id,
                                chapter_id,
                                work_type,
                                work_id,
                                work_name,
                                work_date
                            FROM
                                mst_class_notebook
                            WHERE
                                work_id NOT IN (SELECT 
                                        work_id
                                    FROM
                                        copy_correction
                                    WHERE
                                        sr_number = @sr_number AND session = @session)
                                    AND session = @session
                                    AND subject_id = @subject_id
                                    AND class_id = @class_id
                                    AND section_id = @section_id
                                    AND chapter_id = @chapter_id
                            ORDER BY work_date DESC , work_type";

            var result = con.Query <copy_correction>(query, new { sr_number = copy.sr_number, session = copy.session, subject_id = copy.subject_id, class_id = copy.class_id, section_id = copy.section_id, chapter_id = copy.chapter_id });

            return(result);
        }
        public ActionResult AllUncheckedQuestions(int sr_number, string session, int class_id, int subject_id, int chapter_id, int section_id)
        {
            copy_correctionMain main = new copy_correctionMain();
            copy_correction     copy = new copy_correction();

            copy.sr_number  = sr_number;
            copy.session    = session;
            copy.subject_id = subject_id;
            copy.class_id   = class_id;
            copy.section_id = section_id;
            copy.chapter_id = chapter_id;


            ViewData["session"]    = session;
            ViewData["subject_id"] = subject_id;
            ViewData["class_id"]   = class_id;
            ViewData["section_id"] = section_id;
            ViewData["sr_number"]  = sr_number;

            var result = main.AllUncheckedQuestions(copy);

            foreach (var corr in result)
            {
                corr.sr_number         = sr_number;
                corr.chapter_id        = chapter_id;
                corr.teacher_correctby = int.Parse(Request.Cookies["loginUserId"].Value.ToString());
                corr.class_id          = class_id;
                corr.section_id        = section_id;
                corr.subject_id        = subject_id;
            }

            return(View(result));
        }
        public ActionResult Student_Copy(copy_correction copy)
        {
            using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
            {
                string query = @"SELECT 
                                    COUNT(*)
                                FROM
                                    mst_std_class a,
                                    mst_std_section b
                                WHERE
                                    a.session = b.session
                                        AND a.sr_num = b.sr_num
                                        AND a.class_id = @class_id
                                        AND b.section_id = @section_id
                                        AND a.sr_num = @sr_number";

                int flag = con.Query <int>(query, new { sr_number = copy.sr_number, class_id = copy.class_id, section_id = copy.section_id }).SingleOrDefault();

                if (flag == 0)
                {
                    ModelState.AddModelError(String.Empty, "Student not found.");
                    return(View(copy));
                }

                return(RedirectToAction("AllUncheckedChapters", new { sr_number = copy.sr_number, session = copy.session, subject_id = copy.subject_id, class_id = copy.class_id, section_id = copy.section_id }));
            }
        }
        public ActionResult Student_Copy(string session, int subject_id, int class_id, int section_id)
        {
            copy_correction copy = new copy_correction();

            copy.subject_id = subject_id;
            copy.session    = session;
            copy.class_id   = class_id;
            copy.section_id = section_id;

            return(View(copy));
        }
        public ActionResult AllUncheckedChapters(int sr_number, string session, int subject_id, int class_id, int section_id)
        {
            copy_correctionMain main = new copy_correctionMain();
            copy_correction     copy = new copy_correction();

            copy.sr_number  = sr_number;
            copy.session    = session;
            copy.subject_id = subject_id;
            copy.class_id   = class_id;
            copy.section_id = section_id;


            ViewData["session"]    = session;
            ViewData["subject_id"] = subject_id;
            ViewData["class_id"]   = class_id;
            ViewData["section_id"] = section_id;
            ViewData["sr_number"]  = sr_number;

            return(View(main.AllUncheckedChapterList(copy)));
        }
        public IEnumerable <mst_chapter> AllUncheckedChapterList(copy_correction copy)
        {
            string query = @"SELECT 
                                    session,
                                    class_id,
                                    section_id,
                                    subject_id,
                                    chapter_id,
                                    chapter_name,
                                    chapter_start_date,
                                    chapter_end_date
                                FROM
                                    mst_chapter
                                WHERE
                                    CONCAT(class_id,
                                            section_id,
                                            subject_id,
                                            chapter_id) IN (SELECT DISTINCT
                                            CONCAT(class_id,
                                                        section_id,
                                                        subject_id,
                                                        chapter_id)
                                        FROM
                                            mst_class_notebook
                                        WHERE
                                            work_id NOT IN (SELECT 
                                                    work_id
                                                FROM
                                                    copy_correction
                                                WHERE
                                                    sr_number = @sr_number AND session = @session)
                                                AND session = @session)
                                        AND session = @session
                                        AND subject_id = @subject_id
                                        AND class_id = @class_id
                                        AND section_id = @section_id";

            var result = con.Query <mst_chapter>(query, new { sr_number = copy.sr_number, session = copy.session, subject_id = copy.subject_id, class_id = copy.class_id, section_id = copy.section_id });

            return(result);
        }