Exemple #1
0
        private void display_data()
        {
            MySqlConnection conn    = Koneksi.getKoneksi();
            MySqlCommand    command = conn.CreateCommand();

            command.CommandText = "SELECT * FROM data_pendaftaran WHERE usia > " + 6;

            conn.Open();
            DataSet          ds = new DataSet();
            MySqlDataAdapter da = new MySqlDataAdapter(command);

            da.Fill(ds, "data");
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = "data";
            conn.Close();
        }
Exemple #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            String          namaLengkap = textBox1.Text;
            MySqlConnection conn        = Koneksi.getKoneksi();
            MySqlCommand    command     = conn.CreateCommand();

            command.CommandText = "SELECT * FROM data_pendaftaran WHERE nama_lengkap LIKE '%" + namaLengkap + "%' AND usia >= " + 6;

            conn.Open();
            DataSet          ds = new DataSet();
            MySqlDataAdapter da = new MySqlDataAdapter(command);

            da.Fill(ds, "data");
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = "data";
            conn.Close();
        }
Exemple #3
0
        private void btn_hapus_Click(object sender, EventArgs e)
        {
            String selectedId_id = dataGridView1.CurrentRow.Cells["id_pendaftaran"].Value.ToString();

            DialogResult dr = MessageBox.Show("Hapus Data?", "Ingin Menghapus data ini?", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                MySqlConnection conn    = Koneksi.getKoneksi();
                MySqlCommand    command = conn.CreateCommand();
                conn.Open();
                command.CommandText = "DELETE FROM data_pendaftaran WHERE id_pendaftaran = @id";
                command.Parameters.AddWithValue("@id", selectedId_id);

                if (command.ExecuteNonQuery() == 1)
                {
                    MessageBox.Show("Terhapus", "Data Berhasil dihapus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    display_data();
                }
            }
            else
            {
            }
        }