Example #1
0
        private void backhomebtn_Click(object sender, EventArgs e)
        {
            string msg = "Προσοχή! Εάν επιστρέψεις στην αρχική, θα χαθεί όλη η πρόοδος του τεστ." +
                         " Εάν δεν είσαι σίγουρος, κλίκαρε Cancel (Ακύρωση)";
            DialogResult dialogResult = MessageBox.Show(msg, "Προειδοποίηση", MessageBoxButtons.OKCancel);

            if (dialogResult == DialogResult.OK)
            {
                curr_score = 0;
                this.Hide();
                var form2 = new Homepage(logged_user_id);
                form2.Closed += (s, args) => this.Close();
                form2.Show();
            }
        }
Example #2
0
        private void sinbtn_Click(object sender, EventArgs e)
        {
            string connectionString = "Data Source=LAPTOP-KKBOP61F\\SQLEXPRESS01;Initial Catalog=PropediaDB;Integrated Security=True";

            using (SqlConnection connection =
                       new SqlConnection(connectionString))
            {
                connection.Open();
                SqlDataAdapter da = new SqlDataAdapter();

                da.TableMappings.Add("Table", "UserInfo");
                SqlCommand command = new SqlCommand("SELECT * FROM dbo.UserInfo;", connection);
                command.CommandType = CommandType.Text;
                da.SelectCommand    = command;
                DataSet dataSet = new DataSet("UserInfo");
                da.Fill(dataSet);

                DataTable dt = new DataTable();
                dt = dataSet.Tables["UserInfo"];

                // Once a table has been created, use the
                // NewRow to create a DataRow.

                int user_id = 0;

                // Then add the new row to the collection.
                if (!(sinmail.Text.Equals("") || sinpwd.Text.Equals("")))
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr["email"].ToString() == sinmail.Text.ToString() && dr["password"].ToString() == sinpwd.Text.ToString())
                        {
                            Int32.TryParse(dr["UserID"].ToString(), out user_id);
                            break;
                        }
                    }

                    if (user_id == 2)
                    {
                        this.Hide();
                        var form2 = new Admin();
                        form2.Closed += (s, args) => this.Close();
                        form2.Show();
                    }
                    else if (user_id != 0)
                    {
                        this.Hide();
                        var form2 = new Homepage(user_id);
                        form2.Closed += (s, args) => this.Close();
                        form2.Show();
                    }
                    else
                    {
                        MessageBox.Show("Ο κωδικός και το email δεν ταιριάζουν. " +
                                        "Παρακαλώ προασπαθήστε ξανά", "Αποτυχία Σύνδεσης", MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("Παρακαλώ συμπλήρωσε email και κωδικό", "Αποτυχία Σύνδεσης", MessageBoxButtons.OK);
                }

                connection.Close();
            }
        }
