APLIKASI PERPUSTAKAAN VB NET

 

Tahapan pembuatan aplikasi perpustakaan antara lain :

1.     Membuat Project.

 

Untuk database access sebaiknya disimpan di folder debug agar saat membuat koneksi database tidak perlu mengetik path database yang panjang

 

  1. Membuat Database (Access) Dan Beberapa Tabel

 

 

3.     Membuat Relasi Tabel

 

4.     Membuat Module Koneksi

 

Imports System.Data.OleDb

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

 

 

Module Module1

 

    Public conn As OleDbConnection

    Public da As OleDbDataAdapter

    Public ds As DataSet

    Public cmd As OleDbCommand

    Public dr As OleDbDataReader

 

    Public cryRpt As New ReportDocument

    Public crtableLogoninfos As New TableLogOnInfos

    Public crtableLogoninfo As New TableLogOnInfo

    Public crConnectionInfo As New ConnectionInfo

    Public CrTables As Tables

 

    Public Sub seting_laporan()

        With crConnectionInfo

            .ServerName = (Application.StartupPath.ToString & "\perpustakaan.mdb")

            .DatabaseName = (Application.StartupPath.ToString & "\perpustakaan.mdb")

            .UserID = ""

            .Password = "qazxsw"

        End With

 

        CrTables = cryRpt.Database.Tables

        For Each CrTable In CrTables

            crtableLogoninfo = CrTable.LogOnInfo

            crtableLogoninfo.ConnectionInfo = crConnectionInfo

            CrTable.ApplyLogOnInfo(crtableLogoninfo)

        Next

    End Sub

 

 

    Public Sub Konekdb()

        conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=perpustakaan.mdb")

        conn.Open()

    End Sub

 

End Module

 

 

5.     Membuat Form Login

 

 

 

Imports System.Data.OleDb

 

