protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid   = true;
            string classid = Request.QueryString["classid"];

            if (String.IsNullOrEmpty(classid))
            {
                valid = false;
            }

            try
            {
                Int32.Parse(classid);
            }
            catch (Exception ex)
            {
                //catching invalid URL ID entries
                valid = false;
            }

            if (valid)
            {
                var db = new SCHOOLDB();
                //SCHOOLDB.FindClass() is not actually needed since that method can't do inner joins. Only used in this case to check that there is an entry at the given ID
                Dictionary <String, String>         class_record = db.FindClass(Int32.Parse(classid));
                List <Dictionary <String, String> > rs           = db.List_Query("select CLASSES.*, TEACHERS.TEACHERFNAME, TEACHERS.TEACHERLNAME from CLASSES inner join TEACHERS on CLASSES.TEACHERID = TEACHERS.TEACHERID " +
                                                                                 "where CLASSID = " + classid + " order by CLASSCODE asc");

                if (class_record.Count > 0)
                {
                    foreach (Dictionary <String, String> row in rs)
                    {
                        class_title.InnerHtml = row["CLASSCODE"] + ": " + row["CLASSNAME"];
                        class_code.InnerHtml  = row["CLASSCODE"];
                        class_name.InnerHtml  = row["CLASSNAME"];
                        teacher.InnerHtml     = "<a href =\"IndividualTeacher.aspx?teacherid=" + row["TEACHERID"] + "\">" + row["TEACHERFNAME"] + " " + row["TEACHERLNAME"] + "</a>";
                        start_date.InnerHtml  = row["STARTDATE"];
                        finish_date.InnerHtml = row["FINISHDATE"];
                    }
                }
                else
                {
                    valid = false;
                }
            }
            if (!valid)
            {
                error.InnerHtml       = "There was an error finding that student.";
                class_content.Visible = false;
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid   = true;
            string classid = Request.QueryString["classid"];

            if (String.IsNullOrEmpty(classid))
            {
                valid = false;
            }

            try
            {
                Int32.Parse(classid);
            }
            catch (Exception ex)
            {
                //catching invalid URL ID entries
                valid = false;
            }

            if (valid)
            {
                var db = new SCHOOLDB();
                //SCHOOLDB.FindClass() is not actually needed since that method can't do inner joins. Only used in this case to check that there is an entry at the given ID
                Dictionary <String, String>         class_record = db.FindTeacher(Int32.Parse(classid));
                List <Dictionary <String, String> > rs           = db.List_Query("select CLASSES.*, TEACHERS.TEACHERFNAME, TEACHERS.TEACHERLNAME, TEACHERS.EMPLOYEENUMBER from CLASSES inner join TEACHERS on CLASSES.TEACHERID = TEACHERS.TEACHERID " +
                                                                                 "where CLASSID = " + classid + " order by CLASSCODE asc");

                if (class_record.Count > 0)
                {
                    foreach (Dictionary <String, String> row in rs)
                    {
                        classTitle.InnerHtml = row["CLASSCODE"] + ": " + row["CLASSNAME"];
                        classCode.Text       = row["CLASSCODE"];
                        className.Text       = row["CLASSNAME"];
                        employeeNumber.Text  = row["EMPLOYEENUMBER"];
                        startDate.Text       = row["STARTDATE"];
                        finishDate.Text      = row["FINISHDATE"];
                    }
                }
                else
                {
                    valid = false;
                }
            }
            if (!valid)
            {
                updateClassForm.InnerHtml  = "There was an error finding that Class. <br />";
                updateClassForm.InnerHtml += "<button type=\"button\" onclick=\"location.href = 'Classes.aspx' \">Go Back</button>";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid     = true;
            string studentid = Request.QueryString["studentid"];

            if (String.IsNullOrEmpty(studentid))
            {
                valid = false;
            }

            try
            {
                Int32.Parse(studentid);
            }//end of try
            catch (Exception ex)
            {
                //catching invalid URL ID entries
                valid = false;
            }//end of catch

            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String>         student_record = db.FindStudent(Int32.Parse(studentid));
                List <Dictionary <String, String> > rs             = db.List_Query("select STUDENTS.*,count(studentnumber) as 'Enrolled classes' from STUDENTS join STUDENTSXCLASSES on STUDENTSXCLASSES.STUDENTID = STUDENTS.STUDENTID group by STUDENTS.STUDENTNUMBER order by STUDENTFNAME asc");

                if (student_record.Count > 0)
                {
                    student_title_fname.InnerHtml = student_record["STUDENTFNAME"] + " " + student_record["STUDENTLNAME"];
                    student_fname.InnerHtml       = student_record["STUDENTFNAME"];
                    student_lname.InnerHtml       = student_record["STUDENTLNAME"];
                    student_number.InnerHtml      = student_record["STUDENTNUMBER"];
                    enrolment_date.InnerHtml      = student_record["ENROLMENTDATE"];
                    //classes_enrolled.InnerHtml = student_record["Enrolled classes"];
                }
                else
                {
                    valid = false;
                }//end of if
            }
            if (!valid)
            {
                error.InnerHtml = "There was an error finding that student.";
                student.Visible = false;
            }//end of if
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid     = true;
            string teacherid = Request.QueryString["teacherid"];

            if (String.IsNullOrEmpty(teacherid))
            {
                valid = false;
            }

            try
            {
                Int32.Parse(teacherid);
            }
            catch (Exception ex)
            {
                //catching invalid URL ID entries
                valid = false;
            }

            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String>         teacher_record = db.FindTeacher(Int32.Parse(teacherid));
                List <Dictionary <String, String> > rs             = db.List_Query("select * from teachers order by teacherfname asc");

                if (teacher_record.Count > 0)
                {
                    teacher_title_fname.InnerHtml = teacher_record["TEACHERFNAME"] + " " + teacher_record["TEACHERLNAME"];
                    teacher_fname.InnerHtml       = teacher_record["TEACHERFNAME"];
                    teacher_lname.InnerHtml       = teacher_record["TEACHERLNAME"];
                    employee_number.InnerHtml     = teacher_record["EMPLOYEENUMBER"];
                    hire_date.InnerHtml           = teacher_record["HIREDATE"];
                }
                else
                {
                    valid = false;
                }
            }
            if (!valid)
            {
                error.InnerHtml = "There was an error finding that student.";
                teacher.Visible = false;
            }
        }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid     = true;
            string studentid = Request.QueryString["studentid"];

            if (String.IsNullOrEmpty(studentid))
            {
                valid = false;
            }

            try
            {
                Int32.Parse(studentid);
            }
            catch (Exception ex)
            {
                //catching invalid URL ID entries
                valid = false;
            }

            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String>         student_record = db.FindStudent(Int32.Parse(studentid));
                List <Dictionary <String, String> > rs             = db.List_Query("select * from students order by studentfname asc");

                if (student_record.Count > 0)
                {
                    student_FullName.InnerHtml = student_record["STUDENTFNAME"] + " " + student_record["STUDENTLNAME"];
                    student_FName.Text         = student_record["STUDENTFNAME"];
                    student_LName.Text         = student_record["STUDENTLNAME"];
                    student_Number.Text        = student_record["STUDENTNUMBER"];
                    enrolment_Date.Text        = student_record["ENROLMENTDATE"];
                }
                else
                {
                    valid = false;
                }
            }
            if (!valid)
            {
                updatestudentForm.InnerHtml  = "There was an error finding that student. <br />";
                updatestudentForm.InnerHtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"location.href = 'Students.aspx' \">Go Back</button>";
            }
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid     = true;
            string teacherid = Request.QueryString["teacherid"];

            if (String.IsNullOrEmpty(teacherid))
            {
                valid = false;
            }

            try
            {
                Int32.Parse(teacherid);
            }
            catch (Exception ex)
            {
                //catching invalid URL ID entries
                valid = false;
            }

            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String>         teacher_record = db.FindTeacher(Int32.Parse(teacherid));
                List <Dictionary <String, String> > rs             = db.List_Query("select * from teachers order by teacherfname asc");

                if (teacher_record.Count > 0)
                {
                    teacher_FullName.InnerHtml = teacher_record["TEACHERFNAME"] + " " + teacher_record["TEACHERLNAME"];
                    teacher_FName.Text         = teacher_record["TEACHERFNAME"];
                    teacher_LName.Text         = teacher_record["TEACHERLNAME"];
                    employee_Number.Text       = teacher_record["EMPLOYEENUMBER"];
                    hire_Date.Text             = teacher_record["HIREDATE"];
                }
                else
                {
                    valid = false;
                }
            }
            if (!valid)
            {
                updateTeacherForm.InnerHtml  = "There was an error finding that teacher. <br />";
                updateTeacherForm.InnerHtml += "<button type=\"button\" onclick=\"location.href = 'Teachers.aspx' \">Go Back</button>";
            }
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Disabling view of command div because it shows on load
            commandDiv.Visible = false;
            //Checking if page was reached after a CRUD command was just done on another page
            string command = Request.QueryString["cmd"];

            if (!String.IsNullOrEmpty(command))
            {
                commandDiv.Visible       = true;
                commandConfirm.InnerHtml = "Entry " + command;
            }


            //DATABASE READING CODE
            var db = new SCHOOLDB();

            List <Dictionary <String, String> > rs = db.List_Query("select * from TEACHERS order by TEACHERFNAME asc");

            students_result.InnerHtml += "<table class=\"table\"><thead><tr>" +
                                         "<th>FIRST NAME</th>" +
                                         "<th>LAST NAME</th>" +
                                         "<th>EMPLOYEE NUMBER</th>" +
                                         "<th>HIRE DATE</th>" +
                                         "</tr></thead><tbody>";
            foreach (Dictionary <String, String> row in rs)
            {
                string teacherid = row["TEACHERID"];
                students_result.InnerHtml += "<tr>";



                string teacherfirstname = row["TEACHERFNAME"];
                students_result.InnerHtml += "<td><a href=\"IndividualTeacher.aspx?teacherid=" + teacherid + "\">" + teacherfirstname + "</a></td>";

                string teacherlastname = row["TEACHERLNAME"];
                students_result.InnerHtml += "<td>" + teacherlastname + "</td>";

                string employeenumber = row["EMPLOYEENUMBER"];
                students_result.InnerHtml += "<td>" + employeenumber + "</td>";

                string hiredate = row["HIREDATE"];
                students_result.InnerHtml += "<td>" + hiredate + "</td>";

                students_result.InnerHtml += "</tr>";
            }
            students_result.InnerHtml += "</tbody><table>";

            if (Page.IsPostBack)
            {
                //clearing command div (no longer necessary after search is preformed)
                commandConfirm.InnerHtml = "";
                commandDiv.Visible       = false;
                string searchValue = search_value.Text.ToString();
                students_result.InnerHtml  = "";
                students_result.InnerHtml += "<table class=\"table\"><thead><tr>" +
                                             "<th>FIRST NAME</th>" +
                                             "<th>LAST NAME</th>" +
                                             "<th>EMPLOYEE NUMBER</th>" +
                                             "<th>HIRE DATE</th>" +
                                             "</tr></thead><tbody>";


                List <Dictionary <String, String> > rows = db.List_Query("select * from TEACHERS where TEACHERFNAME like '%" + searchValue + "%' or TEACHERLNAME like '%" + searchValue + "%' or EMPLOYEENUMBER  like '%" + searchValue + "%' order by teacherfname asc");
                foreach (Dictionary <String, String> row in rows)
                {
                    string teacherid = row["TEACHERID"];
                    students_result.InnerHtml += "<tr>";

                    string teacherfirstname = row["TEACHERFNAME"];
                    students_result.InnerHtml += "<td><a href=\"IndividualTeacher.aspx?teacherid=" + teacherid + "\">" + teacherfirstname + "</a></td>";

                    string teacherlastname = row["TEACHERLNAME"];
                    students_result.InnerHtml += "<td>" + teacherlastname + "</td>";

                    string employeenumber = row["EMPLOYEENUMBER"];
                    students_result.InnerHtml += "<td>" + employeenumber + "</td>";

                    string hiredate = row["HIREDATE"];
                    students_result.InnerHtml += "<td>" + hiredate + "</td>";

                    students_result.InnerHtml += "</tr>";
                }
                students_result.InnerHtml += "</tbody><table>";
            }
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Disabling view of command div because it shows on load
            commandDiv.Visible = false;
            //Checking if page was reached after a CRUD command was just done on another page
            string command = Request.QueryString["cmd"];

            if (!String.IsNullOrEmpty(command))
            {
                commandDiv.Visible       = true;
                commandConfirm.InnerHtml = "Entry " + command;
            }


            //DATABASE READING CODE
            var db = new SCHOOLDB();


            //Columns are: CLASSID, CLASSCODE, TEACHERID, STARTDATE, FINISHDATE, CLASSNAME
            List <Dictionary <String, String> > rs = db.List_Query("select CLASSES.*, TEACHERS.TEACHERFNAME, TEACHERS.TEACHERLNAME from CLASSES inner join TEACHERS on CLASSES.TEACHERID = TEACHERS.TEACHERID order by CLASSCODE asc");

            students_result.InnerHtml += "<table class=\"table\"><thead><tr>" +
                                         "<th>CLASS CODE</th>" +
                                         "<th>CLASS NAME</th>" +
                                         "<th>TEACHER</th>" +
                                         "<th>START DATE</th>" +
                                         "<th>FINISH DATE</th>" +
                                         "</tr></thead><tbody>";
            foreach (Dictionary <String, String> row in rs)
            {
                string classid = row["CLASSID"];
                students_result.InnerHtml += "<tr>";



                string classcode = row["CLASSCODE"];
                students_result.InnerHtml += "<td>" + classcode + "</td>";

                string classname = row["CLASSNAME"];
                students_result.InnerHtml += "<td><a href=\"IndividualClass.aspx?classid=" + classid + "\">" + classname + "</a></td>";

                string teacher = row["TEACHERFNAME"] + " " + row["TEACHERLNAME"];
                students_result.InnerHtml += "<td>" + teacher + "</td>";

                string startdate = row["STARTDATE"];
                students_result.InnerHtml += "<td>" + startdate + "</td>";

                string finishdate = row["FINISHDATE"];
                students_result.InnerHtml += "<td>" + finishdate + "</td>";

                students_result.InnerHtml += "</tr>";
            }
            students_result.InnerHtml += "</tbody><table>";

            if (Page.IsPostBack)
            {
                //clearing command div (no longer necessary after search is preformed)
                commandConfirm.InnerHtml = "";
                commandDiv.Visible       = false;
                string searchValue = search_value.Text.ToString();
                students_result.InnerHtml  = "";
                students_result.InnerHtml += "<table class=\"table\"><thead><tr>" +
                                             "<th>CLASS CODE</th>" +
                                             "<th>CLASS NAME</th>" +
                                             "<th>TEACHER</th>" +
                                             "<th>START DATE</th>" +
                                             "<th>FINISH DATE</th>" +
                                             "</tr></thead><tbody>";

                List <Dictionary <String, String> > rows = db.List_Query("select CLASSES.*, TEACHERS.TEACHERFNAME, TEACHERS.TEACHERLNAME from CLASSES inner join TEACHERS on " +
                                                                         "CLASSES.TEACHERID = TEACHERS.TEACHERID where CLASSES.CLASSCODE like '%" + searchValue + "%' or CLASSES.CLASSNAME like '%" + searchValue + "%' or " +
                                                                         "TEACHERS.TEACHERFNAME like '%" + searchValue + "%' or TEACHERS.TEACHERLNAME like '%" + searchValue + "%' order by CLASSCODE asc");
                foreach (Dictionary <String, String> row in rows)
                {
                    string classid = row["CLASSID"];
                    students_result.InnerHtml += "<tr>";


                    string classcode = row["CLASSCODE"];
                    students_result.InnerHtml += "<td>" + classcode + "</td>";

                    string classname = row["CLASSNAME"];
                    students_result.InnerHtml += "<td><a href=\"IndividualClass.aspx?classid=" + classid + "\">" + classname + "</a></td>";

                    string teacher = row["TEACHERFNAME"] + " " + row["TEACHERLNAME"];
                    students_result.InnerHtml += "<td>" + teacher + "</td>";

                    string startdate = row["STARTDATE"];
                    students_result.InnerHtml += "<td>" + startdate + "</td>";

                    string finishdate = row["FINISHDATE"];
                    students_result.InnerHtml += "<td>" + finishdate + "</td>";

                    students_result.InnerHtml += "</tr>";
                }
                students_result.InnerHtml += "</tbody><table>";
            }
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Disabling view of command div because it shows on load
            commandDiv.Visible = false;
            //Checking if page was reached after a CRUD command was just done on another page
            string command = Request.QueryString["cmd"];

            if (!String.IsNullOrEmpty(command))
            {
                commandDiv.Visible       = true;
                commandConfirm.InnerHtml = "Entry " + command;
            }


            //DATABASE READING CODE
            var db = new SCHOOLDB();

            //SELECT students.*,COUNT(`STUDENTNUMBER`) FROM STUDENTS
            //JOIN STUDENTSXCLASSES
            //ON STUDENTSXCLASSES.`STUDENTID` = STUDENTS.`STUDENTID`
            //GROUP BY `STUDENTID`;

            List <Dictionary <String, String> > rs = db.List_Query("select STUDENTS.*,count(studentnumber) as 'Enrolled classes' from STUDENTS join STUDENTSXCLASSES on STUDENTSXCLASSES.STUDENTID = STUDENTS.STUDENTID group by STUDENTS.STUDENTNUMBER order by STUDENTFNAME asc");

            students_result.InnerHtml += "<table class=\"table\"><thead><tr>" +
                                         "<th>FIRST NAME</th>" +
                                         "<th>LAST NAME</th>" +
                                         "<th>STUDENT NUMBER</th>" +
                                         "<th>ENROLMENT DATE</th>" +
                                         "<th>CLASSES ENROLED</th>" +
                                         "</tr></thead><tbody>";
            foreach (Dictionary <String, String> row in rs)
            {
                string studentid = row["STUDENTID"];
                students_result.InnerHtml += "<tr>";



                string studentfirstname = row["STUDENTFNAME"];
                students_result.InnerHtml += "<td><a href=\"IndividualStudent.aspx?studentid=" + studentid + "\">" + studentfirstname + "</a></td>";

                string studentlastname = row["STUDENTLNAME"];
                students_result.InnerHtml += "<td>" + studentlastname + "</td>";

                string studentnumber = row["STUDENTNUMBER"];
                students_result.InnerHtml += "<td>" + studentnumber + "</td>";

                string enrolmentdate = row["ENROLMENTDATE"];
                students_result.InnerHtml += "<td>" + enrolmentdate + "</td>";

                string enroledclasses = row["Enrolled classes"];
                students_result.InnerHtml += "<td>" + enroledclasses + "</td>";

                students_result.InnerHtml += "</tr>";
            }
            students_result.InnerHtml += "</tbody><table>";

            if (Page.IsPostBack)
            {
                //clearing command div (no longer necessary after search is preformed)
                commandConfirm.InnerHtml = "";
                commandDiv.Visible       = false;
                string searchValue = search_value.Text.ToString();
                Console.WriteLine(searchValue);
                students_result.InnerHtml  = "";
                students_result.InnerHtml += "<table class=\"table\"><thead><tr>" +
                                             "<th>FIRST NAME</th>" +
                                             "<th>LAST NAME</th>" +
                                             "<th>STUDENT NUMBER</th>" +
                                             "<th>ENROLMENT DATE</th>" +
                                             "<th>CLASSES ENROLED</th>" +
                                             "</tr></thead><tbody>";


                List <Dictionary <String, String> > rows = db.List_Query("select STUDENTS.*,count(studentnumber) as 'Enrolled classes' from STUDENTS join STUDENTSXCLASSES on STUDENTSXCLASSES.STUDENTID = STUDENTS.STUDENTID where STUDENTFNAME like '%" + searchValue + "%' or STUDENTLNAME like '%" + searchValue + "%' or STUDENTNUMBER  like '%" + searchValue + "%' group by STUDENTS.STUDENTNUMBER order by studentfname asc");
                foreach (Dictionary <String, String> row in rows)
                {
                    string studentid = row["STUDENTID"];
                    students_result.InnerHtml += "<tr>";

                    string studentfirstname = row["STUDENTFNAME"];
                    students_result.InnerHtml += "<td><a href=\"IndividualStudent.aspx?studentid=" + studentid + "\">" + studentfirstname + "</a></td>";

                    string studentlastname = row["STUDENTLNAME"];
                    students_result.InnerHtml += "<td>" + studentlastname + "</td>";

                    string studentnumber = row["STUDENTNUMBER"];
                    students_result.InnerHtml += "<td>" + studentnumber + "</td>";

                    string enrolmentdate = row["ENROLMENTDATE"];
                    students_result.InnerHtml += "<td>" + enrolmentdate + "</td>";

                    string enroledclasses = row["Enrolled classes"];
                    students_result.InnerHtml += "<td>" + enroledclasses + "</td>";

                    students_result.InnerHtml += "</tr>";
                }
                students_result.InnerHtml += "</tbody><table>";
            }
        }