Ebookrentalfilm

269 views

Published on

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
269
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ebookrentalfilm

  1. 1. 1 EBOOK PANDUAN PEMROGRAMAN VISUAL BASIC “PEMBUATAN APLICATION RENTAL FILM” Oleh : Yanto Naim Email : infoitbangkep@gmail.com Web : www.itbangkep.wordpress.com Petunjuk : 1. Untuk membuat program ini, di computer anda harus terinstal : a. Visual Basic 6.0 b. Crystal Report 8.5 c. Componen tambahan : XpButton dan Icon Perintah. d. Disarankan system operasi yang digunakan adalah Windows XP. 2. Buat database dengan nama dbssewafilm (databasenya ada di hal. 48). 3. Jalankan Visual Basic, dan tambahkan komponen-komponen sebagai berikut : a. Crystal Report Control b. Microsoft Ado Data Control 6.0 (OLEDB) c. Microsoft Common Dialog Control 6.0 d. Microsoft Data Bound List Control 6.0 e. Microsoft DataGrid Control 6.0 (OLEDB) f. Microsoft DataList Control 6.0 (OLEDB) g. Microsoft Windows Common Control 6.0 (SP6) h. Microsoft Windows Common Control-2 6.0 (SP4) i. ucXPButton Tampilan Microsoft Visual Basic Tampilan Cystal Report 8.5 Form Komponen Aktif Form Properties Form Menu Utama Pengetikan Listing Report Header Page Header Detail Report Footer Page Footer Database & Componen Crystal Menu Utama
  2. 2. 2 PENGATURAN PROPERTIES ALL FORM Objek Properties Keterangan Form Name Nama form BackColor Warna baground form BorderStyle Bingkai form Caption Judul form Icon Icon form MaxButton True, False MinButton True, False Picture Gambar baground form StartUpPosition Posisi form pada saat dijalankan Visible True, False Height Ukuran tinggi form Widht Ukuran lebar form TextBox Name Nama Textbox Alignment Posisi teks (kiri, tengah, kanan) BorderStyle Bingkai textbox TabIndex urutan index MaxLenght banyaknya karakter yang diinput Text Keterangan (dikosongkan saja) ToolTipText Catatan petunjuk Visible True, False Label Name Nama Label Caption Keterangan Label Frame Name Nama Frame Caption Keterangan Frame OptionButton Name Nama OptionButton Caption Keterangan Option XPButton Name Name Command Button Caption Keterangan Command Button ColorScheme - Pilih Custom ComboBox Name Nama Combo DataCombo Name Nama DataCombo UpDown Name Nama Updown Max Nilai tertinggi, misal : 9999 Min Nilai terendah, misal : 2008 DTPicker Name Nama DTPicker DataGrid Name Nama Grid BorderStyle Bingkai Grid RowDividerStyle Bingkai Garis CrystalReport Name Nama CrystalReport Contoh : 1. Penulisan Listing – Modul1 2. Penulisan Listing – FrmAnggota
  3. 3. 3 Modul1 – Modul1 Public Koneksi As New ADODB.Connection Public Rsanggota As New ADODB.Recordset Public Rsfilm As New ADODB.Recordset Public Rssewa As New ADODB.Recordset Public Rskembali As New ADODB.Recordset Public Rsbysewa As New ADODB.Recordset Public Rskaryawan As New ADODB.Recordset Sub BukaDatabase() Set Koneksi = Nothing Koneksi.CursorLocation = adUseClient Koneksi.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "dbssewafilm.mdb;jet OLEDB:Database Password=;" Rsanggota.Open "[tblanggota]", Koneksi, adOpenDynamic, adLockOptimistic Rsfilm.Open "[tblfilm]", Koneksi, adOpenDynamic, adLockOptimistic Rssewa.Open "[tblsewa]", Koneksi, adOpenDynamic, adLockOptimistic Rskembali.Open "[tblkembali]", Koneksi, adOpenDynamic, adLockOptimistic Rsbysewa.Open "[tblbysewa]", Koneksi, adOpenDynamic, adLockOptimistic Rskaryawan.Open "[tblkaryawan]", Koneksi, adOpenDynamic, adLockOptimistic End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Form Anggota – Frmanggota Listing FrmAnggota Public Ada1, Valid As Boolean Dim rstampil As New ADODB.Recordset Private Sub blankform1() txtnamaang.Text = "": txtt4.Text = "": optlaki = False optperempuan = False: optbk = False: optm = False: txtalamat.Text = "" txttelp.Text = "": txtnoktp.Text = "": txtstsang.Text = "Aktif" txtbydaftar.Text = "" End Sub Private Sub tidaksiapisi() txtnamaang.Enabled = False: txtt4.Enabled = False: dtptgllahir.Enabled = False: optlaki.Enabled = False optperempuan.Enabled = False: optbk.Enabled = False: optm.Enabled = False: txtalamat.Enabled = False txttelp.Enabled = False: txtnoktp.Enabled = False: txtstsang.Enabled = False: dtptgldaftar.Enabled = False dtpmsber.Enabled = False: txtbydaftar.Enabled = False End Sub Private Sub SiapIsi1() txtnamaang.Enabled = True: txtt4.Enabled = True: dtptgllahir.Enabled = True: optlaki.Enabled = True optperempuan.Enabled = True: optbk.Enabled = True: optm.Enabled = True: txtalamat.Enabled = True txttelp.Enabled = True: txtnoktp.Enabled = True: txtstsang.Enabled = False: dtptgldaftar.Enabled = True dtpmsber.Enabled = True: txtbydaftar.Enabled = True End Sub txtthn Up1 txtnoang txtnamaang Txtt4 dtplahir optlaki optperempuan optbk optm txtalamat txttelp txtnoktp dtpdaftar dtpmsber txtstsang txtbydaftar Grid1 xpedit xptambah xphapus xpbatal xpkeluar
  4. 4. 4 Private Sub isitabelanggota() If optlaki = True Then ct = "Laki-Laki" Else ct = "Perempuan" End If If optbk = True Then ck = "Belum Menikah" Else ck = "Menikah" End If Rsanggota!noang = txtnoang.Text: Rsanggota!namaang = txtnamaang.Text Rsanggota!T4 = txtt4.Text: Rsanggota!tgllahir = dtptgllahir Rsanggota!jeniskel = ct: Rsanggota!stskel = ck Rsanggota!alamat = txtalamat.Text: Rsanggota!notelp = txttelp.Text Rsanggota!noktp = txtnoktp.Text: Rsanggota!stsang = txtstsang.Text Rsanggota!tgldaftar = dtptgldaftar: Rsanggota!msber = dtpmsber Rsanggota!tahun = txtthn.Text: Rsanggota!bydaftar = txtbydaftar.Text Rsanggota!tglubah = Date End Sub Private Sub AktifTombol() xpsimpan.Enabled = True xpedit.Enabled = True xphapus.Enabled = True End Sub Private Sub tutuptombol() xphapus.Enabled = False xpedit.Enabled = False End Sub Private Sub isiformanggota() txtnamaang.Text = Rsanggota!namaang txtt4.Text = Rsanggota!T4: dtptgllahir = Rsanggota!tgllahir If Rsanggota!jeniskel = "Laki-Laki" Then optlaki.Value = True Else optperempuan.Value = True End If If Rsanggota!stskel = "Belum Menikah" Then optbk.Value = True Else optm.Value = True End If txtalamat.Text = Rsanggota!alamat: txttelp.Text = Rsanggota!notelp txtnoktp.Text = Rsanggota!noktp: txtstsang.Text = Rsanggota!stsang dtptgldaftar = Rsanggota!tgldaftar: dtpmsber = Rsanggota!msber txtbydaftar.Text = Rsanggota!bydaftar End Sub Private Sub Validasi() Valid = False If txtnamaang.Text = Empty Then X = MsgBox("nama anggota harus diisi", 0 + 16, "konfirmasi") txtnamaang.Text = "" txtnamaang.SetFocus Exit Sub ElseIf txtt4.Text = Empty Then X = MsgBox("Tempat lahir harus diisi", 0 + 16, "konfirmasi") txtt4.Text = "" txtt4.SetFocus Exit Sub ElseIf txtalamat.Text = Empty Then X = MsgBox("Alamat harus diisi", 0 + 16, "konfirmasi") txtalamat.Text = "" txtalamat.SetFocus Exit Sub ElseIf txttelp.Text = Empty Then X = MsgBox("No Telpon / HP harus diisi", 0 + 16, "konfirmasi") txttelp.Text = "" txttelp.SetFocus Exit Sub ElseIf txtnoktp.Text = Empty Then
  5. 5. 5 X = MsgBox("No KTP harus diisi", 0 + 16, "konfirmasi") txtnoktp.Text = "" txtnoktp.SetFocus Exit Sub ElseIf txtbydaftar.Text = Empty Then X = MsgBox("Biaya daftar harus diisi", 0 + 16, "konfirmasi") txtbydaftar.Text = "" txtbydaftar.SetFocus Exit Sub End If Valid = True End Sub Private Sub Tampildata() Set rstampil = Nothing rstampil.Open "select noang,namaang,tgldaftar,msber,stsang from tblanggota order by noang ", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = rstampil Grid1.Columns(0).Width = 1100 Grid1.Columns(1).Width = 3000 Grid1.Columns(2).Width = 1000 Grid1.Columns(3).Width = 1250 Grid1.Columns(4).Width = 1000 Grid1.Columns(0).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(4).Alignment = dbgCenter Grid1.Columns(0).Caption = "No Anggota" Grid1.Columns(1).Caption = "Nama Anggota" Grid1.Columns(2).Caption = "Tgl.daftar" Grid1.Columns(3).Caption = "Masa aktif s/d" Grid1.Columns(4).Caption = "Status" End Sub Private Sub Form_Activate() frmmnutama.Enabled = False Aturnoang End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub Form_Load() BukaDatabase blankform1 up1.Value = Year(Date) txtthn.Text = up1 tidaksiapisi tutuptombol xpsimpan.Caption = "&Tambah" Tampildata dtptgldaftar = Date dtptgllahir = Date dtpmsber = Date End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub txtbydaftar_KeyPress(KeyAscii As Integer) If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _ KeyAscii = vbKeyBack) Then KeyAscii = 0 End If End Sub Private Sub txtnoang_Click() blankform1 End Sub Private Sub txtnoang_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub
  6. 6. 6 -blankform1() -tidaksiapisi() -SiapIsi1() -isitabelanggota() -AktifTombol() -tutuptombol() -isiformanggota() -Validasi() -Tampildata() -Form_Activate() -Up1_Change() -Form_Load() -Form_Unload(in Cancel : Integer) -txtbydaftar_KeyPress(in KeyAscii : Integer) -txtnoang_Click() -txtnoang_KeyPress(in KeyAscii : Integer) -txtnoang_Lostfocus() -xpsimpan_Click() -xpbatal_Click() -xpedit_click() -xphapus_Click() -xpkeluar_Click() -Grid1_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtnoang_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtnamaang_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtt4_keydown(in KeyCode : Integer, in Shift : Integer) -dtptgllahir_keydown(in KeyCode : Integer, in Shift : Integer) -txtalamat_keydown(in KeyCode : Integer, in Shift : Integer) -txttelp_keydown(in KeyCode : Integer, in Shift : Integer) -txtnoktp_keydown(in KeyCode : Integer, in Shift : Integer) -dtptgldaftar_keydown(in KeyCode : Integer, in Shift : Integer) -dtpmsber_keydown(in KeyCode : Integer, in Shift : Integer) -txtbydaftar_keydown(in KeyCode : Integer, in Shift : Integer) -Aturnoang() +Ada1 +Valid : Boolean -rstampil : Recordset frmanggota Private Sub txtnoang_Lostfocus() ckode = Trim(txtnoang.Text) If ckode = Empty Then Exit Sub End If If Rsanggota.RecordCount > 0 Then Rsanggota.MoveFirst End If 'Rsanggota.Find ("noang = '" & ckode & "'") Set Rsanggota = Nothing Rsanggota.Open "[tblanggota] where noang ='" & ckode & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsanggota.EOF Then blankform1 SiapIsi1 txtnamaang.SetFocus Ada1 = False tutuptombol xpsimpan.Caption = "&Simpan" Static Structur Else tidaksiapisi isiformanggota xpedit.Enabled = True xphapus.Enabled = True Ada1 = True End If End Sub Private Sub xpsimpan_Click() If xpsimpan.Caption = "&Tambah" Then xpbatal_Click Aturnoang Exit Sub End If Validasi If Valid = True Then If Ada1 = False Then Rsanggota.AddNew isitabelanggota Rsanggota.Update Else isitabelanggota Rsanggota.Update End If xpsimpan.Caption = "&Tambah" Else xpsimpan.Caption = "&Simpan" End If Rsanggota.Requery Tampildata Aturnoang End Sub Private Sub xpbatal_Click() Aturnoang blankform1 tidaksiapisi txtnoang.Enabled = True txtnoang.SetFocus xpsimpan.Caption = "&Tambah" tutuptombol End Sub Private Sub xpedit_click() tutuptombol Ada1 = True SiapIsi1 txtnoang.Enabled = False xpsimpan.Caption = "&Simpan" txtnamaang.SetFocus End Sub Private Sub xphapus_Click() ckode = Trim(txtnoang.Text)
  7. 7. 7 Rssewa.Find ("noang='" & ckode & "'"), , adSearchForward, 1 Rskembali.Find ("noang='" & ckode & "'"), , adSearchForward, 1 If Not Rssewa.EOF Then X = MsgBox("maaf data anggota tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnoang.SetFocus Exit Sub ElseIf Not Rskembali.EOF Then X = MsgBox("maaf data anggota tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnoang.SetFocus Exit Sub Else y = MsgBox("Benar anda ingin hapus ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes Koneksi.Execute "delete * from tblanggota where noang ='" & ckode & "' and tahun='" & txtthn & "'" Case vbNo End Select End If xpbatal_Click Rsanggota.Requery Tampildata End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then If Rsanggota.RecordCount > 0 Then txtnoang.Text = Grid1.Columns(0) txtnoang_Lostfocus End If End If End Sub Private Sub txtnoang_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtnamaang_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtt4_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub dtptgllahir_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtalamat_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txttelp_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtnoktp_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then
  8. 8. 8 SendKeys vbTab End If End Sub Private Sub dtptgldaftar_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub dtpmsber_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtbydaftar_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub Aturnoang() Set Rsanggota = Nothing Rsanggota.Open "Select * From tblanggota Where tahun ='" & txtthn & "' order by noang", Koneksi k1 = Right(txtthn, 2) + "-" If Rsanggota.RecordCount = 0 Then cno = "0001" Else Rsanggota.MoveLast Na = Val(Right(Rsanggota!noang, 4)) + 1 If Len(Na) = 1 Then cno = "000" + Trim(Str(Na)) ElseIf Len(Na) = 2 Then cno = "00" + Trim(Str(Na)) ElseIf Len(Na) = 3 Then cno = "0" + Trim(Str(Na)) ElseIf Len(Na) = 4 Then cno = Trim(Str(Na)) End If End If txtnoang.Text = k1 + cno End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Form Film - FrmFilm txtthn Up1 Label19 txtnofilm Txtnamafilm dtptglmasuk dcjenis txtsinopsis cbokeping txtaktris txtaktor dtptglproduksi txtstatusfisik Grid1 xpedit xptambah xphapus xpbatal xpkeluar txtstatusfilm
  9. 9. 9 Listing FrmFilm Public Ada, Ada1, Valid As Boolean Public sql As String Dim rstampil As New ADODB.Recordset Dim rscari As New ADODB.Recordset Private Sub blankform1() txtnamafilm.Text = "": dcjenis.Text = "": cbokeping.Text = "": dcjenis.Text = "" txtsinopsis.Text = "": txtaktor.Text = "": txtaktris.Text = "" txtstatusfilm.Text = "": txtstatusfisik.Text = "": chkcari.Value = novbchecked End Sub Private Sub tidaksiapisi() txtnamafilm.Enabled = False: dcjenis.Enabled = False: dtptglmasuk.Enabled = False: cbokeping.Enabled = False txtsinopsis.Enabled = False: txtaktor.Enabled = False: txtaktris.Enabled = False: dtptglproduksi.Enabled = False txtstatusfilm.Enabled = False: txtstatusfisikEnabled = False: chkcari.Enabled = False ---- gk perlu End Sub Private Sub SiapIsi1() txtnamafilm.Enabled = True: dcjenis.Enabled = True: cbokeping.Enabled = True: dtptglmasuk.Enabled = True txtsinopsis.Enabled = True: txtaktor.Enabled = True: txtaktris.Enabled = True: dtptglproduksi.Enabled = True End Sub Private Sub isitabelfilm() Rsfilm!nofilm = txtnofilm.Text If chkcari.Value = vbchecked Then Rsfilm!namafilm = dcnamafilm.Text Else Rsfilm!namafilm = txtnamafilm.Text End If Rsfilm!jenisfilm = dcjenis: Rsfilm!tglmasuk = dtptglmasuk Rsfilm!jmlkeping = cbokeping.Text: Rsfilm!sinopsis = txtsinopsis.Text Rsfilm!aktor = txtaktor.Text: Rsfilm!aktris = txtaktris.Text Rsfilm!tglproduksi = dtptglproduksi: Rsfilm!stsfilm = "Ada" Rsfilm!tahun = txtthn.Text: Rsfilm!stsfisik = "Baik" End Sub Private Sub AktifTombol() xpsimpan.Enabled = True xpedit.Enabled = True xphapus.Enabled = True End Sub Private Sub tutuptombol() xphapus.Enabled = False xpedit.Enabled = False End Sub Private Sub isiformfilm() txtnamafilm.Text = Rsfilm!namafilm dcjenis = Rsfilm!jenisfilm: dtptglmasuk = Rsfilm!tglmasuk cbokeping.Text = Rsfilm!jmlkeping: txtsinopsis.Text = Rsfilm!sinopsis txtaktor.Text = Rsfilm!aktor: txtaktris.Text = Rsfilm!aktris dtptglproduksi = Rsfilm!tglproduksi: txtstatusfilm.Text = Rsfilm!stsfilm txtstatusfisik.Text = Rsfilm!stsfisik End Sub Private Sub Validasi() Valid = False If chkcari.Value = novbchecked Then If txtnamafilm.Text = Empty Then X = MsgBox("nama film harus diisi", 0 + 16, "konfirmasi") txtnamafilm.Text = "" txtnamafilm.SetFocus Exit Sub ElseIf dcjenis.Text = Empty Then X = MsgBox("Jenis film harus diisi", 0 + 16, "konfirmasi") dcjenis.Text = "" dcjenis.SetFocus Exit Sub ElseIf cbokeping.Text = Empty Then X = MsgBox("Jumlah keping film harus diisi", 0 + 16, "konfirmasi") cbokeping.Text = ""
  10. 10. 10 cbokeping.SetFocus Exit Sub ElseIf txtsinopsis.Text = Empty Then X = MsgBox("Sinopsis film harus diisi", 0 + 16, "konfirmasi") txtsinopsis.Text = "" txtsinopsis.SetFocus Exit Sub ElseIf txtaktor.Text = Empty Then X = MsgBox("Nama Aktor Film harus diisi", 0 + 16, "konfirmasi") txtaktor.Text = "" txtaktor.SetFocus Exit Sub ElseIf txtaktris.Text = Empty Then X = MsgBox("Nama Aktris Film harus diisi", 0 + 16, "konfirmasi") txtaktris.Text = "" txtaktris.SetFocus Exit Sub End If End If Valid = True End Sub Private Sub Tampildata() Set rstampil = Nothing rstampil.Open "select nofilm,namafilm,tglmasuk,jenisfilm,stsfilm from tblfilm order by nofilm ", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = rstampil Grid1.Columns(0).Width = 1100 Grid1.Columns(1).Width = 3500 Grid1.Columns(2).Width = 1250 Grid1.Columns(3).Width = 1000 Grid1.Columns(4).Width = 1000 Grid1.Columns(0).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(0).Caption = "No. Film" Grid1.Columns(1).Caption = "Nama Film" Grid1.Columns(2).Caption = "Tgl.Masuk" Grid1.Columns(3).Caption = "Jenis Film" Grid1.Columns(4).Caption = "Status Film" If rstampil.RecordCount > 0 Then Label19.Caption = "Jumlah Film " + Format(rstampil.RecordCount) Else Label19.Caption = "" End If End Sub Private Sub Form_Activate() frmmnutama.Enabled = False End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub Form_Load() BukaDatabase aturnofilm blankform1 up1.Value = Year(Date) txtthn.Text = up1 tidaksiapisi tutuptombol xpsimpan.Caption = "&Tambah" Tampildata Carifilm -------- gk perlu dtptglmasuk = Date dtptglproduksi = Date cbokeping.List(0) = "1" cbokeping.List(1) = "2" cbokeping.List(2) = "3" cbokeping.List(3) = "4" cbokeping.List(4) = "5" dcnamafilm.Visible = False Set rscari = Nothing
  11. 11. 11 rscari.Open "Select jenisfilm from tblbysewa where tahun='" & txtthn & "' group by jenisfilm", Koneksi, adOpenDynamic, adLockOptimistic Set dcjenis.RowSource = rscari dcjenis.ListField = "jenisfilm" End Sub Private Sub chkcari_Click() If chkcari.Value = vbchecked Then dcnamafilm.Visible = True txtnamafilm.Visible = False dcnamafilm.SetFocus Else dcnamafilm.Visible = False txtnamafilm.Visible = True blankform1 txtnofilm.SetFocus End If End Sub Private Sub dcnamafilm_Click(Area As Integer) Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where namafilm ='" & dcnamafilm & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsfilm.EOF Then isiform2 End If End Sub Private Sub isiform2() dcjenis = Rsfilm!jenisfilm: dtptglmasuk = Rsfilm!tglmasuk cbokeping.Text = Rsfilm!jmlkeping: txtsinopsis.Text = Rsfilm!sinopsis txtaktor.Text = Rsfilm!aktor: txtaktris.Text = Rsfilm!aktris dtptglproduksi = Rsfilm!tglproduksi: txtstatusfilm.Text = Rsfilm!stsfilm txtstatusfisik.Text = Rsfilm!stsfisik End Sub Private Sub carifilm() Set rscari = Nothing rscari.Open "Select namafilm from tblfilm where tahun='" & txtthn & "' group by namafilm", Koneksi, adOpenDynamic, adLockOptimistic Set dcnamafilm.RowSource = rscari dcnamafilm.ListField = "namafilm" End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub txtnofilm_Click() blankform1 End Sub Private Sub txtnofilm_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub Private Sub txtnofilm_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF1 Then txtnofilm.Text = "" sql = "Select namafilm,nofilm,stsfilm from tblfilm Where tahun='" & txtthn & "' order by nofilm" Ada = True frminfo.Caption = ">>> Info Data Film Tahun " & txtthn & " <<<" frminfo.Grid1.Columns(0).Width = 3000 frminfo.Grid1.Columns(1).Width = 1000 frminfo.Grid1.Columns(2).Width = 1250 frminfo.Show vbModal, Me Ada = False txtnofilm.Text = frminfo.Kode txtnofilm_Lostfocus End If If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub
  12. 12. 12 -blankform1() -tidaksiapisi() -SiapIsi1() -isitabelfilm() -AktifTombol() -tutuptombol() -isiformfilm() -Validasi() -Tampildata() -Form_Activate() -Up1_Change() -Form_Load() -chkcari_Click() -dcnamafilm_Click(in Area : Integer) -carifilm() -isiform2() -Form_Unload(in Cancel : Integer) -txtnofilm_Click() -txtnofilm_KeyPress(in KeyAscii : Integer) -txtnofilm_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtnofilm_Lostfocus() -xpsimpan_Click() -xpbatal_Click() -xpedit_click() -xphapus_Click() -xpkeluar_Click() -Grid1_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtnamafilm_keydown(in KeyCode : Integer, in Shift : Integer) -dcjenis_keydown(in KeyCode : Integer, in Shift : Integer) -dtptglmasuk_keydown(in KeyCode : Integer, in Shift : Integer) -txtsinopsis_keydown(in KeyCode : Integer, in Shift : Integer) -txtaktor_keydown(in KeyCode : Integer, in Shift : Integer) -txtaktris_keydown(in KeyCode : Integer, in Shift : Integer) -dtptglproduksi_keydown(in KeyCode : Integer, in Shift : Integer) -cbokeping_keydown(in KeyCode : Integer, in Shift : Integer) -aturnofilm() +Ada +Ada1 +Valid : Boolean +sql : String -rstampil : Recordset -rscari : Recordset frmfilm Private Sub txtnofilm_Lostfocus() ckode = Trim(txtnofilm.Text) If ckode = Empty Then Exit Sub End If If Rsfilm.RecordCount > 0 Then Rsfilm.MoveFirst End If 'Rsfilm.Find ("nofilm = '" & ckode & "'") Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where nofilm ='" & ckode & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.EOF Then blankform1 SiapIsi1 chkcari.Enabled = True ---- gk perlu txtnamafilm.SetFocus Ada1 = False tutuptombol xpsimpan.Caption = "&Simpan" Else tidaksiapisi isiformfilm xpedit.Enabled = True xphapus.Enabled = True Static Structur Ada1 = True End If End Sub Private Sub xpsimpan_Click() If xpsimpan.Caption = "&Tambah" Then xpbatal_Click aturnofilm Exit Sub End If Validasi If Valid = True Then If Ada1 = False Then Rsfilm.AddNew isitabelfilm Rsfilm.Update Else isitabelfilm Rsfilm.Update End If xpsimpan.Caption = "&Tambah" Else xpsimpan.Caption = "&Simpan" End If Rsfilm.Requery Tampildata aturnofilm End Sub Private Sub xpbatal_Click() aturnofilm blankform1 tidaksiapisi chkcari.Value = novbchecked ---- gk perlu txtnofilm.Enabled = True txtnofilm.SetFocus xpsimpan.Caption = "&Tambah" tutuptombol End Sub Private Sub xpedit_click() tutuptombol Ada1 = True SiapIsi1 txtnofilm.Enabled = False xpsimpan.Caption = "&Simpan" txtnamafilm.SetFocus End Sub
  13. 13. 13 Private Sub xphapus_Click() ckode = Trim(txtnofilm.Text) Rssewa.Find ("nofilm='" & ckode & "'"), , adSearchForward, 1 Rskembali.Find ("nofilm='" & ckode & "'"), , adSearchForward, 1 If Not Rssewa.EOF Then X = MsgBox("maaf data film tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnofilm.SetFocus Exit Sub ElseIf Not Rskembali.EOF Then X = MsgBox("maaf data film tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnofilm.SetFocus Exit Sub Else y = MsgBox("Benar anda ingin hapus ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes Koneksi.Execute "delete * from tblfilm where nofilm ='" & ckode & "' and tahun='" & txtthn & "'" Case vbNo End Select End If xpbatal_Click Rsfilm.Requery Tampildata End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then If Rsfilm.RecordCount > 0 Then txtnofilm.Text = Grid1.Columns(0) txtnofilm_Lostfocus End If End If End Sub Private Sub txtnamafilm_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub dcjenis_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub dtptglmasuk_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtsinopsis_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtaktor_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtaktris_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub
  14. 14. 14 Private Sub dtptglproduksi_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub cbokeping_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub aturnofilm() Set Rsfilm = Nothing Rsfilm.Open "Select * From tblfilm order by nofilm", Koneksi 'k1 = Right(txtthn, 2) + "-" If Rsfilm.RecordCount = 0 Then cno = "0001" Else Rsfilm.MoveLast Na = Val(Right(Rsfilm!nofilm, 4)) + 1 If Len(Na) = 1 Then cno = "000" + Trim(Str(Na)) ElseIf Len(Na) = 2 Then cno = "00" + Trim(Str(Na)) ElseIf Len(Na) = 3 Then cno = "0" + Trim(Str(Na)) ElseIf Len(Na) = 4 Then cno = Trim(Str(Na)) End If End If txtnofilm.Text = cno End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Form Biaya Sewa & Denda --- Frmbysewa Listing Frmbysewa Public Ada1, Valid As Boolean Dim rstampil As New ADODB.Recordset Private Sub blankform1() txtjml.Text = "": txtdenda.Text = "" End Sub Private Sub tidaksiapisi() txtjml.Enabled = False: txtdenda.Enabled = False End Sub Private Sub SiapIsi1() txtjml.Enabled = True: txtdenda.Enabled = True End Sub Private Sub isitabelbysewa() Rsbysewa!jenisfilm = txtjenis.Text: Rsbysewa!jmlby = txtjml.Text: Rsbysewa!tahun = txtthn.Text Rsbysewa!denda = txtdenda.Text End Sub txtthn Up1txtjenis txtjml txtdenda Grid1 Xpsimpan Xpedit Xphapus Xpbatal Xpkeluar
  15. 15. 15 Private Sub AktifTombol() xpsimpan.Enabled = True: xpedit.Enabled = True xphapus.Enabled = True: End Sub Private Sub tutuptombol() xphapus.Enabled = False: xpedit.Enabled = False End Sub Private Sub isiformbysewa() txtjml.Text = Rsbysewa!jmlby txtdenda.Text = Rsbysewa!denda End Sub Private Sub Validasi() Valid = False If txtjml.Text = Empty Then X = MsgBox("biaya sewa harus diisi", 0 + 16, "konfirmasi") txtjml.Text = "" txtjml.SetFocus Exit Sub ElseIf txtdenda.Text = Empty Then X = MsgBox("biaya denda harus diisi", 0 + 16, "konfirmasi") txtdenda.Text = "" txtdenda.SetFocus Exit Sub End If Valid = True End Sub Private Sub Tampildata() Set rstampil = Nothing rstampil.Open "select jenisfilm,jmlby,denda from tblbysewa order by jenisfilm ", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = rstampil Grid1.Columns(0).Width = 1250 Grid1.Columns(1).Width = 1250 Grid1.Columns(1).Width = 1250 Grid1.Columns(0).Alignment = dbgCenter Grid1.Columns(1).Alignment = dbgRight Grid1.Columns(2).Alignment = dbgRight Grid1.Columns(0).Caption = " Jenis Film" Grid1.Columns(1).Caption = " By.Sewa" Grid1.Columns(2).Caption = " By.Denda" Grid1.Columns(1).NumberFormat = "#,###,### " Grid1.Columns(2).NumberFormat = "#,###,### " End Sub Private Sub Form_Activate() frmmnutama.Enabled = False End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub Form_Load() BukaDatabase blankform1 up1.Value = Year(Date) txtthn.Text = up1 tidaksiapisi tutuptombol xpsimpan.Caption = "&Tambah" Tampildata End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub txtjenisfilm_Click() blankform1 End Sub
  16. 16. 16 -blankform1() -tidaksiapisi() -SiapIsi1() -isitabelbysewa() -AktifTombol() -tutuptombol() -isiformbysewa() -Validasi() -Tampildata() -Form_Activate() -Up1_Change() -Form_Load() -Form_Unload(in Cancel : Integer) -txtjenisfilm_Click() -txtjenisfilm_KeyPress(in KeyAscii : Integer) -txtjenis_Lostfocus() -xpsimpan_Click() -xpbatal_Click() -xpedit_click() -xphapus_Click() -xpkeluar_Click() -Grid1_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtjenis_keydown(in KeyCode : Integer, in Shift : Integer) -txtjml_keydown(in KeyCode : Integer, in Shift : Integer) -txtdenda_keydown(in KeyCode : Integer, in Shift : Integer) -txtjml_KeyPress(in KeyAscii : Integer) -txtdenda_KeyPress(in KeyAscii : Integer) +Ada1 +Valid : Boolean -rstampil : Recordset frmbysewa Private Sub txtjenisfilm_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub Private Sub txtjenis_Lostfocus() ckode = Trim(txtjenis.Text) If ckode = Empty Then Exit Sub End If If Rsbysewa.RecordCount > 0 Then Rsbysewa.MoveFirst End If Set Rsbysewa = Nothing Rsbysewa.Open "[tblbysewa] where jenisfilm ='" & ckode & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsbysewa.EOF Then blankform1 SiapIsi1 txtjml.SetFocus Ada1 = False tutuptombol xpsimpan.Caption = "&Simpan" Else tidaksiapisi isiformbysewa xpedit.Enabled = True xphapus.Enabled = True Ada1 = True End If End Sub Private Sub xpsimpan_Click() Static Structur If xpsimpan.Caption = "&Tambah" Then xpbatal_Click Exit Sub End If Validasi If Valid = True Then If Ada1 = False Then Rsbysewa.AddNew isitabelbysewa Rsbysewa.Update Else isitabelbysewa Rsbysewa.Update End If xpsimpan.Caption = "&Tambah" Else xpsimpan.Caption = "&Simpan" End If Rsbysewa.Requery Tampildata End Sub Private Sub xpbatal_Click() blankform1 tidaksiapisi txtjenis.Enabled = True txtjenis.SetFocus xpsimpan.Caption = "&Tambah" tutuptombol End Sub Private Sub xpedit_click() tutuptombol Ada1 = True SiapIsi1 txtjenis.Enabled = False xpsimpan.Caption = "&Simpan" txtjml.SetFocus End Sub Private Sub xphapus_Click() ckode = Trim(txtjenis.Text)
  17. 17. 17 Rsfilm.Find ("jenisfilm='" & ckode & "'"), , adSearchForward, 1 If Not Rsfilm.EOF Then X = MsgBox("maaf jenis film tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtjenis.SetFocus Exit Sub Else y = MsgBox("Benar anda ingin hapus ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes Koneksi.Execute "delete * from tblbysewa where jenisfilm ='" & ckode & "' and tahun='" & txtthn & "'" Case vbNo End Select End If xpbatal_Click Rsbysewa.Requery Tampildata End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then If Rsbysewa.RecordCount > 0 Then txtjenis.Text = Grid1.Columns(0) txtjenis_Lostfocus End If End If End Sub Private Sub txtjenis_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtjml_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtdenda_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtjml_KeyPress(KeyAscii As Integer) If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _ KeyAscii = vbKeyBack) Then KeyAscii = 0 End If End Sub Private Sub txtdenda_KeyPress(KeyAscii As Integer) If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _ KeyAscii = vbKeyBack) Then KeyAscii = 0 End If End Sub ----------------------------------------------------------------------------------------------------------------------------------------
  18. 18. 18 Form Karyawan - Frmkaryawan Listing Frmkaryawan Public Ada1, Valid As Boolean Dim rstampil As New ADODB.Recordset Private Sub blankform1() txtnamakary.Text = "": txtt4.Text = "": optlaki = False optperempuan = False: optbk = False: optm = False: txtalamat.Text = "" txttelp.Text = "": txtnoktp.Text = "": txtstskary.Text = "" txtpassword.Text = "": txtkonfirmasi.Text = "" End Sub Private Sub tidaksiapisi() txtnamakary.Enabled = False: txtt4.Enabled = False: dtptgllahir.Enabled = False: optlaki.Enabled = False optperempuan.Enabled = False: optbk.Enabled = False: optm.Enabled = False: txtalamat.Enabled = False txttelp.Enabled = False: txtnoktp.Enabled = False: txtstskary.Enabled = False: dtptglkerja.Enabled = False txtpassword.Enabled = False: txtkonfirmasi.Enabled = False: chklihat.Enabled = False: chklihat = False End Sub Private Sub SiapIsi1() txtnamakary.Enabled = True: txtt4.Enabled = True: dtptgllahir.Enabled = True: optlaki.Enabled = True optperempuan.Enabled = True: optbk.Enabled = True: optm.Enabled = True: txtalamat.Enabled = True txttelp.Enabled = True: txtnoktp.Enabled = True: txtstskary.Enabled = False: dtptglkerja.Enabled = True txtpassword.Enabled = True: txtkonfirmasi.Enabled = True End Sub Private Sub isitabelkaryawan() If optlaki = True Then ct = "Laki-Laki" Else ct = "Perempuan" End If If optbk = True Then ck = "Belum Menikah" Else ck = "Menikah" End If Rskaryawan!nokary = txtnokary.Text: Rskaryawan!namakary = txtnamakary.Text Rskaryawan!T4 = txtt4.Text: Rskaryawan!tgllahir = dtptgllahir Rskaryawan!jeniskel = ct: Rskaryawan!stskel = ck Rskaryawan!alamat = txtalamat.Text: Rskaryawan!notelp = txttelp.Text Rskaryawan!noktp = txtnoktp.Text: Rskaryawan!stskary = txtstskary.Text Rskaryawan!tglkerja = dtptglkerja Rskaryawan!tahun = txtthn.Text: Rskaryawan!Password = txtpassword.Text Name objek disesuaikan dengan Listing. Lihat form sebelumnya
  19. 19. 19 Rskaryawan!tglubah = Date End Sub Private Sub AktifTombol() xpsimpan.Enabled = True xpedit.Enabled = True xphapus.Enabled = True End Sub Private Sub tutuptombol() xphapus.Enabled = False xpedit.Enabled = False End Sub Private Sub isiformanggota() txtnamakary.Text = Rskaryawan!namakary txtt4.Text = Rskaryawan!T4: dtptgllahir = Rskaryawan!tgllahir If Rskaryawan!jeniskel = "Laki-Laki" Then optlaki.Value = True Else optperempuan.Value = True End If If Rskaryawan!stskel = "Belum Menikah" Then optbk.Value = True Else optm.Value = True End If txtalamat.Text = Rskaryawan!alamat: txttelp.Text = Rskaryawan!notelp txtnoktp.Text = Rskaryawan!noktp: txtstskary.Text = Rskaryawan!stskary dtptglkerja = Rskaryawan!tglkerja txtpassword.Text = Rskaryawan!Password: txtkonfirmasi.Text = Rskaryawan!Password End Sub Private Sub Validasi() Valid = False If txtnamakary.Text = Empty Then X = MsgBox("nama karyawan harus diisi", 0 + 16, "konfirmasi") txtnamakary.Text = "" txtnamakary.SetFocus Exit Sub ElseIf txtt4.Text = Empty Then X = MsgBox("Tempat lahir harus diisi", 0 + 16, "konfirmasi") txtt4.Text = "" txtt4.SetFocus Exit Sub ElseIf txtalamat.Text = Empty Then X = MsgBox("Alamat harus diisi", 0 + 16, "konfirmasi") txtalamat.Text = "" txtalamat.SetFocus Exit Sub ElseIf txtpassword.Text = Empty Then X = MsgBox("Password harus diisi", 0 + 16, "konfirmasi") txtpassword.Text = "" txtpassword.SetFocus Exit Sub ElseIf txtkonfirmasi.Text = Empty Then X = MsgBox("Konfirmasi password harus diisi", 0 + 16, "konfirmasi") txtkonfirmasi.Text = "" txtkonfirmasi.SetFocus Exit Sub End If Valid = True End Sub Private Sub Tampildata() Set rstampil = Nothing rstampil.Open "select nokary,namakary,tglkerja,stskary from tblkaryawan order by nokary ", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = rstampil Grid1.Columns(0).Width = 1100 Grid1.Columns(1).Width = 3500 Grid1.Columns(2).Width = 1500 Grid1.Columns(3).Width = 1250 Grid1.Columns(0).Alignment = dbgCenter
  20. 20. 20 Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(0).Caption = "No.ID Kary" Grid1.Columns(1).Caption = "Nama Karyawan" Grid1.Columns(2).Caption = "Tgl.Mulai Kerja" Grid1.Columns(3).Caption = "Status Kerja" End Sub Private Sub chklihat_Click() If chklihat.Value = vbchecked Then lihatpass Else txtpassword.PasswordChar = "?" xpkeluar.SetFocus End If End Sub Private Sub Form_Activate() frmmnutama.Enabled = False Aturnokary End Sub Private Sub txtkonfirmasi_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then If txtpassword.Text <> txtkonfirmasi.Text Then MsgBox "Pengisian konfirmasi harus sama dengan nama password", 0 + 64, "Konfirmasi" txtkonfirmasi.SetFocus Else SendKeys vbTab End If End If End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub Form_Load() BukaDatabase blankform1 up1.Value = Year(Date) txtthn.Text = up1 tidaksiapisi tutuptombol xpsimpan.Caption = "&Tambah" Tampildata dtptglkerja = Date dtptgllahir = Date End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub txtnokary_Click() blankform1 End Sub Private Sub txtnokary_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub Private Sub txtnokary_Lostfocus() ckode = Trim(txtnokary.Text) If ckode = Empty Then Exit Sub End If If Rskaryawan.RecordCount > 0 Then Rskaryawan.MoveFirst End If If Right(ckode, 4) = "0000" Or Len(ckode) <> 10 Then MsgBox "No.ID karyawan tersebut tidak dikenal! " & vbCrLf & " anda akan dibantu penomoran otomatis.", 0 + 64, "Konfirmasi" Aturnokary
  21. 21. 21 -blankform1() -tidaksiapisi() -SiapIsi1() -isitabelkaryawan() -AktifTombol() -tutuptombol() -isiformanggota() -Validasi() -Tampildata() -chklihat_Click() -Form_Activate() -txtkonfirmasi_keydown(in KeyCode : Integer, in Shift : Integer) -Up1_Change() -Form_Load() -Form_Unload(in Cancel : Integer) -txtnokary_Click() -txtnokary_KeyPress(in KeyAscii : Integer) -txtnokary_Lostfocus() -xpsimpan_Click() -xpbatal_Click() -xpedit_click() -xphapus_Click() -xpkeluar_Click() -Grid1_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtnokary_keydown(in KeyCode : Integer, in Shift : Integer) -txtnamakary_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtt4_keydown(in KeyCode : Integer, in Shift : Integer) -dtptgllahir_keydown(in KeyCode : Integer, in Shift : Integer) -txtalamat_keydown(in KeyCode : Integer, in Shift : Integer) -txttelp_keydown(in KeyCode : Integer, in Shift : Integer) -dtptglkerja_keydown(in KeyCode : Integer, in Shift : Integer) -txtnoktp_keydown(in KeyCode : Integer, in Shift : Integer) -txtpassword_keydown(in KeyCode : Integer, in Shift : Integer) -Aturnokary() -lihatpass() +Ada1 +Valid : Boolean -rstampil : Recordset frmkaryawan Exit Sub End If Set Rskaryawan = Nothing Rskaryawan.Open "[tblkaryawan] where nokary ='" & ckode & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rskaryawan.EOF Then blankform1 SiapIsi1 txtnamakary.SetFocus txtstskary.Text = "Aktif" Ada1 = False tutuptombol xpsimpan.Caption = "&Simpan" Else tidaksiapisi isiformanggota xpedit.Enabled = True xphapus.Enabled = True Ada1 = True End If Static Structur End Sub Private Sub xpsimpan_Click() If xpsimpan.Caption = "&Tambah" Then xpbatal_Click Aturnokary Exit Sub End If Validasi If Valid = True Then If Ada1 = False Then Rskaryawan.AddNew isitabelkaryawan Rskaryawan.Update Else isitabelkaryawan Rskaryawan.Update End If xpsimpan.Caption = "&Tambah" Else xpsimpan.Caption = "&Simpan" End If Rskaryawan.Requery Tampildata Aturnokary End Sub Private Sub xpbatal_Click() Aturnokary blankform1 tidaksiapisi txtnokary.Enabled = True txtnokary.SetFocus xpsimpan.Caption = "&Tambah" tutuptombol End Sub Private Sub xpedit_click() tutuptombol chklihat.Enabled = True Ada1 = True SiapIsi1 txtnokary.Enabled = False xpsimpan.Caption = "&Simpan" txtnamakary.SetFocus End Sub Private Sub xphapus_Click() ckode = Trim(txtnokary.Text) Rssewa.Find ("nokary='" & ckode & "'"), , adSearchForward, 1 Rskembali.Find ("nokary='" & ckode & "'"), , adSearchForward, 1 If Not Rssewa.EOF Then X = MsgBox("maaf data karyawan tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnokary.SetFocus
  22. 22. 22 Exit Sub ElseIf Not Rskembali.EOF Then X = MsgBox("maaf data karyawan tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnokary.SetFocus Exit Sub Else y = MsgBox("Benar anda ingin hapus ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes Koneksi.Execute "delete * from tblkaryawan where nokary ='" & ckode & "' and tahun='" & txtthn & "'" Case vbNo End Select End If xpbatal_Click Rskaryawan.Requery Tampildata End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then If Rskaryawan.RecordCount > 0 Then txtnokary.Text = Grid1.Columns(0) txtnokary_Lostfocus End If End If End Sub Private Sub txtnokary_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtnamakary_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtt4_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub dtptgllahir_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtalamat_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txttelp_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub dtptglkerja_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub
  23. 23. 23 Private Sub txtnoktp_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtpassword_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub Aturnokary() Set Rskaryawan = Nothing Rskaryawan.Open "Select * From tblkaryawan Where tahun ='" & txtthn & "' order by nokary", Koneksi k1 = "ID" + "-" + Right(txtthn, 2) + "-" If Rskaryawan.RecordCount = 0 Then cno = "0001" Else Rskaryawan.MoveLast Na = Val(Right(Rskaryawan!nokary, 4)) + 1 If Len(Na) = 1 Then cno = "000" + Trim(Str(Na)) ElseIf Len(Na) = 2 Then cno = "00" + Trim(Str(Na)) ElseIf Len(Na) = 3 Then cno = "0" + Trim(Str(Na)) ElseIf Len(Na) = 4 Then cno = Trim(Str(Na)) End If End If txtnokary.Text = k1 + cno End Sub Private Sub lihatpass() Dim lihat, pass lihat = "Masukkan kunci password !" pass = InputBox(lihat, "Masukkan") If pass <> Right(txtnokary, 2) Then MsgBox "Kunci password tersebut salah !", , "Ulangi lagi" Exit Sub Else MsgBox "Password berhasil!", , "Konfirmasi" txtpassword.PasswordChar = "" txtpassword.SetFocus End If End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Form Penyewaan Film - Frmpenyewaan Up1 txtthn dtptglsewa txtjamsewa Label6 List2 txtbayar xplagi xpbatal txtnamaang txtnoang txtkriteria cbokriteria chkcari Label5 List1 lblsinopsis xpsewa xpcetak
  24. 24. 24 -cbokriteria_Click() -chkcari_Click() -dtptglsewa_keydown(in KeyCode : Integer, in Shift : Integer) -Form_Activate() -Form_Load() -dtptglsewa_LostFocus() -ls1() -List1_Click() -Timer1_Timer() -txtkriteria_Change() -carinofilm() -cariaktor() -cariaktris() -ls2() -txtnamaang_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtnoang_Lostfocus() -Form_Unload(in Cancel : Integer) -Up1_Change() -xpcetak_Click() -xpkeluar_Click() -xplagi_Click() -xpsewa_Click() -xpbatal_Click() -cekbyr() +Ada +Ada1 +Valid : Boolean +sql : String -rstampil : Recordset +T1 +b1 +Th1 : Integer frmpenyewaan Listing Frmpenyewaan Public Ada, Ada1, Valid As Boolean Public sql As String Dim rstampil As New ADODB.Recordset Public T1, b1, Th1 As Integer Private Sub cbokriteria_Click() txtkriteria.SetFocus End Sub Private Sub chkcari_Click() If chkcari.Value = vbchecked Then If txtnoang.Text = Empty Then MsgBox "Masukkan dulu Data anggota yang menyewa ! " & vbCrLf & " Bantuan tekan F1", 0 + 64, "Konfirmasi" txtnamaang.SetFocus chkcari = False Exit Sub Else cbokriteria.Enabled = True txtkriteria.Enabled = True cbokriteria.SetFocus End If Else cbokriteria.Enabled = False txtkriteria.Enabled = False cbokriteria.Text = "" txtkriteria.Text = "" ls1 End If End Sub Private Sub dtptglsewa_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Static Structur Private Sub Form_Activate() cbokriteria.Enabled = False txtkriteria.Enabled = False frmmnutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase xpsewa.Enabled = False xpbatal.Enabled = False xpcetak.Enabled = False List1.Enabled = False List2.Enabled = False cbokriteria.List(0) = "No Film" cbokriteria.List(1) = "Aktor" cbokriteria.List(2) = "Aktris" up1.Value = Year(Date) txtthn.Text = up1 dtptglsewa = Date dtptglsewa_LostFocus ls1 End Sub Private Sub dtptglsewa_LostFocus() T1 = Left(dtptglsewa, 2) b1 = Mid(dtptglsewa, 4, 2) Th1 = Right(dtptglsewa, 4) End Sub Private Sub ls1() Set Rsfilm = Nothing Rsfilm.Open "Select namafilm from tblfilm where tahun='" & txtthn & "' and stsfilm='Ada' group by namafilm", Koneksi, adOpenDynamic, adLockOptimistic Set List1.RowSource = Rsfilm List1.ListField = "namafilm"
  25. 25. 25 If Rsfilm.RecordCount > 0 Then List1.Enabled = True bn = Rsfilm.RecordCount Label5.Caption = "Browse Film (" + Format(bn) + " judul Film)" Else List1.Enabled = False xpsewa.Enabled = False Label5.Caption = "" lblsinopsis.Caption = "" End If End Sub Private Sub List1_Click() xpsewa.Enabled = True Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where namafilm ='" & List1 & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.RecordCount > 0 Then lblsinopsis.Caption = "Sinopasis : " & vbCrLf & "" + Rsfilm!sinopsis Else lblsinopsis.Caption = "" xpsewa.Enabled = False End If End Sub Private Sub Timer1_Timer() txtjamsewa.Text = Time End Sub Private Sub txtkriteria_Change() If cbokriteria.Text = "Aktor" Then cariaktor ElseIf cbokriteria.Text = "Aktris" Then cariaktris ElseIf cbokriteria.Text = "No Film" Then carinofilm End If End Sub Private Sub carinofilm() Set Rsfilm = Nothing Rsfilm.Open "Select namafilm from tblfilm Where nofilm like '" & txtkriteria & "%' and tahun='" & txtthn & "' and stsfilm='Ada' group by namafilm", Koneksi, adOpenDynamic, adLockOptimistic Set List1.RowSource = Rsfilm List1.ListField = "namafilm" If Rsfilm.RecordCount > 0 Then xpsewa.Enabled = True Else xpsewa.Enabled = False End If End Sub Private Sub cariaktor() Set Rsfilm = Nothing Rsfilm.Open "Select namafilm from tblfilm Where aktor like '" & txtkriteria & "%' and tahun='" & txtthn & "' and stsfilm='Ada' group by namafilm", Koneksi, adOpenDynamic, adLockOptimistic Set List1.RowSource = Rsfilm List1.ListField = "namafilm" If Rsfilm.RecordCount > 0 Then xpsewa.Enabled = True Else xpsewa.Enabled = False End If End Sub Private Sub cariaktris() Set Rsfilm = Nothing Rsfilm.Open "Select namafilm from tblfilm Where aktris like '" & txtkriteria & "%' and tahun='" & txtthn & "' and stsfilm='Ada' group by namafilm", Koneksi, adOpenDynamic, adLockOptimistic Set List1.RowSource = Rsfilm List1.ListField = "namafilm" If Rsfilm.RecordCount > 0 Then xpsewa.Enabled = True Else
  26. 26. 26 xpsewa.Enabled = False End If End Sub Private Sub ls2() Set rstampil = Nothing rstampil.Open "Select tblfilm.namafilm from tblfilm,tblsewa,tblanggota where tblsewa.tahun='" & txtthn & "' and tblsewa.stssewa='Sewa' and tblsewa.noang='" & txtnoang & "' and tblsewa.noang=tblanggota.noang and tblsewa.nofilm=tblfilm.nofilm and tblsewa.tglsewa= #" & b1 & "/" & T1 & "/" & Th1 & "# group by tblfilm.namafilm", Koneksi, adOpenDynamic, adLockOptimistic Set List2.RowSource = rstampil List2.ListField = "namafilm" If rstampil.RecordCount > 0 Then List2.Enabled = True xpbatal.Enabled = True tt = rstampil.RecordCount Label6.Caption = "Film yang disewa Tgl." + Format(dtptglsewa) + " (" + Format(tt) + " Judul Film)" cekbyr Else List2.Enabled = False xpbatal.Enabled = False xpcetak.Enabled = False Label6.Caption = "" cekbyr End If End Sub Private Sub txtnamaang_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF1 Then 'txtnamaang.Text = "" sql = "Select namaang,noang,stsang from tblanggota Where Namaang like '" & txtnamaang & "%' and stsang='Aktif' and tahun='" & txtthn & "' order by noang" Ada = True frminfo.Caption = ">>> Info Data Anggota Tahun " & txtthn & " <<<" frminfo.Show vbModal, Me Ada = False txtnoang.Text = frminfo.Kode 'txtnamaang.Text = frminfo.Teks txtnoang.Enabled = True txtnoang_Lostfocus End If If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtnoang_Lostfocus() ckode = Trim(txtnoang.Text) If ckode = Empty Then Exit Sub End If If Rsanggota.RecordCount > 0 Then Rsanggota.MoveFirst End If Set Rsanggota = Nothing Rsanggota.Open "[tblanggota] where noang = '" & txtnoang & " ' And " & _ " tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsanggota.EOF Then X = MsgBox("Sorry, Anggota dengan No. Anggota " & txtnoang & " tersebut belum terdaftar", 0 + 64, "Konfirmasi") txtnoang.Text = "" txtnoang.Enabled = False txtnamaang.SetFocus Ada1 = False Else txtnamaang.Text = Rsanggota!namaang ee = Rsanggota!msber If Date > ee Then y = MsgBox("Anggota tersebut sudah habis masa anggotanya ! " & vbCrLf & " Anda ingin mengubah statusnya menjadi 'Tidak Aktif' ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes
  27. 27. 27 Koneksi.Execute "update tblanggota set stsang='Tidak Aktif' where noang='" & txtnoang & "'and tahun='" & txtthn & "'" Case vbNo xplagi_Click End Select End If ls2 cekbyr Ada1 = True End If End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub xpcetak_Click() crpcetak1.ReportFileName = App.Path & "" & "rptbuktisewa.rpt" crpcetak1.SelectionFormula = " {tblsewa.noang} ='" & txtnoang & "' and {tblsewa.tahun} ='" & txtthn & "' and {tblsewa.tglsewa} = #" & b1 & "-" & T1 & "-" & Th1 & "# " 'crpcetak1.RetrieveDataFiles 'crpcetak1.WindowState = crptMaximized 'crpcetak1.Action = 1 crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.CopiesToPrinter = 1 crpcetak1.Destination = crptToPrinter crpcetak1.Action = 1 End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub xplagi_Click() chkcari.Value = novbchecked txtnoang.Text = "" txtnamaang.Text = "" cbokriteria.Text = "" txtkriteria.Text = "" Label6.Caption = "" txtbayar.Text = "Rp. 0" txtnamaang.SetFocus ls2 cekbyr If txtnoang.Text = Empty Then xpcetak.Enabled = False End If End Sub Private Sub xpsewa_Click() xpsewa.Enabled = False cek = frmmnutama.stb.Panels(1).Text If cek = "???" Then MsgBox "Password yang anda gunakan adalah password ! " & vbCrLf & " yang tidak dapat digunakan untuk penyimpanan !", 0 + 64, "Konfirmasi" xplagi_Click xpkeluar.SetFocus Exit Sub End If If txtnoang.Text = Empty Then MsgBox "Masukkan dulu Data anggota yang menyewa ! " & vbCrLf & " Bantuan tekan F1", 0 + 64, "Konfirmasi" txtnamaang.SetFocus Exit Sub End If Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where namafilm ='" & List1 & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.RecordCount > 0 Then
  28. 28. 28 ck = Rsfilm!nofilm kk = Rsfilm!jenisfilm End If Set Rssewa = Nothing Rssewa.Open "[tblsewa] where noang ='" & txtnoang & "' and nofilm='" & ck & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rssewa.EOF Then y = MsgBox("Film dengan judul '" & List1 & "' sudah disewa sebelumnya ! " & vbCrLf & " Anda ingin menyewanya lagi ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes Set Rsbysewa = Nothing Rsbysewa.Open "[tblbysewa] where jenisfilm ='" & kk & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsbysewa.RecordCount > 0 Then ct = Rsbysewa!jmlby End If jj = frmreading.label3.caption Set Rssewa = Nothing Rssewa.Open "[tblsewa] where noang ='" & txtnoang & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rssewa.EOF Then Rssewa.AddNew Rssewa!noang = txtnoang.Text Rssewa!nofilm = ck Rssewa!tglsewa = dtptglsewa Rssewa!jmlbyr = ct Rssewa!tahun = txtthn.Text Rssewa!nokary = jj Rssewa!stssewa = "Sewa" Rssewa!stsfisik = "Baik" Rssewa!jamsewa = txtjamsewa.Text Rssewa.Update Koneksi.Execute "update tblfilm set stsfilm='Sewa' where nofilm='" & ck & "'and tahun='" & txtthn & "'" Else Rssewa.AddNew Rssewa!noang = txtnoang.Text Rssewa!nofilm = ck Rssewa!tglsewa = dtptglsewa Rssewa!jmlbyr = ct Rssewa!tahun = txtthn.Text Rssewa!nokary = jj Rssewa!stssewa = "Sewa" Rssewa!stsfisik = "Baik" Rssewa!jamsewa = txtjamsewa.Text Rssewa.Update Koneksi.Execute "update tblfilm set stsfilm='Sewa' where nofilm='" & ck & "'and tahun='" & txtthn & "'" End If ls2 ls1 cekbyr Case vbNo List1.SetFocus End Select Else Set Rsbysewa = Nothing Rsbysewa.Open "[tblbysewa] where jenisfilm ='" & kk & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsbysewa.RecordCount > 0 Then ct = Rsbysewa!jmlby End If jj = frmreading.label3.caption Set Rssewa = Nothing Rssewa.Open "[tblsewa] where noang ='" & txtnoang & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rssewa.EOF Then Rssewa.AddNew Rssewa!noang = txtnoang.Text Rssewa!nofilm = ck Rssewa!tglsewa = dtptglsewa Rssewa!jmlbyr = ct Rssewa!tahun = txtthn.Text Rssewa!nokary = jj
  29. 29. 29 Rssewa!stssewa = "Sewa" Rssewa!stsfisik = "Baik" Rssewa!jamsewa = txtjamsewa.Text Rssewa.Update Koneksi.Execute "update tblfilm set stsfilm='Sewa' where nofilm='" & ck & "'and tahun='" & txtthn & "'" Else Rssewa.AddNew Rssewa!noang = txtnoang.Text Rssewa!nofilm = ck Rssewa!tglsewa = dtptglsewa Rssewa!jmlbyr = ct Rssewa!tahun = txtthn.Text Rssewa!nokary = jj Rssewa!stssewa = "Sewa" Rssewa!stsfisik = "Baik" Rssewa!jamsewa = txtjamsewa.Text Rssewa.Update Koneksi.Execute "update tblfilm set stsfilm='Sewa' where nofilm='" & ck & "'and tahun='" & txtthn & "'" End If ls2 ls1 cekbyr End If End Sub Private Sub xpbatal_Click() Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where namafilm ='" & List2 & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.RecordCount > 0 Then ck = Rsfilm!nofilm End If Koneksi.Execute "delete * from tblsewa where nofilm ='" & ck & "' and noang ='" & txtnoang & "'and tahun='" & txtthn & "'and tglsewa = #" & b1 & "/" & T1 & "/" & Th1 & "# " Koneksi.Execute "update tblfilm set stsfilm='Ada' where nofilm='" & ck & "'and tahun='" & txtthn & "'" ls1 ls2 cekbyr End Sub Private Sub cekbyr() Set Rssewa = Nothing Rssewa.Open "[tblsewa] where stssewa='Sewa' And noang='" & txtnoang & "' and tglsewa = #" & b1 & "/" & T1 & "/" & Th1 & "# ", Koneksi, adOpenDynamic, adLockOptimistic If Rssewa.EOF Then txtbayar.Text = "Rp. 0" Exit Sub Else Do While Not Rssewa.EOF msub1 = msub1 + Val(Val(Rssewa!jmlbyr)) Rssewa.MoveNext Loop End If txtbayar.Text = "Rp. " + Format(msub1, "###,###,##0") If msub1 > 0 Then xpcetak.Enabled = True Else xpcetak.Enabled = False End If End Sub
  30. 30. 30 Form Pengembalian Film – Frmpengembalian Listing Frmpengembalian Public Ada, Ada1, Valid As Boolean Public sql As String Dim rstampil As New ADODB.Recordset Public T1, b1, Th1, tgl, bln, thn As Integer Public Lama, denda As Single Private Sub dcsewa_Click(Area As Integer) ls1 End Sub Private Sub dtptglkembali_keydown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub Form_Activate() frmmnutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase xpkembali.Enabled = False xpbatal.Enabled = False xpcetak.Enabled = False dcsewa.Enabled = False cbofisik.Enabled = False List1.Enabled = False up1.Value = Year(Date) txtthn.Text = up1 dtptglkembali = Date dcsewa = Date dtptglkembali_LostFocus cbofisik.List(0) = "Baik" cbofisik.List(1) = "Rusak" End Sub Private Sub dtptglkembali_LostFocus() T1 = Left(dtptglkembali, 2) b1 = Mid(dtptglkembali, 4, 2) Th1 = Right(dtptglkembali, 4) End Sub Private Sub tgsewa() tgl = Left(dcsewa, 2) bln = Mid(dcsewa, 4, 2) thn = Right(dcsewa, 4) End Sub Up1 txtthn dtptglkembali txtjamkembali Label6 List2 txtbayar xplagi xpbatal txtnamaang txtnoang cbofisik dcsewa Label5 List1 xpkembali xpcetak
  31. 31. 31 Private Sub ls1() tgsewa Set rstampil = Nothing rstampil.Open "Select tblfilm.namafilm from tblfilm,tblsewa where tblsewa.tahun='" & txtthn & "' and tblsewa.stssewa='Sewa' and tblsewa.nofilm=tblfilm.nofilm and tblsewa.noang='" & txtnoang & "' and tblsewa.tglsewa= #" & bln & "/" & tgl & "/" & thn & "# group by tblfilm.namafilm", Koneksi, adOpenDynamic, adLockOptimistic Set List1.RowSource = rstampil List1.ListField = "namafilm" If rstampil.RecordCount > 0 Then Label5.Caption = "Film yang disewa Tgl." + dcsewa List1.Enabled = True Else xpkembali.Enabled = False List1.Enabled = False Label5.Caption = "" xplagi.SetFocus End If End Sub Private Sub List1_Click() xpkembali.Enabled = True End Sub Private Sub Timer1_Timer() txtjamkembali.Text = Time End Sub Private Sub caritglsewa() Set Rssewa = Nothing Rssewa.Open "Select tglsewa from tblsewa Where noang = '" & txtnoang & "' and tahun='" & txtthn & "' and stssewa='Sewa' group by tglsewa", Koneksi, adOpenDynamic, adLockOptimistic Set dcsewa.RowSource = Rssewa dcsewa.ListField = "tglsewa" End Sub Private Sub ls2() Set rstampil = Nothing rstampil.Open "Select tblfilm.namafilm from tblfilm,tblkembali where tblkembali.tahun='" & txtthn & "' and tblkembali.noang='" & txtnoang & "' and tblkembali.nofilm=tblfilm.nofilm and tblkembali.tglkembali= #" & b1 & "/" & T1 & "/" & Th1 & "# group by tblfilm.namafilm", Koneksi, adOpenDynamic, adLockOptimistic Set List2.RowSource = rstampil List2.ListField = "namafilm" If rstampil.RecordCount > 0 Then xpbatal.Enabled = True List2.Enabled = True cekbyr Label6.Caption = "Film yang dikembalikan Tgl." + Format(dtptglkembali) Else List2.Enabled = False xpbatal.Enabled = False Label6.Caption = "" cekbyr End If End Sub Private Sub txtnamaang_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF1 Then 'txtnamaang.Text = "" sql = "Select namaang,noang,stsang from tblanggota Where Namaang like '" & txtnamaang & "%' and tahun='" & txtthn & "' order by noang" Ada = True frminfo.Caption = ">>> Info Data Anggota Tahun " & txtthn & " <<<" frminfo.Show vbModal, Me Ada = False txtnoang.Text = frminfo.Kode 'txtnamaang.Text = frminfo.Teks txtnoang.Enabled = True txtnoang_Lostfocus End If If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub
  32. 32. 32 Private Sub txtnoang_Lostfocus() ckode = Trim(txtnoang.Text) If ckode = Empty Then Exit Sub End If If Rsanggota.RecordCount > 0 Then Rsanggota.MoveFirst End If Set Rsanggota = Nothing Rsanggota.Open "[tblanggota] where noang = '" & txtnoang & " ' And " & _ " tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsanggota.EOF Then X = MsgBox("Sorry, Anggota dengan No. Anggota " & txtnoang & " tersebut belum terdaftar", 0 + 64, "Konfirmasi") txtnoang.Text = "" txtnoang.Enabled = False txtnamaang.SetFocus Ada1 = False Else txtnamaang.Text = Rsanggota!namaang Set Rssewa = Nothing Rssewa.Open "Select * from tblsewa Where noang = '" & txtnoang & "' and tahun='" & txtthn & "'and stssewa='Sewa'", Koneksi, adOpenDynamic, adLockOptimistic If Rssewa.RecordCount > 0 Then kj = Rssewa!tglsewa dcsewa.Enabled = True cbofisik.Enabled = True xpkembali.Enabled = True Else dcsewa.Enabled = False cbofisik.Enabled = False xpkembali.Enabled = False End If ls2 caritglsewa dcsewa = Date If kj <> dcsewa Then xpbatal.Enabled = False Else xpbatal.Enabled = True End If 'dcsewa.Text = "" Ada1 = True End If End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub xpcetak_Click() tgsewa Set Rssewa = Nothing Rssewa.Open "[tblsewa] where noang='" & txtnoang & "' and tglsewa= #" & bln & "/" & tgl & "/" & thn & "#", Koneksi, adOpenDynamic, adLockOptimistic If Rssewa.RecordCount > 0 Then rr = Rssewa.RecordCount End If If txtnoang.Text <> Empty Then Lama = dtptglkembali - CDate(dcsewa.Text) If Lama = 0 Then Lama = 1 Else If Lama >= 1 Then If Val(Left(txtjamkembali.Text, 2)) < 15 Then Lama = Lama ElseIf Val(Left(txtjamkembali.Text, 2)) > 15 Then Lama = Lama + 0.5 ElseIf Val(Left(txtjamkembali.Text, 2)) > 16 Then Lama = Lama + 1 End If
  33. 33. 33 End If End If aa = Lama If Val(aa) > Val(rr) Then lm = (Val(aa) - Val(rr)) Else lm = "-" End If End If crpcetak1.ReportFileName = App.Path & "" & "rptbuktidenda.rpt" crpcetak1.SelectionFormula = " {tblkembali.noang} ='" & txtnoang & "' and {tblkembali.tahun} ='" & txtthn & "' and {tblkembali.tglkembali} = #" & b1 & "-" & T1 & "-" & Th1 & "# " crpcetak1.Formulas(0) = "tglsewa ='" & dcsewa & "'" crpcetak1.Formulas(1) = "lama='" & lm & " Hari'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 'crpcetak1.RetrieveDataFiles 'crpcetak1.WindowState = crptMaximized 'crpcetak1.CopiesToPrinter = 1 'crpcetak1.Destination = crptToPrinter 'crpcetak1.Action = 1 End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub xplagi_Click() If List1.Text = Empty Then y = MsgBox("Yakin tidak data yang keliru ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes lagi Case vbNo List2.SetFocus End Select Else lagi End If End Sub Private Sub lagi() txtnoang.Text = "" txtnamaang.Text = "" Label5.Caption = "" Label6.Caption = "" cbofisik.Text = "" dcsewa.Enabled = False dcsewa = Date txtbayar.Text = "Rp. 0" ls1 ls2 cekbyr txtnamaang.SetFocus End Sub Private Sub xpkembali_Click() 'dcsewa = Date xpkembali.Enabled = False cek = frmmnutama.stb.Panels(1).Text If cek = "???" Then MsgBox "Password yang anda gunakan adalah password ! " & vbCrLf & " yang tidak dapat digunakan untuk penyimpanan !", 0 + 64, "Konfirmasi" xplagi_Click xpkeluar.SetFocus Exit Sub End If If txtnoang.Text = Empty Then MsgBox "Masukkan dulu Data anggota yang mengembalikan ! " & vbCrLf & " Bantuan tekan F1", 0 + 64, "Konfirmasi" txtnamaang.SetFocus Exit Sub End If
  34. 34. 34 If cbofisik.Text = Empty Then MsgBox "Masukkan dulu keadaan film yang dikembalikan !", 0 + 64, "Konfirmasi" cbofisik.SetFocus Exit Sub End If Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where namafilm ='" & List1 & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.RecordCount > 0 Then ck = Rsfilm!nofilm kk = Rsfilm!jenisfilm End If Set Rsbysewa = Nothing Rsbysewa.Open "[tblbysewa] where jenisfilm ='" & kk & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsbysewa.RecordCount > 0 Then ct = Rsbysewa!jmlby dd = Rsbysewa!denda End If tgsewa Set Rssewa = Nothing Rssewa.Open "[tblsewa] where noang='" & txtnoang & "' and tglsewa= #" & bln & "/" & tgl & "/" & thn & "#", Koneksi, adOpenDynamic, adLockOptimistic If Rssewa.RecordCount > 0 Then ll = Rssewa!jamsewa rr = Rssewa.RecordCount End If If txtnoang.Text <> Empty Then Lama = dtptglkembali - CDate(dcsewa.Text) If Lama = 0 Then Lama = 1 Else If Lama >= 1 Then If Val(Left(txtjamkembali.Text, 2)) < 15 Then Lama = Lama ElseIf Val(Left(txtjamkembali.Text, 2)) > 15 Then Lama = Lama + 0.5 ElseIf Val(Left(txtjamkembali.Text, 2)) > 16 Then Lama = Lama + 1 End If End If End If aa = Lama End If If Val(aa) > Val(rr) Then denda = dd * (aa - rr) '=====> rumus denda lm = aa - rr Else denda = 0 End If jj = frmreading.label3.caption tgsewa Set Rskembali = Nothing Rskembali.Open "[tblkembali] where noang ='" & txtnoang & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rskembali.EOF Then Rskembali.AddNew Rskembali!noang = txtnoang.Text Rskembali!nofilm = ck Rskembali!tglkembali = dtptglkembali Rskembali!denda = denda Rskembali!tahun = txtthn.Text Rskembali!nokary = jj Rskembali!stsfisik = cbofisik.Text Rskembali!jamkembali = txtjamkembali.Text Rskembali.Update Koneksi.Execute "update tblfilm set stsfilm='Ada' where nofilm='" & ck & "'and tahun='" & txtthn & "'" Koneksi.Execute "update tblsewa set stssewa='Kembali' where nofilm='" & ck & "'and noang='" & txtnoang & "' and tahun='" & txtthn & "' and tglsewa= #" & bln & "/" & tgl & "/" & thn & "#" Else Rskembali.AddNew Rskembali!noang = txtnoang.Text Rskembali!nofilm = ck Rskembali!tglkembali = dtptglkembali
  35. 35. 35 Rskembali!denda = denda Rskembali!tahun = txtthn.Text Rskembali!nokary = jj Rskembali!stsfisik = cbofisik.Text Rskembali!jamkembali = txtjamkembali.Text Rskembali.Update Koneksi.Execute "update tblfilm set stsfilm='Ada' where nofilm='" & ck & "'and tahun='" & txtthn & "'" Koneksi.Execute "update tblsewa set stssewa='Kembali' where nofilm='" & ck & "'and noang='" & txtnoang & "' and tahun='" & txtthn & "' and tglsewa= #" & bln & "/" & tgl & "/" & thn & "#" End If ls2 ls1 'cekbyr End Sub Private Sub xpbatal_Click() tgsewa Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where namafilm ='" & List2 & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.RecordCount > 0 Then ck = Rsfilm!nofilm End If Koneksi.Execute "delete * from tblkembali where nofilm ='" & ck & "' and noang ='" & txtnoang & "'and tahun='" & txtthn & "'and tglkembali= #" & b1 & "/" & T1 & "/" & Th1 & "# " Koneksi.Execute "update tblfilm set stsfilm='Sewa' where nofilm='" & ck & "'" Koneksi.Execute "update tblsewa set stssewa='Sewa' where nofilm ='" & ck & "' and noang ='" & txtnoang & "'and tahun='" & txtthn & "'and tglsewa= #" & bln & "/" & tgl & "/" & thn & "#" ls1 ls2 cekbyr End Sub Private Sub cekbyr() Set Rskembali = Nothing Rskembali.Open "[tblkembali] where noang='" & txtnoang & "' and tglkembali = #" & b1 & "/" & T1 & "/" & Th1 & "# ", Koneksi, adOpenDynamic, adLockOptimistic If Rskembali.EOF Then txtbayar.Text = "Rp. 0" Exit Sub Else Do While Not Rskembali.EOF msub1 = msub1 + Val(Val(Rskembali!denda)) Rskembali.MoveNext Loop End If txtbayar.Text = "Rp. " + Format(msub1, "###,###,##0") If msub1 > 0 Then xpcetak.Enabled = True Else xpcetak.Enabled = False End If End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Form Cetak Anggota – Frmcetakanggota Up1 txtthn optseluruh cbostatus optstatus optdaftar xpcetak xpkeluar Dtptgl1 Dtptgl2
  36. 36. 36 -Form_Activate() -Form_Load() -dtpTgl1_LostFocus() -DTPTgl2_LostFocus() -Form_Unload(in Cancel : Integer) -optdaftar_Click() -optseluruh_Click() -optstatus_Click() -xpkeluar_Click() -Up1_Change() -xpcetak_Click() +T1 +T2 +b1 +B2 +Th1 +Th2 : Integer frmcetakanggota Listing Frmcetakanggota Public T1, T2, b1, B2, Th1, Th2 As Integer Private Sub Form_Activate() frmmnutama.Enabled = False End Sub Private Sub Form_Load() Static Structur BukaDatabase up1.Value = Year(Date) txtthn.Text = up1 dtptgl1 = Date dtptgl2 = Date dtpTgl1_LostFocus DTPTgl2_LostFocus cbostatus.Enabled = False dtptgl1.Enabled = False dtptgl2.Enabled = False cbostatus.List(0) = "Aktif" cbostatus.List(1) = "Tidak Aktif" End Sub Private Sub dtpTgl1_LostFocus() T1 = Left(dtptgl1, 2) b1 = Mid(dtptgl1, 4, 2) Th1 = Right(dtptgl1, 4) DTPTgl2_LostFocus End Sub Private Sub DTPTgl2_LostFocus() T2 = Left(dtptgl2, 2) B2 = Mid(dtptgl2, 4, 2) Th2 = Right(dtptgl2, 4) End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub optdaftar_Click() cbostatus.Enabled = False dtptgl1.Enabled = True dtptgl2.Enabled = True End Sub Private Sub optseluruh_Click() cbostatus.Enabled = False dtptgl1.Enabled = False dtptgl2.Enabled = False End Sub Private Sub optstatus_Click() cbostatus.Enabled = True dtptgl1.Enabled = False dtptgl2.Enabled = False End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub xpcetak_Click() If optseluruh = True Then Set Rsanggota = Nothing Rsanggota.Open "[tblanggota] where Tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsanggota.EOF Then X = MsgBox("Data anggota untuk Tahun '" & txtthn & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else
  37. 37. 37 crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_anggota.rpt" crpcetak1.SelectionFormula = " {tblanggota.tahun} ='" & txtthn & "'" crpcetak1.Formulas(0) = "periode ='Tahun : " & txtthn & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If If optstatus = True Then If cbostatus.Text = Empty Then MsgBox "Masukkan dulu status anggota !", , "Konfirmasi" cbostatus.SetFocus Exit Sub End If Set Rsanggota = Nothing Rsanggota.Open "[tblanggota] where stsang = '" & cbostatus & "' And " & _ " Tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsanggota.EOF Then X = MsgBox("Data anggota yang berstatus '" & cbostatus & "' " & vbCrLf & " untuk Tahun '" & txtthn & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_anggota.rpt" crpcetak1.SelectionFormula = " {tblanggota.stsang} ='" & cbostatus & "' and {tblanggota.tahun} ='" & txtthn & "'" crpcetak1.Formulas(0) = "periode ='Status " & cbostatus & " Tahun : " & txtthn & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If If optdaftar = True Then Set Rsanggota = Nothing Rsanggota.Open "[tblanggota] where tblanggota.stsang = 'Aktif' And " & _ " tblanggota.Tahun='" & txtthn & "' and (tblanggota.tgldaftar>= #" & b1 & "/" & T1 & "/" & Th1 & "# " & _ "and tblanggota.tgldaftar <= #" & B2 & "/" & T2 & "/" & Th2 & "# )", Koneksi, adOpenDynamic, adLockOptimistic If Rsanggota.EOF Then X = MsgBox("Data Anggota Aktif yg mendaftar " & vbCrLf & " periode Tgl. '" & dtptgl1 & "' s/d '" & dtptgl2 & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_anggota.rpt" crpcetak1.SelectionFormula = " {tblanggota.stsang} ='Aktif' and {tblanggota.tahun} ='" & txtthn & "' and {tblanggota.tgldaftar} >= #" & b1 & "-" & T1 & "-" & Th1 & "# " & _ "and {tblanggota.tgldaftar} <= #" & B2 & "-" & T2 & "-" & Th2 & "#" If dtptgl1 = dtptgl2 Then tt = Format(dtptgl1) Else tt = Format(dtptgl1) + " s/d " + Format(dtptgl2) End If crpcetak1.Formulas(0) = "periode ='Tgl.Daftar : " & tt & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If End Sub
  38. 38. 38 Form Cetak Film – FrmCetakfilm Listing Frmcetakfilm Public T1, T2, b1, B2, Th1, Th2 As Integer Dim rscari As New ADODB.Recordset Private Sub Form_Activate() frmmnutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase up1.Value = Year(Date) txtthn.Text = up1 dtptgl1 = Date dtptgl2 = Date dtpTgl1_LostFocus DTPTgl2_LostFocus cbostatus.Enabled = False cbostatusfisik.Enabled = False dcaktor.Enabled = False dcaktris.Enabled = False dtptgl1.Enabled = False dtptgl2.Enabled = False cbostatus.List(0) = "Ada" cbostatus.List(1) = "Sewa" cbostatusfisik.List(0) = "Baik" cbostatusfisik.List(1) = "Rusak" Set rscari = Nothing rscari.Open "Select aktris from tblfilm where tahun='" & txtthn & "' group by aktris", Koneksi, adOpenDynamic, adLockOptimistic Set dcaktris.RowSource = rscari dcaktris.ListField = "aktris" Set rscari = Nothing rscari.Open "Select aktor from tblfilm where tahun='" & txtthn & "' group by aktor", Koneksi, adOpenDynamic, adLockOptimistic Set dcaktor.RowSource = rscari dcaktor.ListField = "aktor" End Sub Private Sub dtpTgl1_LostFocus() T1 = Left(dtptgl1, 2) b1 = Mid(dtptgl1, 4, 2) Th1 = Right(dtptgl1, 4) DTPTgl2_LostFocus End Sub Private Sub DTPTgl2_LostFocus() T2 = Left(dtptgl2, 2) B2 = Mid(dtptgl2, 4, 2) Th2 = Right(dtptgl2, 4) End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Up1 txtthn optseluruh cbostatus optstatus optaktor xpcetak xpkeluar Dtptgl1 Dtptgl2 optaktris optmasuk optstatusfisik cbostatusfisik
  39. 39. 39 -Form_Activate() -Form_Load() -dtpTgl1_LostFocus() -DTPTgl2_LostFocus() -Form_Unload(in Cancel : Integer) -optdaftar_Click() -optaktor_Click() -optaktris_Click() -optmasuk_Click() -optseluruh_Click() -optstatus_Click() -optstatusfisik_Click() -xpkeluar_Click() -Up1_Change() -xpcetak_Click() +T1 +T2 +b1 +B2 +Th1 +Th2 : Integer -rscari : Recordset frmcetakfilm Private Sub optdaftar_Click() cbostatus.Enabled = False: dtptgl1.Enabled = True dtptgl2.Enabled = True End Sub Private Sub optaktor_Click() cbostatus.Enabled = False: cbostatusfisik.Enabled = False Static Structur dtptgl1.Enabled = False: dtptgl2.Enabled = False dcaktor.Enabled = True: dcaktris.Enabled = False End Sub Private Sub optaktris_Click() cbostatus.Enabled = False: cbostatusfisik.Enabled = False dtptgl1.Enabled = False: dtptgl2.Enabled = False dcaktor.Enabled = False: dcaktris.Enabled = True End Sub Private Sub optmasuk_Click() cbostatus.Enabled = False: cbostatusfisik.Enabled = False dtptgl1.Enabled = True: dtptgl2.Enabled = True dcaktor.Enabled = False: dcaktris.Enabled = False End Sub Private Sub optseluruh_Click() cbostatus.Enabled = False: cbostatusfisik.Enabled = False dtptgl1.Enabled = False: dtptgl2.Enabled = False dcaktor.Enabled = False: dcaktris.Enabled = False End Sub Private Sub optstatus_Click() cbostatus.Enabled = True: cbostatusfisik.Enabled = False dtptgl1.Enabled = False: dtptgl2.Enabled = False dcaktor.Enabled = False: dcaktris.Enabled = False End Sub Private Sub optstatusfisik_Click() cbostatus.Enabled = False: cbostatusfisik.Enabled = True dtptgl1.Enabled = False: dtptgl2.Enabled = False dcaktor.Enabled = False: dcaktris.Enabled = False End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub xpcetak_Click() If optseluruh = True Then Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where Tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.EOF Then X = MsgBox("Data film untuk Tahun '" & txtthn & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_film.rpt" crpcetak1.SelectionFormula = " {tblfilm.tahun} ='" & txtthn & "'" crpcetak1.Formulas(0) = "periode ='Tahun : " & txtthn & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If If optstatus = True Then If cbostatus.Text = Empty Then MsgBox "Masukkan dulu status film !", , "Konfirmasi" cbostatus.SetFocus Exit Sub End If Set Rsfilm = Nothing
  40. 40. 40 Rsfilm.Open "[tblfilm] where stsfilm = '" & cbostatus & "' And " & _ " Tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.EOF Then X = MsgBox("Data film yang berstatus '" & cbostatus & "' " & vbCrLf & " untuk Tahun '" & txtthn & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_film.rpt" crpcetak1.SelectionFormula = " {tblfilm.stsfilm} ='" & cbostatus & "' and {tblfilm.tahun} ='" & txtthn & "'" crpcetak1.Formulas(0) = "periode ='Status " & cbostatus & " Tahun : " & txtthn & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If If optstatusfisik = True Then If cbostatusfisik.Text = Empty Then MsgBox "Masukkan dulu status fisik film !", , "Konfirmasi" cbostatusfisik.SetFocus Exit Sub End If Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where stsfisik = '" & cbostatusfisik & "' And " & _ " Tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.EOF Then X = MsgBox("Data film yang berstatus '" & cbostatusfisik & "' " & vbCrLf & " untuk Tahun '" & txtthn & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_film.rpt" crpcetak1.SelectionFormula = " {tblfilm.stsfisik} ='" & cbostatusfisik & "' and {tblfilm.tahun} ='" & txtthn & "'" crpcetak1.Formulas(0) = "periode ='Status Fisik " & cbostatusfisik & " Tahun : " & txtthn & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If If optaktor = True Then If dcaktor.Text = Empty Then MsgBox "Masukkan dulu aktor film !", , "Konfirmasi" dcaktor.SetFocus Exit Sub End If Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where aktor = '" & dcaktor & "' And " & _ " Tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.EOF Then X = MsgBox("Data film yang aktornya '" & dcaktor & "' " & vbCrLf & " untuk Tahun '" & txtthn & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_film.rpt" crpcetak1.SelectionFormula = " {tblfilm.aktor} ='" & dcaktor & "' and {tblfilm.tahun} ='" & txtthn & "'" crpcetak1.Formulas(0) = "periode ='Aktor Film " & dcaktor & " Tahun : " & txtthn & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If If optaktris = True Then If dcaktris.Text = Empty Then MsgBox "Masukkan dulu aktris film !", , "Konfirmasi" dcaktris.SetFocus Exit Sub End If Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where aktris = '" & dcaktris & "' And " & _
  41. 41. 41 " Tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.EOF Then X = MsgBox("Data film yang aktrisnya '" & dcaktris & "' " & vbCrLf & " untuk Tahun '" & txtthn & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_film.rpt" crpcetak1.SelectionFormula = " {tblfilm.aktris} ='" & dcaktris & "' and {tblfilm.tahun} ='" & txtthn & "'" crpcetak1.Formulas(0) = "periode ='Aktris Film " & dcaktris & " Tahun : " & txtthn & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If If optmasuk = True Then Set Rsfilm = Nothing Rsfilm.Open "[tblfilm] where tblfilm.stsfilm = 'Ada' And " & _ " tblfilm.Tahun='" & txtthn & "' and (tblfilm.tglmasuk>= #" & b1 & "/" & T1 & "/" & Th1 & "# " & _ "and tblfilm.tglmasuk <= #" & B2 & "/" & T2 & "/" & Th2 & "# )", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.EOF Then X = MsgBox("Data Film yg ada " & vbCrLf & " periode Tgl. '" & dtptgl1 & "' s/d '" & dtptgl2 & "' tidak ada", 0 + 64, "Konfirmasi") xpcetak.Enabled = True xpcetak.SetFocus Exit Sub Else crpcetak1.ReportFileName = App.Path & "" & "rptseluruh_film.rpt" crpcetak1.SelectionFormula = " {tblfilm.stsfilm} ='Ada' and {tblfilm.tahun} ='" & txtthn & "' and {tblfilm.tglmasuk} >= #" & b1 & "-" & T1 & "-" & Th1 & "# " & _ "and {tblfilm.tglmasuk} <= #" & B2 & "-" & T2 & "-" & Th2 & "#" If dtptgl1 = dtptgl2 Then tt = Format(dtptgl1) Else tt = Format(dtptgl1) + " s/d " + Format(dtptgl2) End If crpcetak1.Formulas(0) = "periode ='Status Ada Tgl.Masuk : " & tt & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End If End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Laporan Anggota – crpseluruh_anggota
  42. 42. 42 Laporan Film – crpseluruh_film Laporan Bukti Sewa – crpbuktisewa Laporan Bukti Denda – crpbuktidenda Merancang Menu Utama ----------------------------------------------------------------------------------------------------------------------------------------
  43. 43. 43 Form Ubah Status - Frmubahstatus Listing Frmubahstatus Public Ada, Ada1, Valid As Boolean Public sql As String Private Sub chkanggota_Click() If chkanggota.Value = vbchecked Then txtnoang.Enabled = True: txtnamaang.Enabled = True cbostatus.Enabled = True: txtnokary.Enabled = False txtnamakary.Enabled = False: chkkary.Enabled = False txtnamaang.SetFocus: Label7.Visible = True: dtpmsber.Visible = True Else txtnoang.Enabled = False: txtnamaang.Enabled = False txtnokary.Enabled = False: txtnamakary.Enabled = False xpubah.Enabled = False: chkkary.Enabled = True cbostatus.Enabled = False txtnoang.Text = "": txtnamaang.Text = "": Label7.Visible = False: dtpmsber.Visible = False End If End Sub Private Sub chkkary_Click() If chkkary.Value = vbchecked Then txtnoang.Enabled = False: txtnamaang.Enabled = False txtnokary.Enabled = True: cbostatus.Enabled = True txtnamakary.Enabled = True: txtnamakary.SetFocus chkanggota.Enabled = False Else txtnoang.Enabled = False: cbostatus.Enabled = False txtnamaang.Enabled = False: txtnokary.Enabled = False txtnamakary.Enabled = False: xpubah.Enabled = False chkanggota.Enabled = True txtnokary.Text = "": txtnamakary.Text = "" End If End Sub Private Sub Form_Activate() frmmnutama.Enabled = False End Sub Private Sub txtnoang_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub Up1_Change() txtthn.Text = up1 End Sub Private Sub Form_Load() BukaDatabase up1.Value = Year(Date) Label7.Visible = False dtpmsber.Visible = False txtthn.Text = up1 cbostatus.List(0) = "Aktif" cbostatus.List(1) = "Tidak Aktif" txtthn Up1chkanggota txtnoang txtnamaang txtnamakary chkkary txtnokary Xpubah cbostatus dtpmsber Xpkeluar
  44. 44. 44 gkaktif dtpmsber = Date End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub gkaktif() txtnoang.Enabled = False txtnamaang.Enabled = False txtnokary.Enabled = False txtnamakary.Enabled = False xpubah.Enabled = False cbostatus.Enabled = False End Sub Private Sub txtnamaang_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF1 Then txtnamaang.Text = "" sql = "Select namaang,noang,stsang from tblanggota Where tahun='" & txtthn & "' order by noang" Ada = True frminfo.Caption = ">>> Info Data Anggota Tahun " & txtthn & " <<<" frminfo.Grid1.Columns(0).Width = 3000 frminfo.Grid1.Columns(1).Width = 1000 frminfo.Grid1.Columns(2).Width = 1250 frminfo.Show vbModal, Me Ada = False txtnoang.Text = frminfo.Kode txtnoang_Lostfocus End If If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtnoang_Lostfocus() ckode = Trim(txtnoang.Text) If ckode = Empty Then Exit Sub End If If Rsanggota.RecordCount > 0 Then Rsanggota.MoveFirst End If Set Rsanggota = Nothing Rsanggota.Open "[tblanggota] where noang ='" & ckode & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsanggota.EOF Then MsgBox "No anggota tersebut tidak terdaftar ! F1 bantuan", 0 + 64, "Konfirmasi" txtnoang.Text = "" txtnamaang.SetFocus Ada1 = False xpubah.Enabled = False Else txtnamaang.Text = Rsanggota!namaang xpubah.Enabled = True xpubah.SetFocus Ada1 = True End If End Sub Private Sub txtnamakary_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF1 Then txtnamakary.Text = "" sql = "Select namakary,nokary,stskary from tblkaryawan Where tahun='" & txtthn & "' order by nokary" Ada = True frminfo.Caption = ">>> Info Data Karyawan Tahun " & txtthn & " <<<" frminfo.Grid1.Columns(0).Width = 3000 frminfo.Grid1.Columns(1).Width = 1000 frminfo.Grid1.Columns(2).Width = 1250 frminfo.Show vbModal, Me Ada = False txtnokary.Text = frminfo.Kode txtnokary_Lostfocus
  45. 45. 45 End If If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtnokary_Lostfocus() ckode = Trim(txtnokary.Text) If ckode = Empty Then Exit Sub End If If Rskaryawan.RecordCount > 0 Then Rskaryawan.MoveFirst End If Set Rskaryawan = Nothing Rskaryawan.Open "[tblkaryawan] where nokary ='" & ckode & "' and tahun='" & txtthn & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rskaryawan.EOF Then MsgBox "Karyawan tersebut tidak terdaftar ! F1 bantuan", 0 + 64, "Konfirmasi" txtnokary.Text = "" txtnamakary.SetFocus Ada1 = False xpubah.Enabled = False Else txtnamakary.Text = Rskaryawan!namakary xpubah.Enabled = True xpubah.SetFocus Ada1 = True End If End Sub Private Sub xpkeluar_Click() Unload Me frmmnutama.Enabled = True End Sub Private Sub xpubah_Click() If cbostatus.Text = Empty Then MsgBox "Pilih dulu status !", 0 + 64, "Konfirmasi" cbostatus.SetFocus Exit Sub End If If chkanggota.Value = vbchecked Then Koneksi.Execute "update tblanggota set stsang='" & cbostatus & "',msber='" & dtpmsber & "' where noang ='" & txtnoang & "' and tahun='" & txtthn & "'" End If If chkkary.Value = vbchecked Then Koneksi.Execute "update tblkaryawan set stskary='" & cbostatus & "' where nokary ='" & txtnokary & "' and tahun='" & txtthn & "'" End If End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Form Info- Frminfo Grid1 Ado
  46. 46. 46 Listing Frminfo Public Kode, Teks As String Private Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyEscape Then Kode = "" Teks = "" Unload Me Exit Sub End If If KeyCode = vbKeyReturn Then If Ado.Recordset.RecordCount = 0 Then Kode = "" Teks = "" Else Kode = Grid1.Columns(1) Teks = Grid1.Columns(0) End If Unload Me End If End Sub Private Sub Form_Load() Ado.ConnectionString = Koneksi If frmfilm.Ada Then Ado.RecordSource = frmfilm.sql Ado.Refresh ElseIf frmpenyewaan.Ada Then Ado.RecordSource = frmpenyewaan.sql Ado.Refresh ElseIf frmpengembalian.Ada Then Ado.RecordSource = frmpengembalian.sql Ado.Refresh ElseIf frmubahstatus.Ada Then Ado.RecordSource = frmubahstatus.sql Ado.Refresh End If Grid1.Col = 0 Grid1.Columns(0).Width = 2500 Grid1.Columns(1).Width = 1500 Grid1.Columns(1).Alignment = dbgCenter End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Form reading password- Frmreading Listing Frmreading Private Sub Form_Activate() frmmnutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase cekkary frmmnutama.Show frmmnutama.Enabled = False End Sub Private Sub cekkary() Set Rskaryawan = Nothing Rskaryawan.Open "Select namakary from tblkaryawan where tahun='" & Year(Date) & "' and stskary='Aktif' group by namakary", Koneksi, adOpenDynamic, adLockOptimistic List1 txtPass XpKeluar
  47. 47. 47 Set List1.RowSource = Rskaryawan List1.ListField = "namakary" End Sub Private Sub List1_Click() txtpass.SetFocus End Sub Private Sub txtpass_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then Set Rskaryawan = Nothing Rskaryawan.Open "[tblkaryawan] where namakary ='" & List1 & "' and tahun='" & Year(Date) & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rskaryawan.RecordCount > 0 Then ck = Rskaryawan!Password Label3.Caption = Rskaryawan!nokary End If If txtpass.Text = ck Then frmmnutama.Show frmmnutama.Enabled = True frmmnutama.stb.Panels(1).Text = frmreading.List1 Koneksi.Close frmreading.Hide Else MsgBox "Password anda salah, ulangi lagi !", 0 + 16, "Konfirmasi" txtpass.SetFocus End If End If End Sub Private Sub xpkeluar_Click() End End Sub ----------------------------------------------------------------------------------------------------------------------------------------
  48. 48. 48 Form Utama - FrmmnUtama Listing FrmmnUtama Private Sub Form_Load() Frmreading.show stb.Panels(2).Text = "Aplikasi Pelayanan Rental Film" stb.Panels(3).Text = "Terima kasih anda telah berpartisipasi di dalam peminjaman film kami " stb.Panels(1).Width = 2000 stb.Panels(2).Width = 4500 stb.Panels(3).Width = 6000 stb.Panels(4).Width = 1500 End Sub Private Sub mnfilm_Click() frmfilm.Show End Sub Private Sub mnjnsfilm_Click() frmbysewa.Show End Sub Private Sub mnkary_Click() frmkaryawan.Show End Sub Private Sub mnkembali_Click() frmpengembalian.Show End Sub Private Sub mnnyewa_Click() frmpenyewaan.Show End Sub Private Sub mnubah_Click() frmubahstatus.Show End Sub ---------------------------------------------------------------------------------------------------------------------------------------- Private Sub mnag_Click() frmanggota.Show End Sub Private Sub mnctang_Click() frmcetakanggota.Show End Sub Private Sub mnctkfilm_Click() frmcetakfilm.Show End Sub Private Sub mnexit_Click() pesan = MsgBox("Anda yakin mau keluar !", 4 + 256 + 32, "Konfirmasi") If pesan = 6 Then End Else frmmnutama.Show End If End Sub Toolbar

×