private void SignInButton_Click(object sender, EventArgs e) { String userName = usrName.Text; String passWord = pass.Text; infoVal = new UserInfoVal(userName, passWord); logincheck = Login.searchLogin(userName, passWord); if (logincheck == true) { User user = JsonConvert.DeserializeObject <User>(File.ReadAllText(@"../../Login/" + userName + ".txt")); MessageBox.Show("Profile found!\n" + "Logging in as: " + userName, "Sucess"); this.Hide(); //Error message Disposable object created by 'new UserHome() is never disposed. Include dispose() method or wrap in using statement? (KJ) UserHome homePage = new UserHome(user); homePage.ShowDialog(); this.Close(); homePage.Dispose(); } else if (userName == "" && passWord == "") { MessageBox.Show("Please enter a UserName and PassWord."); } else if (userName == "") { MessageBox.Show("Please enter the UserName."); } else if (passWord == "") { MessageBox.Show("Please enter the PassWord."); } else { MessageBox.Show("Profile not found.", "Error"); } }
private void SubmitButton_Click(object sender, EventArgs e) { String fName, lName, address, confirmPass, zipCode, userN; DateTime dob; userN = userName; fName = fNameBox.Text; lName = lNameBox.Text; address = addressBox.Text; confirmPass = confirmPassBox.Text; zipCode = zipcodeBox.Text; dob = dobBox.Value; // User creation (CK) User user = new User(); user.UserInformation.Add("userName", userN); user.UserInformation.Add("firstName", fName); user.UserInformation.Add("lastName", lName); user.UserInformation.Add("address", address); user.UserInformation.Add("zipCode", zipCode); user.UserInformation.Add("dateOfBirth", dob.ToString()); string path = (@"../../Login/" + userName + ".txt"); string temp = JsonConvert.SerializeObject(user); using (StreamWriter streamWriter = new StreamWriter(path)){ streamWriter.WriteLine(temp.ToString()); streamWriter.Close(); } this.Hide(); UserHome userHome = new UserHome(user); userHome.ShowDialog(); this.Close(); }