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

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

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

                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"];
                }
                else
                {
                    valid = false;
                }
            }

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

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


            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String> student_record = db.FindStudent(Int32.Parse(studentid));

                if (student_record.Count > 0)
                {
                    student_title_fname.InnerHtml = student_record["STUDENTFNAME"] + " " + student_record["STUDENTLNAME"];
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                student.InnerHtml = "There was an error finding that student.";
            }
            studentsubmit_btn.PostBackUrl = "~/ShowStudent.aspx?studentid=" + studentid;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid     = true;
            string studentid = Request.QueryString["studentid"];

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

            if (valid)
            {
                var db = new SCHOOLDB();
                Dictionary <String, String> student_record = db.FindStudent(Int32.Parse(studentid));

                if (student_record.Count > 0)
                {
                    student_fullname.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"];
                }
                else
                {
                    valid = false;
                }
                if (Page.IsPostBack)
                {
                    Page.Validate();
                    if (Page.IsValid)
                    {
                        deleting_summary.InnerHtml  = "You have successfully deleted the following student: <br>";
                        deleting_summary.InnerHtml += "First name: " + student_fname.InnerHtml + "<br>";
                        deleting_summary.InnerHtml += "Last name: " + student_lname.InnerHtml + "<br>";
                        deleting_summary.InnerHtml += "Student number: " + student_number.InnerHtml + "<br>";
                        deleting_summary.InnerHtml += "Enrolment date: " + enrolment_date.InnerHtml + "<br>";
                        deleting_summary.InnerHtml += "Please go back to " + "<a href=\"ListStudents.aspx\">" + "Students page " + "</a>" + "to check.";

                        string query = "Delete from students where studentid = " + studentid;
                        sql_debugger.InnerHtml = query;


                        int delete = db.Modify_Query(query);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid     = true;
            string studentid = Request.QueryString["studentid"];

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

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

                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"];
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                student.InnerHtml = "There was an error finding that student.";
            }
            /*https://stackoverflow.com/questions/23976683/asp-net-button-to-redirect-to-another-page */
            studentedit_btn.PostBackUrl = "~/StudentEdit.aspx?studentid=" + studentid;
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            classes_header.InnerHtml = "";
            classes_result.InnerHtml = "";
            //This code is provided by Christine Bittle, modified by Paul Tran
            bool   valid     = true;
            string studentid = Request.QueryString["studentid"];

            //string classid = Request.QueryString["classid"];
            if (String.IsNullOrEmpty(studentid))
            {
                valid = false;
            }

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

                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"];
                    //WHAT IF user want to see which class the student enrolled  in
                    //enrolled_class.InnerHtml = "";
                    //string query = "SELECT classes.classname, classes.classcode from classes inner join studentsxclasses on classes.classid = studentsxclasses.classid inner join students on studentsxclasses.studentid = students.studentid where students.studentid = " + studentid;
                    if (Page.IsPostBack)
                    {
                        classes_header.InnerHtml = "<div class=\"listitem\"><div class=\"col4\">Class code</div><div class=\"col4\">Class name</div><div class=\"col4\">Start date</div><div class=\"col4last\">Finish date</div></div>";
                        string query = "SELECT classes.* from classes inner join studentsxclasses on classes.classid = studentsxclasses.classid inner join students on studentsxclasses.studentid = students.studentid where students.studentid =" + studentid;
                        List <Dictionary <String, String> > rs = db.List_Query(query);
                        foreach (Dictionary <String, String> row in rs)
                        {
                            classes_result.InnerHtml += "<div class=\"listitem\">";

                            string classid = row["CLASSID"];

                            string classcode = row["CLASSCODE"];
                            classes_result.InnerHtml += "<div class=\"col4\">" + classcode + "</div>";

                            string classname = row["CLASSNAME"];
                            classes_result.InnerHtml += "<div class=\"col4\">" + classname + "</div>";

                            string startdate = row["STARTDATE"];
                            classes_result.InnerHtml += "<div class=\"col4\">" + startdate + "</div>";

                            string finishdate = row["FINISHDATE"];
                            classes_result.InnerHtml += "<div class=\"col4last\">" + finishdate + "</div>";
                            classes_result.InnerHtml += "</div>";
                            //To test this, I add myself in the database and enrolled me in a class and the code actually show I am a student
                        }
                    }
                }


                else
                {
                    valid = false;
                }
            }
            if (!valid)
            {
                student.InnerHtml = "There was an error finding that student.";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            bool   valid     = true;
            string studentid = Request.QueryString["studentid"];

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

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

                if (student_record.Count > 0)
                {
                    student_fullname.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"];
                }
                else
                {
                    valid = false;
                }
                if (Page.IsPostBack)
                {
                    Page.Validate();
                    if (Page.IsValid)
                    {
                        string Update_Studentfname         = update_studentfname.Text.ToString();
                        string Update_Studentlname         = update_studentlname.Text.ToString();
                        string Update_Studentnumber        = update_studentnumber.Text.ToString();
                        string Update_Studentenrolmentdate = update_studentenrolmentdate.Text.ToString();

                        updating_summary.InnerHtml = "You have changed the following information about " + student_fullname.InnerHtml + ":<br>";
                        //if user doesn't want to change a field it will be display as unchange
                        //if a field is change the information will be display accordingly
                        if (Update_Studentfname != "")
                        {
                            updating_summary.InnerHtml += "First name: " + Update_Studentfname + "<br>";
                        }
                        else
                        {
                            updating_summary.InnerHtml += "First name: unchange <br>";
                        }
                        if (Update_Studentlname != "")
                        {
                            updating_summary.InnerHtml += "Last name: " + Update_Studentlname + "<br>";
                        }
                        else
                        {
                            updating_summary.InnerHtml += "Last name: unchange <br>";
                        }
                        if (Update_Studentnumber != "")
                        {
                            updating_summary.InnerHtml += "Student number: " + Update_Studentnumber + "<br>";
                        }
                        else
                        {
                            updating_summary.InnerHtml += "Student number: unchange <br>";
                        }
                        if (Update_Studentenrolmentdate != "")
                        {
                            updating_summary.InnerHtml += "Enrolment date: " + Update_Studentenrolmentdate + "<br>";
                        }
                        else
                        {
                            updating_summary.InnerHtml += "Enrolment date: unchange <br>";
                        }
                    }
                }
            }
        }