Пример #1
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var password = Password.Password;
                if (string.IsNullOrEmpty(Login.Text) || string.IsNullOrEmpty(password))
                {
                    throw new Exception("Введите логин и пароль");
                }

                var user = new EF.User();

                using (var db = new EF.Context())
                {
                    if (!db.Users.Any(u => u.Login.Equals(Login.Text) && u.Password.Equals(password)))
                    {
                        throw new Exception("Такого пользователя не существует");
                    }
                    else
                    {
                        user = db.Users.FirstOrDefault(u => u.Login.Equals(Login.Text) && u.Password.Equals(password));
                    }
                }

                Shelf shelf = new Shelf(user);
                shelf.Show();
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK);
                return;
            }
        }
Пример #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Shelf shelf2 = new Shelf(CurrentUser);

            shelf2.Show();
            this.Close();
        }