Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //declare what we are looking for
            bool   valid    = true;
            string class_id = Request.QueryString["classid"];

            // validating if statements
            if (String.IsNullOrEmpty(class_id))
            {
                valid = false;
            }

            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String> class_info = db.FindClass(Int32.Parse(class_id));

                if (class_info.Count > 0)
                {
                    class_name.InnerHtml = class_info["CLASSNAME"];
                    class_code.InnerHtml = class_info["CLASSCODE"];
                    start_date.InnerHtml = class_info["STARTDATE"];
                    end_date.InnerHtml   = class_info["FINISHDATE"];
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                class_detail.InnerHtml = "There was an error finding that student.";
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid   = true;
            string classid = Request.QueryString["classid"];

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

            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String> class_record = db.FindClass(Int32.Parse(classid));


                if (class_record.Count > 0)
                {
                    class_title.InnerHtml  = class_record["CLASSCODE"] + " " + class_record["CLASSNAME"];
                    class_code.InnerHtml   = class_record["CLASSCODE"];
                    class_name.InnerHtml   = class_record["CLASSNAME"];
                    class_start.InnerHtml  = class_record["STARTDATE"];
                    class_finish.InnerHtml = class_record["FINISHDATE"];
                    //teacher_name.InnerHtml = class_record["concat(teachers.TEACHERFNAME, ' ', teachers.TEACHERLNAME)"];
                }

                string teacherid = class_record["TEACHERID"];

                Dictionary <String, String> teacher_record = db.FindTeacher(Int32.Parse(teacherid));

                if (teacher_record.Count > 0)
                {
                    teacher_name.InnerHtml = teacher_record["TEACHERFNAME"] + " " + teacher_record["TEACHERLNAME"];
                }

                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                class_div.InnerHtml = "There was an error finding that class";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //using modification of code written by Christine Bittle for HTTP5101, modified on Nov. 18 2019 by Christopher Jones for educational purposes
            bool   valid   = true;
            string classid = Request.QueryString["classid"];

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

            //We will attempt to get the record we need
            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String> class_record = db.FindClass(Int32.Parse(classid));

                if (class_record.Count > 0)
                {
                    classcode_title.InnerHtml   = class_record["CLASSCODE"];
                    classcode_display.InnerHtml = class_record["CLASSCODE"];
                    teacherid.InnerHtml         = class_record["TEACHERID"];
                    startdate.InnerHtml         = class_record["STARTDATE"].Substring(0, 10);
                    finishdate.InnerHtml        = class_record["FINISHDATE"].Substring(0, 10);
                    classname.InnerHtml         = class_record["CLASSNAME"];
                    if (Page.IsPostBack)
                    {
                        string query    = "DELETE from `classes` where classid = " + classid;
                        var    deletedb = new SCHOOLDB();
                        int    delete   = deletedb.Modify_Query(query);
                        Response.Redirect("~/ListClasses.aspx");
                    }
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                schoolclass.InnerHtml = "There was an error finding that class.";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //using modification of code written by Christine Bittle for HTTP5101, modified on Nov. 18 2019 by Christopher Jones for educational purposes
            bool   valid   = true;
            string classid = Request.QueryString["classid"];

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

            //We will attempt to get the record we need
            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String> class_record = db.FindClass(Int32.Parse(classid));

                if (class_record.Count > 0)
                {
                    classcode_title.InnerHtml   = class_record["CLASSCODE"];
                    classcode_display.InnerHtml = class_record["CLASSCODE"];
                    teacherid.InnerHtml         = class_record["TEACHERID"];
                    startdate.InnerHtml         = class_record["STARTDATE"].Substring(0, 10);
                    finishdate.InnerHtml        = class_record["FINISHDATE"].Substring(0, 10);
                    classname.InnerHtml         = class_record["CLASSNAME"];
                    if (Page.IsPostBack)
                    {
                        string ClassCode  = new_classcode.Text.ToString();
                        string TeacherId  = new_teacherid.Text.ToString();
                        string StartDate  = new_startdate.Text.ToString();
                        string FinishDate = new_finishdate.Text.ToString();
                        string ClassName  = new_classname.Text.ToString();
                        //should probably do the handling with a function or a loop (nesting the data within a list and incremeting to check for blank input)
                        if (ClassCode == "")
                        {
                            ClassCode = class_record["CLASSCODE"];
                        }
                        if (TeacherId == "")
                        {
                            TeacherId = class_record["TEACHERID"];
                        }
                        if (StartDate == "")
                        {
                            StartDate = class_record["STARTDATE"].Substring(0, 10);
                        }
                        if (FinishDate == "")
                        {
                            FinishDate = class_record["FINISHDATE"].Substring(0, 10);
                        }
                        if (ClassName == "")
                        {
                            ClassName = class_record["CLASSNAME"];
                        }
                        string query = "UPDATE classes SET CLASSCODE ='" + ClassCode + "', TEACHERID =" + TeacherId + ", STARTDATE='" + StartDate + "', FINISHDATE='" + FinishDate + "', CLASSNAME='" + ClassName + "' WHERE CLASSID = " + classid;
                        var    edit  = new SCHOOLDB();
                        int    add   = edit.Modify_Query(query);
                        Response.Redirect("~/ShowClass.aspx?classid=" + classid);
                    }
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                schoolclass.InnerHtml = "There was an error finding that class.";
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid   = true;
            string classid = Request.QueryString["classid"];

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

            //We will attempt to get the record we need
            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String> class_record = db.FindClass(Int32.Parse(classid));

                if (class_record.Count > 0)
                {
                    class_title_name.InnerHtml = class_record["CLASSNAME"];
                    class_code.InnerHtml       = class_record["CLASSCODE"];
                    teacher_id.InnerHtml       = class_record["TEACHERID"];
                    start_date.InnerHtml       = class_record["STARTDATE"];
                    finish_date.InnerHtml      = class_record["FINISHDATE"];
                    class_name.InnerHtml       = class_record["CLASSNAME"];
                    if (teacher_id.InnerHtml == "0")
                    {
                        teacher_id.InnerHtml = "Not assigned";
                    }
                    else if (teacher_id.InnerHtml == "1")
                    {
                        teacher_id.InnerHtml = "Alexander Bennett";
                    }
                    else if (teacher_id.InnerHtml == "2")
                    {
                        teacher_id.InnerHtml = "Caitlin Cummings";
                    }
                    else if (teacher_id.InnerHtml == "3")
                    {
                        teacher_id.InnerHtml = "Linda Chan";
                    }
                    else if (teacher_id.InnerHtml == "4")
                    {
                        teacher_id.InnerHtml = "Lauren Smith";
                    }
                    else if (teacher_id.InnerHtml == "5")
                    {
                        teacher_id.InnerHtml = "Jessica Morris";
                    }
                    else if (teacher_id.InnerHtml == "6")
                    {
                        teacher_id.InnerHtml = "Thomas Hawkins";
                    }
                    else if (teacher_id.InnerHtml == "7")
                    {
                        teacher_id.InnerHtml = "Shannon Barton";
                    }
                    else if (teacher_id.InnerHtml == "8")
                    {
                        teacher_id.InnerHtml = "Dana Ford";
                    }
                    else if (teacher_id.InnerHtml == "9")
                    {
                        teacher_id.InnerHtml = "Cody Holland";
                    }
                    else if (teacher_id.InnerHtml == "10")
                    {
                        teacher_id.InnerHtml = "John Taram";
                    }
                    else
                    {
                        teacher_id.InnerHtml = "There was a mistake finding teacher's name";
                    };
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                class_class.InnerHtml = "There was an error finding that class.";
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //blank the students table on load
            students_header.InnerHtml = "";
            students_result.InnerHtml = "";
            //using modification of code written by Christine Bittle for HTTP5101, modified on Nov. 18 2019 by Christopher Jones for educational purposes
            bool   valid   = true;
            string classid = Request.QueryString["classid"];

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

            //We will attempt to get the record we need
            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String> class_record = db.FindClass(Int32.Parse(classid));

                if (class_record.Count > 0)
                {
                    classcode_title.InnerHtml   = class_record["CLASSCODE"];
                    classcode_display.InnerHtml = class_record["CLASSCODE"];
                    teacherid.InnerHtml         = "<a href=\"ShowTeacher.aspx?teacherid=" + class_record["TEACHERID"] + "\">" + class_record["TEACHERID"] + "</a>";
                    startdate.InnerHtml         = class_record["STARTDATE"].Substring(0, 10);
                    finishdate.InnerHtml        = class_record["FINISHDATE"].Substring(0, 10);
                    classname.InnerHtml         = class_record["CLASSNAME"];

                    //create render loop for postback if the button is clicked, and the classid is valid
                    if (Page.IsPostBack)
                    {
                        //setup the header for the table
                        students_header.InnerHtml = "<div class=\"listitem\"> <div class=\"col4\">FIRST NAME</div> <div class=\"col4\">LAST NAME</div> <div class=\"col4\">STUDENT NUMBER</div> <div class=\"col4last\">ENROLMENT DATE</div> </div>";
                        string query = "SELECT STUDENTS.* from STUDENTS inner join studentsxclasses on students.studentid = studentsxclasses.studentid inner join classes on studentsxclasses.classid = classes.classid where classes.classid = " + classid;

                        var studentdb = new SCHOOLDB();
                        List <Dictionary <String, String> > rs = studentdb.List_Query(query);
                        foreach (Dictionary <String, String> row in rs)
                        {
                            students_result.InnerHtml += "<div class=\"listitem\">";
                            //grab the studentid to act as a unique id for linking directly to the view student as well
                            string studentid = row["STUDENTID"];

                            string studentfirstname = row["STUDENTFNAME"];
                            students_result.InnerHtml += "<div class=\"col4\"><a href=\"ShowStudent.aspx?studentid=" + studentid + "\">" + studentfirstname + "</a></div>";

                            string studentlastname = row["STUDENTLNAME"];
                            students_result.InnerHtml += "<div class=\"col4\">" + studentlastname + "</div>";

                            string studentnumber = row["STUDENTNUMBER"];
                            students_result.InnerHtml += "<div class=\"col4\">" + studentnumber + "</div>";

                            string enrolmentdate = row["ENROLMENTDATE"];
                            students_result.InnerHtml += "<div class=\"col4last\">" + enrolmentdate + "</div>";

                            //future steps: add CRUD control to this page, allowing students to be added or dropped from classes

                            students_result.InnerHtml += "</div>";
                        }
                    }
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                schoolclass.InnerHtml = "There was an error finding that class.";
            }
        }