/** * @desc Executes when the "Accept" button is clicked * It checks the use rname and password and loads in the profile * @params [none] No input parameter. * @return [none] No directly returned data. */ private void button_accept_Click(object sender, EventArgs e) { // Create mysql connection mySqlConn conn = new mySqlConn(); conn.connect(); // Create password md5 hash format string md5Hash = Utils.CreateMD5Hash(txt_password.Text.Trim()); // Launch the query List<Hashtable> lhResultset = conn.lhSqlQuery("Select * from users where login='******' and password = '******' and active = 1"); // If the user with the given credentials was not found if ((int)lhResultset.Count != 1) MessageBox.Show("The username or password are wrong, please use the correct credentials and try it again"); // If it was found else { // Create a user object with the retrieved user id User userLogged = new User(int.Parse(lhResultset[0]["id_user"].ToString())); // Load in the outlook bar this.frmMain.vLoadOutlookBar(); // Display bar options based on profile this.frmMain.ShowUserOptions(lhResultset[0]["profile"].ToString()); // Pass the user to the main form this.frmMain.UserLogged = userLogged; // Close this form this.Close(); } }
/** * @desc Default constructor. * Sets id_member to -1 so the fact of this is a new member can be referenced. * Creates a new user parent class instance. * @params [none] No input parameter. * @return [none] No directly returned data. */ public Member() { this.id_member = -1; this.clUser = new User(); }
/** * @desc Constructor * Loads in all fields from a single row of the MEMBERS table. * @params [int] id_member identifies the member uniquely. * @return [none] No directly returned data. */ public Member(int id_member) { // Create mysql connection mySqlConn conn = new mySqlConn(); conn.connect(); // Launch the query to return all fields from a single row of the MEMBERS table List<Hashtable> lhResultset = conn.lhSqlQuery("Select * from members m, users u where u.id_user = m.id_user AND m.id_member = '" + id_member + "'"); // Check if we found the member if ((int)lhResultset.Count > 0) { // Fill in all member and parent user fields with table data this.clUser = new User(); this.clUser.Id_user = int.Parse(lhResultset[0]["id_user"].ToString()); this.clUser.Login = lhResultset[0]["login"].ToString(); this.clUser.Password = lhResultset[0]["password"].ToString(); this.clUser.Profile = lhResultset[0]["profile"].ToString(); this.IsActive = (lhResultset[0]["is_active"].ToString() == "True") ? true : false; this.Id_member = int.Parse(lhResultset[0]["id_member"].ToString()); this.Address_2 = lhResultset[0]["address_2"].ToString(); this.Address_1 = lhResultset[0]["address_1"].ToString(); this.Birthdate = lhResultset[0]["birthdate"].ToString(); this.City = lhResultset[0]["city"].ToString(); this.County = lhResultset[0]["county"].ToString(); this.Email = lhResultset[0]["email"].ToString(); this.EmergContactMobile = lhResultset[0]["emerg_contact_mobile"].ToString(); this.EmergContactName = lhResultset[0]["emerg_contact_name"].ToString(); this.EmergContactPhone = lhResultset[0]["emerg_contact_phone"].ToString(); this.EmergContactRelation = lhResultset[0]["emerg_contact_relation"].ToString(); this.FirstName = lhResultset[0]["firstName"].ToString(); this.LastName = lhResultset[0]["lastName"].ToString(); this.MedicalAllergies = lhResultset[0]["medical_allergies"].ToString(); this.MedicalDoctorName = lhResultset[0]["medical_doctor_name"].ToString(); this.MedicalNotes = lhResultset[0]["medical_notes"].ToString(); this.MedicalPhone = lhResultset[0]["medical_phone"].ToString(); this.MemberNumber = lhResultset[0]["member_number"].ToString(); this.Id_file = lhResultset[0]["id_file"].ToString(); this.PostalCode = lhResultset[0]["postalcode"].ToString(); this.Type = lhResultset[0]["type"].ToString(); this.Mobile = lhResultset[0]["mobile"].ToString(); this.Phone = lhResultset[0]["phone"].ToString(); this.Gender = lhResultset[0]["gender"].ToString(); } }
// This method is never used for some reason /** * @desc This method sets the current user * @params [User] user: the current user * @return [none] No directly returned data. */ private void SetUserLogged(User user) { this.userLogged = user; }