Example #1
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>";
            }
        }
Example #2
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;
            }
        }
Example #3
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>";
            }
        }