public Registration_and_Marks()
 {
     student = new Student();
     marks = new Marks();
     course = new Course();
     session = new Session();
 }
Exemple #2
0
 private void InsertButton_Click(object sender, EventArgs e)
 {
     int deleteFailureCounter = 0, updateFailureCounter = 0, insertFailureCounter = 0;
     for (int i = 0; i < dataGridView1.RowCount - 1; i++)
     {
         if ((UpdateType)dataGridView1.Rows[i].Tag == UpdateType.Delete)
         {
             if (!Course.Delete((int?)dataGridView1["courseIDColumn",i].Value))
             {
                 deleteFailureCounter++;
             }
         }
         else if ((UpdateType)dataGridView1.Rows[i].Tag == UpdateType.Insert)
         {
             Course course = new Course();
             course.Prefix = (string)dataGridView1["CoursePrefixColumn", i].Value;
             course.Title = (string)dataGridView1["CourseTitleColumn", i].Value;
             course.Is_Optional = (bool?)dataGridView1["IsOptionalColumn", i].Value;
             string CourseNumber = (string)dataGridView1["courseNumberColumn", i].Value;
             if (CourseNumber.Length == 4)
             {
                 int courseYear = int.Parse(CourseNumber[0].ToString());
                 if (courseYear > 0 && courseYear <= 4)
                 {
                     int courseTerm = int.Parse(CourseNumber[1].ToString());
                     if (courseTerm > 0 && courseTerm <= 2)
                     {
                         course.Year = courseYear;
                         course.Term = courseTerm;
                         course.Course_No = CourseNumber.Substring(2, 2);
                         try
                         {
                             course.Credit = (decimal?)decimal.Parse("0" + dataGridView1["CreditHourColumn", i].Value.ToString());
                             if (!course.Insert())
                             {
                                 insertFailureCounter++;
                             }
                             courseList.Add(course);
                             dataGridView1.Rows[i].Tag = UpdateType.Update;
                         }
                         catch {
                             insertFailureCounter++;
                         }
                     }
                     else
                         insertFailureCounter++;
                 }
                 else
                     insertFailureCounter++;
             }
             else
                 insertFailureCounter++;
         }
         else if ((UpdateType)dataGridView1.Rows[i].Tag == UpdateType.Update)
         { 
             Course course = courseList[i];
             course.ID = (int?)dataGridView1["CourseIDColumn", i].Value;
             course.Prefix = (string)dataGridView1["CoursePrefixColumn", i].Value;
             course.Title = (string)dataGridView1["CourseTitleColumn", i].Value;
             course.Is_Optional = (bool?)dataGridView1["IsOptionalColumn", i].Value;
             string CourseNumber = (string)dataGridView1["courseNumberColumn", i].Value;
             if (CourseNumber.Length == 4)
             {
                 int courseYear = int.Parse(CourseNumber[0].ToString());
                 if (courseYear > 0 && courseYear <= 4)
                 {
                     int courseTerm = int.Parse(CourseNumber[1].ToString());
                     if (courseTerm > 0 && courseTerm <= 2)
                     {
                         course.Year = courseYear;
                         course.Term = courseTerm;
                         course.Course_No = CourseNumber.Substring(2, 2);
                         try
                         {
                             course.Credit = (decimal?)decimal.Parse("0" + dataGridView1["CreditHourColumn", i].Value.ToString());
                             if (!course.Update())
                             {
                                 updateFailureCounter++;
                             }
                         }
                         catch
                         {
                             updateFailureCounter++;
                         }
                     }
                     else
                         updateFailureCounter++;
                 }
                 else
                     updateFailureCounter++;
             }
             else
                 updateFailureCounter++;
         }
     }
     if (updateFailureCounter == 0 && deleteFailureCounter == 0 && insertFailureCounter == 0)
         MessageBox.Show("Updated Successfully");
     else
     {
         string s = "";
         if(deleteFailureCounter != 0)
             s+=deleteFailureCounter + " rows failed to delete.\r\n";
         if(updateFailureCounter != 0)
             s += updateFailureCounter + " rows failed to update.Pssible Reason is Duplicate/Invalid Course Number or Invalid Credit Hour\r\n";
         if(insertFailureCounter != 0)
             s += insertFailureCounter + " rows failed to Insert. Pssible Reason is Duplicate/Invalid Course Number or Invalid Credit Hour";
         MessageBox.Show(s);
     }
 }
        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;
        }
Exemple #4
0
        public static List<Course> getCourseListOfATerm(int? year, int? term)
        {
            OleDbConnection connection = new OleDbConnection(global::ResultManagement.Properties.Settings.Default.ConnectionString);

            string cmdStr = @"SELECT ID, Course_Prefix, Course_Year, Course_Term, Course_No,
                                Credit, Title, is_Optional
                                From Course
                                WHERE 1 ";
            if (year != null)
            {
                cmdStr += " AND Course_Year = " + year;
            }
            if (term != null)
            {
                cmdStr += " AND Course_Term = " + term;
            }
            cmdStr += @" ORDER BY Course_prefix,Course_year desc,Course_term desc,Course_no";
            
            List<Course> courseList = new List<Course>();

            OleDbCommand cmd = new OleDbCommand(cmdStr, connection);

            try
            {
                connection.Open();
                OleDbDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Course course = new Course();
                    course.ID = (int)reader.GetValue(reader.GetOrdinal("ID"));
                    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"));
                    
                    courseList.Add(course);
                }
            }
            finally
            {
                connection.Close();
            }
            return courseList;
        }