예제 #1
0
        // завершение теста: выход из окна
        private void FinishHim()
        {
            UserWindow userWindow = new UserWindow();

            userWindow.Show();
            Close();
        }
예제 #2
0
 public ChooseTest()
 {
     InitializeComponent();
     if (CurrentTest.test != null)
     {
         string topic  = "";
         string header = "";
         using (Context db = new Context())
         {
             var test = db.Tests.Where(t => t.Id == CurrentTest.test.Id).First();
             FillTest(db); // заполнение теста
             topic  = test.Topic;
             header = test.Header;
         }
         Topic.Content  += topic;
         Header.Content += header;
     }
     else
     {
         //MessageBox.Show(this.Resources["noselectTest"].ToString());
         UserWindow user = new UserWindow();
         user.Show();
         Close();
     }
 }
예제 #3
0
        //ВХОД
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            bool isLoginCorrect    = CheckLogin(Login, Alert_Login);
            bool isPasswordCorrect = CheckPassword(Password, Alert_Password);

            if (isLoginCorrect && isPasswordCorrect)
            {
                try
                {
                    User user = new User
                    {
                        Login    = Login.Text,
                        Password = Validation.GetHashString(Password.Password)
                    };
                    Class.CurrentUser.user = user;

                    using (Context db = new Context())
                    {
                        var  users      = db.Users;
                        bool isUserFind = false;

                        foreach (User u in users)
                        {
                            if (user.Password == u.Password && user.Login == u.Login)
                            {
                                isUserFind = true;

                                if (u.UserType == "User")
                                {
                                    UserWindow userWindow = new UserWindow();
                                    userWindow.Show();
                                    this.Close();
                                }
                                else
                                {
                                    CreaterWindow createrWindow = new CreaterWindow();
                                    createrWindow.Show();
                                    this.Close();
                                }
                            }
                        }
                        if (isUserFind == false)
                        {
                            MessageBox.Show("Check the entered data", "", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                }
                catch
                {
                }
            }
        }
예제 #4
0
        //РЕГИСТРАЦИЯ
        private void OnRegisterButton_Click(object sender, RoutedEventArgs e)
        {
            bool isLoginCorrect    = CheckLogin(NewLogin, Alert_NewLogin);
            bool isPasswordCorrect = CheckPassword(NewPassword, Alert_NewPassword);

            if (isLoginCorrect && isPasswordCorrect)
            {
                try
                {
                    User user = new User
                    {
                        Login    = NewLogin.Text,
                        Password = Validation.GetHashString(NewPassword.Password)
                    };
                    ComboBoxItem selectedItem = (ComboBoxItem)UserType.SelectedItem;
                    user.UserType          = selectedItem.Content.ToString();
                    Class.CurrentUser.user = user;

                    // Создание подключения
                    using (Context db = new Context())
                    {
                        // добавляем их в бд
                        db.Users.Add(user);
                        db.SaveChanges();

                        switch (UserType.SelectedIndex)
                        {
                        case 0:
                            UserWindow userWindow = new UserWindow();
                            userWindow.Show();
                            this.Close();
                            break;

                        case 1:
                            CreaterWindow createrWindow = new CreaterWindow();
                            createrWindow.Show();
                            this.Close();
                            break;
                        }
                    }
                }
                catch
                {
                }
            }
        }