private void btnSubmit_Click(object sender, RoutedEventArgs e) { string username = txtUsername.Text; string paswoord = txtPaswoord.Password; if (txtUsername.Text == "" || txtPaswoord.Password == "") { MessageBox.Show("Please fill in User name and Pasword "); } using (WareHouseBEntities cxt = new WareHouseBEntities()) { var checkPaswoord = cxt.Paswoords.Where(p => p.UserName == username && p.UserPaswoord == paswoord).Count(); if (checkPaswoord == 1) { Paswoord login = cxt.Paswoords.Where(p => p.UserName == username).FirstOrDefault(); MainMenu mainMenu = new MainMenu(); mainMenu.Show(); this.Close(); } else { MessageBox.Show("Not corect paswoord or username", "Error Box"); } } }
private void btnAdmin_Click(object sender, RoutedEventArgs e) { string username = txtUsername.Text; string paswoord = txtPaswoord.Password; using (WareHouseBEntities cxt = new WareHouseBEntities()) { var checkAdmin = cxt.Paswoords.Where(ap => ap.UserName == username && ap.UserPaswoord == paswoord && ap.UserId == 1).Count(); if (checkAdmin == 1) { Paswoord login = cxt.Paswoords.Where(p => p.UserName == username).FirstOrDefault(); AdminMenu adminMenu = new AdminMenu(); adminMenu.Show(); this.Close(); } else { MessageBox.Show("You are not administrator"); } } }