Example #3
0
        private void nextques_Click(object sender, EventArgs e)
        {
            if (randomList.Count() < desiredQuesTotal)
            {
                //TODO Check if input is max 2 chars and digits
                if (Int32.Parse(qinput.Text) == Int32.Parse(randnumber.Text) * Int32.Parse(questno2.Text))
                {
                    curr_score              += 1;
                    yesnobox.Visible         = true;
                    yesnobox.BackgroundImage = Image.FromFile("..//..//Resources//Pics//without_bg//sosto.png");
                    timer.Interval           = 3000;
                    timer.Tick              += new EventHandler(timer_Tick);
                    timer.Start();
                }
                else
                {
                    yesnobox.Visible         = true;
                    yesnobox.BackgroundImage = Image.FromFile("..//..//Resources//Pics//without_bg//lathos.png");
                    timer.Interval           = 3000;
                    timer.Tick += new EventHandler(timer_Tick);
                    timer.Start();
                }
                NewNumber(); //Then Roll the dice
                questno.Text = (Int32.Parse(questno.Text) + 1).ToString();
                if (isRep)
                {
                    questno2.Text = extraNumber.ToString();
                }
                qinput.Clear();
            }
            else   //if capacity is reached
                   //adding final score but not doing any other actions for moving forward to next question
            {
                if (Int32.Parse(qinput.Text) == Int32.Parse(randnumber.Text) * Int32.Parse(questno2.Text))
                {
                    curr_score += 1;
                }
                int final_perc = Convert.ToInt32(((double)curr_score / (double)desiredQuesTotal) * 10);
                using (SqlConnection connection =
                           new SqlConnection(connectionString))
                {
                    connection.Open();
                    SqlCommand command2;
                    if (!isRep)
                    {
                        command2 = new SqlCommand("UPDATE UserStats SET test" + test_id + " = " + final_perc.ToString() + " WHERE UserID = " + (logged_user_id).ToString() + ";");
                    }
                    else
                    {
                        command2 = new SqlCommand("UPDATE UserStats SET test" + test_id + "rep = " + final_perc.ToString() + " WHERE UserID = " + (logged_user_id).ToString() + ";");
                    }
                    command2.CommandType = CommandType.Text;
                    command2.Connection  = connection;

                    command2.ExecuteNonQuery();
                    connection.Close();

                    string       msg = "";
                    DialogResult dialogResult;
                    if (!isRep)
                    {
                        if (final_perc == 100)
                        {
                            msg          = "Μόλις ολοκλήρωσες την δοκιμασία της προπαίδειας του " + test_id + " με άριστα! Πάτησε ΟΚ για να επιστρέψεις πίσω στην αρχική.";
                            dialogResult = MessageBox.Show(msg, "Προειδοποίηση", MessageBoxButtons.OK);
                            if (dialogResult == DialogResult.OK)
                            {
                                this.Hide();
                                var form2 = new Homepage(logged_user_id);
                                form2.Closed += (s, args) => this.Close();
                                form2.Show();
                            }
                        }
                        else
                        {
                            msg = "Μόλις ολοκλήρωσες την δοκιμασία της προπαίδειας του " + test_id + " με σκορ " + (final_perc * 10).ToString() + "% !"
                                  + " Σε περίπτωση που επιθυμείς να ξαναπροσπαθήσεις, μπορείς να πατήσεις ακύρωση (Cancel), " +
                                  "ενώ εάν θέλεις να επιστρέψεις στην αρχική πάτησε ΟΚ!";
                            dialogResult = MessageBox.Show(msg, "Προειδοποίηση", MessageBoxButtons.OKCancel);
                            if (dialogResult == DialogResult.OK)
                            {
                                testpanel.Visible = false;
                                this.Hide();
                                var form2 = new Homepage(logged_user_id);
                                form2.Closed += (s, args) => this.Close();
                                form2.Show();
                            }
                            else if (dialogResult == DialogResult.Cancel)
                            {
                                this.Hide();
                                testpanel.Visible = false;
                                var form2 = new Testpage(logged_user_id, test_id, isRep);
                                form2.Closed += (s, args) => this.Close();
                                form2.Show();
                            }
                        }
                    }
                    else
                    {
                        if (test_id == 4)
                        {
                            msg = "Μόλις ολοκλήρωσες το τελικό επαναληπτικό τεστ με σκορ " + (final_perc * 10).ToString() + "% !" +
                                  "Εάν επιθυμείς να βελτιώσεις την επίδοση σου, στην αρχική σελίδα έχουν επισημανθεί τα " +
                                  "κεφάλαια στα οποία ο Κύριος Χι διέκρινε ότι έχεις αδυναμία.";
                            dialogResult = MessageBox.Show(msg, "Προειδοποίηση", MessageBoxButtons.OK);
                            if (dialogResult == DialogResult.OK)
                            {
                                this.Hide();
                                var form2 = new Homepage(logged_user_id);
                                form2.Closed += (s, args) => this.Close();
                                form2.Show();
                            }
                        }
                        else
                        {
                            if (test_id == 1)
                            {
                                msg = "Μόλις ολοκλήρωσες το επαναληπτικό τεστ των αριθμών 1 εώς 3 με σκορ " + (final_perc * 10).ToString() + "% !"
                                      + " Σε περίπτωση που επιθυμείς να ξαναπροσπαθήσεις, μπορείς να πατήσεις ακύρωση (Cancel), " +
                                      "ενώ εάν θέλεις να επιστρέψεις στην αρχική πάτησε ΟΚ!";
                                ;
                            }
                            else if (test_id == 2)
                            {
                                msg = "Μόλις ολοκλήρωσες το επαναληπτικό τεστ των αριθμών 4 εώς 6 με σκορ " + (final_perc * 10).ToString() + "% !"
                                      + " Σε περίπτωση που επιθυμείς να ξαναπροσπαθήσεις, μπορείς να πατήσεις ακύρωση (Cancel), " +
                                      "ενώ εάν θέλεις να επιστρέψεις στην αρχική πάτησε ΟΚ!";
                                ;
                            }
                            else if (test_id == 3)
                            {
                                msg = "Μόλις ολοκλήρωσες το επαναληπτικό τεστ των αριθμών 7 εώς 9 με σκορ " + (final_perc * 10).ToString() + "% !"
                                      + " Σε περίπτωση που επιθυμείς να ξαναπροσπαθήσεις, μπορείς να πατήσεις ακύρωση (Cancel), " +
                                      "ενώ εάν θέλεις να επιστρέψεις στην αρχική πάτησε ΟΚ!";
                                ;
                            }

                            dialogResult = MessageBox.Show(msg, "Προειδοποίηση", MessageBoxButtons.OKCancel);
                            if (dialogResult == DialogResult.OK)
                            {
                                this.Hide();
                                var form2 = new Homepage(logged_user_id);
                                form2.Closed += (s, args) => this.Close();
                                form2.Show();
                            }
                            else if (dialogResult == DialogResult.Cancel)
                            {
                                this.Hide();
                                var form2 = new Testpage(logged_user_id, test_id, isRep);
                                form2.Closed += (s, args) => this.Close();
                                form2.Show();
                            }
                        }
                    }
                }
                //reseting current score
                curr_score = 0;
            }
        }
