Aplikasi Perpustakaan Admin Using Visual Studio 2010 (4) Finish
Pada tahap terakhir ini, penulis akan menjelaskan Button Cari, Peminjam, Peminjaman, Pengembalian dan Keluar. Pertama sekali pada form Menut Utama, buat kode berikut ini pada setiap Button Cari, Peminjam, Peminjaman, Pengembalian dan Keluar.
Private Sub
BtnPeminjam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnPeminjam.Click
FormPeminjam.ShowDialog()
End Sub
Private Sub
BtnPeminjaman_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnPeminjaman.Click
FormProsesPeminjaman.ShowDialog()
End Sub
Private Sub
BtnCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnCari.Click
FormCari.ShowDialog()
End Sub
Private Sub
BtnPengembalian_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnPengembalian.Click
FormPengembalian.ShowDialog()
End Sub
Private Sub
BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnExit.Click
End
End Sub
Pertama sekali, penulis akan menjelaskan mengenai Button Cari. Jika Button di Klik, maka akan muncul FormCari yang berfungsi untuk mencari buku yang berada di rak tertentu. Penulis akan membuat desain Form seperti ini:
Toolbox
|
Name
|
Text
|
Event
|
Button
|
BtnKeluar
|
Keluar
|
Click
|
Button
|
BtnCari
|
-
|
Click
|
Label
|
Label1
|
Rak
|
-
|
Label
|
Label2
|
Kode
Buku
|
TextChanged
|
TextBox
|
TxtRak
|
-
|
-
|
TextBox
|
TxtKodeBuku
|
-
|
-
|
Kode program:
Public Class FormCari
Private Sub
TxtKodeBuku_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TxtKodeBuku.TextChanged
Try
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
DML.CommandText = "select * from
Table_Buku where Kode_Buku='" & TxtKodeBuku.Text & "'"
Cari = DML.ExecuteReader
If Cari.HasRows = True
Then
Cari.Read()
TxtRak.Text = Cari("Rak")
Else
TxtKodeBuku.Text = ""
TxtRak.Text = ""
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
FormCari_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Me.CenterToParent()
End Sub
Private Sub
BtnCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnCari.Click
Dim Kode_Buku = InputBox("Masukkan
kode buku yang akan dicari")
TxtKodeBuku.Text = Kode_Buku
End Sub
Private Sub
BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnKeluar.Click
Me.Close()
End Sub
End Class
Selanjutnya pada Button Peminjam, jika diklik maka akan muncul Form Peminjam. Form ini berfungsi untuk mendata anggota/member/peminjam yang sering berkunjung ke perpustakaan, sehingga jika ingin meminjam buku maka proses yang dilakukan akan lebih mudah. Desainnya sebagai berikut:
Toolbox
|
Name
|
Text
|
Event
|
Button
|
BtnSimpan
|
Simpan
|
Click
|
Button
|
BtnEdit
|
Ubah
|
Click
|
Button
|
BtnHapus
|
Hapus
|
Click
|
Button
|
BtnKeluar
|
Keluar
|
Click
|
Label
|
Label1
|
Kode
Peminjam
|
-
|
Label
|
Label2
|
No.
Identitas
|
-
|
Label
|
Label3
|
Nama
Peminjam
|
-
|
Label
|
Label4
|
Alamat
|
-
|
Label
|
Label5
|
Telepon
|
-
|
TextBox
|
TxtPeminjam
|
-
|
-
|
TextBox
|
TxtIdentitas
|
-
|
-
|
TextBox
|
TxtNama
|
-
|
-
|
TextBox
|
TxtAlamat
|
-
|
-
|
TextBox
|
TxtTelepom
|
-
|
-
|
DataGridView
|
DGVPeminjam
|
-
|
CellContentClick
|
Kode Program:
Imports System.Data
Imports System.Data.OleDb
Public Class FormPeminjam
Sub Data_Record()
Try
'memanggil koneksi database
Call Koneksi()
'mengambil data dari tabel buku
Tabel = New Data.OleDb.OleDbDataAdapter("select
* from Table_Peminjam", Database)
'inisialisasi DataSet
Data = New DataSet
'memasukkan data tabel ke DataSet
Tabel.Fill(Data)
Record.DataSource = Data
Record.DataMember = Data.Tables(0).ToString()
DGVPeminjam.DataSource = Record
DGVPeminjam.Columns(3).Width = 150
DGVPeminjam.Columns(4).Width = 250
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub Clear()
BtnSimpan.Enabled = True
BtnEdit.Enabled = False
BtnHapus.Enabled = False
TxtPeminjam.Text = ""
TxtIdentitas.Text = ""
TxtNama.Text = ""
TxtAlamat.Text = ""
TxtTelepon.Text = ""
TxtPeminjam.Enabled = False
TxtPeminjam.Focus()
Call
Kode_Peminjam()
Call Koneksi()
Call Data_Record()
End Sub
Sub Kode_Peminjam()
Tabel
= New Data.OleDb.OleDbDataAdapter("select * from Table_Peminjam order by No asc",
Database)
Data
= New DataSet
Tabel.Fill(Data)
Record.DataSource = Data
Record.DataMember = Data.Tables(0).ToString()
Try
Dim A As DataRow
Dim B As Integer = 0
TxtPeminjam.Text = ""
For Each A In Data.Tables(0).Rows
TxtPeminjam.Text = A.Item(0) + 1
B = B + 1
Next A
Select Case B
Case Is
= 0
TxtPeminjam.Text = "Member 1"
Case Is
> 0
TxtPeminjam.Text = "Member " & TxtPeminjam.Text & ""
End Select
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
FormPeminjam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Me.CenterToParent()
Call Clear()
End Sub
Private Sub
BtnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnSimpan.Click
Try
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
DML.CommandText = "insert into
Table_Peminjam (Kode_Peminjam, No_Identitas, Nama_Peminjam, Alamat,
No_Telp)" & _
"values('" &
TxtPeminjam.Text & "','" &
TxtIdentitas.Text & "','"
& TxtNama.Text & _
"','" & TxtAlamat.Text
& "','" & TxtTelepon.Text
& "')"
DML.ExecuteNonQuery()
MsgBox("Data Telah Disimpan")
Call Clear()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnEdit.Click
Try
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
DML.CommandText = "update
Table_Peminjam set No_Identitas='" & TxtIdentitas.Text & _
"',Nama_Peminjam ='" &
TxtNama.Text & "', Alamat='"
& TxtAlamat.Text & _
"',No_Telp='" &
TxtTelepon.Text & "' where
Kode_Peminjam='" & TxtPeminjam.Text & "'"
DML.ExecuteNonQuery()
MsgBox("Data Telah Diubah")
Call Clear()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
BtnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnHapus.Click
Try
Dim pesan = MsgBox("Anda
Yakin Ingin Menghapus Data?", vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
DML.CommandText = "delete from
Table_Peminjam where Kode_Peminjam='" & TxtPeminjam.Text & "'"
DML.ExecuteNonQuery()
MsgBox("Data Telah Dihapus")
Call Clear()
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
DGVPeminjam_CellContentClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs)
Handles DGVPeminjam.CellContentClick
Try
TxtPeminjam.Text = DGVPeminjam.Rows(e.RowIndex).Cells(1).Value
TxtIdentitas.Text = DGVPeminjam.Rows(e.RowIndex).Cells(2).Value
TxtNama.Text = DGVPeminjam.Rows(e.RowIndex).Cells(3).Value
TxtAlamat.Text = DGVPeminjam.Rows(e.RowIndex).Cells(4).Value
TxtTelepon.Text = DGVPeminjam.Rows(e.RowIndex).Cells(5).Value
BtnSimpan.Enabled = False
BtnEdit.Enabled = True
BtnHapus.Enabled = True
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnKeluar.Click
Me.Close()
End Sub
End Class
Pada Button Peminjaman, jika di klik makan akan muncul Form untuk melakukan transaksi peminjaman. Penulis akan membuat Form seperti berikut ini:
Toolbox
|
Name
|
Text
|
Event
|
Button
|
BtnTransaksi
|
Transaksi
Peminjaman
|
Click
|
Button
|
BtnEdit
|
Ubah
|
Click
|
Button
|
BtnHapus
|
Hapus
|
Click
|
Button
|
BtnKeluar
|
Keluar
|
Click
|
DataGridView
|
DGVPeminjam
|
-
|
CellContentClick
|
Dengan Kode Program:
Imports System.Data
Imports System.Data.OleDb
Public Class FormProsesPeminjaman
Sub Data_Record()
Try
Call Koneksi()
Tabel = New
Data.OleDb.OleDbDataAdapter("select * from Query1 where Status='Pinjam'",
Database)
Data = New DataSet
Tabel.Fill(Data)
Record_Peminjaman.DataSource = Data
Record_Peminjaman.DataMember = Data.Tables(0).ToString()
DGVPeminjaman.DataSource = Record_Peminjaman
DGVPeminjaman.Columns(1).Visible = False
DGVPeminjaman.Columns(2).Width = 175
DGVPeminjaman.Columns(3).Visible = False
DGVPeminjaman.Columns(4).Visible = False
DGVPeminjaman.Columns(5).Visible = False
DGVPeminjaman.Columns(6).Visible = False
DGVPeminjaman.Columns(7).Width = 175
DGVPeminjaman.Columns(8).Visible = False
DGVPeminjaman.Columns(9).Visible = False
DGVPeminjaman.Columns(12).Width = 175
DGVPeminjaman.Columns(13).Visible = False
DGVPeminjaman.Columns(14).Visible = False
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub Clear()
BtnTransaksi.Enabled = True
BtnEdit.Enabled = False
BtnHapus.Enabled = False
Call Koneksi()
Call Data_Record()
End Sub
Private Sub
FrmDataPeminjaman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Call Clear()
End Sub
Private Sub
BtnTransaksi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnTransaksi.Click
FormPeminjaman.Text = "Ok"
FormPeminjaman.ShowDialog()
End Sub
Private Sub
BtnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnEdit.Click
FormPeminjaman.BtnOk.Text = "Ubah"
FormPeminjaman.TxtNoPeminjaman.Text =
DGVPeminjaman.SelectedCells(0).Value
FormPeminjaman.ShowDialog()
End Sub
Private Sub
BtnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnHapus.Click
FormPeminjaman.BtnOk.Text
= "Hapus"
FormPeminjaman.TxtNoPeminjaman.Text =
DGVPeminjaman.SelectedCells(0).Value
FormPeminjaman.ShowDialog()
End Sub
Private Sub
BtnTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnKeluar.Click
Me.Close()
End Sub
Private Sub
DGVPeminjaman_CellContentClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs)
Handles DGVPeminjaman.CellContentClick
Try
FormPeminjaman.TxtNoPeminjaman.Text =
DGVPeminjaman.Rows(e.RowIndex).Cells(0).Value
FormPeminjaman.TxtKodeBuku.Text =
DGVPeminjaman.Rows(e.RowIndex).Cells(1).Value
FormPeminjaman.TxtKode.Text = DGVPeminjaman.Rows(e.RowIndex).Cells(5).Value
FormPeminjaman.DPPinjam.Value =
DGVPeminjaman.Rows(e.RowIndex).Cells(10).Value
FormPeminjaman.DPKembali.Value =
DGVPeminjaman.Rows(e.RowIndex).Cells(11).Value
FormPeminjaman.TxtHari.Text = DGVPeminjaman.Rows(e.RowIndex).Cells(12).Value
BtnEdit.Enabled = True
BtnHapus.Enabled = True
BtnTransaksi.Enabled = False
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
FormProsesPeminjaman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Me.CenterToParent()
End Sub
End Class
Apabila Button Transaksi Peminjaman diklik, maka akan muncul Form baru dimana form ini berfungsi untuk menambah transaksi untuk meminjam dengan desain seperi berikut:
Toolbox
|
Name
|
Text
|
Event
|
Button
|
BtnOk
|
Ok
|
Click
|
Button
|
BtnKeluar
|
Keluar
|
Click
|
Button
|
BtnKodeBuku
|
-
|
Click
|
Button
|
BtnKodePeminjam
|
-
|
Click
|
Label
|
Label1
|
No. Peminjaman
|
-
|
Label
|
Label2
|
Kode Peminjam
|
-
|
Label
|
Label3
|
No. Identitas
|
-
|
Label
|
Label4
|
Nama Peminjam
|
-
|
Label
|
Label5
|
Alamat
|
-
|
Label
|
Label6
|
Telepon
|
-
|
Label
|
Label7
|
Kode Buku
|
-
|
Label
|
Label8
|
Judul Buku
|
-
|
Label
|
Label9
|
Kategori
|
-
|
Label
|
Label10
|
Rak
|
|
Label
|
Label11
|
Lama Pinjam (Hari)
|
-
|
Label
|
Label12
|
Tanggal Pinjam
|
-
|
Label
|
Label13
|
Tanggal Kembali
|
-
|
TextBox
|
TxtNoPeminjaman
|
-
|
-
|
TextBox
|
TxtKode
|
-
|
TextChanged
|
TextBox
|
TxtIdentitas
|
-
|
-
|
TextBox
|
TxtNama
|
-
|
-
|
TextBox
|
TxtAlamat
|
-
|
-
|
TextBox
|
TxtTelepon
|
-
|
-
|
TextBox
|
TxtKodeBuku
|
-
|
TextChanged
|
TextBox
|
TxtJudulBuku
|
-
|
|
TextBox
|
TxtKategori
|
-
|
-
|
TextBox
|
TxtRak
|
-
|
-
|
DateTimePicker
|
DPPinjam
|
-
|
ValueChanged
|
DateTimePicker
|
DPKembali
|
-
|
ValueChanged
|
PictureBox
|
FotoPix
|
-
|
-
|
Kode Programnya:
Imports System.Data
Imports System.Data.OleDb
Public Class FormPeminjaman
Sub No_Peminjaman()
Tabel
= New Data.OleDb.OleDbDataAdapter("select * from Table_Peminjaman order by No
Asc", Database)
Data
= New DataSet
Tabel.Fill(Data)
Record.DataSource = Data
Record.DataMember = Data.Tables(0).ToString()
Try
Dim A As DataRow
Dim B As Integer = 0
TxtNoPeminjaman.Text = ""
For Each A In Data.Tables(0).Rows
TxtNoPeminjaman.Text = A.Item(0) + 1
B = B + 1
Next A
Select Case B
Case Is
= 0
TxtNoPeminjaman.Text = ""
& Format(Now, "dd/MM/yy")
& "-1"
Case Is
> 0
TxtNoPeminjaman.Text = ""
& Format(Now, "dd/MM/yy")
& "-" &
TxtNoPeminjaman.Text & ""
End Select
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub Clear()
Call Koneksi()
If BtnOk.Text = "Ok"
Then
TxtKodeBuku.Text = ""
TxtKode.Text = ""
TxtHari.Text = ""
DPPinjam.Value = Format(Now, "dd/MM/yyyy")
DPKembali.Value = Format(Now, "dd/MM/yyyy")
Call No_Peminjaman()
End If
End Sub
Sub Lama_Pinjam()
Dim SelisihHari As Long
SelisihHari = DateDiff(DateInterval.Day,
DPPinjam.Value, DPKembali.Value)
TxtHari.Text = "" &
SelisihHari & " Hari"
End Sub
Private Sub
FormPeminjaman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Call Clear()
Me.CenterToParent()
End Sub
Private Sub
BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnOk.Click
Try
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
Select Case
BtnOk.Text
Case
"Ok"
DML.CommandText = "insert into
Table_Peminjaman(No_Peminjaman, Kode_Buku, Kode_Peminjam," & _
"Tgl_Pinjam, Tgl_Kembali, Lama_Pinjam, Status) values('"
& TxtNoPeminjaman.Text & _
"','" & TxtKodeBuku.Text & "','" & TxtKode.Text & "','" & DPPinjam.Value & _
"','" & DPKembali.Value & "','" & TxtHari.Text & "','Pinjam')"
Case "Ubah"
DML.CommandText = "update
Table_Peminjaman set Kode_Buku='" & TxtKode.Text & _
"', Kode_Peminjam='" & TxtKode.Text & "', Tgl_Pinjam='" & DPPinjam.Value
& _
"', Tgl_Kembali='" & DPKembali.Value & "', Lama_Pinjam='" & TxtHari.Text
& _
"' where No_Peminjaman='" & TxtNoPeminjaman.Text
& "'"
Case "Hapus"
DML.CommandText = "delete from
Table_Peminjaman where No_Peminjaman='" & TxtNoPeminjaman.Text
& "'"
End Select
DML.ExecuteNonQuery()
MsgBox("Data Telah Diproses")
Call FormProsesPeminjaman.Data_Record()
TxtKodeBuku.Text = ""
TxtKode.Text = ""
TxtHari.Text = ""
FotoPic.Image = Nothing
DPPinjam.Value = Format(Now, "dd/MM/yyyy")
DPKembali.Value = Format(Now, "dd/MM/yyyy")
Call No_Peminjaman()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
BtnKodeBuku_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnKodeBuku.Click
Dim Kode_Buku = InputBox("Masukkan
kode buku (Kode Buku yang akan dipinjam)")
TxtKodeBuku.Text = Kode_Buku
End Sub
Private Sub
TxtKodeBuku_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TxtKodeBuku.TextChanged
Try
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
DML.CommandText = "select * from
Table_Buku where Kode_Buku='" & TxtKodeBuku.Text & "'"
Cari = DML.ExecuteReader
If Cari.HasRows = True
Then
Cari.Read()
TxtJudulBuku.Text = Cari("Judul_Buku")
TxtKategori.Text = Cari("Kategori")
TxtRak.Text = Cari("Rak")
FotoPic.ImageLocation = Cari("Foto")
Else
TxtKodeBuku.Text = ""
TxtJudulBuku.Text = ""
TxtKategori.Text = ""
TxtRak.Text = ""
FotoPic.Image = Nothing
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
BtnKodePeminjam_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnKodePeminjam.Click
Dim Kode = InputBox("Masukkan
Kode Peminjam (Kode Peminjam yang akan meminjam Buku)")
TxtKode.Text = Kode
End Sub
Private Sub
DPPinjam_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
DPPinjam.ValueChanged
Call Lama_Pinjam()
End Sub
Private Sub
DPKembali_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
DPKembali.ValueChanged
Call Lama_Pinjam()
End Sub
Private Sub
BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnKeluar.Click
Me.Close()
End Sub
Private Sub
TxtKode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TxtKode.TextChanged
Try
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
DML.CommandText = "select * from
Table_Peminjam where Kode_Peminjam='" & TxtKode.Text & "'"
Cari = DML.ExecuteReader
If Cari.HasRows = True
Then
Cari.Read()
TxtIdentitas.Text = Cari("No_Identitas")
TxtNama.Text = Cari("Nama_Peminjam")
TxtAlamat.Text = Cari("Alamat")
TxtTelepon.Text = Cari("No_Telp")
Else
TxtIdentitas.Text = ""
TxtNama.Text = ""
TxtAlamat.Text = ""
TxtTelepon.Text = ""
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
End Class
Dan yang terkahir ialah Form Pengembalian, Penulis membuat desain sebagai berikut:
Toolbox
|
Name
|
Text
|
Event
|
Button
|
BtnOk
|
Ok
|
Click
|
Button
|
BtnKeluar
|
Keluar
|
Click
|
Button
|
BtnPeminjam
|
-
|
Click
|
Label
|
Label1
|
No. Peminjaman
|
-
|
Label
|
Label2
|
Kode Peminjam
|
-
|
Label
|
Label3
|
No. Identitas
|
-
|
Label
|
Label4
|
Nama Peminjam
|
-
|
Label
|
Label5
|
Alamat
|
-
|
Label
|
Label6
|
Telepon
|
-
|
Label
|
Label7
|
Kode Buku
|
-
|
Label
|
Label8
|
Judul Buku
|
-
|
Label
|
Label9
|
Tgl Peminjaman
|
-
|
Label
|
Label10
|
Tgl Harus Kembali
|
|
Label
|
Label11
|
Tgl Pengembalian
|
-
|
Label
|
Label12
|
Terlambat
|
-
|
Label
|
Label13
|
Hari
|
-
|
TextBox
|
TxtNoPeminjaman
|
-
|
TextChanged
|
TextBox
|
TxtKode
|
-
|
-
|
TextBox
|
TxtIdentitas
|
-
|
-
|
TextBox
|
TxtNama
|
-
|
-
|
TextBox
|
TxtAlamat
|
-
|
-
|
TextBox
|
TxtTelepon
|
-
|
-
|
TextBox
|
TxtKodeBuku
|
-
|
-
|
TextBox
|
TxtJudulBuku
|
-
|
|
TextBox
|
TxtTelat
|
-
|
-
|
DateTimePicker
|
DPPinjam
|
-
|
ValueChanged
|
DateTimePicker
|
DPPengembalian
|
-
|
ValueChanged
|
DateTimePicker
|
DPKembali
|
-
|
ValueChanged
|
PictureBox
|
FotoPic
|
-
|
-
|
Imports System.Data
Imports System.Data.OleDb
Public Class FormPengembalian
Sub Hitung_Telat()
Dim TelatHari As Long
TelatHari = DateDiff(DateInterval.Day,
DPKembali.Value, DPPengembalian.Value)
TxtTelat.Text = "" &
TelatHari & " Hari"
End Sub
Private Sub
FormPengembalian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
DPPengembalian.Value = Format(Now, "dd/MM/yyyy")
Me.CenterToParent()
End Sub
Private Sub
BtnPeminjaman_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnPeminjaman.Click
Dim No_Peminjaman = InputBox("Masukkan
nomor pada saat transaksi peminjaman")
TxtNoPeminjaman.Text = No_Peminjaman
End Sub
Private Sub
TxtNoPeminjaman_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles
TxtNoPeminjaman.TextChanged
Try
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
DML.CommandText = "select * from Query1
where No_Peminjaman='" & TxtNoPeminjaman.Text & _
"' and Status='Pinjam'"
Cari = DML.ExecuteReader
If Cari.HasRows = True
Then
Cari.Read()
TxtKodeBuku.Text = Cari("Kode_Buku")
TxtJudulBuku.Text = Cari("Judul_Buku")
FotoPic.ImageLocation = Cari("Foto")
TxtIdentitas.Text = Cari("No_Identitas")
TxtKode.Text = Cari("Kode_Peminjam")
TxtNama.Text = Cari("Nama_Peminjam")
TxtAlamat.Text = Cari("Alamat")
TxtTelepon.Text = Cari("No_Telp")
DPPinjam.Value = Cari("Tgl_Pinjam")
DPKembali.Value = Cari("Tgl_Kembali")
Call Hitung_Telat()
Else
TxtKodeBuku.Text = ""
TxtJudulBuku.Text = ""
FotoPic.ImageLocation = ""
TxtIdentitas.Text = ""
TxtKode.Text = ""
TxtNama.Text = ""
TxtAlamat.Text = ""
TxtTelepon.Text = ""
DPPengembalian.Value = Format(Now, "dd/MM/yyyy")
TxtTelat.Text = ""
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnOk.Click
Try
Call Koneksi()
DML.Connection = Database
DML.CommandType = CommandType.Text
DML.CommandText = "update
Table_Peminjaman set Status='Kembali' where No_Peminjaman='" &
TxtNoPeminjaman.Text & "'"
DML.ExecuteNonQuery()
MsgBox("data telah diproses")
Me.Close()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub
DPPengembalian_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles
DPPengembalian.ValueChanged
Call Hitung_Telat()
End Sub
Private Sub
BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
BtnKeluar.Click
Me.Close()
End Sub
End Class
Sekian.
Bang kalo pakai bahasa c# di visual studio apakah codenya sama ?
ReplyDeletec# dan vb mempunyai beberapa perbedaan, seperti saat pemanggilan nama variabel dan operator, sehingga otomatis codenya berbeda.
Deletebang,, boleh minta SC yg sudah jadi ?
ReplyDeletesaya ada eror d FotoTxt dan OFDFoto
terims