Ejemplo n.º 1
0
 private void btnSubmit_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ProjectRestaurantEntities _db = new ProjectRestaurantEntities();
         var user = _db.users.FirstOrDefault(x =>
                                             x.login == txtUsername.Text && x.password == txtPassword.Password);
         if (user != null && user.login == "admin")
         {
             AdminWindow dashboard = new AdminWindow();
             dashboard.Show();
             this.Close();
         }
         else if (user != null && user.login == "chef")
         {
             ChefWindow forChef = new ChefWindow();
             forChef.Show();
             this.Close();
         }
         else if (user != null && user.login == "accountant")
         {
             AccountantWindow forAccountant = new AccountantWindow();
             forAccountant.Show();
             this.Close();
         }
         else if (user != null && user.login == "manager")
         {
             ProviderWindow forProvider = new ProviderWindow();
             forProvider.Show();
             this.Close();
         }
         else if (user != null && user.login == "waiter")
         {
             WaiterWindow forWaiter = new WaiterWindow();
             forWaiter.Show();
             this.Close();
         }
         else
         {
             MessageBox.Show("Користувача з такими даними не існує");
         }
     }
     catch (SqlException ex)
     {
         MessageBox.Show(Convert.ToString(ex));
     }
 }