public ArtistView(User currentUser, frmMusicPlayer mscPl) { //Set user and music player upon initialise this.currentUser = currentUser; this.musicPlayer = mscPl; InitializeComponent(); }
public void setUser(User theUser) { currentUser = theUser; if ((currentUser.getBio().Equals("")) || (currentUser.getBio().Equals(null))) { lblBioText.Text = "Enter your bio here..."; } else { lblBioText.Text = currentUser.getBio(); } //Display full name lblFullName.Text = currentUser.getFirstName() + " " + currentUser.getLastName(); //Display username lblUsername.Text = currentUser.getUsername(); //Display email lblEmail.Text = currentUser.getEmail(); //TODO - DISPLAY PROFILE PIC //Display info in text boxes txtEmail.Text = currentUser.getEmail(); txtFirstName.Text = currentUser.getFirstName(); txtLastName.Text = currentUser.getLastName(); }
private void cmdRegister_Click(object sender, EventArgs e) { // Extract details from the form String first_name = txtFirstName.Text; String last_name = txtLastName.Text; String email = txtEmail.Text; String username = txtUsername.Text; String password = txtPassword.Text; String confirmPassword = txtConfirmPassword.Text; // Create a user object User newUser = new User(username, password, first_name, last_name, email, "Enter your bio here..."); // Create a registerModel RegisterModel registerModel = new RegisterModel(); //Validate the data Validation validation = registerModel.validateData(newUser, confirmPassword); // Output the state of the Login MessageBox.Show(validation.getError()); // If it was valid, add the user if (validation.getValidity()) { // Convert username to lower case - for storage String lowerCaseUsername = newUser.getUsername().ToLower(); newUser.setUsername(lowerCaseUsername); // Attempt to add the user to the database bool success = registerModel.doRegister(newUser); // If it succeeded, close the current form if (success) { this.Close(); //Set the parent to be login // Login parent = (Login)this.Parent; //Call the method to show //parent.showForm(); } } }
public User getDetailsForUser(String username) { try { //THIS NULL POINTERS // no it doesn't // init(); // Connect to cluster ISession session = cluster.Connect("maltmusic"); User user; String todo = ("select * from userprofiles where user_id = :uid"); PreparedStatement ps = session.Prepare(todo); BoundStatement bs = ps.Bind(username); // Execute Query RowSet rows = session.Execute(bs); foreach (Row row in rows) { //public User(String username, String password, String firstName, String surname, HashSet<String> email) String password = (String)row["password"]; String fname = (String)row["first_name"]; String sname = (String)row["last_name"]; String bio = (String)row["bio"]; if (row["email"] != null) { String email = row["email"].ToString(); user = new User(username, password, fname, sname, email, bio); } else { user = new User(username, password, fname, sname, null, "Enter your details here..."); } return user; } }catch(Exception e) { Console.WriteLine("ERROR GETTING user profile deets " + e); } return null; }
public bool doRegister(User toRegister) { try { // Call to initialise cluster connection //init(); // Get the relevant details String uname = toRegister.getUsername(); String fname = toRegister.getFirstName(); String sname = toRegister.getLastName(); String password = toRegister.getPassword(); String bio = toRegister.getBio(); String email = toRegister.getEmail(); //Encrypt the password password = Encryption.calcMD5(password); // Connect to cluster ISession session = cluster.Connect("maltmusic"); // Prepare and bind statement passing in username PreparedStatement ps = session.Prepare("insert into userprofiles (user_id, password, first_name, last_name, email, bio) values (:un,:pw,:fn,:sn,:em, :bi) if not exists"); // Bind BoundStatement bs = ps.Bind(uname, password, fname, sname, email, bio); //Execute Query session.Execute(bs); return true; // Catch exceptions } catch (Exception ex) { // Output the error Console.WriteLine("SOMETHING WENT WRONG DURING REG : " + ex.Message); return false; } }
public List<User> searchUsers(String target) { List<User> users = new List<User>(); try { // Call to initialise cluster connection //init(); // Connect to cluster ISession session = cluster.Connect("maltmusic"); // Prepare and bind statement passing in username String todo = ("SELECT * FROM userprofiles"); PreparedStatement ps = session.Prepare(todo); BoundStatement bs = ps.Bind(); // Execute Query RowSet rows = session.Execute(bs); foreach (Row r in rows) { String username = (String)r["user_id"]; if (username.ToLower().Contains(target.ToLower())) { // this one // public User(String username, String firstName, String surname, String email) //String username = (String)r["user_id"]; String fname = (String)r["first_name"]; String sname = (String)r["last_name"]; String email = (String)r["email"]; User u = new User(username, fname,sname, email); users.Add(u); } } return users; // Catch exceptions } catch (Exception e) { Console.WriteLine("SOMETHING WENT WRONG in GET Album BY ARTIST: " + e); return users; } }
private void cmdSkipLogin_Click(object sender, EventArgs e) { HomePage homePage = new HomePage(); User newUser = new User("username", "password", "Admin", "Hack", null, "Example bio"); homePage.setCurrentUser(newUser); homePage.Show(); this.Hide(); }
public PasswordChange(User currentUser) { InitializeComponent(); this.currentUser = currentUser; }
public void savePlaylist(Playlist playlist, User newUser) { // Get details of current playlist // Create new playlist, same name different owner String newOwner = newUser.getUsername(); Guid newID = Guid.NewGuid(); playlist.setOwner(newOwner); playlist.setGuid(newID); List<Song> tracks = playlist.getSongs(); createPlaylist(playlist); populatePlaylist(playlist, tracks); }
//Method to set user public void setCurrentUser(User theUser) { this.currentUser = theUser; }
public void setCurrentUser(User u) { this.currentUser = u; }
public ViewPlaylist(Playlist playlist, frmMusicPlayer music, User currentUser, HomePage parent) { InitializeComponent(); picSave.Visible = true; //Set player, playlist, user this.musicPlayer = music; this.currentUser = currentUser; this.thePlaylist = playlist; lblPlaylistName.Text = thePlaylist.getPlaylistName(); lblOwner.Text = thePlaylist.getOwner(); this.parent = parent; //Initially hide edit box txtPlaylistNameEdit.Hide(); List<Song> songs = thePlaylist.getSongs(); int numSongs = thePlaylist.getSongs().Count; lblNumSongs.Text = numSongs.ToString(); if (numSongs == 1) { lblNumSongs.Text += " song"; } else { lblNumSongs.Text += " songs"; } //Get total playlist length int totalLength = 0; for (int i = 0; i < songs.Count; i++) { totalLength += songs[i].getLength(); } int hours = totalLength / 3600; int minutes = (totalLength - hours * 3600) / 60; int seconds = totalLength - (hours * 3600) - (minutes * 60); //Set up string saying how long the playlist is String output = ""; if(hours > 0) { output += hours.ToString() + " hours, \n"; } if (minutes > 0) { output += minutes.ToString() + " minutes, \n"; } if (seconds > 0) { output += seconds.ToString() + " seconds, \n"; } if (output.Equals("")) { output = "O seconds"; } else { output = output.Substring(0, output.Length - 3); } //Set length to label lblTime.Text = output; String currUser = this.currentUser.getUsername(); String owner = thePlaylist.getOwner(); String first6 = ""; if (!(thePlaylist.getPlaylistName().Length < 6)) { first6 = thePlaylist.getPlaylistName().Substring(0, 6); } if (currUser.Equals(owner) && first6 != "" ) { if (first6.Equals("$temp$")) { lblPlaylistName.Text = thePlaylist.getPlaylistName().Substring(6); thePlaylist.setName(thePlaylist.getPlaylistName().Substring(6)); } else { picSave.Visible = false; } picRecommend.Visible = true; picPlay.Left = lblPlaylistName.Left + lblPlaylistName.Width + 10; } else { picSave.Left = lblPlaylistName.Left + lblPlaylistName.Width + 10; picPlay.Left = lblPlaylistName.Left + lblPlaylistName.Width + 15 + picSave.Width; picRecommend.Visible = false; } }
/* * METHOD TO VALIDATE THE USER'S INPUT * @PARAMETERS: - user: the user to validate the data for * @RETURNS: a boolean value: whether or not the data is valid * @AUTHOR: Andrew Davis */ public Validation validateData(User user, String confirmPassword) { // First Name Validation: String fName = user.getFirstName(); fName = fName.Trim(); // Trim trailing/leading whitespaces if (fName == null || fName.Length == 0) { return new Validation("First Name must be at least 7 characters long", false); } // Length Check // Last Name Validation: String lName = user.getLastName(); lName = lName.Trim(); // Trim trailing/leading whitespaces if (lName == null || lName.Length == 0) { return new Validation("Last Name must be at least 7 characters long", false); } // Length Check // User Name Validation: String username = user.getUsername(); username = username.Trim(); // Trim trailing/leading whitespaces if (username == null || username.Length == 0) { return new Validation("Username must be at least 7 characters long", false); } // Length Check bool usernameTaken = checkUsername(username); // Check that the username is not already taken if (usernameTaken) { return new Validation("Username has already been taken", false); } // Email Validation: String email = user.getEmail(); if (email.Trim().Length < 7) { return new Validation("Email address is not long enough", false); } // Length validation if (!email.Contains('@')) { return new Validation("Email address must contain a '@'", false); } // Content validation if (!email.Contains('.')) { return new Validation("Email address must contain a '.'", false); } // Content validation // Password Validation: String password = user.getPassword(); if (password.Trim().Length < 7) { return new Validation("Password is not long enough - must be at least 7 characters", false); } // Length validation if (!password.Equals(confirmPassword)) { return new Validation("Password's entered do not match", false); } if (!password.Any(char.IsDigit)) { return new Validation("Password must contain at least 1 number", false); } // Content validation // Length validation if (!password.Any(char.IsUpper)) { return new Validation("Password must contain at least 1 Upper Case letter", false); } // Content validation return new Validation("SUCCESS", true); }