예제 #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            string query = "INSERT INTO member (username, password, nama_member, no_hp, email) VALUES (@username, @password, @nama_member, @no_hp, @email)";

            try
            {
                //open the database
                dbCon.Open();
                MySqlCommand cmd = new MySqlCommand(query, dbCon);
                cmd.CommandTimeout = 60;
                cmd.Parameters.AddWithValue("@username", username.Text);
                cmd.Parameters.AddWithValue("@password", GetHashedText(pass.Text));
                cmd.Parameters.AddWithValue("@nama_member", name.Text);
                cmd.Parameters.AddWithValue("@no_hp", hp.Text);
                cmd.Parameters.AddWithValue("@email", email.Text);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Data berhasil ditambahkan");
                HalamanTIket f1 = new HalamanTIket();
                f1.Show();
                this.Close();
            }
            catch (Exception ex)
            {
                //show any error message
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string kiriman;

            kiriman = name.Text;
            HalamanTIket f1 = new HalamanTIket(kiriman);

            f1.Show();
            this.Close();
        }
예제 #3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            string kiriman;

            dbCon.Open();
//                        MySqlCommand cmd = dbCon.CreateCommand();
//                    string sql = "SELECT * FROM member WHERE username like '" + textBox1.Text + "'" +
//                    " AND password like '" + textBox2.Text+"'";
//            cmd.CommandText = sql;

            MySqlCommand cmd = new MySqlCommand("select * from member where username=@username and" +
                                                " password=@password", dbCon);

            cmd.Parameters.AddWithValue("@username", textBox1.Text);
            cmd.Parameters.AddWithValue("@password", GetHashedText(textBox2.Text));
            {
            }
            MySqlDataReader reader = cmd.ExecuteReader();



            if (reader.Read())
            {
                MessageBox.Show("Login berhasil", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                kiriman = reader["nama_member"].ToString();
                //Form4 f4 = new Form4();
                //f4.kiriman(kiriman);

                HalamanTIket f1  = new HalamanTIket(kiriman);
                Keranjang    krj = new Keranjang(null, null, null);
                f1.Show();
                this.Hide();
            }
            else if ((textBox1.Text == "admin") && (textBox2.Text == "admin"))
            {
                MessageBox.Show("Login berhasil", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);

                HalamanAdmin admin = new HalamanAdmin();
                admin.Show();
                this.Hide();
            }

            else
            {
                MessageBox.Show("Username dan Password tidak cocok", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            dbCon.Close();
        }