private void btnLogin_Click(object sender, RoutedEventArgs e) { PoseidonDBEntities db = new PoseidonDBEntities(); if (txtName.Text == "" || txtPwd.Password == "") { lblAlert.Content = "Please fill all feilds"; } else { var username = txtName.Text; var password = txtPwd.Password; var f = db.Accounts.Where(x => x.Username == username && x.Password == password).ToList(); if (f.Count() > 0) { new MainWindow().Show(); this.Close(); } else { lblAlert.Content = "Incorrect username and password"; } } }