Example #1
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (txtPwd.Text == string.Empty)//doesn't set the password to blank if no new password specified
     {
         clsDBConnector dbConnector = new clsDBConnector();
         string         cmdStr      = "UPDATE tblUsers " +
                                      "SET UserName ='******', RealName ='" + txtName.Text +
                                      "', School_Year = " + nudSchoolYear.Value +
                                      "\nWHERE (User_ID = " + editing_ID + ")";//makes sure only the details of the student being edited are changed
         dbConnector.Connect();
         dbConnector.DoDML(cmdStr);
         dbConnector.close();
     }
     else if (txtPwd.Text != string.Empty) // password reset as well as new password is specified
     {
         clsDBConnector dbConnector = new clsDBConnector();
         string         cmdStr      = "UPDATE tblUsers " +
                                      "SET UserName ='******', RealName ='" + txtName.Text +
                                      "', pwdHash ='" + hash_password(txtPwd.Text) +//Hashes the password before it is sent to the database
                                      "', School_Year = " + nudSchoolYear.Value + " " +
                                      "\nWHERE (User_ID = " + editing_ID + ")";
         dbConnector.Connect();
         dbConnector.DoDML(cmdStr);
         dbConnector.close();
     }
     lblLastAction.Text = "User:"******" edited";
 }
Example #2
0
        private void removeUser(int ID)
        {
            clsDBConnector dbConnector = new clsDBConnector();
            string         cmdStr      = "DELETE FROM tblUsers " +//Deletes a user specified as ID
                                         "WHERE (User_ID = " + ID + ")";

            dbConnector.Connect();
            dbConnector.DoDML(cmdStr);
            dbConnector.close();
        }
Example #3
0
        private void add_user(string hashed_password)
        {
            clsDBConnector dbConnector = new clsDBConnector();
            string         cmdStr      = "INSERT INTO tblUsers  (UserName, RealName, pwdHash, School_ID, Teacher_ID, School_Year) " +
                                         "VALUES ('" + txtUser.Text + "' , '" + clean_string(txtName.Text) + "' , '" + hashed_password + "' , '" + school + "' , '" + teacher + "' , '" + nudSchoolYear.Value + "')";

            dbConnector.Connect();
            dbConnector.DoDML(cmdStr);
            dbConnector.close();
        }
Example #4
0
        private void update_highScore(int score)
        {
            clsDBConnector dbConnector = new clsDBConnector();
            string         cmdStr      = "UPDATE tblUsers " +
                                         "SET Hi_Score =" + score +
                                         "\nWHERE (User_ID = " + user_ID + ")";

            dbConnector.Connect();
            dbConnector.DoDML(cmdStr);
            dbConnector.close();
        }
Example #5
0
        private void update_Score(int score)
        {
            clsDBConnector dbConnector = new clsDBConnector();
            string         cmdStr      = "UPDATE tblUsers " +
                                         "SET last_score =" + score +
                                         "\nWHERE (User_ID = " + user_ID + ")";//Sets the last score to equal the score

            dbConnector.Connect();
            dbConnector.DoDML(cmdStr);
            dbConnector.close();
            int high_score = get_HighScore(); //gets the users current high score

            if (score > high_score)           //checks if the new score is greater than current high score
            {
                MessageBox.Show("You got a new High Score Your new score is " + score + "Your old score was " + high_score, "New High Score!");
                update_highScore(score);//updates the highscore on the database
            }
        }