Exemple #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            String login    = LoginTextBox.Text;
            String password = PasswordBox.Password;

            try
            {
                using (var context = new DataBaseModel())
                {
                    var user = context.Users.FirstOrDefault(_user => (_user.Login == login && _user.Password == password));
                    if (user != null)
                    {
                        UserSingleton.Instance().Login = login;
                        Information information        = new Information();
                        information.Show();
                        this.Close();
                    }
                    else
                    {
                        throw new Exception("");
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Проверьте введеные вами данные", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //if (TextBoxLogin.Text == "login1" && MainPasswordBox.Password == "tuptup")
            //{

            //    Manager ManagerWindow = new Manager();
            //    ManagerWindow.Show();

            //}
            //else MessageBox.Show("Введён неверный пароль и(или) логин!","Ошибка!",MessageBoxButton.OK,MessageBoxImage.Error);
            String login    = TextBoxLogin.Text;
            String password = MainPasswordBox.Password;


            try
            {
                using (var context = new DataBase())
                {
                    var user = context.Users.FirstOrDefault(_user => (_user.Login == login && _user.Password == password));
                    if (user != null)
                    {
                        UserSingleton.Instance().Login = login;

                        Manager ManagerWindow = new Manager(user);
                        ManagerWindow.Show();
                    }
                    else
                    {
                        throw new Exception("");
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Пользователь не найден!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            //this.Close();
        }