private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (RegexAdmin(LoginBox.Text))
     {
         AdminWindow admin = new AdminWindow();
         admin.Show();
         Close();
     }
     else if (RegexLogin(LoginBox.Text))
     {
         DataTable find = DB.Select($"select * from [Users] where email='{LoginBox.Text}'");
         if (find.Rows.Count > 0)
         {
             MainWindow mw = new MainWindow();
             DB.UserID = Convert.ToInt32(find.Rows[0]["id"]);
             DB.GetUserId(LoginBox.Text);
             mw.Show();
             Close();
             MessageBox.Show("Пользователь авторизовался");
         }
         else
         {
             DB.Command($"insert into [Users] values ('{LoginBox.Text}')");
             MainWindow mw = new MainWindow();
             find      = DB.Select($"select * from [Users] where email='{LoginBox.Text}'");
             DB.UserID = Convert.ToInt32(find.Rows[0]["id"]);
             mw.Show();
             Close();
         }
     }
     else
     {
         MessageBox.Show("Введите E-mail");
     }
 }
 public void DeletePreviousAnsers()
 {
     if (DB.Command($"delete from Question_Answers where id_u = {DB.UserID}"))
     {
         MessageBox.Show("Старт");
     }
 }
Exemple #3
0
 private void Next_Click(object sender, RoutedEventArgs e)
 {
     if (Name.Text.Length > 0 && Score.Text.Length > 0)
     {
         if (DB.Command($"update Questions set [name] = '{Name.Text}', score = '{Score.Text}' where id={ID}"))
         {
             Close();
         }
     }
     else
     {
         if (Name.Text.Length > 0)
         {
             if (DB.Command($"update Questions set [name] = '{Name.Text}' where id={ID}"))
             {
                 Close();
             }
         }
         if (Score.Text.Length > 0)
         {
             if (DB.Command($"update Questions set score = '{Score.Text}' where id={ID}"))
             {
                 Close();
             }
         }
     }
 }
Exemple #4
0
 private void Next_Click(object sender, RoutedEventArgs e)
 {
     if (Name.Text.Length > 0 && AnswersCount.Text.Length > 0 && Score.Text.Length > 0)
     {
         if (DB.Command($"insert into Questions values({IDTest}, '{Name.Text}', {Score.Text})"))
         {
             int        id     = DB.GetId($"select id from Questions where name='{Name.Text}'");
             addAnswers window = new addAnswers(Convert.ToInt32(AnswersCount.Text), id);
             window.Show();
             Close();
         }
     }
     else
     {
         MessageBox.Show("Введите данные");
     }
 }
Exemple #5
0
 private void Next_Click(object sender, RoutedEventArgs e)
 {
     if (Count + 1 == Amount)
     {
         AdminWindow window = new AdminWindow();
         window.Show();
         Close();
     }
     if (AnswerText.Text.Length > 0)
     {
         if (DB.Command($"insert into Answers values({QuestionID}, '{AnswerText.Text}')"))
         {
             Count          += 1;
             AnswerText.Text = "";
             MessageBox.Show("Ответ добавлен");
         }
     }
     else
     {
         MessageBox.Show("Введите ответ");
     }
 }
        private void Answers_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Answer answer = (Answer)Answers.SelectedItem;

            if (DB.Command($"insert into Question_Answers values ({questions[Count].ID}, {answer.ID}, {DB.UserID})"))
            {
                MessageBox.Show("Ответ принят");
                Count += 1;
                if (Count == questions.Count)
                {
                    ResultWindow result = new ResultWindow();
                    result.Show();
                }
                else
                {
                    ChangeQuestion();
                }
            }
            else
            {
                MessageBox.Show("Ошибка");
            }
        }