Public Class Login

 

    Dim Hitung As Integer

 

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        Call Konekdb()

        cmd = New OleDbCommand("select * from petugas where nama_petugas='" & txtnama.Text & "' and pwd='" & txtpassword.Text & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If dr.HasRows Then

            If txtpassword.Text <> dr.Item("pwd") Then

                MsgBox("password salah")

                txtpassword.Clear()

                txtpassword.Focus()

                Exit Sub

            End If

 

            Me.Visible = False

            MNUtama.Show()

 

            MNUtama.PanelKode.Text = dr.Item("id_petugas")

            MNUtama.PanelNama.Text = dr.Item("nama_petugas")

            MNUtama.PanelHakAkses.Text = UCase(dr.Item("hak_akses"))

 

            If MNUtama.PanelHakAkses.Text <> "ADMIN" Then

                MNUtama.Button1.Visible = False

                MNUtama.Button4.Visible = False

            End If

 

            cmd = New OleDbCommand("select * from pengaturan", conn)

            dr = cmd.ExecuteReader

            dr.Read()

            If dr.HasRows Then

                MNUtama.BatasBuku1.Text = dr.Item("batas_buku")

                MNUtama.BatasHari1.Text = dr.Item("batas_hari")

                MNUtama.DendaPerhari1.Text = dr.Item("denda_perhari")

                MNUtama.DendaRusak1.Text = dr.Item("denda_rusak")

            Else

                MsgBox("Segera isi pengaturan")

                Pengaturan.Show()

            End If

 

            cmd = New OleDbCommand("select * from lembaga", conn)

            dr = cmd.ExecuteReader

            dr.Read()

            If dr.HasRows Then

                MNUtama.IDLembaga.Text = dr.Item("id_lembaga")

            Else

                MsgBox("Segera isi profil lembaga")

                Lembaga.Show()

            End If

        Else

            MsgBox("Login gagal")

            txtnama.Clear()

            txtpassword.Clear()

            txtnama.Focus()

 

            Hitung = Hitung + 1

            If Hitung > 2 Then

                End

            End If

        End If

    End Sub

 

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

        Me.Close()

    End Sub

 

End Class

 

 

6.     Membuat Form Menu Utama

 

 

7.     Membuat Form User Atau Petugas

 

 

Imports System.Data.OleDb

 

Public Class Petugas

 

    Sub IDPetugasOtomatis()

        cmd = New OleDbCommand("select id_Petugas from Petugas order by id_Petugas desc", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If Not dr.HasRows Then

            TextBox1.Text = "P0001"

        Else

            TextBox1.Text = "P" + Format(Microsoft.VisualBasic.Right(dr.Item("id_Petugas"), 4) + 1, "0000")

        End If

        TextBox1.Enabled = False

    End Sub

 

    Sub Kosongkan()

        On Error Resume Next

        'TextBox1.Clear()

        TextBox2.Clear()

        TextBox3.Clear()

        ComboBox1.Text = ""

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

 

    Sub DataBaru()

        On Error Resume Next

        TextBox2.Clear()

        TextBox3.Clear()

        ComboBox1.Text = ""

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        On Error Resume Next

        TextBox2.Text = dr.Item(1)

        TextBox3.Text = dr.Item(2)

        ComboBox1.Text = dr.Item(3)

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub TampilHakAkses()

        cmd = New OleDbCommand("select distinct Hak_Akses from Petugas", conn)

        dr = cmd.ExecuteReader

        ComboBox1.Items.Clear()

        Do While dr.Read

            ComboBox1.Items.Add(dr.Item("Hak_Akses"))

        Loop

    End Sub

 

   

    Sub TampilGrid()

        da = New OleDbDataAdapter("select * from Petugas", conn)

        ds = New DataSet

        da.Fill(ds)

        DGV.DataSource = ds.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub CariIdPetugas()

        cmd = New OleDbCommand("select * from Petugas where id_Petugas='" & TextBox1.Text & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

    End Sub

 

    Sub Awal()

        Call IDPetugasOtomatis()

        Call Kosongkan()

        Call TampilGrid()

        Call TampilHakAkses()

    End Sub

 

    Private Sub Petugas_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Konekdb()

        Call Awal()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Try

            Call CariIdPetugas()

            If Not dr.HasRows Then

                Dim simpan As String = "insert into Petugas values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.Text & "')"

                cmd = New OleDbCommand(simpan, conn)

                cmd.ExecuteNonQuery()

            Else

                Dim edit As String = "update Petugas set nama_petugas='" & TextBox2.Text & "',pwd='" & TextBox3.Text & "',Hak_Akses='" & ComboBox1.Text & "' where id_Petugas='" & TextBox1.Text & "'"

                cmd = New OleDbCommand(edit, conn)

                cmd.ExecuteNonQuery()

            End If

            Call Awal()

 

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        TextBox1.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        Call CariIdPetugas()

        If dr.HasRows Then

            Call Ketemu()

        End If

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Call CariIdPetugas()

        If Not dr.HasRows Then

            MsgBox("ID Petugas tidak terdaftar")

            Exit Sub

        End If

 

        If MessageBox.Show("Yakin akan dihapus...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from Petugas  where id_Petugas='" & TextBox1.Text & "'"

            cmd = New OleDbCommand(hapus, conn)

            cmd.ExecuteNonQuery()

            Call Awal()

        Else

            Call Kosongkan()

        End If

    End Sub

 

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Call Kosongkan()

        Call IDPetugasOtomatis()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

        da = New OleDbDataAdapter("select * from Petugas where nama_petugas like '%" & TextBox6.Text & "%' or Hak_Akses like '%" & TextBox6.Text & "%'", conn)

        ds = New DataSet

        da.Fill(ds)

        DGV.DataSource = ds.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

End Class

 

8.     Membuat Form Anggota

 

9.     Membuat Form Buku

 

 

Imports System.Data.OleDb

 

Public Class Buku

 

    Sub IDBukuOtomatis()

        cmd = New OleDbCommand("select id_buku from buku order by id_buku desc", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If Not dr.HasRows Then

            TextBox1.Text = "B0001"

        Else

            TextBox1.Text = "B" + Format(Microsoft.VisualBasic.Right(dr.Item("id_Buku"), 4) + 1, "0000")

        End If

        TextBox1.Enabled = False

    End Sub

 

    Sub Kosongkan()

        On Error Resume Next

        'TextBox1.Clear()

        TextBox2.Clear()

        ComboBox1.Text = ""

        ComboBox2.Text = ""

        ComboBox3.Text = ""

        ComboBox4.Text = ""

        TextBox3.Clear()

        ComboBox5.Text = ""

        TextBox4.Clear()

        TextBox5.Clear()

        TextBox5.Enabled = False

        PictureBox1.Load(TextBox5.Text)

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

 

    Sub DataBaru()

        On Error Resume Next

        TextBox2.Clear()

        ComboBox1.Text = ""

        ComboBox2.Text = ""

        ComboBox3.Text = ""

        ComboBox4.Text = ""

        TextBox3.Clear()

        ComboBox5.Text = ""

        TextBox4.Clear()

        TextBox5.Clear()

        PictureBox1.Load(TextBox5.Text)

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        On Error Resume Next

        TextBox2.Text = dr.Item(1)

        ComboBox1.Text = dr.Item(2)

        ComboBox2.Text = dr.Item(3)

        ComboBox3.Text = dr.Item(4)

        ComboBox4.Text = dr.Item(5)

        TextBox3.Text = dr.Item(6)

        ComboBox5.Text = dr.Item(7)

        DateTimePicker1.Text = dr.Item(8)

        TextBox4.Text = dr.Item(9)

        TextBox5.Text = dr.Item(10)

        PictureBox1.Load(TextBox5.Text)

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub TampilPengarang()

        cmd = New OleDbCommand("select distinct pengarang from buku", conn)

        dr = cmd.ExecuteReader

        ComboBox1.Items.Clear()

        Do While dr.Read

            ComboBox1.Items.Add(dr.Item("pengarang"))

        Loop

    End Sub

 

    Sub TampilPenerbit()

        cmd = New OleDbCommand("select distinct penerbit from buku", conn)

        dr = cmd.ExecuteReader

        ComboBox2.Items.Clear()

        Do While dr.Read

            ComboBox2.Items.Add(dr.Item("penerbit"))

        Loop

 

    End Sub

 

    Sub TampilKategori()

        cmd = New OleDbCommand("select distinct kategori from buku", conn)

        dr = cmd.ExecuteReader

        ComboBox3.Items.Clear()

        Do While dr.Read

            ComboBox3.Items.Add(dr.Item("kategori"))

        Loop

 

    End Sub

 

    Sub TampiltahunTerbit()

        cmd = New OleDbCommand("select distinct tahun from buku", conn)

        dr = cmd.ExecuteReader

        ComboBox4.Items.Clear()

        Do While dr.Read

            ComboBox4.Items.Add(dr.Item("tahun"))

        Loop

 

    End Sub

 

    Sub TampilLokasirak()

        cmd = New OleDbCommand("select distinct lokasi from buku", conn)

        dr = cmd.ExecuteReader

        ComboBox5.Items.Clear()

        Do While dr.Read

            ComboBox5.Items.Add(dr.Item("lokasi"))

        Loop

    End Sub

 

    Sub TampilGrid()

        da = New OleDbDataAdapter("select * from buku", conn)

        ds = New DataSet

        da.Fill(ds)

        DGV.DataSource = ds.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub CariIdBuku()

        cmd = New OleDbCommand("select * from buku where id_buku='" & TextBox1.Text & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

    End Sub

 

    Sub Awal()

        Call IDBukuOtomatis()

        Call Kosongkan()

        Call TampilGrid()

        Call TampilKategori()

        Call TampilLokasirak()

        Call TampilPenerbit()

        Call TampilPengarang()

        Call TampiltahunTerbit()

    End Sub

 

    Private Sub Buku_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Konekdb()

        Call Awal()

    End Sub

 

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click

        On Error Resume Next

        OpenFileDialog1.ShowDialog()

        TextBox5.Text = OpenFileDialog1.FileName

        PictureBox1.Load(TextBox5.Text)

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Try

            Call CariIdBuku()

            If Not dr.HasRows Then

                Dim simpan As String = "insert into buku values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & ComboBox1.Text & "','" & ComboBox2.Text & "','" & ComboBox3.Text & "','" & ComboBox4.Text & "','" & TextBox3.Text & "','" & ComboBox5.Text & "','" & DateTimePicker1.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"

                cmd = New OleDbCommand(simpan, conn)

                cmd.ExecuteNonQuery()

            Else

                Dim edit As String = "update buku set judul='" & TextBox2.Text & "',pengarang='" & ComboBox1.Text & "',penerbit='" & ComboBox2.Text & "',kategori='" & ComboBox3.Text & "',tahun='" & ComboBox4.Text & "',stok='" & TextBox3.Text & "',lokasi='" & ComboBox5.Text & "',Tanggal_masuk='" & DateTimePicker1.Text & "',harga_buku='" & TextBox4.Text & "',gambar='" & TextBox5.Text & "' where id_buku='" & TextBox1.Text & "'"

                cmd = New OleDbCommand(edit, conn)

                cmd.ExecuteNonQuery()

            End If

            Call Awal()

 

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        TextBox1.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        Call CariIdBuku()

        If dr.HasRows Then

            Call Ketemu()

        End If

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Call CariIdBuku()

        If Not dr.HasRows Then

            MsgBox("ID buku tidak terdaftar")

            Exit Sub

        End If

 

        If MessageBox.Show("Yakin akan dihapus...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from buku  where id_buku='" & TextBox1.Text & "'"

            cmd = New OleDbCommand(hapus, conn)

            cmd.ExecuteNonQuery()

            Call Awal()

        Else

            Call Kosongkan()

        End If

    End Sub

 

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Call Kosongkan()

        Call IDBukuOtomatis()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox6.TextChanged

        da = New OleDbDataAdapter("select * from buku where judul like '%" & TextBox6.Text & "%' or pengarang like '%" & TextBox6.Text & "%'", conn)

        ds = New DataSet

        da.Fill(ds)

        DGV.DataSource = ds.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress

        If Not (e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = vbBack) Then

            e.Handled = True

        End If

    End Sub

 

    Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress

        If Not (e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = vbBack) Then

            e.Handled = True

        End If

    End Sub

 

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        On Error Resume Next

        OpenFileDialog1.ShowDialog()

        TextBox5.Text = OpenFileDialog1.FileName

        PictureBox1.Load(TextBox5.Text)

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

    End Sub

End Class

 

10.                       Membuat Form Lembaga

 

 

Imports System.Data.OleDb

 

Public Class Lembaga

 

    Sub IDLembagaOtomatis()

        cmd = New OleDbCommand("select id_Lembaga from Lembaga order by id_Lembaga desc", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If Not dr.HasRows Then

            ID.Text = "01"

        Else

            ID.Text = "01"

        End If

        ID.Enabled = False

    End Sub

 

    Sub Kosongkan()

        On Error Resume Next

        Nama.Clear()

        Alamat.Clear()

        Telepon.Clear()

        Fax.Clear()

        Email.Clear()

        Website.Clear()

        Nama.Focus()

    End Sub

 

    Sub Ketemu()

        On Error Resume Next

        Nama.Text = dr.Item(1)

        Alamat.Text = dr.Item(2)

        Telepon.Text = Microsoft.VisualBasic.Mid(dr.Item(3), 9, 30)

        Fax.Text = Microsoft.VisualBasic.Mid(dr.Item(4), 5, 30)

        Email.Text = Microsoft.VisualBasic.Mid(dr.Item(5), 7, 30)

        Website.Text = Microsoft.VisualBasic.Mid(dr.Item(6), 9, 30)

        Nama.Focus()

    End Sub

 

 

    Sub CariIdLembaga()

        cmd = New OleDbCommand("select * from Lembaga where id_Lembaga='" & ID.Text & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

    End Sub

 

    Sub Awal()

        Call IDLembagaOtomatis()

        Call Kosongkan()

    End Sub

 

    Private Sub Lembaga_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Konekdb()

        'Call Awal()

        Call IDLembagaOtomatis()

        Call CariIdLembaga()

        If dr.HasRows Then

            Call Ketemu()

        End If

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Try

            Call CariIdLembaga()

            If Not dr.HasRows Then

                Dim simpan As String = "insert into Lembaga values('" & ID.Text & "','" & Nama.Text & "','" & Alamat.Text & "', '" & Label4.Text & Space(1) & Telepon.Text & "', '" & Label5.Text & Space(1) & Fax.Text & " ', '" & Label6.Text & Space(1) & Email.Text & "', '" & Label7.Text & Space(1) & Website.Text & "')"

                cmd = New OleDbCommand(simpan, conn)

                cmd.ExecuteNonQuery()

            Else

                cmd = New OleDbCommand("delete * from lembaga", conn)

                cmd.ExecuteNonQuery()

                Dim simpan As String = "insert into Lembaga values('" & ID.Text & "','" & Nama.Text & "','" & Alamat.Text & "', '" & Label4.Text & Space(1) & Telepon.Text & "', '" & Label5.Text & Space(1) & Fax.Text & " ', '" & Label6.Text & Space(1) & Email.Text & "', '" & Label7.Text & Space(1) & Website.Text & "')"

                cmd = New OleDbCommand(simpan, conn)

                cmd.ExecuteNonQuery()

            End If

            'Call Awal()

            MNUtama.IDLembaga.Text = ID.Text

            MsgBox("Data berhasil disimpan")

            Me.Close()

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        'Call Kosongkan()

        Call IDLembagaOtomatis()

        Call Ketemu()

        Nama.Focus()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

End Class

 

11.                       Membuat Form Pengaturan

 

 

Imports System.Data.OleDb

 

Public Class Pengaturan

 

    Sub IDPengaturanOtomatis()

        cmd = New OleDbCommand("select id_Pengaturan from Pengaturan order by id_Pengaturan desc", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If Not dr.HasRows Then

            TextBox1.Text = "1"

        Else

            TextBox1.Text = "1"

        End If

        TextBox1.Enabled = False

    End Sub

 

    Sub Kosongkan()

        On Error Resume Next

        TextBox2.Clear()

        TextBox3.Clear()

        TextBox4.Clear()

        TextBox5.Clear()

        TextBox2.Focus()

    End Sub

 

 

    Sub DataBaru()

        On Error Resume Next

        TextBox2.Clear()

        TextBox3.Clear()

        TextBox4.Clear()

        TextBox5.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        On Error Resume Next

        TextBox2.Text = dr.Item(1)

        TextBox3.Text = dr.Item(2)

        TextBox4.Text = dr.Item(3)

        TextBox5.Text = dr.Item(4)

        TextBox2.Focus()

    End Sub

   

    Sub CariIdPengaturan()

        cmd = New OleDbCommand("select * from Pengaturan where id_Pengaturan='" & TextBox1.Text & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

    End Sub

 

    Sub Awal()

        Call IDPengaturanOtomatis()

        Call Kosongkan()

    End Sub

 

    Private Sub Pengaturan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Konekdb()

        Call Awal()

        Call CariIdPengaturan()

        If dr.HasRows Then

            Call Ketemu()

        End If

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Try

            Call CariIdPengaturan()

            If Not dr.HasRows Then

                Dim simpan As String = "insert into Pengaturan values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & MNUtama.PanelKode.Text & "')"

                cmd = New OleDbCommand(simpan, conn)

                cmd.ExecuteNonQuery()

            Else

 

                Dim edit As String = "update Pengaturan set BATAS_BUKU='" & TextBox2.Text & "',batas_hari='" & TextBox3.Text & "',denda_perhari='" & TextBox4.Text & "',denda_rusak='" & TextBox5.Text & "',id_petugas='" & MNUtama.PanelKode.Text & "' where id_Pengaturan='" & TextBox1.Text & "'"

                cmd = New OleDbCommand(edit, conn)

                cmd.ExecuteNonQuery()

            End If

            Call Awal()

 

            cmd = New OleDbCommand("select * from pengaturan", conn)

            dr = cmd.ExecuteReader

            dr.Read()

            If dr.HasRows Then

                MNUtama.BatasBuku1.Text = dr.Item("batas_buku")

                MNUtama.BatasHari1.Text = dr.Item("batas_hari")

                MNUtama.DendaPerhari1.Text = dr.Item("denda_perhari")

                MNUtama.DendaRusak1.Text = dr.Item("denda_rusak")

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

            MsgBox("Harus login dulu")

            Login.Show()

        End Try

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Call Kosongkan()

        Call IDPengaturanOtomatis()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

 

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress

        If Not (e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = vbBack) Then

            e.Handled = True

        End If

    End Sub

 

    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress

        If Not (e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = vbBack) Then

            e.Handled = True

        End If

    End Sub

 

    Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress

        If Not (e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = vbBack) Then

            e.Handled = True

        End If

    End Sub

 

 

    Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress

        If Not (e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = vbBack) Then

            e.Handled = True

        End If

    End Sub

End Class

 

12.                       Membuat Form Katalog

 

 

Imports System.Data.OleDb

 

Public Class Katalog

 

    Private Sub Katalog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Konekdb()

        da = New OleDbDataAdapter("select * from buku", conn)

        ds = New DataSet

        da.Fill(ds)

        DGV.DataSource = ds.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

        If e.KeyCode = Keys.Escape Then

            Me.Close()

        End If

    End Sub

 

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        da = New OleDbDataAdapter("select * from buku where judul like '%" & TextBox1.Text & "%' or pengarang like '%" & TextBox1.Text & "%' or penerbit like '%" & TextBox1.Text & "%' ", conn)

        ds = New DataSet

        da.Fill(ds)

        DGV.DataSource = ds.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        Label1.Text = DGV.Rows(e.RowIndex).Cells(10).Value

        PictureBox1.Load(Label1.Text)

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

 

    End Sub

End Class

 

13.                       Membuat Form Peminjman Buku

 

 

Imports System.Data.OleDb

 

Public Class Peminjaman

 

    'id pinjaman otomatis dengan pola thn-bln-tgl+ nomor urut

    Sub IDPinjamOtomatis()

        cmd = New OleDbCommand("select ID_pinjam from pinjam order by id_pinjam desc", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If Not dr.HasRows Then

            LBLIdPinjaman.Text = "PJ" + Format(Today, "yyMMdd") + "01"

        Else

            If Microsoft.VisualBasic.Mid(dr.Item("id_pinjam"), 3, 6) = Format(Today, "yyMMdd") Then

                LBLIdPinjaman.Text = "PJ" + Format(Microsoft.VisualBasic.Right(dr.Item("id_pinjam"), 8) + 1, "00")

            Else

                LBLIdPinjaman.Text = "PJ" + Format(Today, "yyMMdd") + "01"

            End If

        End If

    End Sub

 

    'menampilkan id anggota di combobox

    Sub TampilAnggota()

        cmd = New OleDbCommand("select ID_anggota from anggota", conn)

        dr = cmd.ExecuteReader

        Do While dr.Read

            ComboBox1.Items.Add(dr.Item("ID_anggota"))

        Loop

    End Sub

 

    'menampilkan data buku di sebelah kanan

    Sub TampilBuku()

        da = New OleDbDataAdapter("select * from buku where stok>0", conn)

        ds = New DataSet

        da.Fill(ds)

        DGV3.DataSource = ds.Tables(0)

        DGV3.ReadOnly = True

    End Sub

 

    Sub Kosongkan()

        On Error Resume Next

        DGV3.Enabled = True

        ComboBox1.Text = ""

        LBLNama.Text = ""

        LBLPinjamSekarang.Text = 0

        LBLPernahPinjam.Text = 0

        LBLTotalPinjam.Text = 0

        DGV1.Rows.Clear()

        DGV2.Columns.Clear()

        TextBox1.Clear()

 

        PictureBox2.Load(TextBox1.Text)

        PictureBox2.SizeMode = PictureBoxSizeMode.StretchImage

    End Sub

 

    Private Sub Peminjaman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Kosongkan()

        Call Konekdb()

        Call TampilBuku()

        Call IDPinjamOtomatis()

        LBLtanggal.Text = Format(Today, "dd/MMMM/yyyy")

        Call TampilAnggota()

        DGV1.ReadOnly = True

    End Sub

 

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

 

        'mencari judul buku di bawah kanan

        da = New OleDbDataAdapter("select * from buku where judul like '%" & TextBox2.Text & "%' and stok>0", conn)

        ds = New DataSet

        da.Fill(ds)

        DGV3.DataSource = ds.Tables(0)

        DGV3.ReadOnly = True

    End Sub

 

    Private Sub DGV3_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV3.CellMouseClick

        If ComboBox1.Text = "" Then

            MsgBox("pilih atau Isi id anggota terlebih dahulu...!")

            Exit Sub

        End If

        TextBox2.Clear()

        Dim baris1 As Integer = DGV1.RowCount - 1

        'Dim baris3 As Integer = DGV3.RowCount - 1

 

        Dim kode As String = DGV3.Rows(e.RowIndex).Cells(0).Value

 

        'mencegah pinjaman buku2x ketika masih dipinjam

        cmd = New OleDbCommand("select id_buku from pinjamdetail,pinjam, anggota where pinjam.id_pinjam=pinjamdetail.id_pinjam and pinjam.id_anggota=anggota.id_anggota and pinjamdetail.id_buku='" & kode & "' and pinjam.id_anggota='" & ComboBox1.Text & "' and pinjamdetail.keterangan='Dipinjam'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If dr.HasRows Then

            MsgBox("Buku sedang dipinjam")

            Exit Sub

 

        End If

 

        'menampilkan id buku, judul dan pengarang yang dipinjam dari grid sebelah kanan

        cmd = New OleDbCommand("select Judul,Pengarang from buku where id_buku='" & DGV3.Rows(e.RowIndex).Cells(0).Value & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If dr.HasRows Then

            DGV1.Rows.Add(DGV3.Rows(e.RowIndex).Cells(0).Value, DGV3.Rows(e.RowIndex).Cells(1).Value, dr.Item("pengarang"))

            'mencegah peminjaman buku yang sama

            For barisatas As Integer = 0 To DGV1.RowCount - 1

                For barisbawah As Integer = barisatas + 1 To DGV1.RowCount - 1

                    If DGV1.Rows(barisbawah).Cells(0).Value = DGV1.Rows(barisatas).Cells(0).Value Then

                        MsgBox("Buku sudah dalam transaksi peminjaman")

                        DGV1.Rows.RemoveAt(barisbawah)

                        Exit Sub

                    End If

                Next

            Next

        End If

 

        'menampilkan gambar buku dari lokasi hardisk

        cmd = New OleDbCommand("select gambar from buku where id_buku='" & DGV1.Rows(baris1).Cells(0).Value & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If dr.HasRows Then

            TextBox1.Text = dr.Item("gambar")

            PictureBox2.Load(TextBox1.Text)

            PictureBox2.SizeMode = PictureBoxSizeMode.Zoom

        End If

        'menghitung jumlah buku yang dipinjam dari grid atas kanan

        LBLPinjamSekarang.Text = DGV1.RowCount - 1

        'menghitung total pinjaman sekarang dan yang lalu

        LBLTotalPinjam.Text = Val(LBLPernahPinjam.Text) + Val(LBLPinjamSekarang.Text)

 

        'menampilkan batas jumlah pinjaman

        If LBLTotalPinjam.Text >= MNUtama.BatasBuku1.Text Then

            MsgBox("pinjaman sudah maksimal")

            DGV3.Enabled = False

        End If

 

    End Sub

 

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        DGV3.Enabled = True

        cmd = New OleDbCommand("select Nama_anggota from anggota where id_anggota='" & ComboBox1.Text & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If dr.HasRows Then

            LBLNama.Text = dr.Item("nama_anggota")

        End If

 

        'menampilkan data buku yang pernah dan sedang dipinjam oleh anggota

        da = New OleDbDataAdapter("select pinjamdetail.ID_Pinjam,pinjamdetail.ID_Buku,buku.Judul,Pengarang,Penerbit from pinjamdetail,pinjam,buku where pinjamdetail.id_pinjam=pinjam.id_pinjam and buku.id_buku=pinjamdetail.id_buku and pinjam.id_anggota='" & ComboBox1.Text & "' and pinjamdetail.keterangan='Dipinjam'", conn)

 

        ds = New DataSet

        da.Fill(ds)

        DGV2.DataSource = ds.Tables(0)

        DGV2.ReadOnly = True

        DGV2.Columns(0).HeaderText = "ID Pinjam"

        DGV2.Columns(1).HeaderText = "ID Buku"

        DGV2.Columns(2).HeaderText = "Judul"

        LBLPernahPinjam.Text = DGV2.RowCount - 1

 

        'menampilkan batas jumlah pinjaman

        If LBLPernahPinjam.Text >= MNUtama.BatasBuku1.Text Then

            MsgBox("pinjaman sudah maksimal")

            DGV3.Enabled = False

        End If

    End Sub

 

    Private Sub BTNBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBatal.Click

        Call Kosongkan()

 

    End Sub

 

 

    Private Sub BTNTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTutup.Click

        Me.Close()

    End Sub

 

    Private Sub DGV1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DGV1.KeyDown

        'menghapus data dengan tombol delete atau escape

        On Error Resume Next

        If e.KeyCode = Keys.Delete Or e.KeyCode = Keys.Escape Then

            DGV1.Rows.Remove(DGV1.CurrentRow)

            LBLPinjamSekarang.Text = DGV1.RowCount - 1

            LBLTotalPinjam.Text = Val(LBLPernahPinjam.Text) + Val(LBLPinjamSekarang.Text)

            DGV3.Enabled = True

        End If

    End Sub

End Class

 

14.                       Membuat Form Pengembalian Buku

 

 

Imports System.Data.OleDb

 

Public Class Pengembalian

 

    Sub Kosongkan()

        On Error Resume Next

        ComboBox1.Text = ""

        LBLIDAnggota.Text = ""

        LBLNama.Text = ""

        LBLTotalPinjam.Text = 0

        LBLTotalDenda.Text = 0

        txtdibayar.Text = 0

        LBLKembali.Text = 0

        DGV1.Rows.Clear()

        DGV2.Columns.Clear()

        TextBox1.Clear()

        PictureBox1.Load(TextBox1.Text)

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

    End Sub

 

 

    Sub IDKembaliOtomatis()

        cmd = New OleDbCommand("select ID_kembali from kembali order by id_kembali desc", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If Not dr.HasRows Then

            LBLIDKembali.Text = "KB" + Format(Today, "yyMMdd") + "01"

        Else

            If Microsoft.VisualBasic.Mid(dr.Item("id_kembali"), 3, 6) = Format(Today, "yyMMdd") Then

                LBLIDKembali.Text = "KB" + Format(Microsoft.VisualBasic.Right(dr.Item("id_kembali"), 8) + 1, "00")

            Else

                LBLIDKembali.Text = "KB" + Format(Today, "yyMMdd") + "01"

            End If

        End If

    End Sub

 

    'menampilkan id pinjam yang keterangannya "Dipinjam'

    Sub TampilIDPinjam()

        cmd = New OleDbCommand("select distinct ID_pinjam from pinjamdetail where keterangan='Dipinjam'", conn)

        dr = cmd.ExecuteReader

        ComboBox1.Items.Clear()

        Do While dr.Read

            ComboBox1.Items.Add(dr.Item("ID_Pinjam"))

        Loop

    End Sub

 

    Private Sub Pengembalian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Konekdb()

        Call IDKembaliOtomatis()

        LBLtanggal.Text = Format(Today, "dd/MMM/yyyy")

        Call TampilIDPinjam()

        Call Kosongkan()

 

        DGV1.Columns(0).ReadOnly = True

        DGV1.Columns(1).ReadOnly = True

        DGV1.Columns(2).ReadOnly = True

        DGV1.Columns(3).ReadOnly = True

        DGV1.Columns(4).ReadOnly = True

        DGV1.Columns(7).ReadOnly = True

    End Sub

 

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        'bersihkan grid transaksi dan cari identitas anggota

        DGV1.Rows.Clear()

        'Call Pilihan()

        cmd = New OleDbCommand("select anggota.id_anggota,anggota.Nama_anggota from anggota,pinjam,pinjamdetail where pinjam.id_anggota=anggota.id_anggota and pinjam.id_pinjam='" & ComboBox1.Text & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If dr.HasRows Then

            LBLIDAnggota.Text = dr.Item("id_anggota")

            LBLNama.Text = dr.Item("nama_anggota")

        End If

 

        'menampilkan data buku yang akan dikembalikan

        da = New OleDbDataAdapter("select pinjamdetail.id_buku,buku.judul,Pengarang,Penerbit from pinjamdetail,pinjam,buku where pinjamdetail.id_pinjam=pinjam.id_pinjam and buku.id_buku=pinjamdetail.id_buku and pinjam.id_pinjam='" & ComboBox1.Text & "'  and pinjamdetail.keterangan='Dipinjam'", conn)

 

        ds = New DataSet

        da.Fill(ds)

        DGV2.DataSource = ds.Tables(0)

        DGV2.ReadOnly = True

        DGV2.Columns(0).HeaderText = "ID Buku"

        DGV2.Columns(1).HeaderText = "Judul"

        LBLTotalPinjam.Text = DGV2.RowCount - 1

    End Sub

 

    Sub HitungDenda()

        Dim hitung As Double

        For baris As Integer = 0 To DGV1.RowCount - 1

            hitung = hitung + DGV1.Rows(baris).Cells(7).Value

        Next

        LBLTotalDenda.Text = hitung

 

        If LBLTotalDenda.Text = 0 Then

            LBLTotalDenda.Text = 0

            txtdibayar.Text = 0

            LBLKembali.Text = 0

        Else

 

        End If

    End Sub

 

    Private Sub DGV2_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV2.CellMouseClick

 

        Dim baris As Integer = DGV1.RowCount - 1

        cmd = New OleDbCommand("select tanggal_pinjam from pinjam,pinjamdetail where pinjam.id_pinjam='" & ComboBox1.Text & "' and pinjamdetail.id_buku='" & DGV2.Rows(e.RowIndex).Cells(0).Value & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If dr.HasRows Then

            'masukkan data buku ke dalam grid pengembalian

            DGV1.Rows.Add(DGV2.Rows(e.RowIndex).Cells(0).Value, DGV2.Rows(e.RowIndex).Cells(1).Value, Format(DateValue(dr.Item("tanggal_pinjam")), "dd/MMM/yyyy"), "", "", "Tidak", "Tidak")

 

            For barisatas As Integer = 0 To DGV1.RowCount - 1

                For barisbawah As Integer = barisatas + 1 To DGV1.RowCount - 1

                    If DGV1.Rows(barisbawah).Cells(0).Value = DGV1.Rows(barisatas).Cells(0).Value Then

                        MsgBox("Buku sedang dalam proses pengembalian")

                        DGV1.Rows.RemoveAt(barisbawah)

                        Exit Sub

                    End If

                Next

            Next

            'hitug lama pinjam

            If DGV1.Rows(baris).Cells(2).Value = Today Then

                DGV1.Rows(baris).Cells(3).Value = 1

            Else

                DGV1.Rows(baris).Cells(3).Value = DateDiff(DateInterval.Day, DGV1.Rows(baris).Cells(2).Value, Today())

            End If

            If DGV1.Rows(baris).Cells(3).Value <= Val(MNUtama.BatasBuku1.Text) Then

                DGV1.Rows(baris).Cells(4).Value = 0

                DGV1.Rows(baris).Cells(7).Value = 0

            Else

                DGV1.Rows(baris).Cells(4).Value = DGV1.Rows(baris).Cells(3).Value - Val(MNUtama.BatasHari1.Text)

                DGV1.Rows(baris).Cells(7).Value = Val(MNUtama.DendaPerhari1.Text) * DGV1.Rows(baris).Cells(4).Value

            End If

        Else

            MsgBox("Buku sedang dalam proses pengembalian")

        End If

 

        'cari gambar buku yang dikembalikan

        cmd = New OleDbCommand("select gambar from buku where id_buku='" & DGV1.Rows(baris).Cells(0).Value & "'", conn)

        dr = cmd.ExecuteReader

        dr.Read()

        If dr.HasRows Then

            On Error Resume Next

            TextBox1.Text = dr.Item("gambar")

            PictureBox1.Load(TextBox1.Text)

            PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

        End If

        Call HitungDenda()

    End Sub

 

    Private Sub BTNTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTutup.Click

        Me.Close()

    End Sub

 

 

    Private Sub BTNBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub txtdibayar_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtdibayar.KeyDown

        'proses pembayaran denda

        If e.KeyCode = Keys.Enter Then

            If Val(txtdibayar.Text) < Val(LBLTotalDenda.Text) Then

                MsgBox("pembayaran kurang")

                Exit Sub

            ElseIf Val(txtdibayar.Text) >= Val(LBLTotalDenda.Text) Then

                LBLKembali.Text = Val(txtdibayar.Text) - Val(LBLTotalDenda.Text)

                BTNSimpan.Focus()

            End If

        End If

    End Sub

 

 

 

    Private Sub DGV1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DGV1.KeyDown

        'hapus data jika ingin dibatalkan dengan esc atau delete

        On Error Resume Next

        If e.KeyCode = Keys.Delete Or e.KeyCode = Keys.Escape Then

            DGV1.Rows.Remove(DGV1.CurrentRow)

            LBLTotalPinjam.Text = DGV1.RowCount - 1

            Call HitungDenda()

            txtdibayar.Text = 0

            LBLKembali.Text = 0

        End If

    End Sub

End Class

 

15.                       Membuat Histori

 

 

Imports System.Data.OleDb

 

Public Class Histori

 

    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

        If e.KeyCode = Keys.Escape Then

            Me.Close()

        End If

    End Sub

 

    Private Sub TextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox2.KeyDown

        If e.KeyCode = Keys.Escape Then

            Me.Close()

        End If

    End Sub

 

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        Call Konekdb()

        da = New OleDbDataAdapter("select DISTINCT pinjam.ID_Pinjam,pinjam.Tanggal_Pinjam, buku.Judul,buku.Pengarang,Pinjamdetail.Keterangan from pinjam,buku,pinjamdetail,ANGGOTA WHERE PINJAM.ID_PINJAM=PINJAMDETAIL.ID_PINJAM AND BUKU.ID_BUKU=PINJAMDETAIL.ID_BUKU AND ANGGOTA.ID_ANGGOTA=PINJAM.ID_ANGGOTA AND ANGGOTA.NAMA_ANGGOTA like '%" & TextBox1.Text & "%'", conn)

 

        ds = New DataSet

        da.Fill(ds)

        DGVPinjam.DataSource = ds.Tables(0)

        DGVPinjam.ReadOnly = True

 

        da = New OleDbDataAdapter("select DISTINCT Kembali.ID_Kembali,Kembali.Tanggal_Kembali, buku.Judul,buku.Pengarang,Kembalidetail.Lama_Pinjam,kembalidetail.Terlambat,kembalidetail.Rusak,kembalidetail.Hilang,kembalidetail.Denda from anggota,Kembali,buku,Kembalidetail,pinjam WHERE Kembali.ID_Kembali=KembaliDETAIL.ID_Kembali AND BUKU.ID_BUKU=KembaliDETAIL.ID_BUKU AND ANGGOTA.ID_ANGGOTA=pinjam.ID_ANGGOTA AND pinjam.id_pinjam=kembali.id_pinjam and ANGGOTA.NAMA_ANGGOTA like '%" & TextBox1.Text & "%'", conn)

        ds = New DataSet

        da.Fill(ds)

        DGVKembali.DataSource = ds.Tables(0)

        DGVKembali.ReadOnly = True

    End Sub

 

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

        Call Konekdb()

        da = New OleDbDataAdapter("select DISTINCT pinjam.ID_Pinjam,pinjam.Tanggal_Pinjam, buku.Judul,buku.Pengarang,pinjamdetail.Keterangan from pinjam,buku,pinjamdetail,ANGGOTA WHERE PINJAM.ID_PINJAM=PINJAMDETAIL.ID_PINJAM AND BUKU.ID_BUKU=PINJAMDETAIL.ID_BUKU AND ANGGOTA.ID_ANGGOTA=PINJAM.ID_ANGGOTA AND pinjam.id_pinjam like '%" & TextBox2.Text & "%'", conn)

 

        ds = New DataSet

        da.Fill(ds)

        DGVPinjam.DataSource = ds.Tables(0)

        DGVPinjam.ReadOnly = True

 

        da = New OleDbDataAdapter("select DISTINCT Kembali.ID_Kembali,Kembali.Tanggal_Kembali, buku.Judul,buku.Pengarang,Kembalidetail.Lama_Pinjam,kembalidetail.Terlambat,kembalidetail.Rusak,kembalidetail.Hilang,kembalidetail.Denda from anggota,Kembali,buku,Kembalidetail,pinjam WHERE Kembali.ID_Kembali=KembaliDETAIL.ID_Kembali AND BUKU.ID_BUKU=KembaliDETAIL.ID_BUKU AND ANGGOTA.ID_ANGGOTA=pinjam.ID_ANGGOTA AND pinjam.id_pinjam=kembali.id_pinjam and pinjam.id_pinjam like '%" & TextBox2.Text & "%'", conn)

        ds = New DataSet

        da.Fill(ds)

        DGVKembali.DataSource = ds.Tables(0)

        DGVKembali.ReadOnly = True

    End Sub

End Class

 

16.                       Membuat Laporan Peminjaman

 

 

17.                       Membuat  Laporan Pengembalian