Пример #1
0
        /*
         * Method: GenerateAllClassessGridData
         * Areguments: none
         * Return: none
         * Des: this method is to fill the all classes GridView with data
         */
        protected void GenerateAllClassessGridData()
        {
            DataTable table = new DataTable();             // create data table object

            // add the table columns
            table.Columns.Add("Course Id");
            table.Columns.Add("Section Id");
            table.Columns.Add("Course Title");
            table.Columns.Add("Location");
            table.Columns.Add("Time");
            table.Columns.Add("Date");
            table.Columns.Add("Instructor Name");

            foreach (Schedule schedule in scheduleList.List)
            {
                /* foreach element in the scheduleList
                 */
                sectionsList.Filter("SectionID", schedule.SectionID);                                                                                                               // filter the sectionList with sectionID
                Section section = (Section)sectionsList.List.ElementAt(0);                                                                                                          // get the first element in the list and cast it to ( section )
                taughtList.Filter("TaughtCourseID", section.TaughtCourseID);                                                                                                        // filter the taughtCourseList with taughtcourseID from the section object
                TaughtCourse taughtcourse = (TaughtCourse)taughtList.List.ElementAt(0);                                                                                             // get the first element in the list and cast it to ( TaughtCourse )
                courseList.Filter("CourseID", taughtcourse.CourseID);                                                                                                               //filter the CoursList with courseID from taughCourse object
                Course course = (Course)courseList.List.ElementAt(0);                                                                                                               // get the first element in the list and cast it to ( Course )
                locationList.Filter("LocationID", schedule.LocationID);                                                                                                             // filter the locationList with locationID from the section object
                Location location = (Location)locationList.List.ElementAt(0);                                                                                                       // get the first element in the list and cast it to ( Location )
                instructorList.Filter("InstructorID", section.InstructorID);                                                                                                        // filter the instructorList with the instructorID from section object
                Instructor instructor = (Instructor)instructorList.List.ElementAt(0);                                                                                               // get the first element in the list and cast it to ( Instructor )
                table.Rows.Add(taughtcourse.CourseID, section.getID(), course.Title, location.Name, schedule.Time, schedule.Day, instructor.FirstName + " " + instructor.LastName); // add information as row to the table object
            }
            allclassListGrid.DataSource = table;                                                                                                                                    // set table as the dataSource of the grid view
            allclassListGrid.DataBind();                                                                                                                                            // bind the data
        }
Пример #2
0
        /*
         * Method: GenerateGridData
         * Areguments: none
         * Return: none
         * Des: this method is to fill the GridView with data
         */
        protected void GenerateGridData()
        {
            DataTable table = new DataTable();            // declare and instantiate DataTable object

            /*
             * Add Columns to the data table
             */
            table.Columns.Add("Course Id");
            table.Columns.Add("Section Id");
            table.Columns.Add("Course Title");
            table.Columns.Add("Location");
            table.Columns.Add("Time");
            table.Columns.Add("Date");
            table.Columns.Add("Instructor Name");
            foreach (Schedule schedule in scheduleList.List)
            {
                /*
                 * Foreach Element in the scheduleList
                 */
                sectionsList.Filter("SectionID", schedule.SectionID);                   // filter the sectionList using the section id from the element of scheduleList
                Section section = (Section)sectionsList.List.ElementAt(0);              // get the section object from the sectionList

                taughtList.Filter("TaughtCourseID", section.TaughtCourseID);            // filter the taughtCourseList usign the taughtCourse id from the section object
                TaughtCourse taughtcourse = (TaughtCourse)taughtList.List.ElementAt(0); // get the taughtCourse object from the list
                courseList.Filter("CourseID", taughtcourse.CourseID);                   //filter the courseList using the CourseId from the taughtCourse object
                Course course = (Course)courseList.List.ElementAt(0);                   // get the course object fom the couseList
                locationList.Filter("LocationID", schedule.LocationID);                 //filter the locationList using the location id from the element
                Location location = (Location)locationList.List.ElementAt(0);           // get location object
                instructorList.Filter("InstructorID", section.InstructorID);            // filter the instructor id form the
                Instructor instructor = (Instructor)instructorList.List.ElementAt(0);   // get the instructor object form the instructorList
                table.Rows.Add(taughtcourse.CourseID, section.getID(), course.Title, location.Name, schedule.Time, schedule.Day, instructor.FirstName + " " + instructor.LastName);
                // add a row to the dataTable object with the information from the above objects
            }
            classListGrid.DataSource = table;     // set the dataTable object as the dataSource of the GidView element
            classListGrid.DataBind();             // bind the data
        }
