Exemplo n.º 1
0
        private void buttonAdminLogin_Submit_Click(object sender, EventArgs e)
        {
            DB db = new DB();

            String username = textUsername.Text;
            String password = textPassword.Text;

            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `admin_data` WHERE `username` = @usn and `password` = @pass", db.getConnect());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;

            adapter.SelectCommand = command;

            adapter.Fill(table);

            if (table.Rows.Count > 0)
            {
                this.Hide();
                AdminDashboard adminDashboard = new AdminDashboard();
                adminDashboard.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Please check your username or password", "Invalid Input");
            }
        }
Exemplo n.º 2
0
        private void buttonBack_Click(object sender, EventArgs e)
        {
            this.Hide();
            AdminDashboard adminDashboard = new AdminDashboard();

            adminDashboard.ShowDialog();
            this.Close();
        }
Exemplo n.º 3
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            // add new user

            DB db = new DB();

            MySqlCommand command = new MySqlCommand("INSERT INTO `user_data`(`student_no`, `name`, `course`, `address`, `phone_no`, `username`, `password`) VALUES (@student_no, @name, @course, @address, @phone_no, @username, @password)", db.getConnect());

            command.Parameters.Add("@student_no", MySqlDbType.VarChar).Value = textBox1.Text;
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value       = textBox2.Text;
            command.Parameters.Add("@course", MySqlDbType.VarChar).Value     = textBox3.Text;
            command.Parameters.Add("@address", MySqlDbType.VarChar).Value    = textBox4.Text;
            command.Parameters.Add("@phone_no", MySqlDbType.Int16).Value     = textBox5.Text;
            command.Parameters.Add("@username", MySqlDbType.VarChar).Value   = textBox6.Text;
            command.Parameters.Add("@password", MySqlDbType.VarChar).Value   = textBox7.Text;

            // open connection

            db.openConnection();

            //execute query
            if (command.ExecuteNonQuery() > 0)
            {
                MessageBox.Show("Account Created");
                this.Hide();
                AdminDashboard adminDashboard = new AdminDashboard();
                adminDashboard.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("Error");
            }

            //close connection
            db.closeConnection();
        }