Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            questionBank questionObj = new questionBank();

            this.Hide();
            questionObj.Show();
        }
Exemplo n.º 2
0
        public void addOptions()
        {
            string connectionString = "datasource=127.0.0.1;port=3306;username=root;password='';database=csharp";

            MySqlDataAdapter adapter;

            DataTable table = new DataTable();

            adapter = new MySqlDataAdapter("SELECT * FROM question order by _id desc", connectionString);
            adapter.Fill(table);

            foreach (DataRow item in table.Rows)
            {
                this.question_id = item[0].ToString();
                break;
            }

            table.Clear();


            string query = "INSERT INTO options VALUES ('', '" + this.question_id + "', '" + this.textBox2.Text + "', '" + this.radioButton1.Checked + "'), ('', '" + this.question_id + "', '" + this.textBox3.Text + "', '" + this.radioButton2.Checked + "'), ('', '" + this.question_id + "', '" + this.textBox4.Text + "', '" + this.radioButton3.Checked + "'), ('', '" + this.question_id + "', '" + this.textBox5.Text + "', '" + this.radioButton4.Checked + "')";

            MySqlConnection databaseConnection = new MySqlConnection(connectionString);
            MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);

            commandDatabase.CommandTimeout = 60;
            MySqlDataReader reader;

            try
            {
                databaseConnection.Open();
                reader             = commandDatabase.ExecuteReader();
                this.textBox2.Text = "";
                this.textBox3.Text = "";
                this.textBox4.Text = "";
                this.textBox5.Text = "";

                questionBank questionObj = new questionBank();
                MessageBox.Show("Question Successfully Created!");
                this.Hide();
                questionObj.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text == "" || this.textBox2.Text == "" || this.textBox3.Text == "" || this.textBox4.Text == "" || this.textBox5.Text == "")
            {
                MessageBox.Show("Invalid Entry: Fields cannot be empty!");
            }
            else if (this.textBox2.Text != this.textBox3.Text)
            {
                MessageBox.Show("Invalid Entry: Password fields do not match!");
            }
            else
            {
                string connectionString = "datasource=127.0.0.1;port=3306;username=root;password='';database=csharp";
                string query            = "INSERT INTO users VALUES ('', '" + this.textBox4.Text + "', '" + this.textBox5.Text + "', '" + this.textBox1.Text + "', sha1('" + this.textBox2.Text + "'))";

                MySqlConnection databaseConnection = new MySqlConnection(connectionString);
                MySqlCommand    commandDatabase    = new MySqlCommand(query, databaseConnection);
                commandDatabase.CommandTimeout = 60;
                MySqlDataReader reader;

                try {
                    databaseConnection.Open();
                    reader             = commandDatabase.ExecuteReader();
                    this.textBox1.Text = "";
                    this.textBox2.Text = "";
                    this.textBox3.Text = "";
                    this.textBox4.Text = "";
                    this.textBox5.Text = "";

                    MessageBox.Show("Sign Up Successful!");
                    questionBank bankObj = new questionBank();
                    this.Hide();
                    bankObj.Show();
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 4
0
        private void button5_Click(object sender, EventArgs e)
        {
            if (this.textBox1.Text == "" || this.textBox2.Text == "")
            {
                MessageBox.Show("Invalid Entry: Fields cannot be empty!");
            }
            else
            {
                MySqlConnection connection = new MySqlConnection("datasource=127.0.0.1;port=3306;username=root;password='';database=csharp");

                MySqlDataAdapter adapter;

                DataTable table = new DataTable();

                adapter = new MySqlDataAdapter("SELECT * FROM users WHERE email='" + textBox1.Text + "' AND password= sha1('" + textBox2.Text + "')", connection);
                adapter.Fill(table);

                if (table.Rows.Count <= 0)
                {
                    MessageBox.Show("Error: Invalid email/password!");
                }
                else
                {
                    MessageBox.Show("Login Successful!");
                    questionBank bankObj = new questionBank();
                    foreach (DataRow item in table.Rows)
                    {
                        bankObj._id = item[0].ToString();
                    }
                    this.Hide();
                    bankObj.Show();
                }

                table.Clear();
            }
        }