Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string StudentNumber = LoginForm.Username_user;

            //Debug.WriteLine(Student);

            var all_details_query = "Select * from students WHERE STUDENTNUMBER LIKE '%" + StudentNumber + "%'";

            var db = new SCHOOLDB();
            List <Dictionary <String, String> > rs = db.List_Query(all_details_query);

            foreach (Dictionary <String, String> row in rs)
            {
                string studentID        = row["STUDENTID"];
                string studentfirstname = row["STUDENTFNAME"];
                string studentlastname  = row["STUDENTLNAME"];
                string enrolmentdate    = row["ENROLMENTDATE"];

                StudentDetails.InnerHtml  = "<div class=\"Detailslistitem\" style=\"text-align:center;\">";
                StudentDetails.InnerHtml += "<div> Name: " + studentfirstname + " " + studentlastname + "</div>";
                StudentDetails.InnerHtml += "<div> Student Number: " + StudentNumber + "</div>";
                StudentDetails.InnerHtml += "<div> Enrolment: " + enrolmentdate + "</div> </div>";
            }

            var classes_query = "SELECT studentnumber,students.studentid,classname from classes inner join studentsxclasses on studentsxclasses.classid = classes.classid  inner join students on students.STUDENTID = studentsxclasses.STUDENTID where studentnumber = '" + StudentNumber + "'";
            List <Dictionary <String, String> > EnrolledClasses = db.List_Query(classes_query);

            //checking if record exists
            if (!EnrolledClasses.Any())
            {
                StudentDetails.InnerHtml += "<div style=\"padding:1em; text-align:center; color:red;\">No classes enrolled</div>";
            }
            else
            {
                StudentDetails.InnerHtml += "<div style=\"font-size:1.125em; font-weight: bold; padding:1em; text-align:center;\">Classes Enrolled</div>";
                foreach (Dictionary <String, String> row in EnrolledClasses)
                {
                    string className = row["classname"];
                    StudentDetails.InnerHtml += "<div style=\"text-align:center;\">" + className + "</div>";
                }
            }
        }
Ejemplo n.º 2
0
        void SubmitInfo(object sender, EventArgs e)
        {
            string StudentFname     = student_fname.Text.ToString();
            string StudentLname     = student_lname.Text.ToString();
            string StudentNumber    = student_number.Text.ToString();
            string StudentEnrolment = student_enrolment.Text.ToString();


            string query = "INSERT INTO students (STUDENTFNAME,STUDENTLNAME,STUDENTNUMBER,ENROLMENTDATE) VALUES ('" + StudentFname + "','" + StudentLname + "','" + StudentNumber + "','" + StudentEnrolment + "')";

            var db = new SCHOOLDB();
            List <Dictionary <String, String> > rs = db.List_Query(query);

            Debug.WriteLine(query);
            Response.Redirect("~/StudentList.aspx");
        }
Ejemplo n.º 3
0
        //Once Click, the data will be postback to gather the new data that was change, then it will be used to update the data for that Student
        void UpdateInfo(object sender, EventArgs e)
        {
            string StudentFname  = student_fname.Text;
            string StudentLname  = student_lname.Text;
            string StudentNumber = student_number.Text;
            //string EnrolmentDate = student_enrolment.Text;

            string query = "UPDATE students SET STUDENTFNAME = '" + StudentFname + "', STUDENTLNAME= '" + StudentLname + "', STUDENTNUMBER = '" + StudentNumber + "' WHERE STUDENTID = " + updatestudentId;
            // Getting Incorrect Value for dates
            //string query = "UPDATE students SET STUDENTFNAME = '" + StudentFname + "', STUDENTLNAME= '" + StudentLname + "', STUDENTNUMBER = '" + StudentNumber + "', ENROLMENTDATE = '" + EnrolmentDate + "' WHERE STUDENTID = " + updatestudentId;
            var db = new SCHOOLDB();
            List <Dictionary <String, String> > rs = db.List_Query(query);

            Debug.WriteLine(query);
            Response.Redirect("~/StudentList.aspx");
        }