private void btnLogin(object sender, EventArgs e) { if (txtEmail.Text.Equals("")) { MessageBox.Show("Please enter Email", "Field Empty", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Focus(); return; } if (txtPassword.Text.Equals("")) { MessageBox.Show("Please enter password", "Field Empty", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Focus(); return; } var gameUser = from u in context.GAMEUSERs where u.USEREMAIL == txtEmail.Text select u; //This validates if gameuser's email is in the database var checkGameUser = gameUser.FirstOrDefault(a => a.USEREMAIL.Equals(txtEmail.Text)); //if the email is not in the database if (checkGameUser != null) { //if the password is in the database it will display successful dialog if (checkGameUser.USERPASSWORD.Equals(txtPassword.Text)) { MessageBox.Show("You have Successful logged in", "Login succesful", MessageBoxButtons.OK, MessageBoxIcon.Information); //txtEmail.Text = ""; // txtPassword.Text = ""; frmGameUserMenu frmNext = new frmGameUserMenu(txtEmail.Text); //email that is inputed by user this.Close(); frmNext.Show(); } else { //displays error message if password is not valid MessageBox.Show("Invalid Password,Please re-enter your password", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Focus(); return; } } else { //displays error message if Email is not valid MessageBox.Show("We cannot find an account with that Email address ,Please re-enter your Email ", "Invalid Email address", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Focus(); return; } txtPassword.UseSystemPasswordChar = true; }
public frmLoginMenu(frmGameUserMenu frmGameUserMenu) { this.frmGameUserMenu = frmGameUserMenu; }