コード例 #1
0
        private void Back_picturebox_Click(object sender, EventArgs e)
        {
            Main_programm main = new Main_programm();

            this.Hide();
            main.ShowDialog();
        }
 private void Next_question_picturebox_Click(object sender, EventArgs e)
 {
     if (radioButton1.Checked == true)
     {
         UserAnswers.Add("a");
     }
     else if (radioButton2.Checked == true)
     {
         UserAnswers.Add("b");
     }
     else if (radioButton3.Checked == true)
     {
         UserAnswers.Add("c");
     }
     else
     {
         UserAnswers.Add("d");
     }
     //got user answers
     if (arithmos1 == number)
     {
         for (int i = 0; i < number; i++)
         {
             if (UserAnswers[i] == CorrectAnswers[i])
             {
                 total_correct_answers++;
             }
         }
         MessageBox.Show("Total correct answers : " + total_correct_answers.ToString());
         Main_programm main = new Main_programm();
         this.Hide();
         main.ShowDialog();
     }
     else
     {
         arithmos1++;
         richTextBox2.Text          = Question[arithmos1 - 1];
         radioButton1.Text          = AnswersA[arithmos1 - 1];
         radioButton2.Text          = AnswersB[arithmos1 - 1];
         radioButton3.Text          = AnswersC[arithmos1 - 1];
         radioButton4.Text          = AnswersD[arithmos1 - 1];
         question_number_label.Text = arithmos1.ToString() + "/" + number.ToString();
     }
 }
        private void Login_button_Click(object sender, EventArgs e)
        {
            if (Username_textbox.Text == "" || Password_textbox.Text == "")
            {
                MessageBox.Show("Don't leave empty fields !");
            }
            else
            {
                try
                {
                    connection.Open();
                    query = "SELECT * FROM Table1 WHERE Username='******' and [Password]='" + Password_textbox.Text + "'";
                    OleDbCommand    command = new OleDbCommand(query, connection);
                    OleDbDataReader reader  = command.ExecuteReader();
                    int             counter = 0;
                    while (reader.Read())
                    {
                        counter++;
                        username = reader.GetString(1);
                    }

                    connection.Close();
                    if (counter == 0)
                    {
                        MessageBox.Show("Invalid information! Check your inputs or if you don't have an account click on Create a new account to create one!");
                    }
                    else
                    {
                        MessageBox.Show("Welcome " + username);
                        username_logged_in = username;
                        Main_programm programm = new Main_programm();
                        this.Hide();
                        programm.ShowDialog();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("An error occured , please try again!");
                }
            }
        }