Example #4
0
        private void egbtn_Click(object sender, EventArgs e)
        {
            string connectionString = "Data Source=LAPTOP-KKBOP61F\\SQLEXPRESS01;Initial Catalog=PropediaDB;Integrated Security=True";

            using (SqlConnection connection =
                       new SqlConnection(connectionString))
            {
                //check if pass
                var regex = @".{8,}";

                // Then add the new row to the collection.
                if (!(egname.Text.Equals("") || egsurname.Text.Equals("") || egmail.Text.Equals("") || egpwd.Text.Equals("")))
                {
                    if (!(Regex.Match(egpwd.Text.ToString(), regex, RegexOptions.IgnoreCase).Success))
                    {
                        MessageBox.Show("Ο κωδικός πρέπει να διαθέτει πάνω από 8 χαρακτήρες", "Αποτυχία Εγγραφής", MessageBoxButtons.OK);
                    }
                    else
                    {
                        string birthdate = "";
                        if (!egage.Text.Equals(""))
                        {
                            birthdate = egage.Text.ToString();
                        }
                        connection.Open();

                        SqlDataAdapter da = new SqlDataAdapter();

                        da.TableMappings.Add("Table", "UserInfo");
                        SqlCommand command = new SqlCommand("SELECT * FROM dbo.UserInfo;", connection);
                        command.CommandType = CommandType.Text;
                        da.SelectCommand    = command;
                        DataSet dataSet = new DataSet("UserInfo");
                        da.Fill(dataSet);

                        DataTable dt = new DataTable();
                        dt = dataSet.Tables["UserInfo"];
                        int new_id = dt.Select().Length + 1;
                        connection.Close();

                        SqlCommand command2 = new SqlCommand("INSERT UserInfo (UserID, Name, Surname, email, password, birthdate ) VALUES " +
                                                             "('" + (new_id).ToString() + "', '" + egname.Text.ToString() + "', '" + egsurname.Text.ToString() +
                                                             "', '" + egmail.Text.ToString() + "', '" + egpwd.Text.ToString() + "', '" + birthdate + "');");
                        command2.CommandType = CommandType.Text;
                        command2.Connection  = connection;

                        connection.Open();
                        command2.ExecuteNonQuery();
                        connection.Close();

                        //now create an empty userstats row

                        SqlCommand command3 = new SqlCommand("INSERT UserStats (UserID) VALUES " +
                                                             "(" + (new_id).ToString() + ");");
                        command3.CommandType = CommandType.Text;
                        command3.Connection  = connection;

                        connection.Open();
                        command3.ExecuteNonQuery();
                        connection.Close();

                        this.Hide();
                        var form2 = new Homepage(new_id);
                        //var form2 = new Homepage(egmail.Text.ToString());
                        form2.Closed += (s, args) => this.Close();
                        form2.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Πρέπει να συμπληρώσετε όλα τα απαραίτητα πεδία", "Αποτυχία Εγγραφής", MessageBoxButtons.OK);
                }


                connection.Close();
            }
        }