Alam, M Agus. 2000. Manajemen Database dengan Microsoft Visual Basic 6.0. Jakarta: PT. Elex Media Komputindo.
Bigelow, Stephen John. 2001. Sistem Informasi. Yogyakarta: Andi.
Malik, Jaja Jamaluddin. 2007. Kumpulan Tip dan Trik Pemrograman Visual Basic6.0. Edisi Pertama. Yogyakarta: Andi.
Muhklis, Ahmad. 2009. Aplikasi Perpustakaan dengan Menggunakan Microsoft Access. Jakarta: PT. Elex Media Komputindo.
Ramadhan, Arief. 2004. Microsoft Visual Basic 6.0. Jakarta: PT. Elex Komputindo. Prayuga, Rahma. 2004. Seri Panduan Pemrogramam Aplikasi Database Visual
Basic6.0 dengan Cristal Report. Yogyakarta: Andi.
Yunk, Kok. 2002. Membangun Database dengan Microsoft Visual Basic 6.0. Jakarta: PT. Elex Media Komputindo.
Listing Program
Form Login: Option Explicit
Public Function Encrypt(ByVal strInput As String)
Dim iCount As Long, ingPtr As Long, strKey As String, CryptCode As String strKey = StrReverse(strInput)
For iCount = 1 To Len(strInput)
CryptCode = CryptCode + Hex(Asc(Chr((Asc(Mid(strInput, iCount, 1))) Xor (Asc(Mid(strKey, ingPtr + 1, 1))))))
ingPtr = ((ingPtr + 1) Mod Len(strKey)) Next iCount
Encrypt = CryptCode End Function
Private Sub cmdCancel_Click() Unload Me: End
End Sub
Private Sub cmdLogin_Click() Dim lPass As String, rPass As String lPass = txtPassword.Text
rPass = GetSetting("BasuDip", App.Title, "Login")
If txtUser.Text = "admin" And Encrypt(lPass) = rPass Then Me.Hide
frmMain.Show Else
MsgBox "Username atau password yang anda masukkan salah", vbCritical, "Login Gagal" txtUser.Text = vbNullString txtPassword.Text = vbNullString txtUser.SetFocus End If End Sub
Private Sub Form_Activate() txtUser.Text = vbNullString txtPassword.Text = vbNullString txtUser.SetFocus
End Sub
Private Sub txtPassword_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdLogin_Click End If End Sub Form Main: Option Explicit
Private Declare Function InitCommonControls Lib "comctl32.dll" () As Long Private Sub MDIForm_Activate()
mnuLogin.Enabled = False mnuLogout.Enabled = True Toolbar1.Enabled = True mnuSettings.Enabled = True mnuChangePassword.Enabled = True mnuRecords.Enabled = True mnuTransaction.Enabled = True mnuReports.Enabled = True End Sub
Private Sub MDIForm_Load() Me.Show
Set CN = New ADODB.Connection
CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\perpustakaan.mdb;Persist Security Info=False;"
If CN.State <> adStateOpen Then MsgBox "Tidak ada koneksi dengan database" & vbNewLine & "Database seharusnya berada di ApplicationPath\perpustakaan.mdb", vbExclamation, "Database tidak ditemukan!": Unload Me
frmKembali.FineAmnt = CCur(GetSetting(App.Title, "Settings", "Fine Amount", "500"))
frmKembali.MaxDays = CInt(GetSetting(App.Title, "Settings", "Max Days", "2")) End Sub
Private Sub MDIForm_Unload(Cancel As Integer) Dim Form As Form
For Each Form In Forms Unload Form
Set Form = Nothing Next Form
Set CN = Nothing End Sub
Private Sub MDIForm_Initialize() InitCommonControls
End Sub
Private Sub mnuAbout_Click() frmAbout.Show vbModal End Sub
Private Sub mnuBookRec_Click() With frmBooks
.Show .SetFocus End With End Sub
Private Sub mnuChangePassword_Click() frmChangePassword.Enabled = True frmChangePassword.Show
End Sub
Private Sub mnuIssue_Click() frmPinjam.Show vbModal End Sub
Private Sub mnuLapBuku_Click()
CrRpt1.ReportFileName = App.Path & "\rptBuku.rpt" CrRpt1.DataFiles(0) = App.Path & "perpustakaan.mdb" CrRpt1.WindowState = crptMaximized
CrRpt1.RetrieveDataFiles CrRpt1.Action = 1
CrRpt1.Reset End Sub
Private Sub mnuLapPeminjam_Click()
CrRpt1.RetrieveDataFiles CrRpt1.Action = 1
CrRpt1.Reset End Sub
Private Sub mnuLapPinjamBuku_Click()
CrRpt1.ReportFileName = App.Path & "\rptTransaksi.rpt" CrRpt1.DataFiles(0) = App.Path & "perpustakaan.mdb" CrRpt1.WindowState = crptMaximized
CrRpt1.RetrieveDataFiles CrRpt1.Action = 1
CrRpt1.Reset End Sub
Private Sub mnuLogin_Click() frmLogin.Show mnuLogin.Enabled = False mnuLogout.Enabled = True Toolbar1.Enabled = True mnuSettings.Enabled = True mnuChangePassword.Enabled = True mnuRecords.Enabled = True mnuTransaction.Enabled = True mnuReports.Enabled = True End Sub
Private Sub mnuLogout_Click() mnuLogin.Enabled = True mnuLogout.Enabled = False mnuSettings.Enabled = False mnuChangePassword.Enabled = False mnuRecords.Enabled = False mnuTransaction.Enabled = False mnuReports.Enabled = False Toolbar1.Enabled = False
MsgBox "Anda telah berhasil Logout...!!!", vbInformation, "Logout" End Sub
Private Sub mnuMembers_Click() With frmMembers
.Show .SetFocus End With End Sub
frmKembali.Show vbModal End Sub
Private Sub mnuSettings_Click() frmSettings.Show vbModal End Sub
Private Sub mnuExit_Click() End
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Index
Case 1: mnuIssue_Click Case 2: mnuReturn_Click Case 4: mnuBookRec_Click Case 5: mnuMembers_Click
Case 6: PopupMenu mnuReports, , Toolbar1.Buttons(6).Left, Toolbar1.Top + Toolbar1.Height Case 8: mnuSettings_Click Case 9: mnuChangePassword_Click Case 10: mnuAbout_Click Case 12: mnuExit_Click End Select End Sub Form Settings: Option Explicit
Private Sub Command1_Click() On Error GoTo hell
If Text1.Text = "" Or IsNumeric(Text1.Text) = False Or Text1.Text < 0 Or Text2.Text = "" Or IsNumeric(Text2.Text) = False Or Text2.Text < 0 Then GoTo hell
Exit Sub Else
Unload Me End If
Exit Sub hell:
MsgBox "Data yang anda masukkan tidak valid atau tidak ada data yang anda masukkan" & vbNewLine & "oleh karena itu anda tidak dapat menyimpan perubahan" & vbNewLine & "Anda hanya boleh memasukkan angka", vbExclamation
End Sub
Private Sub Form_Load()
Text2.Text = GetSetting(App.Title, "Settings", "Denda yang dikenakan ???", "500") Text1.Text = GetSetting(App.Title, "Settings", "Lama pinjaman yang dibolehkan ???", "2")
End Sub
Form Ganti Password: Option Explicit
Private Sub Command1_Click() On Error GoTo eh:
If Trim(Text1.Text) = vbNullString Then Text1.Text = "Password"
ElseIf Len(Text2.Text) < 5 And Text2.Text <> vbNullString Then Text2.SetFocus
Call MsgBox("Password paling sedikit 5 karakter", vbInformation, App.Title) Exit Sub
ElseIf Len(Text2.Text) > 10 Then
Call MsgBox("Password maksimal 10 karakter", vbInformation, App.Title) Exit Sub
End If
Dim rPass As String
rPass = GetSetting("BasuDip", App.Title, "Login")
If frmLogin.Encrypt(Text1.Text) = rPass Or rPass = vbNullString Then If Text2.Text = Text3.Text Then
If Text2.Text = vbNullString And rPass <> vbNullString Then Call DeleteSetting("BasuDip", App.Title, "Login")
Call MsgBox("Password berhasil dihapus", vbInformation, "Login Password Dikosongkan")
Unload Me Else
rPass = frmLogin.Encrypt(Text2.Text)
Call MsgBox("Password berhasil diganti", vbInformation, App.Title) Unload Me
End If Else
Call MsgBox("Password tidak cocok", vbInformation, App.Title) End If
Else
Call MsgBox("Login password tidak benar", vbInformation, App.Title) Text1.SetFocus
End If Exit Sub eh:
MsgBox Err.Source & " reports " & Err.Description, , "Error " & Err.Number End Sub
Private Sub Command2_Click() Unload Me
End Sub
Private Sub Form_Unload(Cancel As Integer) Unload Me
End Sub
Private Sub Text1_GotFocus() With Text1
.SelStart = 0
.SelLength = Len(.Text) End With
End Sub
Private Sub Text2_GotFocus() With Text2
.SelStart = 0
.SelLength = Len(.Text) End With
End Sub
Private Sub Text3_GotFocus() With Text3 .SelStart = 0 .SelLength = Len(.Text) End With End Sub Form Buku: Option Explicit Private RS As ADODB.RecordSet
On Error GoTo hell
Set RS = New ADODB.RecordSet RS.CursorLocation = adUseClient
RS.Open "SELECT * FROM tblBooks", CN, adOpenDynamic, adLockOptimistic Set DataGrid1.DataSource = RS DisplayRecords Exit Sub hell: Handler Err Resume Next End Sub
Private Sub Form_Resize()
On Error Resume Next
SSTab1.Height = Me.Height - 2500 SSTab1.Width = Me.Width - 400 Line2.X1 = SSTab1.Left
Line2.X2 = SSTab1.Left + SSTab1.Width Line2.Y1 = SSTab1.Top + SSTab1.Height + 400 Line2.Y2 = Line2.Y1 Line2.ZOrder vbBringToFront DataGrid1.Width = SSTab1.Width - 280 DataGrid1.Height = SSTab1.Height - 580 Frame1.Height = DataGrid1.Height - 100 Frame1.Width = DataGrid1.Width - 200 Line3.X1 = Frame1.Left
Line3.X2 = Frame1.Width - Frame1.Left - 180
Line3.Y1 = txtDisp(6).Height + txtDisp(6).Top + 1000 Line3.Y2 = Line3.Y1
LineMove Line4, Line3 LineMove Line1, Line2 pic.Top = Line1.Y1 + 200 Label9.Top = pic.Top
Label11.Top = Label9.Top + Label9.Height Image1.Top = pic.Top
fraNavigation.Top = pic.Top
fraNavigation.Left = Line1.X2 - fraNavigation.Width End Sub
Private Sub Form_Unload(Cancel As Integer) Set RS = Nothing
Set frmBooks = Nothing End Sub
Private Sub cmdOperations_Click(Index As Integer)
Dim obj As Form
If Index = 0 Then Set obj = frmSearch If Index = 1 Then Set obj = frmSort With obj
Set .SourceRs = RS .Show vbModal End With
Set obj = Nothing End Sub
Private Sub DataGrid1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = 38 Or KeyCode = 40 Then DisplayRecords
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
DisplayRecords End Sub
Private Sub DisplayRecords()
Dim i As Integer
On Error Resume Next With RS
If .RecordCount < 1 Then txtcount.Text = 0 Else
lblmax.Caption = .RecordCount For i = 0 To 6 txtDisp(i).Text = .Fields(i) Next i End With End Sub
Private Sub cmdDelete_Click() Dim ans As Integer, pos As Integer On Error GoTo hell
With RS
If .RecordCount < 1 Then MsgBox "Tidak ada data.", vbExclamation: Exit Sub If .Fields("Borrowed") = True Then MsgBox "Anda tidak bisa menghapus buku ini karena sedang dipinjam" & vbNewLine & "Buku tersebut harus dikembalikan terlebih dahulu.", vbInformation, "Book Borrowed"
ans = MsgBox("Anda yakin ingin menghapus buku ini?", vbCritical + vbYesNo, "Confirm Record Deletion")
Screen.MousePointer = vbHourglass If ans = vbYes Then
pos = .AbsolutePosition CN.BeginTrans
.Delete .Requery
CN.CommitTrans
If pos > .RecordCount Then
If Not .EOF Or .BOF Then .MoveFirst Else
.AbsolutePosition = pos End If
MsgBox "Data telah dihapus.", vbInformation, "Konfirmasi" End If
Screen.MousePointer = vbDefault End With
Exit Sub hell:
On Error Resume Next Handler Err
CN.RollbackTrans End Sub
Navigate Index, RS DisplayRecords End Sub
Private Sub cmdRefresh_Click() With RS .Filter = adFilterNone .Requery End With DisplayRecords End Sub
Private Sub cmdClose_Click() Unload Me
End Sub
Private Sub cmdAMod_Click(Index As Integer) On Error Resume Next
With frmBooksInput .AddState = Index .OldID = RS.Fields(0) If Index = 0 Then .msdID.Text = RS.Fields(0) .txtTitle.Text = RS.Fields(1) .txtAuthor.Text = RS.Fields(2) End If .Show vbModal End With cmdRefresh_Click DisplayRecords End Sub
Form Input Buku: Option Explicit
Public AddState As Boolean, OldID As String Private RS As ADODB.RecordSet
On Error GoTo Err
Set RS = New ADODB.RecordSet If AddState Then
Image1.Picture = frmBooks.cmdAMod(1).Picture
RS.Open "SELECT * FROM tblBooks", CN, adOpenStatic, adLockOptimistic Me.Caption = "Tambah Data Buku"
Else
Image1.Picture = frmBooks.cmdAMod(0).Picture Me.Caption = "Edit Data Buku"
cmdAddSave.Caption = "&Update"
RS.Open "SELECT * FROM tblBooks WHERE [Kode_Buku] = '" & OldID & "'", CN, adOpenStatic, adLockOptimistic
End If Exit Sub Err:
If Err.Number = 94 Or Err.Number = 3265 Then Resume Next
Else
Handler Err End If
End Sub
Private Sub cmdAddSave_Click() On Error GoTo hell
If msdID.Text = "" Then msdID.SetFocus: Exit Sub If txtTitle.Text = "" Then txtTitle.SetFocus: Exit Sub If txtAuthor.Text = "" Then txtAuthor.SetFocus: Exit Sub
If Len(msdID.Text) <> 8 Then MsgBox "Semua Kode Buku harus 8 karakter", vbExclamation: HighLight msdID: Exit Sub
msdID.Text = UCase$(msdID.Text)
If IsNumeric(Right$(msdID.Text, 5)) = False Then MsgBox "Kode Buku harus dimulai dengan 96M dan diikuti 5 digit angka", vbExclamation: HighLight msdID: Exit Sub
If AddState Then
If RecordExists("tblBooks", "Kode_Buku", msdID.Text, msdID) = True Then Exit Sub
Else
If msdID.Text <> OldID Then
If RecordExists("tblBooks", "Kode_Buku", msdID.Text, msdID) = True Then Exit Sub
End If End If
With RS
If AddState = True Then RS.AddNew .Fields(0) = msdID.Text
.Fields(1) = txtTitle.Text .Fields(2) = txtAuthor.Text
If txtAuthor.Text = "" Then .Fields(2) = " " Else .Fields(2) = txtAuthor.Text RS.Update
End With
CN.CommitTrans If AddState Then
FindRecord RS, RS.Fields(0).Name, True, msdID.Text, 0 MsgBox "Data baru telah ditambah", vbInformation
If MsgBox("Apakah Anda ingin menambah data buku lagi?", vbQuestion + vbYesNo + vbDefaultButton1) = vbYes Then
cmdReset_Click Else
Unload Me End If
Else
FindRecord RS, RS.Fields(0).Name, True, msdID.Text, 0 MsgBox "Perubahan pada data telah disimpan", vbInformation Unload Me
End If Exit Sub hell:
On Error Resume Next Handler Err
CN.RollbackTrans End Sub
Private Sub cmdCancel_Click() Unload Me
End Sub
Private Sub cmdReset_Click() msdID.Mask = "##M#####"
msdID.SetFocus End Sub
Form Peminjam (Member): Option Explicit
Private RS As ADODB.RecordSet
Private Sub cmdOperations_Click(Index As Integer) Dim obj As Form
If Index = 0 Then Set obj = frmSearch If Index = 1 Then Set obj = frmSort With obj
Set .SourceRs = RS .Show vbModal End With
Set obj = Nothing End Sub
Private Sub Form_Load() On Error GoTo hell
Set RS = New ADODB.RecordSet RS.CursorLocation = adUseClient
RS.Open "SELECT * FROM tblMembers", CN, adOpenDynamic, adLockOptimistic Set DataGrid1.DataSource = RS DisplayRecords Exit Sub hell: Handler Err Resume Next End Sub
Private Sub Form_Resize() On Error Resume Next
SSTab1.Height = Me.Height - 2500 SSTab1.Width = Me.Width - 400 Line1.X1 = SSTab1.Left
Line1.Y1 = SSTab1.Top + SSTab1.Height + 400 Line1.Y2 = Line1.Y1 DataGrid1.Width = SSTab1.Width - 280 DataGrid1.Height = SSTab1.Height - 580 Frame1.Height = DataGrid1.Height - 100 Frame1.Width = DataGrid1.Width - 200 lnBorder(0).X1 = Frame1.Left
lnBorder(0).X2 = Frame1.Width - Frame1.Left - 180 lnBorder(0).Y1 = txtDisp(3).Height + txtDisp(3).Top + 180 lnBorder(0).Y2 = lnBorder(0).Y1
lnBorder(2).X1 = lnBorder(1).X1 lnBorder(2).X2 = lnBorder(1).X2
lnBorder(2).Y1 = txtDisp(6).Height + txtDisp(6).Top + 180 lnBorder(2).Y2 = lnBorder(2).Y1
LineMove Line2, Line1
LineMove lnBorder(1), lnBorder(0) LineMove lnBorder(3), lnBorder(2) pic.Top = Line1.Y1 + 200
Label9.Top = pic.Top
Label11.Top = Label9.Top + Label9.Height Image1.Top = pic.Top
fraNavigation.Top = pic.Top
fraNavigation.Left = Line1.X2 - fraNavigation.Width End Sub
Private Sub Form_Unload(Cancel As Integer)
Set RS = Nothing
Set frmMembers = Nothing End Sub
Private Sub DataGrid1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = 38 Or KeyCode = 40 Then DisplayRecords
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
End Sub
Private Sub DisplayRecords() Dim i As Integer
On Error Resume Next With RS If .RecordCount < 1 Then txtcount.Text = 0 Else txtcount.Text = .AbsolutePosition End If lblmax.Caption = .RecordCount For i = 0 To 6 txtDisp(i).Text = .Fields(i) Next i End With End Sub
Private Sub cmdDelete_Click() On Error GoTo hell
With RS
If .RecordCount < 1 Then MsgBox "Tidak ada data.", vbExclamation: Exit Sub Dim ans As Integer, pos As Integer
ans = MsgBox("Anda yakin ingin menghapusnya?", vbCritical + vbYesNo, "Konfirmasi Menghapus")
Screen.MousePointer = vbHourglass If ans = vbYes Then
pos = .AbsolutePosition CN.BeginTrans
.Delete .Requery
CN.CommitTrans
If pos > .RecordCount Then
If Not .EOF Or .BOF Then .MoveFirst Else
.AbsolutePosition = pos End If
MsgBox "Data telah dihapus.", vbInformation, "Konfirmasi" End If
Screen.MousePointer = vbDefault End With
Exit Sub hell:
Handler Err CN.RollbackTrans End Sub
Private Sub cmdNavigate_Click(Index As Integer)
Navigate Index, RS DisplayRecords End Sub
Private Sub cmdRefresh_Click() With RS
.Filter = adFilterNone .Requery
End With End Sub
Private Sub cmdClose_Click() Unload Me
End Sub
Private Sub cmdAMod_Click(Index As Integer) On Error Resume Next
With frmMembersInput .AddState = Index .OldID = RS.Fields(0) If Index = 0 Then .msdNIM.Text = RS(0) .txtName.Text = RS(1) .cmbJurusan.Text = RS(2) .txtKelas.Text = RS(3) End If .Show vbModal End With cmdRefresh_Click DisplayRecords
Form Input Peminjam: Option Explicit
Private RS As ADODB.RecordSet
Public OldID As String, AddState As Boolean Private Sub Form_Load()
On Error GoTo Err
Set RS = New ADODB.RecordSet If AddState Then
Image1.Picture = frmMembers.cmdAMod(1).Picture
RS.Open "SELECT * FROM tblMembers", CN, adOpenStatic, adLockOptimistic
Me.Caption = "Tambah Data Peminjam" Else
Image1.Picture = frmMembers.cmdAMod(0).Picture Me.Caption = "Edit Data Peminjam"
cmdAddSave.Caption = "&Update"
RS.Open "SELECT * FROM tblMembers WHERE [NIM] = '" & OldID & "'", CN, adOpenStatic, adLockOptimistic
End If Exit Sub Err:
If Err.Number = 94 Or Err.Number = 3265 Then Resume Next
Else
Handler Err End If
End Sub
Private Sub cmdAddSave_Click() On Error GoTo hell
If msdNIM.Text = "" Then msdNIM.SetFocus: Exit Sub If txtName.Text = "" Then txtName.SetFocus: Exit Sub If cmbJurusan.Text = "" Then cmbJurusan.SetFocus: Exit Sub If txtKelas.Text = "" Then txtKelas.SetFocus: Exit Sub
If AddState Then
If RecordExists("tblMembers", "NIM", msdNIM.Text, msdNIM) = True Then Exit Sub
Else
If RecordExists("tblMembers", "NIM", msdNIM.Text, msdNIM) = True Then Exit Sub End If End If CN.BeginTrans With RS
If AddState Then RS.AddNew .Fields(0) = msdNIM.Text .Fields(1) = txtName.Text .Fields(2) = cmbJurusan.Text .Fields(3) = txtKelas.Text RS.Update End With CN.CommitTrans If AddState Then
FindRecord RS, RS.Fields(0).Name, True, msdNIM.Text, 0 MsgBox "Data baru telah ditambah", vbInformation
If MsgBox("Apakah Anda ingin menambah data peminjam lagi?", vbQuestion + vbYesNo + vbDefaultButton1) = vbYes Then
cmdReset_Click Else
Unload Me End If
Else
FindRecord RS, RS.Fields(0).Name, True, msdNIM.Text, 0 MsgBox "Perubahan pada data telah disimpan", vbInformation Unload Me
End If Exit Sub hell:
On Error Resume Next CN.RollbackTrans Handler Err End Sub
Private Sub cmdCancel_Click() Unload Me
Private Sub cmdReset_Click() msdNIM.Mask = "#########" txtName.Text = "" cmbJurusan.ListIndex = 0 txtKelas.Text = "" msdNIM.SetFocus End Sub
Form Peminjaman Buku: Option Explicit
Private Sub cmdBook_Click() With frmSelectDg
.CommandText = "Select * From tblBooks where Borrowed=False" .DataGrid1.Caption = "Data Buku"
.Show vbModal If .OKPressed Then Text5.Text = .rRS1 Text2.Text = .rRS2 End If End With End Sub
Private Sub cmdCancel_Click() Unload Me
End Sub
Private Sub cmdCode_Click()
Dim A As String, b As String, c As String With frmSelectDg
.CommandText = "Select * From tblMembers" .DataGrid1.Caption = "Data Peminjam"
.Show vbModal If .OKPressed Then Text4.Text = .rRS1 A = .rRS2 b = .rRS3 c = .rRS4
Text1.Text = A & " | " & b & " | " & c End If
End With End Sub
Private Sub cmdIssue_Click() Dim RS As ADODB.RecordSet
If Text4.Text = "" Then Text4.SetFocus: Exit Sub If Text5.Text = "" Then Text5.SetFocus: Exit Sub On Error GoTo hell
CN.BeginTrans
Set RS = New ADODB.RecordSet With RS
.Open "Select * from tblTrans", CN, adOpenDynamic, adLockOptimistic .AddNew .Fields(0) = Text5.Text .Fields(1) = Text2.Text .Fields(2) = Text4.Text .Fields(3) = Text1.Text .Fields(4) = Date .Fields(5) = Text6.Text .Update .Close
.Open "Select [Borrowed] from tblBooks where [Kode_Buku]='" & Text5.Text & "'", CN, adOpenDynamic, adLockOptimistic
.MoveFirst .Fields(0) = True .Update .Close Set RS = Nothing End With CN.CommitTrans
If MsgBox("Buku " & Text5.Text & " dipinjam oleh " & Text4.Text & vbNewLine & "Apakah Anda ingin melakukan proses peminjaman buku?", vbInformation + vbYesNo) = vbYes Then
cmdReset_Click Else Unload Me End If Exit Sub hell:
End Sub
Private Sub cmdReset_Click() Text1.Text = ""
Text2.Text = "" Text5.Text = "" Text4.Text = ""
Text3.Text = FormatDateTime$(Date, vbShortDate)
Text6.Text = FormatDateTime$(Date + frmKembali.MaxDays, vbShortDate) End Sub
Private Sub Form_Load() cmdReset_Click With frmMain cmdCode.Picture = .ImgList16.ListImages(1).Picture Me.Icon = .ImgList32.ListImages(7).Picture End With cmdBook.Picture = cmdCode.Picture Image1.Picture = Me.Icon End Sub
Private Sub Text4_Keypress(KeyAscii As Integer) cmdCode_Click
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer) cmdBook_Click
End Sub
Form Pengembalian Buku: Option Explicit
Public MaxDays As Integer Public FineAmnt As Currency Private Sub cmdCancel_Click()
Unload Me End Sub
Private Sub cmdReset_Click() lblLate.Caption = "" lblFines.Caption = "" lblDate.Caption = "" txtFines.Text = "" txtFines.Locked = True Text1.Text = "" Text4.Text = ""
Text2.Text = FormatDateTime$(Date, vbShortDate) End Sub
Private Sub cmdReturn_Click() Dim RS As ADODB.RecordSet
If Text4.Text = "" Then Text4.SetFocus On Error GoTo hell
Set RS = New ADODB.RecordSet With RS
CN.BeginTrans
.Open "Select [Borrowed] from tblBooks where [Kode_Buku]='" & Text4.Text & "'", CN, adOpenDynamic, adLockOptimistic
.MoveFirst .Fields(0) = False .Update
.Close
.Open "Select [Denda],[Tanggal_Kembali],[Returned] From tblTrans where [Kode_Buku]='" & Text4.Text & "'" & "And [Returned] = False", CN,
adOpenDynamic, adLockOptimistic .MoveFirst .Fields("Tanggal_Kembali") = Text2.Text .Fields("Denda") = CCur(txtFines.Text) .Fields("Returned") = True .Update .Close CN.CommitTrans End With Set RS = Nothing
cmdReset_Click Else Unload Me End If Exit Sub hell: Handler Err
On Error Resume Next CN.RollbackTrans End Sub
Private Sub cmdCode_Click()
Dim RS As ADODB.RecordSet, i As Integer On Error Resume Next
With frmSelectDg
.CommandText = "SELECT tblTrans.[Kode_Buku], tblTrans.[NIM],
tblTrans.[Judul], tblTrans.[Nama] AS Peminjam, tblTrans.[Tanggal_Pinjam] FROM tblMembers INNER JOIN (tblBooks INNER JOIN tblTrans ON
tblBooks.[Kode_Buku] = tblTrans.[Kode_Buku]) ON tblMembers.[NIM] = tblTrans.[NIM] Where (((tblTrans.Returned) = False)) ORDER BY
tblTrans.[Kode_Buku];"
.DataGrid1.Caption = "Data Peminjaman" .Show vbModal If .OKPressed Then Text4.Text = .rRS1 Text1.Text = .rRS2 txtFines.Locked = False Else Exit Sub End If End With
Set RS = New ADODB.RecordSet
RS.Open "Select * from tblTrans Where [Kode_Buku] ='" & Text4.Text & "'", CN, adOpenDynamic, adLockOptimistic
lblDate.Caption = CDate(RS(4)) i = Date - CDate(lblDate.Caption) If i < 0 Then i = 0
If MaxDays < i Then lblLate.Caption = i - MaxDays Else lblLate.Caption = "0"
txtFines.Text = lblFines.Caption Set RS = Nothing
End Sub
Private Sub Command4_Click() On Error GoTo hell
Shell "calc.exe", vbNormalFocus Exit Sub
hell:
MsgBox "Sistem operasi tidak dapat menemukan aplikasi kalkulator." & vbNewLine & "Pastikan aplikasi kalkulator telah terinstal", vbCritical, "Tidak Ditemukan"
End Sub
Private Sub Form_Load()
Me.Icon = frmMain.ImgList32.ListImages(8).Picture Image1.Picture = Me.Icon
cmdReset_Click
cmdCode.Picture = frmMain.ImgList16.ListImages(1).Picture End Sub
Private Sub Text4_Keypress(KeyAscii As Integer) cmdCode_Click
End Sub
Form Select Data Peminjaman: Option Explicit
Public CommandText As String, OKPressed As Boolean
Public rRS1 As String, rRS2 As String, rRS3 As String, rRS4 As String Private RS As ADODB.RecordSet