示例#1
0
 public Registration_and_Marks()
 {
     student = new Student();
     marks = new Marks();
     course = new Course();
     session = new Session();
 }
示例#2
0
        public static List<Registration_and_Marks> getAllRegistrationList(int? sessionID, string batch, int? year, int? term, int? courseID, int? stdID)
        {
            OleDbConnection connection = new OleDbConnection(global::ResultManagement.Properties.Settings.Default.ConnectionString);

            /*string cmdStr = @"SELECT 
                             [session].ID as SessionID, [session].sessionName,
                              Student.ID as StdID, Student.Batch, Student.Roll, Student.St_Name,
                              Registered_Session.ID as registered_session_ID, Registered_Session.Reg_Year, Registered_Session.Reg_Term,
                              Registration_and_Marks.ID as MarksID, Registration_and_Marks.is_Retake, Registration_and_Marks.Attendence,
                                Registration_and_Marks.CT_or_Viva,Registration_and_Marks.SA_or_SecA, Registration_and_Marks.SecB,
                              Course.ID as CourseID, Course.Course_Prefix, Course.Course_Year, Course.Course_Term,
                                Course.Course_No, Course.Credit, Course.Title, Course.is_Optional
                              FROM [Session],Student,Registered_Session,Registration_and_Marks,Course
                              WHERE 
                             [Session].ID = Registered_Session.Sess_ID AND
                              Student.ID = Registered_Session.Std_ID AND
                              Registered_Session.ID = Registration_and_Marks.Reg_Sess_ID AND
                              Registration_and_Marks.Course_ID = Course.ID";*/

            string cmdStr = @"SELECT 
                             SessionID, sessionName,
                             StdID, Batch, Roll, St_Name,
                             registered_session_ID, Reg_Year, Reg_Term,
                             MarksID, is_Retake, Attendence,CT_or_Viva,SA_or_SecA, SecB,
                             CourseID, Course_Prefix, Course_Year, Course_Term,Course_No,Credit, Title, is_Optional
                             FROM 
                                (SELECT [session].ID as SessionID, [session].sessionName,
                                Student.ID as StdID, Student.Batch, Student.Roll, Student.St_Name,
                                Registered_Session.ID as registered_session_ID, Registered_Session.Reg_Year, Registered_Session.Reg_Term
                                FROM Student INNER JOIN 
                                    ([Session] INNER JOIN Registered_Session ON 
                                        [Session].ID=Registered_Session.Sess_ID) ON 
                                        Student.ID=Registered_Session.Std_ID) AS T1 
                              LEFT JOIN 
                                (SELECT Registration_and_Marks.ID as MarksID, Registration_and_Marks.Reg_Sess_ID, Registration_and_Marks.is_Retake, Registration_and_Marks.Attendence,
                                Registration_and_Marks.CT_or_Viva,Registration_and_Marks.SA_or_SecA, Registration_and_Marks.SecB,
                              Course.ID as CourseID, Course.Course_Prefix, Course.Course_Year, Course.Course_Term,
                                Course.Course_No, Course.Credit, Course.Title, Course.is_Optional 
                                FROM Course INNER JOIN 
                                     Registration_and_Marks ON 
                                        Course.ID=Registration_and_Marks.Course_ID) AS T2 
                              ON T1.registered_session_ID=T2.Reg_Sess_ID
                              WHERE 1 ";

            if (sessionID != null)
            {
                cmdStr += @" AND SessionID = " + sessionID;
            }
            if (batch != null)
            {
                cmdStr += @" AND Batch = '" + batch + "'";
            }
            if (year != null)
            {
                cmdStr += @" AND Reg_Year = " + year;
            }
            if (term != null)
            {
                cmdStr += @" AND Reg_Term = " + term;
            }
            if(courseID != null)
            {
                cmdStr += @" AND CourseID = " + courseID;
            }
            if (stdID != null)
            {
                cmdStr += @" AND StdID = " + stdID;
            }
            cmdStr += @" ORDER BY registered_session_ID, StdID, reg_year, reg_term, course_year desc, course_term desc, course_no, course_prefix";
            OleDbCommand cmd = new OleDbCommand(cmdStr, connection);
            List<Registration_and_Marks> registration_and_MarksList = new List<Registration_and_Marks>();
                
            try
            {
                connection.Open();
                OleDbDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Registration_and_Marks regisTration_and_Marks = new Registration_and_Marks();
                    regisTration_and_Marks.Registered_Session_ID = (int)reader.GetValue(reader.GetOrdinal("registered_session_ID"));
                    regisTration_and_Marks.Reg_Year = (int)reader.GetValue(reader.GetOrdinal("Reg_Year"));
                    regisTration_and_Marks.Reg_Term = (int)reader.GetValue(reader.GetOrdinal("Reg_Term"));

                    Session session = new Session();
                    session.SessionID = (int)reader.GetValue(reader.GetOrdinal("SessionID"));
                    session.SessionName = (string)reader.GetValue(reader.GetOrdinal("SessionName"));
                    regisTration_and_Marks.Session = session;

                    Student student = new Student();
                    student.Batch = (string)reader.GetValue(reader.GetOrdinal("Batch"));
                    student.StudentId = (int)reader.GetValue(reader.GetOrdinal("StdID"));
                    student.Roll = (string)reader.GetValue(reader.GetOrdinal("Roll"));
                    student.Name = (string)reader.GetValue(reader.GetOrdinal("St_Name"));
                    regisTration_and_Marks.Student = student;

                    Course course = new Course();
                    try
                    {
                        course.ID = (int?)reader.GetValue(reader.GetOrdinal("CourseID"));
                        course.Prefix = (string)reader.GetValue(reader.GetOrdinal("Course_Prefix"));
                        course.Year = (int?)reader.GetValue(reader.GetOrdinal("Course_Year"));
                        course.Term = (int?)reader.GetValue(reader.GetOrdinal("Course_Term"));
                        course.Course_No = (string)reader.GetValue(reader.GetOrdinal("Course_No"));
                        course.Credit = (decimal?)reader.GetValue(reader.GetOrdinal("Credit"));
                        course.Title = (string)reader.GetValue(reader.GetOrdinal("Title"));
                        course.Is_Optional = (bool?)reader.GetValue(reader.GetOrdinal("is_Optional"));
                        regisTration_and_Marks.Course = course;
                    }
                    catch { }
                    
                    Marks marks = new Marks();
                    try
                    {
                        marks.MarksID = (int?)reader.GetValue(reader.GetOrdinal("MarksID"));
                        marks.IsRetake = (bool?)reader.GetValue(reader.GetOrdinal("is_Retake"));
                        marks.Attendence = (int?)reader.GetValue(reader.GetOrdinal("Attendence"));
                        marks.Ct_or_Viva = (int?)reader.GetValue(reader.GetOrdinal("CT_or_Viva"));
                        marks.SA_or_SecA = (int?)reader.GetValue(reader.GetOrdinal("SA_or_SecA"));
                        marks.SecB = (int?)reader.GetValue(reader.GetOrdinal("SecB"));
                        regisTration_and_Marks.Marks = marks;
                    }
                    catch { }
                    
                    registration_and_MarksList.Add(regisTration_and_Marks);
                }
            }
            finally
            {
                connection.Close();
            }
            return registration_and_MarksList;
        }