Ejemplo n.º 1
0
        private void connect_Click(object sender, EventArgs e)
        {
            SQLiteCommand cmd = new SQLiteCommand(m_dbConnection);

            Globals.strUsername = username.Text;
            string strPassword = password.Text;

            m_dbConnection.Open();
            cmd.Parameters.AddWithValue("@username", Globals.strUsername);
            cmd.Parameters.AddWithValue("@password", strPassword);
            cmd.CommandText = "SELECT count(*) FROM users WHERE username=@username and password=@password";
            int count = Convert.ToInt32(cmd.ExecuteScalar());

            if (count == 1)
            {
                MutliplicationTables newMutliplicationTables = new MutliplicationTables();
                newMutliplicationTables.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Ο χρήστης δεν υπάρχει ή ο κωδικός είναι λανθασμένος");
            }
            cmd.ExecuteNonQuery();
            m_dbConnection.Close();
        }
Ejemplo n.º 2
0
        private void πΙΣΩToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MutliplicationTables newMutliplicationTables = new MutliplicationTables();

            newMutliplicationTables.Show();
            this.Hide();
        }
Ejemplo n.º 3
0
        private void OKButton_Click_1(object sender, EventArgs e)
        {
            int correct = 0, wrong = 0;

            string[] value_array = new string[10] {
                textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, textBox7.Text, textBox8.Text, textBox9.Text, textBox10.Text
            };
            Label[] label_array3 = new Label[10] {
                label11, label12, label13, label14, label15, label16, label17, label18, label19, label20
            };

            for (int i = 0; i < 10; i++)
            {
                if (value_array[i].Equals(myvalue_array[i].ToString()))
                {
                    label_array3[i].Text = "ΣΩΣΤΟ";
                    correct = correct + 1;
                    label_array3[i].ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    label_array3[i].Text = "ΛΑΘΟΣ";
                    wrong = wrong + 1;
                    label_array3[i].ForeColor = System.Drawing.Color.Red;
                }
            }
            int score = 100 * correct / (correct + wrong);

            SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");

            m_dbConnection.Open();
            SQLiteCommand cmd = new SQLiteCommand(m_dbConnection);

            cmd.Parameters.AddWithValue("@score", score);
            cmd.Parameters.AddWithValue("@username", Globals.strUsername);
            cmd.CommandText = $"UPDATE mult{myvalue} SET score=@score WHERE username=@username";
            cmd.ExecuteNonQuery();
            m_dbConnection.Close();

            if (score < 80)
            {
                DialogResult dialog = MessageBox.Show("Έκανες αρκετά λάθη, θα πρέπει να ξαναδιαβάσεις τη θεωρία");
                if (dialog == DialogResult.OK)
                {
                    Learning newLearning = new Learning(myvalue);
                    newLearning.Show();
                    this.Hide();
                }
            }
            else
            {
                DialogResult dialog = MessageBox.Show("ΜΠΡΑΒΟ!Τα πήγες πολύ καλά");
                if (dialog == DialogResult.OK)
                {
                    MutliplicationTables newMutliplicationTables = new MutliplicationTables();
                    newMutliplicationTables.Show();
                    this.Hide();
                }
            }
        }
Ejemplo n.º 4
0
        private void okButton_Click(object sender, EventArgs e)
        {
            int correct = 0, wrong = 0;

            string[] value_array = new string[22] {
                textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text, textBox5.Text, textBox6.Text, textBox7.Text, textBox8.Text, textBox9.Text, textBox10.Text, textBox11.Text, textBox12.Text, textBox13.Text, textBox14.Text, textBox15.Text, textBox16.Text, textBox17.Text, textBox18.Text, textBox19.Text, textBox20.Text, textBox21.Text, textBox22.Text
            };
            Label[] label_array3 = new Label[22] {
                label11, label12, label13, label14, label15, label16, label17, label18, label19, label20, label21, label24, label25, label26, label27, label28, label29, label30, label31, label32, label33, label34
            };

            for (int i = 0; i < 22; i++)
            {
                if (value_array[i].Equals(myvalue_array[i].ToString()))
                {
                    label_array3[i].Text = "ΣΩΣΤΟ";
                    correct = correct + 1;
                    label_array3[i].ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    label_array3[i].Text = "ΛΑΘΟΣ";
                    wrong = wrong + 1;
                    label_array3[i].ForeColor = System.Drawing.Color.Red;
                }
            }
            int score = 100 * correct / (correct + wrong);
            SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");

            m_dbConnection.Open();
            SQLiteCommand cmd = new SQLiteCommand(m_dbConnection);

            cmd.Parameters.AddWithValue("@score", score);
            cmd.Parameters.AddWithValue("@username", Globals.strUsername);
            for (int y = 1; y < 5; y++)
            {
                cmd.CommandText = $"UPDATE exams SET exscore{y}=exscore{y + 1} WHERE username=@username";
                cmd.ExecuteNonQuery();
            }
            cmd.CommandText = $"UPDATE exams SET exscore5=@score WHERE username=@username";
            cmd.ExecuteNonQuery();
            m_dbConnection.Close();
            DialogResult dialog = MessageBox.Show("Το σκορ σου είναι: " + score.ToString() + " % ");

            if (dialog == DialogResult.OK)
            {
                MutliplicationTables newMutliplicationTables = new MutliplicationTables();
                newMutliplicationTables.Show();
                this.Hide();
            }
        }