Пример #3
0
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            /*
             * when the button login clicked run this code
             *
             */

            if (lg_username.Text == "" || lg_password.Text == "")
            {
                /*
                 * if the username or password are empty then show error message
                 */
                errormsg.Text         = "Please Complete your account information";
                meassgaePanel.Visible = true;
            }
            else if (!instructorAccount.Checked && !studentAccount.Checked)
            {
                /*
                 * if non of the account type radio buttons checked then show error message
                 */
                errormsg.Text         = "Please Choose  your account type";
                meassgaePanel.Visible = true;
            }
            else if (instructorAccount.Checked && lg_username.Text != "" && lg_password.Text != "")
            {
                /*
                 * if the user checked the instructor and the username and password aren't empty then check for information and do the login
                 */

                meassgaePanel.Visible = false;                                         // hide the message panel
                instructors.Filter("InstructorID", lg_username.Text.ToString());       // filter the instructors list with the id the user filed
                if (instructors.List.Count == 1)                                       // if the id is correct the instructors list count should be 1
                {
                    Instructor instructor = (Instructor)instructors.List.ElementAt(0); // get the instructor object from the list
                    instructors.Populate(instructor);                                  // populate the instructor
                    if (instructor.Password == lg_password.Text.ToString())            // if the password user filled is the same as the instructor object
                    {
                        Session["User"]    = instructor.getID();                       // create new session called User with the value of the id of the instructor
                        Session["Account"] = "Instructor";                             // create new Session called Account with  instructor as value this to make sure that the user dosen't visit pages not allwoed for him/her to visit
                        Response.Redirect("~/instructor/MainPage.aspx");               // redirect to main page of the instructor
                    }
                    else
                    {
                        /*
                         * else show error message "password Wrong"
                         */
                        errormsg.Text         = "Wrong password, Please check your password and try again";
                        meassgaePanel.Visible = true;
                    }
                }
                else
                {
                    /*
                     * else show error message "User not found"
                     */
                    errormsg.Text         = "User Not Found, Please check your userId and account type and try again ";
                    meassgaePanel.Visible = true;
                }
            }
            else if (studentAccount.Checked && lg_username.Text != "" && lg_password.Text != "")
            {
                /*
                 * if the user checked the student and the username and password aren't empty then check for information and do the login
                 */
                meassgaePanel.Visible = false;                             // hide the message panel
                students.Filter("StudentID", lg_username.Text);            // filter the students list with the id the user filed
                if (students.List.Count == 1)                              // if the id is correct the students list count should be 1
                {
                    Student student = (Student)students.List.ElementAt(0); // get the student object from the list
                    students.Populate(student);                            // populate the student
                    if (student.Password == lg_password.Text)              // if the password user filled is the same as the student object
                    {
                        Session["User"]    = student.getID();              // create new session called User with the value of the id of the student
                        Session["Account"] = "Student";                    // create new Session called Account with student as value this to make sure that the user dosen't visit pages not allwoed for him/her to visit
                        Response.Redirect("~/student/MainPage.aspx");      // Redirect to student's main page
                    }
                    else
                    {
                        /*
                         * else show error message "password Wrong"
                         */
                        errormsg.Text         = "Wrong password, Please check your password and try again";
                        meassgaePanel.Visible = true;
                    }
                }
                else
                {
                    /*
                     * else show error message "User not found"
                     */
                    errormsg.Text         = "User Not Found, Please check your userId and account type and try again ";
                    meassgaePanel.Visible = true;
                }
            }
        }