Professional Documents
Culture Documents
Imports System.Data.Odbc
Module Module1
Public conn As OdbcConnection
Public ds As DataSet
Public cmd As OdbcCommand
Public da As OdbcDataAdapter
Public dr As OdbcDataReader
Sub tampilGrid_Buku()
Call koneksi()
da = New OdbcDataAdapter("select * from buku", conn)
ds = New DataSet
da.Fill(ds)
home.DGV_buku.DataSource = ds.Tables(0)
home.DGV_buku.ReadOnly = True
End Sub
Sub tampilGrid_Member()
Call koneksi()
da = New OdbcDataAdapter("select * from user where status='peminjam'",
conn)
ds = New DataSet
da.Fill(ds)
home.DGV_member.DataSource = ds.Tables(0)
home.DGV_member.ReadOnly = True
End Sub
Sub tampilGrid_Ulasan()
Call koneksi()
da = New OdbcDataAdapter("select * from ulasan_buku", conn)
ds = New DataSet
da.Fill(ds)
home.DGV_ulasan.DataSource = ds.Tables(0)
home.DGV_ulasan.ReadOnly = True
End Sub
Sub tampil_koleksi_pribadi()
cmd = New OdbcCommand("select * from koleksi_pribadi inner join buku on
koleksi_pribadi.id_buku = buku.id_buku where id_user='" & home.Panel1.Text & "'",
conn)
dr = cmd.ExecuteReader
home.ListBox1.Items.Clear()
Do While dr.Read
home.ListBox1.Items.Add(dr.Item("id_buku") & Space(2) &
dr.Item("judul"))
Loop
End Sub
End Module
USER
Imports System.Data.Odbc
Public Class user
'kodingan sub
Sub tampilGrid()
Call koneksi()
da = New OdbcDataAdapter("select id_user, nama_lengkap, status, email,
alamat, no_telepon from user", conn)
ds = New DataSet
da.Fill(ds)
DGV.DataSource = ds.Tables(0)
DGV.ReadOnly = True
DGV.Columns("id_user").Width = 100
DGV.Columns("nama_lengkap").Width = 120
DGV.Columns("status").Width = 95
DGV.Columns("email").Width = 100
DGV.Columns("alamat").Width = 100
DGV.Columns("no_telepon").Width = 100
End Sub
Sub panggilKode()
Call koneksi()
cmd = New OdbcCommand("select * from user where id_user='" & TextBox1.Text
& "'", conn)
dr = cmd.ExecuteReader
dr.Read()
End Sub
Sub panggilData()
On Error Resume Next
TextBox2.Text = dr("nama_lengkap")
TextBox3.Text = dr("password")
ComboBox1.Text = dr("status")
TextBox4.Text = dr("email")
TextBox5.Text = dr("no_telepon")
TextBox6.Text = dr("alamat")
End Sub
Sub hapus()
TextBox2.Clear()
TextBox3.Clear()
ComboBox1.Text = ""
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
End Sub
Sub caridata()
Call koneksi()
da = New OdbcDataAdapter("select id_user, nama_lengkap, status, email,
alamat, no_telepon from user where id_user like '%" & TextBox7.Text & "%' or
nama_lengkap like '%" & TextBox7.Text & "%' or email like '%" & TextBox7.Text & "%'
or alamat like '%" & TextBox7.Text & "%' or status like '%" & TextBox7.Text & "%'
or no_telepon like '%" & TextBox7.Text & "%'", conn)
ds = New DataSet
da.Fill(ds)
DGV.DataSource = ds.Tables(0)
DGV.ReadOnly = True
End Sub
'kodingan textbox
If dr.HasRows Then
Call panggilData()
Else
Call hapus()
End If
End If
End Sub
'kodingan combobox
'kodingan button
Call panggilKode()
'caridata
HOME
Imports System.Data.Odbc
End Sub
'kodingan sub
'kodingan TabControl
'kodingan button
'master
'laporan
End Sub
Private Sub btn_laporan_buku_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btn_laporan_buku.Click
laporan_buku.Show()
End Sub
'umum
'keluar
End Class
PEMINJAMAN
Imports System.Data.Odbc
End Sub
'kodingan sub
Sub idPeminjaman()
Call koneksi()
cmd = New OdbcCommand("select id_peminjaman from peminjaman order by
id_peminjaman desc", conn)
dr = cmd.ExecuteReader
dr.Read()
If Not dr.HasRows Then
TextBox1.Text = Format(Today, "yyMMdd") + "001"
Else
If Microsoft.VisualBasic.Left(dr("id_peminjaman"), 6) = Format(Today,
"yyMMdd") Then
TextBox1.Text = dr("id_peminjaman") + 1
Else
TextBox1.Text = Format(Today, "yyMMdd") + "001"
End If
End If
End Sub
Sub hapus()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox7.Clear()
TextBox8.Clear()
PictureBox1.Image = Nothing
ListBox1.Items.Clear()
End Sub
Sub hapusBuku()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
PictureBox1.Image = Nothing
End Sub
Sub tampilRiwayat()
Call koneksi()
cmd = New OdbcCommand("SELECT id_peminjaman, judul, tanggal_peminjaman,
status_peminjaman FROM peminjaman inner join buku on peminjaman.id_buku =
buku.id_buku where id_user='" & TextBox7.Text & "'", conn)
dr = cmd.ExecuteReader
ListBox1.Items.Clear()
If dr.HasRows Then
Do While dr.Read
ListBox1.Items.Add(dr("id_peminjaman") & Space(3) & dr("judul") &
Space(3) & dr("tanggal_peminjaman") & Space(3) & dr("status_peminjaman"))
Loop
Else
ListBox1.Items.Add("Tidak ada riwayat buku yang dipinjam")
End If
End Sub
Sub ubahTanggal()
Dim hariIni As DateTime = DateTime.Now
TextBox5.Text = Format(hariIni, "yyyy-MM-dd")
Dim TujuhHari As DateTime = hariIni.AddDays(7)
TextBox6.Text = Format(TujuhHari, "yyyy-MM-dd")
End Sub
Sub panggilBuku()
Call koneksi()
cmd = New OdbcCommand("select * from buku where id_buku='" & TextBox2.Text
& "'", conn)
dr = cmd.ExecuteReader
dr.Read()
If dr.HasRows Then
TextBox3.Text = dr("judul")
TextBox4.Text = dr("ketersediaan_buku")
Sub panggilAnggota()
Call koneksi()
cmd = New OdbcCommand("select * from user where status='peminjam' and
id_user='" & TextBox7.Text & "'", conn)
dr = cmd.ExecuteReader
dr.Read()
End Sub
Sub cekPeminjaman()
Call koneksi()
cmd = New OdbcCommand("select count(id_peminjaman) as hitungPeminjaman from
peminjaman where id_user='" & TextBox7.Text & "' and status_peminjaman='dipinjam'",
conn)
dr = cmd.ExecuteReader
dr.Read()
End Sub
'kodingan textbox
If dr.HasRows Then
TextBox8.Text = dr("nama_lengkap")
Call tampilRiwayat()
Else
MsgBox("Anggota tidak ditemukan", MsgBoxStyle.Information,
"Informasi")
TextBox7.Clear()
TextBox8.Clear()
End If
End If
End Sub
'kodinngan button
Call cekPeminjaman()
If dr("hitungPeminjaman") > 3 Then
MsgBox("Anggota sudah meminjam 3 buku", MsgBoxStyle.Information,
"Informasi")
Call hapus()
Exit Sub
End If
Call koneksi()
Dim simpan As String = "insert into peminjaman values('" & TextBox1.Text &
"', '" & TextBox7.Text & "', '" & TextBox2.Text & "', '" & TextBox5.Text & "', '" &
TextBox6.Text & "', '', 'dipinjam', 'Belum Dikembalikan', '', '', '')"
cmd = New OdbcCommand(simpan, conn)
cmd.ExecuteNonQuery()
'kodingan listbox
PENGEMBALIAN
Imports System.Data.Odbc
Call hapus()
End Sub
'kodingan variabel
'kodingan sub
Sub hapus()
TextBox2.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
TextBox8.Clear()
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox2.Enabled = False
TextBox7.ReadOnly = True
PictureBox1.Image = Nothing
End Sub
Sub hitungKeterlambatan()
Dim tanggalKembali As Date = TextBox3.Text
Dim denda As Integer = 5000
DendaTerlambat = 0
Call hitungDenda()
Else
Dim selisihHari As Integer = (tanggalKembali - jatuhTempo).Days
TextBox5.Text = "Terlambat " & selisihHari & " Hari"
Call hitungDenda()
End If
End Sub
Sub hitungDenda()
TotalDenda = DendaTerlambat + DendaKondisi
TextBox6.Text = TotalDenda
End Sub
Sub panggilPeminjaman()
Call koneksi()
cmd = New OdbcCommand("select * from user where id_user='" & TextBox1.Text
& "' and status='peminjam'", conn)
dr = cmd.ExecuteReader
dr.Read()
If dr.HasRows Then
Do While dr.Read()
ComboBox1.Items.Add(dr("id_peminjaman"))
Loop
ComboBox1.Enabled = True
ComboBox1.Focus()
Else
ComboBox1.Text = "Anggota tidak meminjam buku apapun"
ComboBox1.Enabled = False
End If
End If
End Sub
'kodingan textbox
End If
End Sub
'kodingan combobox
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Call koneksi()
cmd = New OdbcCommand("select * from peminjaman inner join buku on
peminjaman.id_buku = buku.id_buku where id_peminjaman='" & ComboBox1.Text & "'",
conn)
dr = cmd.ExecuteReader
dr.Read()
If dr.HasRows Then
jatuhTempo = dr("jatuh_tempo")
TextBox2.Text = dr("id_buku")
TextBox4.Text = Format(jatuhTempo, "yyyy-MM-dd")
PictureBox1.Load(dr("gambar"))
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
Call hitungKeterlambatan()
ComboBox2.Enabled = True
End If
End Sub
TextBox7.Clear()
TextBox8.Clear()
TextBox7.ReadOnly = False
End Sub
'kodingan button
Else
End Sub
KATEGORI
Imports System.Data.Odbc
End Sub
'kodingan sub
Sub hapus()
TextBox2.Clear()
End Sub
Sub panggilKode()
Call koneksi()
cmd = New OdbcCommand("select * from kategori_buku where id_kategori = '" &
TextBox1.Text & "'", conn)
dr = cmd.ExecuteReader
dr.Read()
End Sub
Sub panggilData()
TextBox2.Text = dr("nama_kategori")
End Sub
Sub tampil_grid()
Call koneksi()
da = New OdbcDataAdapter("select * from kategori_buku", conn)
ds = New DataSet
da.Fill(ds)
DGV.DataSource = ds.Tables(0)
DGV.ReadOnly = True
End Sub
'kodingan textbox
'kodingan button
Call panggilKode()
End Sub