public void UserEnter() { byte[] data = Encoding.UTF8.GetBytes(pwdUser.Password); var hashPass = CryptPassword(data); var user = db.Users.AsQueryable().Where(x => x.Name.Equals(txtUserName.Text) && x.Password.Equals(hashPass)).FirstOrDefault(); if (user != null) { MessageBox.Show("Login Success."); var listWindow = new ListWindow(); listWindow.Show(); listWindow.GetUser(user); this.Close(); } else { MessageBox.Show("Login Failed. Please check your username or password"); } }