Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

MODULE VB.2010.docx

MODULE Imports System.Data Imports System.Data.Sql Imports System.Data.SqlClient Module Module1 Public comSQL As New SqlClient.SqlCommand Public sql As String Public conn As New SqlConnection Public str As String = "Data Source = .\SQLEXPRESS;initial catalog=db_pkl;trusted_connection = true" Public Sub bukakoneksi() If conn.State = ConnectionState.Closed Then conn.ConnectionString = str Try conn.Open() Catch ex As Exception MsgBox("Koneksi Gagal : " & ex.ToString) End Try End If End Sub Public Sub tutupkoneksi() If conn.State = ConnectionState.Open Then Try conn.Close() Catch ex As Exception MsgBox("Gagal Menutup Koneksi" & ex.ToString) End Try End If End Sub End Module Login Imports System.Data.SqlClient Public Class Login Private Sub bersih() txt_username.Text = "" txt_password.Text = "" End Sub Private Sub btn_login_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_login.Click bukakoneksi() sql = "SELECT * FROM tb_petugas WHERE hak_akses = '" + cbo_login.SelectedItem + "' AND Username = '" + txt_username.Text + "' AND Password = '" + txt_password.Text + "'" comSQL = New SqlCommand(sql, conn) Dim dr As SqlDataReader = comSQL.ExecuteReader() dr.Read() If dr.HasRows = True Then If cbo_login.SelectedItem = "Kepala Pengadilan" Then Me.Hide() MsgBox("Login Sebagai Kepala Pengadilan Berhasil") Menu_KepelaPengadilan.Show() ElseIf cbo_login.SelectedItem = "Petugas" Then Me.Hide() MsgBox("Login Sebagai Petugas Berhasil") Menu_Petugas.Show() End If Else MessageBox.Show("Kombinasi Hak Akses, User Name dan Password Salah", "Konfirmasi", MessageBoxButtons.OK, MessageBoxIcon.Error) End If tutupkoneksi() bersih() End Sub Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load bukakoneksi() sql = "SELECT * FROM tb_petugas" comSQL = New SqlCommand(sql, conn) Dim dr As SqlDataReader = comSQL.ExecuteReader() While dr.Read() cbo_login.Items.Add(dr.GetString(0)) End While tutupkoneksi() txt_username.Enabled = False End Sub Private Sub btn_batal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_batal.Click End End Sub Private Sub cbo_login_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_login.SelectedIndexChanged If cbo_login.SelectedItem = "Kepala Pengadilan" Then txt_username.Text = cbo_login.SelectedItem ElseIf cbo_login.SelectedItem = "Petugas" Then txt_username.Text = cbo_login.SelectedItem End If End Sub End Class Imports System.Data.SqlClient Public Class Pendaftaran Dim pendaftaran As String Public Sub bersih() txt_id_perkara.Text = "" txt_nama_penggugat.Text = "" tgl_lahir_penggugat.Text = "" cbo_Jekel_penggugat.Text = "" txt_alamat_penggugat.Text = "" txt_peker_penggugat.Text = "" txt_nama_tergugat.Text = "" Tgl_lahir_tergugat.Text = "" cbo_jekel_tergugat.Text = "" txt_alamat_tergugat.Text = "" txt_peker_tergugat.Text = "" tgl_daftar.Text = "" txt_alasan.Text = "" End Sub Public Sub tampil() bukakoneksi() sql = "SELECT * FROM tb_pendaftaran" Dim da As New SqlDataAdapter(sql, conn) Dim ds As New DataSet da.Fill(ds) Dim dt As New DataTable For Each dt In ds.Tables DataGridView1.DataSource = dt Next tutupkoneksi() End Sub Private Sub btn_halaman_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_halaman.Click Close() End Sub Private Sub btn_simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_simpan.Click bukakoneksi() sql = "INSERT INTO tb_pendaftaran(Id_perkara, Nama_penggugat, Tgl_lahir_penggugat, Jekel_penggugat, Alamat_penggugat, Pekerjaan_penggugat, Nama_tergugat, Tgl_lahir_tergugat, Jekel_tergugat, Alamat_tergugat, Pekerjaan_tergugat, Tgl_daftar, Alasan, Biaya_daftar) VALUES ( " & "'" & txt_id_perkara.Text & "'," & "'" & txt_nama_penggugat.Text & "'," & "'" & tgl_lahir_penggugat.Text & "'," & "'" & cbo_Jekel_penggugat.Text & "'," & "'" & txt_alamat_penggugat.Text & "'," & "'" & txt_peker_penggugat.Text & "'," & "'" & txt_nama_tergugat.Text & "'," & "'" & Tgl_lahir_tergugat.Text & "'," & "'" & cbo_jekel_tergugat.Text & "'," & "'" & txt_alamat_tergugat.Text & "'," & "'" & txt_peker_tergugat.Text & "'," & "'" & tgl_daftar.Text & "'," & "'" & txt_alasan.Text & "'," & "'" & txt_biaya.Text & "') " comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Simpan Berhasil") Catch ex As Exception MsgBox("Simpan Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btn_ulang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ulang.Click bersih() End Sub Private Sub btn_ubah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ubah.Click bukakoneksi() sql = "UPDATE tb_pendaftaran SET " & "Nama_penggugat= '" & txt_nama_penggugat.Text & "'," & "Tgl_lahir_penggugat= ' " & tgl_lahir_penggugat.Text & "'," & "Jekel_penggugat= '" & cbo_Jekel_penggugat.Text & "'," & "Alamat_penggugat= '" & txt_alamat_penggugat.Text & "'," & "Pekerjaan_penggugat= '" & txt_peker_penggugat.Text & "'," & "Nama_tergugat= '" & txt_nama_tergugat.Text & "'," & "Tgl_lahir_tergugat= '" & Tgl_lahir_tergugat.Text & "'," & "Jekel_tergugat= '" & cbo_jekel_tergugat.Text & "'," & "Alamat_tergugat= '" & txt_alamat_tergugat.Text & "'," & "Pekerjaan_tergugat= '" & txt_peker_tergugat.Text & "'," & "Tgl_daftar= '" & tgl_daftar.Text & "'," & "Alasan= '" & txt_alasan.Text & "'," & "Biaya_daftar= '" & txt_biaya.Text & "'" & "WHERE Id_perkara='" & txt_id_perkara.Text & "'" comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Ubah Berhasil") Catch ex As Exception MsgBox("Ubah Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btn_hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_hapus.Click bukakoneksi() sql = "DELETE FROM tb_pendaftaran WHERE Id_perkara ='" & txt_id_perkara.Text & "'" comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Hapus Berhasil") Catch ex As Exception MsgBox("Hapus Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btn_tampil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_tampil.Click tampil() End Sub Private Sub btn_cari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cari.Click bukakoneksi() If cbo_cari.Text = "Id perkara" Then pendaftaran = "Id_perkara" ElseIf cbo_cari.Text = "Nama Penggugat" Then pendaftaran = "Nama_penggugat" ElseIf cbo_cari.Text = "Tgl Lahir Penggugat" Then pendaftaran = "Tgl_lahir_penggugat" ElseIf cbo_cari.Text = "Jekel Penggugat" Then pendaftaran = "Jekel_penggugat" ElseIf cbo_cari.Text = "Alamat Penggugat" Then pendaftaran = "Alamat_penggugat" ElseIf cbo_cari.Text = "Pekerjaan Penggugat" Then pendaftaran = "Pekerjaan_penggugat" ElseIf cbo_cari.Text = "Nama Tergugat" Then pendaftaran = "Nama_tergugat" ElseIf cbo_cari.Text = "Tgl Lahir Tergugat" Then pendaftaran = "Tgl_lahir_tergugat" ElseIf cbo_cari.Text = "Jekel Tergugat" Then pendaftaran = "Jekel_tergugat" ElseIf cbo_cari.Text = "Alamat Tergugat" Then pendaftaran = "Alamat_tergugat" ElseIf cbo_cari.Text = "Pekerjaan Tergugat" Then pendaftaran = "Pekerjaan_tergugat" ElseIf cbo_cari.Text = "Tgl Daftar" Then pendaftaran = "Tanggal_daftar" ElseIf cbo_cari.Text = "Alasan" Then pendaftaran = "Alasan" ElseIf cbo_cari.Text = "Biaya Daftar" Then pendaftaran = "Biaya_daftar" End If sql = "SELECT * FROM tb_pendaftaran WHERE " & pendaftaran & " LIKE '%" & txt_cari.Text & "%'" If cbo_cari.Text = "" Then sql = "SELECT * FROM tb_pendaftaran" End If Dim da As New SqlDataAdapter(sql, conn) Dim ds As New DataSet da.Fill(ds) Dim dt As New DataTable For Each dt In ds.Tables DataGridView1.DataSource = dt Next tutupkoneksi() End Sub Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Dim i As Integer i = DataGridView1.CurrentRow.Index txt_id_perkara.Text = DataGridView1.Item(0, i).Value txt_nama_penggugat.Text = DataGridView1.Item(1, i).Value tgl_lahir_penggugat.Text = DataGridView1.Item(2, i).Value cbo_Jekel_penggugat.Text = DataGridView1.Item(3, i).Value txt_alamat_penggugat.Text = DataGridView1.Item(4, i).Value txt_peker_penggugat.Text = DataGridView1.Item(5, i).Value txt_nama_tergugat.Text = DataGridView1.Item(6, i).Value Tgl_lahir_tergugat.Text = DataGridView1.Item(7, i).Value cbo_jekel_tergugat.Text = DataGridView1.Item(8, i).Value txt_alamat_tergugat.Text = DataGridView1.Item(9, i).Value txt_peker_tergugat.Text = DataGridView1.Item(10, i).Value tgl_daftar.Text = DataGridView1.Item(11, i).Value txt_alasan.Text = DataGridView1.Item(12, i).Value txt_biaya.Text = DataGridView1.Item(13, i).Value End Sub Private Sub Pendaftaran_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cbo_cari.Items.Add("Id perkara") cbo_cari.Items.Add("Nama Penggugat") cbo_cari.Items.Add("Tgl Lahir Penggugat") cbo_cari.Items.Add("Jekel Penggugat") cbo_cari.Items.Add("Alamat Penggugat") cbo_cari.Items.Add("Pekerjaan Penggugat") cbo_cari.Items.Add("Nama Tergugat") cbo_cari.Items.Add("Tgl Lahir Tergugat") cbo_cari.Items.Add("Jekel Tergugat") cbo_cari.Items.Add("Alamat Tergugat") cbo_cari.Items.Add("Pekerjaan Tergugat") cbo_cari.Items.Add("Tanggal Daftar") cbo_cari.Items.Add("Alasan") cbo_cari.Items.Add("Biaya Daftar") End Sub End Class Imports System.Data.SqlClient Public Class Administrasi Dim Administrasi As String Dim Pendaftaran As String Public Sub bersih() txt_id_adminis.Text = "" cbo_id_perkara.Text = "" tgl_bayar.Text = "" cbo_radius.Text = "" txt_total.Text = "" txt_jumlahbayar.Text = "" txt_pengembalian.Text = "" End Sub Public Sub tampil() bukakoneksi() sql = "SELECT * FROM tb_administrasi" Dim da As New SqlDataAdapter(sql, conn) Dim ds As New DataSet da.Fill(ds) Dim dt As New DataTable For Each dt In ds.Tables DataGridView1.DataSource = dt Next tutupkoneksi() End Sub Private Sub btnMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMenu.Click Close() End Sub Private Sub bnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnTotal.Click txt_total.Text = Val(txt_biaya_radius.Text) + Val(txt_biaya_materai.Text) + Val(txt_biaya_proses.Text) + Val(txt_biaya_mediasi.Text) txt_total.Enabled = False End Sub Private Sub btnPengembalian_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPengembalian.Click txt_pengembalian.Text = Val(txt_jumlahbayar.Text) - Val(txt_total.Text) End Sub Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click bukakoneksi() sql = "INSERT INTO tb_administrasi(Id_administrasi, Id_perkara,Tgl_bayar, Radius, Biaya_radius, Biaya_materai, Biaya_proses, Biaya_mediasi, Total, Jumlah_bayar, Pengembalian) VALUES ( " & "'" & txt_id_adminis.Text & "'," & "'" & cbo_id_perkara.Text & "'," & "'" & tgl_bayar.Text & "'," & "'" & cbo_radius.Text & "'," & "'" & txt_biaya_radius.Text & "'," & "'" & txt_biaya_materai.Text & "'," & "'" & txt_biaya_proses.Text & "'," & "'" & txt_biaya_mediasi.Text & "'," & "'" & txt_total.Text & "'," & "'" & txt_jumlahbayar.Text & "'," & "'" & txt_pengembalian.Text & "') " comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Simpan Berhasil") Catch ex As Exception MsgBox("Simpan Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btnUlang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUlang.Click bersih() End Sub Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click bukakoneksi() sql = "UPDATE tb_administrasi SET " & "Id_perkara= '" & cbo_id_perkara.Text & "'," & "Tgl_bayar= '" & tgl_bayar.Text & "'," & "Radius= '" & cbo_radius.Text & "'," & "Biaya_radius= '" & txt_biaya_radius.Text & "'," & "Biaya_materai= '" & txt_biaya_materai.Text & "'," & "Biaya_proses= '" & txt_biaya_proses.Text & "'," & "Biaya_mediasi= '" & txt_biaya_mediasi.Text & "'," & "Total= '" & txt_total.Text & "'," & "jumlah_bayar= '" & txt_jumlahbayar.Text & "'," & "Pengembalian= '" & txt_pengembalian.Text & "'" & "WHERE Id_administrasi='" & txt_id_adminis.Text & "'" comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Edit Berhasil") Catch ex As Exception MsgBox("Edit Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapus.Click bukakoneksi() sql = "DELETE FROM tb_administrasi WHERE Id_administrasi ='" & txt_id_adminis.Text & "'" comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Hapus Berhasil") Catch ex As Exception MsgBox("Hapus Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btnCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCari.Click bukakoneksi() If cbo_cari.Text = "Id Administrasi" Then Administrasi = "Id_administrasi" ElseIf cbo_cari.Text = "Id Perkara" Then Administrasi = "Id_perkara" ElseIf cbo_cari.Text = "Tgl Bayar" Then Administrasi = "Tgl_bayar" ElseIf cbo_cari.Text = "Radius" Then Administrasi = "Radius" ElseIf cbo_cari.Text = "Biaya Radius" Then Administrasi = "Biaya_radius" ElseIf cbo_cari.Text = "Biaya Materai" Then Administrasi = "Biaya_materai" ElseIf cbo_cari.Text = "Biaya Proses" Then Administrasi = "Biaya_proses" ElseIf cbo_cari.Text = "Biaya Mediasi" Then Administrasi = "Biaya_mediasi" ElseIf cbo_cari.Text = "Total" Then Administrasi = "Total" ElseIf cbo_cari.Text = "Jumlah Bayar" Then Administrasi = "Jumlah_bayar" ElseIf cbo_cari.Text = "Pengembalian" Then Administrasi = "Pengembalian" End If sql = "SELECT * FROM tb_administrasi WHERE " & Administrasi & " LIKE '%" & txt_cari.Text & "%'" If cbo_cari.Text = "" Then sql = "SELECT * FROM tb_administrasi" End If Dim da As New SqlDataAdapter(sql, conn) Dim ds As New DataSet da.Fill(ds) Dim dt As New DataTable For Each dt In ds.Tables DataGridView1.DataSource = dt Next tutupkoneksi() End Sub Private Sub cbo_radius_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_radius.SelectedIndexChanged If cbo_radius.Text = "Radius I (0-20 Km)" Then txt_biaya_radius.Text = "250000" ElseIf cbo_radius.Text = "Radius II (21-55 Km)" Then txt_biaya_radius.Text = "400000" ElseIf cbo_radius.Text = "Radius III (56-80 Km)" Then txt_biaya_radius.Text = "550000" ElseIf cbo_radius.Text = "Radius IV (81-110 Km/Sulit)" Then txt_biaya_radius.Text = "625000" End If End Sub Private Sub cbo_id_perkara_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_id_perkara.SelectedIndexChanged bukakoneksi() sql = "SELECT * FROM tb_pendaftaran WHERE Id_perkara='" & cbo_id_perkara.Text & " ' " comSQL = New SqlCommand(sql, conn) Dim dr As SqlDataReader = comSQL.ExecuteReader() dr.Read() tutupkoneksi() txt_id_adminis.Text = "AD_" & cbo_id_perkara.SelectedItem End Sub Private Sub btnTampil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTampil.Click tampil() End Sub Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Dim i As Integer i = DataGridView1.CurrentRow.Index txt_id_adminis.Text = DataGridView1.Item(0, i).Value cbo_id_perkara.Text = DataGridView1.Item(1, i).Value tgl_bayar.Text = DataGridView1.Item(2, i).Value cbo_radius.Text = DataGridView1.Item(3, i).Value txt_biaya_radius.Text = DataGridView1.Item(4, i).Value txt_biaya_materai.Text = DataGridView1.Item(5, i).Value txt_biaya_proses.Text = DataGridView1.Item(6, i).Value txt_biaya_mediasi.Text = DataGridView1.Item(7, i).Value txt_total.Text = DataGridView1.Item(8, i).Value txt_jumlahbayar.Text = DataGridView1.Item(9, i).Value txt_pengembalian.Text = DataGridView1.Item(10, i).Value End Sub Private Sub Administrasi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cbo_cari.Items.Add("Id Administrasi") cbo_cari.Items.Add("Id Perkara") cbo_cari.Items.Add("Tgl Bayar") cbo_cari.Items.Add("Radius") cbo_cari.Items.Add("Biaya Radius") cbo_cari.Items.Add("Biaya Materai") cbo_cari.Items.Add("Biaya Proses") cbo_cari.Items.Add("Biaya Mediasi") cbo_cari.Items.Add("Total") cbo_cari.Items.Add("Jumlah Bayar") cbo_cari.Items.Add("Pengembalian") bukakoneksi() sql = "SELECT * FROM tb_pendaftaran" comSQL = New SqlCommand(sql, conn) Dim dr1 As SqlDataReader = comSQL.ExecuteReader() While dr1.Read() Pendaftaran = dr1.GetString(0) cbo_id_perkara.Items.Add(Pendaftaran) End While tutupkoneksi() End Sub Private Sub tgl_bayar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tgl_bayar.ValueChanged If tgl_bayar.Text >= Date.Now Then MsgBox("Tidak Boleh Melebihi Tanggal Hari Ini") tgl_bayar.Value = Date.Now Else tgl_bayar.Value = Date.Now End If End Sub End Class Imports System.Data.SqlClient Public Class Jadwal_Sidang Dim Jadwal As String Dim Pendaftaran As String Dim Majelis As String Public Sub bersih() txt_id_jadwal.Text = "" cbo_perkara.Text = "" tgl_sidang.Text = "" cbo_majelis.Text = "" txt_majelis.Text = "" txt_sidang_ke.Text = "" txt_ruang.Text = "" txt_alasan.Text = "" End Sub Public Sub tampil() bukakoneksi() sql = "SELECT * FROM tb_jadwal" Dim da As New SqlDataAdapter(sql, conn) Dim ds As New DataSet da.Fill(ds) Dim dt As New DataTable For Each dt In ds.Tables DataGridView1.DataSource = dt Next tutupkoneksi() End Sub Private Sub btn_halaman_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_halaman.Click Close() End Sub Private Sub btn_simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_simpan.Click bukakoneksi() sql = "INSERT INTO tb_jadwal(Id_jadwal, Id_perkara, tanggal_sidang, Id_majelis, Sidang_ke, Ruang, Alasan_tunda) VALUES ( " & "'" & txt_id_jadwal.Text & "'," & "'" & cbo_perkara.Text & "'," & "'" & tgl_sidang.Text & "'," & "'" & cbo_majelis.Text & "'," & "'" & txt_sidang_ke.Text & "'," & "'" & txt_ruang.Text & "'," & "'" & txt_alasan.Text & "') " comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Simpan Berhasil") Catch ex As Exception MsgBox("Simpan Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btn_ulang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ulang.Click bersih() End Sub Private Sub btn_ubah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ubah.Click bukakoneksi() sql = "UPDATE tb_jadwal SET " & "Id_perkara= '" & cbo_perkara.Text & "'," & "tanggal_sidang= '" & tgl_sidang.Text & "'," & "Id_majelis= '" & cbo_majelis.Text & "'," & "Sidang_ke= '" & txt_sidang_ke.Text & "'," & "Ruang= '" & txt_ruang.Text & "'," & "Alasan_tunda= '" & txt_alasan.Text & "'" & "WHERE Id_jadwal='" & txt_id_jadwal.Text & "'" comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Ubah Berhasil") Catch ex As Exception MsgBox("Ubah Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btn_hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_hapus.Click bukakoneksi() sql = "DELETE FROM tb_jadwal WHERE Id_jadwal ='" & txt_id_jadwal.Text & "'" comSQL = New SqlCommand(sql, conn) Try comSQL.ExecuteNonQuery() MsgBox("Hapus Berhasil") Catch ex As Exception MsgBox("Hapus Gagal") End Try tampil() bersih() tutupkoneksi() End Sub Private Sub btn_cari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_cari.Click bukakoneksi() If cbo_cari.Text = "Id Jadwal" Then Jadwal = "Id_jadwal" ElseIf cbo_cari.Text = "Id Perkara" Then Jadwal = "Id_perkara" ElseIf cbo_cari.Text = "Tanggal Sidang" Then Jadwal = "tanggal_sidang" ElseIf cbo_cari.Text = "Id Majelis" Then Jadwal = "Id_majelis" ElseIf cbo_cari.Text = "Sidang ke" Then Jadwal = "Sidang_ke" ElseIf cbo_cari.Text = "Ruang" Then Jadwal = "Ruang" ElseIf cbo_cari.Text = "Alasan Tunda" Then Jadwal = "Alasan_tunda" End If sql = "SELECT * FROM tb_jadwal WHERE " & Jadwal & " LIKE '%" & txt_cari.Text & "%'" If cbo_cari.Text = "" Then sql = "SELECT * FROM tb_jadwal" End If Dim da As New SqlDataAdapter(sql, conn) Dim ds As New DataSet da.Fill(ds) Dim dt As New DataTable For Each dt In ds.Tables DataGridView1.DataSource = dt Next tutupkoneksi() End Sub Private Sub btn_tampil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_tampil.Click tampil() End Sub Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick Dim i As Integer i = DataGridView1.CurrentRow.Index txt_id_jadwal.Text = DataGridView1.Item(0, i).Value cbo_perkara.Text = DataGridView1.Item(1, i).Value tgl_sidang.Text = DataGridView1.Item(2, i).Value cbo_majelis.Text = DataGridView1.Item(3, i).Value txt_sidang_ke.Text = DataGridView1.Item(4, i).Value txt_ruang.Text = DataGridView1.Item(5, i).Value txt_alasan.Text = DataGridView1.Item(6, i).Value End Sub Private Sub Jadwal_Sidang_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cbo_cari.Items.Add("Id Jadwal") cbo_cari.Items.Add("Id Perkara") cbo_cari.Items.Add("Tanggal Sidang") cbo_cari.Items.Add("Id Majelis") cbo_cari.Items.Add("Sidang ke") cbo_cari.Items.Add("Ruang") cbo_cari.Items.Add("Alasan Tunda") bukakoneksi() sql = "SELECT * FROM tb_pendaftaran" comSQL = New SqlCommand(sql, conn) Dim dr1 As SqlDataReader = comSQL.ExecuteReader() While dr1.Read() Pendaftaran = dr1.GetString(0) cbo_perkara.Items.Add(Pendaftaran) End While tutupkoneksi() bukakoneksi() sql = "SELECT * FROM tb_majelis" comSQL = New SqlCommand(sql, conn) Dim dr2 As SqlDataReader = comSQL.ExecuteReader() While dr2.Read() Majelis = dr2.GetString(0) cbo_majelis.Items.Add(Majelis) End While tutupkoneksi() End Sub Private Sub cbo_perkara_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_perkara.SelectedIndexChanged bukakoneksi() sql = "SELECT * FROM tb_pendaftaran WHERE Id_perkara='" & cbo_perkara.Text & " ' " comSQL = New SqlCommand(sql, conn) Dim dr As SqlDataReader = comSQL.ExecuteReader() dr.Read() tutupkoneksi() txt_id_jadwal.Text = "JS_" & cbo_perkara.SelectedItem End Sub Private Sub cbo_majelis_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_majelis.SelectedIndexChanged bukakoneksi() sql = "SELECT * FROM tb_majelis WHERE Id_majelis='" & cbo_majelis.Text & " ' " comSQL = New SqlCommand(sql, conn) Dim dr As SqlDataReader = comSQL.ExecuteReader() dr.Read() txt_majelis.Text = dr.GetString(1) tutupkoneksi() End Sub End Class