Form Transaksi "Perpustakaan Sederhana"



Listing nyaa nih yaaa: 




'==========================================================='
'||*****************************************************************||'
'||      Cuman Sekedar Program Amatir yg Dishare Sambil belajar                          ||'
'||               Created by : Haditya Syafei Sunarya                                                ||'
'||                    Email : siichampretbhendy@yahoo.co.id                                      ||'
'||                            siichampretbhendy@gmail.com                                           ||'
'||                            www.facebook.com/bangbhendz                                          ||'
'||                                                                                                                  ||'
'||                                                                                                                  ||'
'||               hadityasyafei.blogspot.com                                                             ||'
'||*****************************************************************||'
'==========================================================='

Private Sub Command1_Click()
aktif
bersih
nomat
Dt2.Value = (DT1.Value + 7)
End Sub

Private Sub Command2_Click()
On Error Resume Next
nonaktif
bersih
Adodc3.Recordset.Delete
Adodc3.Recordset.MoveNext
End Sub

Private Sub Command3_Click()
On Error Resume Next
If Adodc3.Recordset.RecordCount = 0 Then
MsgBox "Isi Data Dulu ..... !!"
DC1.SetFocus
End If

Adodc4.RecordSource = "Select * from pinjam"
Adodc4.Refresh
Adodc4.Recordset.AddNew
Adodc4.Recordset.Fields(0) = tno
Adodc4.Recordset.Fields(1) = DC1.Text
Adodc4.Recordset.Fields(2) = DT1.Value
Adodc4.Recordset.Update

If Adodc3.Recordset.RecordCount <> 0 Then
Adodc3.RecordSource = "select * from sementara"
Adodc3.Recordset.MoveFirst
Do While Not Adodc3.Recordset.EOF
Adodc5.RecordSource = "select * from detail_pinjam"
Adodc5.Refresh
With Adodc5.Recordset
.AddNew
.Fields(0) = Adodc3.Recordset.Fields(0)
.Fields(1) = Adodc3.Recordset.Fields(1)
.Fields(2) = Adodc3.Recordset.Fields(2)
.Fields(3) = Adodc3.Recordset.Fields(3)
.Fields(4) = Adodc3.Recordset.Fields(4)
.Fields(5) = Adodc3.Recordset.Fields(5)
.Update
End With
Adodc3.Recordset.Delete
Adodc3.Recordset.MoveNext
Loop

'Adodc1.RecordSource = "Select * from tblbuku"
'Adodc1.Refresh
'Adodc1.Recordset.Fields(5) = Adodc1.Recordset.Fields(5) - 1
'Adodc1.Recordset.Update

MsgBox "Data Tersimpan.......!!"
bersih
End If
End Sub

Private Sub Command4_Click()
With Adodc3.Recordset
.AddNew
!no_pinjam = tno.Text
!kd_buku = DC2.Text
!tgl_pinjam = DT1.Value
!tgl_kembali = Dt2.Value
!denda = "0"
!Status = "P"
.Update
End With
i = MsgBox("Tambahkan Buku Lain ??", vbYesNo, "Perpustakaan Bhendy")
If i = vbYes Then
DC2.SetFocus
Else
Command3.SetFocus
End If
End Sub

Private Sub DC1_Click(Area As Integer)
Adodc1.RecordSource = "select * from tblanggota where kd_anggota='" & DC1.Text & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount <> 0 Then
tnama.Text = Adodc1.Recordset.Fields(1)
End If
Adodc1.RecordSource = " select * from tblanggota"
Adodc1.Refresh
End Sub

Private Sub DC2_Click(Area As Integer)
Adodc2.RecordSource = "select * from tblbuku where kd_buku='" & DC2.Text & "'"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount <> 0 Then
tpeng.Text = Adodc2.Recordset!pengarang
tjudul.Text = Adodc2.Recordset!judul_buku
End If
Adodc2.RecordSource = "select * from tblbuku"
Adodc2.Refresh
End Sub

Private Sub DT1_Change()
Dt2.Value = (DT1.Value + 7)
End Sub

Private Sub Form_Load()
conn Adodc1
Adodc1.RecordSource = "select * from tblanggota"
Adodc1.Refresh
conn Adodc2
Adodc2.RecordSource = "select * from tblbuku"
Adodc2.Refresh
conn Adodc3
Adodc3.RecordSource = "select * from sementara"
Adodc3.Refresh
conn Adodc4
Adodc4.RecordSource = "select * from pinjam"
Adodc4.Refresh
conn Adodc5
Adodc5.RecordSource = "select * from detail_pinjam"
Adodc5.Refresh
nonaktif
bersih
End Sub

Private Sub Image1_Click()
i = MsgBox("Anda Yakin Akan Keluar ?", vbYesNo + vbQuestion, "Perpustakaan Bhendy")
If i = vbYes Then
Unload Me
End If
End Sub

Sub bersih()
DC1.Text = ""
DC2.Text = ""
tnama.Text = ""
tpeng.Text = ""
tjudul.Text = ""
End Sub

Sub nonaktif()
tno.Enabled = False
DC1.Enabled = False
DC2.Enabled = False
tnama.Enabled = False
DT1.Enabled = False
Dt2.Enabled = False
tpeng.Enabled = False
tjudul.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
End Sub

Sub aktif()
DC1.Enabled = True
DC2.Enabled = True
tnama.Enabled = True
DT1.Enabled = True
tpeng.Enabled = True
tjudul.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
DT1.Value = Date
End Sub

Sub nomat()
Dim no, oto As String
Adodc5.RecordSource = "select * from pinjam"
Adodc5.Refresh
If Adodc5.Recordset.RecordCount = 0 Then
oto = Right(DT1.Value, 2) + Mid(DT1.Value, 4, 2) + Left(DT1.Value, 2) + "001"
Else
no = Right(Adodc5.Recordset!no_pinjam, 3) + 1
oto = Right(DT1.Value, 2) + Mid(DT1.Value, 4, 2) + Left(DT1.Value, 2) & Right("00" & no, 3)
End If
tno.Text = oto
End Sub