protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                Page.Validate();
                if (Page.IsValid)
                {
                    string Adding_StudentFname  = adding_studentfname.Text.ToString();
                    string Adding_StudentLname  = adding_studentlname.Text.ToString();
                    string Adding_StudentNumber = adding_studentnumber.Text.ToString();
                    //string Adding_StudentEnrolmentDate = adding_studentenrolmentdate.Text.ToString();

                    Adding_Summary.InnerHtml  = "You have added the following student in the system: <br>";
                    Adding_Summary.InnerHtml += "First Name: " + Adding_StudentFname + "<br>";
                    Adding_Summary.InnerHtml += "Last Name: " + Adding_StudentLname + "<br>";
                    Adding_Summary.InnerHtml += "Student Number: " + Adding_StudentNumber + "<br>";
                    Adding_Summary.InnerHtml += "Please go back to " + "<a href=\"ListStudents.aspx\">" + "Students page " + "</a>" + "to check.";
                    //Adding_Summary.InnerHtml += "Student Enrolment Date: " + Adding_StudentEnrolmentDate + "<br>";

                    string query = "insert into students (STUDENTFNAME, STUDENTLNAME, STUDENTNUMBER) values (";


                    query += "'" + Adding_StudentFname + "'" + ", ";
                    query += "'" + Adding_StudentLname + "'" + ", ";
                    query += "'" + Adding_StudentNumber + "'" + ")";
                    //query += "'" + Adding_StudentEnrolmentDate + "'" + ")";

                    sql_debugger.InnerHtml = query;
                    var db  = new SCHOOLDB();
                    int add = db.Modify_Query(query);
                    List <Dictionary <String, String> > rs = db.List_Query(query);
                }
            }
        }
        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);
                    }
                }
            }
        }
        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.";
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                Page.Validate();

                if (Page.IsValid)
                {
                    string ClassCode  = classcode.Text.ToString();
                    string TeacherId  = teacherid.Text.ToString();
                    string StartDate  = startdate.Text.ToString();
                    string FinishDate = finishdate.Text.ToString();
                    string ClassName  = classname.Text.ToString();
                    string query      = "INSERT INTO classes (CLASSCODE, TEACHERID, STARTDATE, FINISHDATE, CLASSNAME) values ('" + ClassCode + "'," + TeacherId + ",'" + StartDate + "','" + FinishDate + "','" + ClassName + "');";
                    var    db         = new SCHOOLDB();
                    int    add        = db.Modify_Query(query);
                    Response.Redirect("~/ListClasses.aspx");
                }
            }
        }
        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.";
            }
        }