Beispiel #1
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");
        }
Beispiel #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");
        }
Beispiel #3
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>";
                }
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                Page.Validate();
                if (Page.IsValid)
                {
                    //Storing the data of input fields to variables.
                    Username_user = username.Text.ToString();
                    Password_user = password.Text.ToString();

                    //making an object of SCHOOLDB class.
                    var db = new SCHOOLDB();

                    //Setting an admin.
                    string admin_username = "******";
                    string admin_password = "******";

                    //checking if the entered username is not an admin
                    if (Username_user != admin_username)
                    {
                        //fetching student's first name from database on the basis of student number used as username.
                        Dictionary <String, String> student_record = db.FindStudent(Username_user);
                        //checking if record exists
                        if (student_record.Contains(new KeyValuePair <string, string>("row", "0")))
                        {
                            display.InnerHtml = "No record found";
                        }
                        else
                        {
                            if (Password_user == student_record["STUDENTFNAME"])
                            {
                                Response.Redirect("~/StudentInfo.aspx");
                            }
                            else
                            {
                                display.InnerHtml = "INVALID USERNAME OR PASSWORD";
                            }
                        }
                    }
                    //if username is an admin username
                    else
                    {
                        if (Password_user == admin_password)
                        {
                            Response.Redirect("~/StudentList.aspx");
                        }
                        else
                        {
                            display.InnerHtml = "INVALID USERNAME OR PASSWORD";
                        }
                    }

                    /*string adminName = "N1679";
                     * List<Dictionary<String, String>> rs = db.List_Query("select STUDENTFNAME from students where STUDENTNUMBER like '" + adminName + "'");
                     *
                     * foreach (Dictionary<String, String> row in rs)
                     * {
                     *  string studentName = row["STUDENTFNAME"];
                     *
                     *  if (user_name == adminName && pass_word == studentName)
                     *  {
                     *      Response.Redirect("~/StudentList.aspx");
                     *  }
                     *  else
                     *  {
                     *      display.InnerHtml = "ERROR!!";
                     *  }
                     *  Debug.WriteLine(studentName);
                     * }*/
                }
            }
            Debug.WriteLine(Username_user);
        }