Your SlideShare is downloading. ×

Ebook Pembuatan Aplikasi Rental film 2012

1,573

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,573
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
254
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. EBOOK PANDUAN PEMROGRAMAN VISUAL BASIC “PEMBUATAN APLICATION RENTAL FILM” Oleh : Yanto Naim Email : infoitbangkep@gmail.com Web : www.itbangkep.wordpress.comPetunjuk : 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. ucXPButtonTampilan Microsoft Visual Basic Menu Utama Aktif Form Form Properties Form Komponen Pengetikan ListingTampilan Cystal Report 8.5 Menu Utama Report Header Report Footer Page Header Detail Page Footer Database & Componen Crystal 1
  • 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 CrystalReportContoh : 1. Penulisan Listing – Modul1 2. Penulisan Listing – FrmAnggota 2
  • 3. Modul1 – Modul1Public Koneksi As New ADODB.ConnectionPublic Rsanggota As New ADODB.RecordsetPublic Rsfilm As New ADODB.RecordsetPublic Rssewa As New ADODB.RecordsetPublic Rskembali As New ADODB.RecordsetPublic Rsbysewa As New ADODB.RecordsetPublic Rskaryawan As New ADODB.RecordsetSub BukaDatabase() Set Koneksi = Nothing Koneksi.CursorLocation = adUseClient Koneksi.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "dbssewafilm.mdb;jetOLEDB: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, adLockOptimisticEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- Form Anggota – Frmanggota txtthn Up1 txtnamaang txtnoang Txtt4 dtplahir optlaki optbk optperempuan optm txtnoktp txtalamat dtpmsber txttelp txtbydaftar dtpdaftar txtstsang Grid1 xpedit xphapus xpbatal xptambah xpkeluarListing FrmAnggotaPublic Ada1, Valid As BooleanDim rstampil As New ADODB.RecordsetPrivate Sub blankform1()txtnamaang.Text = "": txtt4.Text = "": optlaki = Falseoptperempuan = False: optbk = False: optm = False: txtalamat.Text = ""txttelp.Text = "": txtnoktp.Text = "": txtstsang.Text = "Aktif"txtbydaftar.Text = ""End SubPrivate Sub tidaksiapisi()txtnamaang.Enabled = False: txtt4.Enabled = False: dtptgllahir.Enabled = False: optlaki.Enabled = Falseoptperempuan.Enabled = False: optbk.Enabled = False: optm.Enabled = False: txtalamat.Enabled = Falsetxttelp.Enabled = False: txtnoktp.Enabled = False: txtstsang.Enabled = False: dtptgldaftar.Enabled = Falsedtpmsber.Enabled = False: txtbydaftar.Enabled = FalseEnd SubPrivate Sub SiapIsi1()txtnamaang.Enabled = True: txtt4.Enabled = True: dtptgllahir.Enabled = True: optlaki.Enabled = Trueoptperempuan.Enabled = True: optbk.Enabled = True: optm.Enabled = True: txtalamat.Enabled = Truetxttelp.Enabled = True: txtnoktp.Enabled = True: txtstsang.Enabled = False: dtptgldaftar.Enabled = Truedtpmsber.Enabled = True: txtbydaftar.Enabled = TrueEnd Sub 3
  • 4. Private Sub isitabelanggota()If optlaki = True Then ct = "Laki-Laki"Else ct = "Perempuan"End IfIf optbk = True Then ck = "Belum Menikah"Else ck = "Menikah"End IfRsanggota!noang = txtnoang.Text: Rsanggota!namaang = txtnamaang.TextRsanggota!T4 = txtt4.Text: Rsanggota!tgllahir = dtptgllahirRsanggota!jeniskel = ct: Rsanggota!stskel = ckRsanggota!alamat = txtalamat.Text: Rsanggota!notelp = txttelp.TextRsanggota!noktp = txtnoktp.Text: Rsanggota!stsang = txtstsang.TextRsanggota!tgldaftar = dtptgldaftar: Rsanggota!msber = dtpmsberRsanggota!tahun = txtthn.Text: Rsanggota!bydaftar = txtbydaftar.TextRsanggota!tglubah = DateEnd SubPrivate Sub AktifTombol()xpsimpan.Enabled = Truexpedit.Enabled = Truexphapus.Enabled = TrueEnd SubPrivate Sub tutuptombol()xphapus.Enabled = Falsexpedit.Enabled = FalseEnd SubPrivate Sub isiformanggota()txtnamaang.Text = Rsanggota!namaangtxtt4.Text = Rsanggota!T4: dtptgllahir = Rsanggota!tgllahirIf Rsanggota!jeniskel = "Laki-Laki" Then optlaki.Value = TrueElse optperempuan.Value = TrueEnd IfIf Rsanggota!stskel = "Belum Menikah" Then optbk.Value = TrueElse optm.Value = TrueEnd Iftxtalamat.Text = Rsanggota!alamat: txttelp.Text = Rsanggota!notelptxtnoktp.Text = Rsanggota!noktp: txtstsang.Text = Rsanggota!stsangdtptgldaftar = Rsanggota!tgldaftar: dtpmsber = Rsanggota!msbertxtbydaftar.Text = Rsanggota!bydaftarEnd SubPrivate Sub Validasi()Valid = FalseIf txtnamaang.Text = Empty Then X = MsgBox("nama anggota harus diisi", 0 + 16, "konfirmasi") txtnamaang.Text = "" txtnamaang.SetFocus Exit SubElseIf txtt4.Text = Empty Then X = MsgBox("Tempat lahir harus diisi", 0 + 16, "konfirmasi") txtt4.Text = "" txtt4.SetFocus Exit SubElseIf txtalamat.Text = Empty Then X = MsgBox("Alamat harus diisi", 0 + 16, "konfirmasi") txtalamat.Text = "" txtalamat.SetFocus Exit SubElseIf txttelp.Text = Empty Then X = MsgBox("No Telpon / HP harus diisi", 0 + 16, "konfirmasi") txttelp.Text = "" txttelp.SetFocus Exit SubElseIf txtnoktp.Text = Empty Then 4
  • 5. X = MsgBox("No KTP harus diisi", 0 + 16, "konfirmasi") txtnoktp.Text = "" txtnoktp.SetFocus Exit SubElseIf txtbydaftar.Text = Empty ThenX = MsgBox("Biaya daftar harus diisi", 0 + 16, "konfirmasi") txtbydaftar.Text = "" txtbydaftar.SetFocus Exit SubEnd IfValid = TrueEnd SubPrivate Sub Tampildata()Set rstampil = Nothingrstampil.Open "select noang,namaang,tgldaftar,msber,stsang from tblanggota order by noang ", Koneksi,adOpenDynamic, adLockOptimisticSet Grid1.DataSource = rstampilGrid1.Columns(0).Width = 1100Grid1.Columns(1).Width = 3000Grid1.Columns(2).Width = 1000Grid1.Columns(3).Width = 1250Grid1.Columns(4).Width = 1000Grid1.Columns(0).Alignment = dbgCenterGrid1.Columns(2).Alignment = dbgCenterGrid1.Columns(4).Alignment = dbgCenterGrid1.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 SubPrivate Sub Form_Activate()frmmnutama.Enabled = FalseAturnoangEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate Sub Form_Load()BukaDatabaseblankform1up1.Value = Year(Date)txtthn.Text = up1tidaksiapisitutuptombolxpsimpan.Caption = "&Tambah"Tampildatadtptgldaftar = Datedtptgllahir = Datedtpmsber = DateEnd SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd SubPrivate Sub txtbydaftar_KeyPress(KeyAscii As Integer)If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _ KeyAscii = vbKeyBack) Then KeyAscii = 0End IfEnd SubPrivate Sub txtnoang_Click()blankform1End SubPrivate Sub txtnoang_KeyPress(KeyAscii As Integer)KeyAscii = Asc(UCase(Chr(KeyAscii)))End Sub 5
  • 6. Private Sub txtnoang_Lostfocus()ckode = Trim(txtnoang.Text)If ckode = Empty Then Exit SubEnd IfIf Rsanggota.RecordCount > 0 Then Rsanggota.MoveFirstEnd IfRsanggota.Find ("noang = " & ckode & "")Set Rsanggota = NothingRsanggota.Open "[tblanggota] where noang =" & ckode & " and tahun=" & txtthn & "", Koneksi,adOpenDynamic, adLockOptimisticIf Rsanggota.EOF Then blankform1 SiapIsi1 txtnamaang.SetFocus Ada1 = False tutuptombol xpsimpan.Caption = "&Simpan" Static StructurElse frmanggota tidaksiapisi +Ada1 isiformanggota +Valid : Boolean xpedit.Enabled = True -rstampil : Recordset xphapus.Enabled = True -blankform1() Ada1 = True -tidaksiapisi()End If -SiapIsi1()End Sub -isitabelanggota() -AktifTombol()Private Sub xpsimpan_Click() -tutuptombol()If xpsimpan.Caption = "&Tambah" Then -isiformanggota() xpbatal_Click -Validasi() Aturnoang -Tampildata() -Form_Activate() Exit Sub -Up1_Change()End If -Form_Load()Validasi -Form_Unload(in Cancel : Integer)If Valid = True Then -txtbydaftar_KeyPress(in KeyAscii : Integer) If Ada1 = False Then -txtnoang_Click() Rsanggota.AddNew -txtnoang_KeyPress(in KeyAscii : Integer) isitabelanggota -txtnoang_Lostfocus() Rsanggota.Update -xpsimpan_Click() Else -xpbatal_Click() isitabelanggota -xpedit_click() -xphapus_Click() Rsanggota.Update -xpkeluar_Click() End If -Grid1_KeyDown(in KeyCode : Integer, in Shift : Integer) xpsimpan.Caption = "&Tambah" -txtnoang_KeyDown(in KeyCode : Integer, in Shift : Integer)Else -txtnamaang_KeyDown(in KeyCode : Integer, in Shift : Integer)xpsimpan.Caption = "&Simpan" -txtt4_keydown(in KeyCode : Integer, in Shift : Integer)End If -dtptgllahir_keydown(in KeyCode : Integer, in Shift : Integer)Rsanggota.Requery -txtalamat_keydown(in KeyCode : Integer, in Shift : Integer)Tampildata -txttelp_keydown(in KeyCode : Integer, in Shift : Integer)Aturnoang -txtnoktp_keydown(in KeyCode : Integer, in Shift : Integer)End Sub -dtptgldaftar_keydown(in KeyCode : Integer, in Shift : Integer) -dtpmsber_keydown(in KeyCode : Integer, in Shift : Integer) -txtbydaftar_keydown(in KeyCode : Integer, in Shift : Integer)Private Sub xpbatal_Click() -Aturnoang()Aturnoangblankform1tidaksiapisitxtnoang.Enabled = Truetxtnoang.SetFocusxpsimpan.Caption = "&Tambah"tutuptombolEnd SubPrivate Sub xpedit_click()tutuptombolAda1 = TrueSiapIsi1txtnoang.Enabled = Falsexpsimpan.Caption = "&Simpan"txtnamaang.SetFocusEnd SubPrivate Sub xphapus_Click()ckode = Trim(txtnoang.Text) 6
  • 7. Rssewa.Find ("noang=" & ckode & ""), , adSearchForward, 1Rskembali.Find ("noang=" & ckode & ""), , adSearchForward, 1If Not Rssewa.EOF Then X = MsgBox("maaf data anggota tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnoang.SetFocus Exit SubElseIf Not Rskembali.EOF Then X = MsgBox("maaf data anggota tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnoang.SetFocus Exit SubElse 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 vbNoEnd SelectEnd Ifxpbatal_ClickRsanggota.RequeryTampildataEnd SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate 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 IfEnd IfEnd SubPrivate Sub txtnoang_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtnamaang_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtt4_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub dtptgllahir_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtalamat_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txttelp_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtnoktp_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then 7
  • 8. SendKeys vbTab End IfEnd SubPrivate Sub dtptgldaftar_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub dtpmsber_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtbydaftar_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate 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 + cnoEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- Form Film - FrmFilm txtthn Up1 txtnofilm Label19 Txtnamafilm dtptglmasuk dcjenis cbokeping txtsinopsis txtaktor txtstatusfilm txtaktris txtstatusfisik dtptglproduksi Grid1 xpedit xphapus xptambah xpbatal xpkeluar 8
  • 9. Listing FrmFilmPublic Ada, Ada1, Valid As BooleanPublic sql As StringDim rstampil As New ADODB.RecordsetDim rscari As New ADODB.RecordsetPrivate Sub blankform1()txtnamafilm.Text = "": dcjenis.Text = "": cbokeping.Text = "": dcjenis.Text = ""txtsinopsis.Text = "": txtaktor.Text = "": txtaktris.Text = ""txtstatusfilm.Text = "": txtstatusfisik.Text = "": chkcari.Value = novbcheckedEnd SubPrivate Sub tidaksiapisi()txtnamafilm.Enabled = False: dcjenis.Enabled = False: dtptglmasuk.Enabled = False: cbokeping.Enabled = Falsetxtsinopsis.Enabled = False: txtaktor.Enabled = False: txtaktris.Enabled = False: dtptglproduksi.Enabled = Falsetxtstatusfilm.Enabled = False: txtstatusfisikEnabled = False: chkcari.Enabled = False ---- gk perluEnd SubPrivate Sub SiapIsi1()txtnamafilm.Enabled = True: dcjenis.Enabled = True: cbokeping.Enabled = True: dtptglmasuk.Enabled = Truetxtsinopsis.Enabled = True: txtaktor.Enabled = True: txtaktris.Enabled = True: dtptglproduksi.Enabled = TrueEnd SubPrivate Sub isitabelfilm()Rsfilm!nofilm = txtnofilm.TextIf chkcari.Value = vbchecked Then Rsfilm!namafilm = dcnamafilm.TextElse Rsfilm!namafilm = txtnamafilm.TextEnd IfRsfilm!jenisfilm = dcjenis: Rsfilm!tglmasuk = dtptglmasukRsfilm!jmlkeping = cbokeping.Text: Rsfilm!sinopsis = txtsinopsis.TextRsfilm!aktor = txtaktor.Text: Rsfilm!aktris = txtaktris.TextRsfilm!tglproduksi = dtptglproduksi: Rsfilm!stsfilm = "Ada"Rsfilm!tahun = txtthn.Text: Rsfilm!stsfisik = "Baik"End SubPrivate Sub AktifTombol()xpsimpan.Enabled = Truexpedit.Enabled = Truexphapus.Enabled = TrueEnd SubPrivate Sub tutuptombol()xphapus.Enabled = Falsexpedit.Enabled = FalseEnd SubPrivate Sub isiformfilm()txtnamafilm.Text = Rsfilm!namafilmdcjenis = Rsfilm!jenisfilm: dtptglmasuk = Rsfilm!tglmasukcbokeping.Text = Rsfilm!jmlkeping: txtsinopsis.Text = Rsfilm!sinopsistxtaktor.Text = Rsfilm!aktor: txtaktris.Text = Rsfilm!aktrisdtptglproduksi = Rsfilm!tglproduksi: txtstatusfilm.Text = Rsfilm!stsfilmtxtstatusfisik.Text = Rsfilm!stsfisikEnd SubPrivate Sub Validasi()Valid = FalseIf 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 = "" 9
  • 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 IfEnd IfValid = TrueEnd SubPrivate Sub Tampildata()Set rstampil = Nothingrstampil.Open "select nofilm,namafilm,tglmasuk,jenisfilm,stsfilm from tblfilm order by nofilm ", Koneksi,adOpenDynamic, adLockOptimisticSet Grid1.DataSource = rstampilGrid1.Columns(0).Width = 1100Grid1.Columns(1).Width = 3500Grid1.Columns(2).Width = 1250Grid1.Columns(3).Width = 1000Grid1.Columns(4).Width = 1000Grid1.Columns(0).Alignment = dbgCenterGrid1.Columns(2).Alignment = dbgCenterGrid1.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 IfEnd SubPrivate Sub Form_Activate()frmmnutama.Enabled = FalseEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate Sub Form_Load()BukaDatabaseaturnofilmblankform1up1.Value = Year(Date)txtthn.Text = up1tidaksiapisitutuptombolxpsimpan.Caption = "&Tambah"TampildataCarifilm -------- gk perludtptglmasuk = Datedtptglproduksi = Datecbokeping.List(0) = "1"cbokeping.List(1) = "2"cbokeping.List(2) = "3"cbokeping.List(3) = "4"cbokeping.List(4) = "5"dcnamafilm.Visible = FalseSet rscari = Nothing 10
  • 11. rscari.Open "Select jenisfilm from tblbysewa where tahun=" & txtthn & " group by jenisfilm", Koneksi,adOpenDynamic, adLockOptimisticSet dcjenis.RowSource = rscaridcjenis.ListField = "jenisfilm"End SubPrivate Sub chkcari_Click()If chkcari.Value = vbchecked Then dcnamafilm.Visible = True txtnamafilm.Visible = False dcnamafilm.SetFocusElse dcnamafilm.Visible = False txtnamafilm.Visible = True blankform1 txtnofilm.SetFocusEnd IfEnd SubPrivate Sub dcnamafilm_Click(Area As Integer)Set Rsfilm = NothingRsfilm.Open "[tblfilm] where namafilm =" & dcnamafilm & " and tahun=" & txtthn & "", Koneksi,adOpenDynamic, adLockOptimisticIf Not Rsfilm.EOF Then isiform2End IfEnd SubPrivate 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!stsfisikEnd SubPrivate Sub carifilm()Set rscari = Nothingrscari.Open "Select namafilm from tblfilm where tahun=" & txtthn & " group by namafilm", Koneksi,adOpenDynamic, adLockOptimisticSet dcnamafilm.RowSource = rscaridcnamafilm.ListField = "namafilm"End SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd SubPrivate Sub txtnofilm_Click()blankform1End SubPrivate Sub txtnofilm_KeyPress(KeyAscii As Integer)KeyAscii = Asc(UCase(Chr(KeyAscii)))End SubPrivate 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 IfEnd Sub 11
  • 12. Private Sub txtnofilm_Lostfocus()ckode = Trim(txtnofilm.Text)If ckode = Empty Then Exit SubEnd IfIf Rsfilm.RecordCount > 0 Then Rsfilm.MoveFirstEnd IfRsfilm.Find ("nofilm = " & ckode & "")Set Rsfilm = NothingRsfilm.Open "[tblfilm] where nofilm =" & ckode & " and tahun=" & txtthn & "", Koneksi, adOpenDynamic,adLockOptimisticIf 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 frmfilmEnd If +AdaEnd Sub +Ada1 +Valid : BooleanPrivate Sub xpsimpan_Click() +sql : String -rstampil : RecordsetIf xpsimpan.Caption = "&Tambah" Then -rscari : Recordset xpbatal_Click -blankform1() aturnofilm -tidaksiapisi() Exit Sub -SiapIsi1()End If -isitabelfilm()Validasi -AktifTombol() -tutuptombol()If Valid = True Then -isiformfilm() If Ada1 = False Then -Validasi() Rsfilm.AddNew -Tampildata() isitabelfilm -Form_Activate() Rsfilm.Update -Up1_Change() -Form_Load() Else -chkcari_Click() isitabelfilm -dcnamafilm_Click(in Area : Integer) Rsfilm.Update -carifilm() End If -isiform2() xpsimpan.Caption = "&Tambah" -Form_Unload(in Cancel : Integer) -txtnofilm_Click()Else -txtnofilm_KeyPress(in KeyAscii : Integer)xpsimpan.Caption = "&Simpan" -txtnofilm_KeyDown(in KeyCode : Integer, in Shift : Integer)End If -txtnofilm_Lostfocus()Rsfilm.Requery -xpsimpan_Click()Tampildata -xpbatal_Click() -xpedit_click()aturnofilm -xphapus_Click()End Sub -xpkeluar_Click() -Grid1_KeyDown(in KeyCode : Integer, in Shift : Integer)Private Sub xpbatal_Click() -txtnamafilm_keydown(in KeyCode : Integer, in Shift : Integer)aturnofilm -dcjenis_keydown(in KeyCode : Integer, in Shift : Integer) -dtptglmasuk_keydown(in KeyCode : Integer, in Shift : Integer)blankform1 -txtsinopsis_keydown(in KeyCode : Integer, in Shift : Integer)tidaksiapisi -txtaktor_keydown(in KeyCode : Integer, in Shift : Integer)chkcari.Value = novbchecked ---- gk perlu -txtaktris_keydown(in KeyCode : Integer, in Shift : Integer)txtnofilm.Enabled = True -dtptglproduksi_keydown(in KeyCode : Integer, in Shift : Integer)txtnofilm.SetFocus -cbokeping_keydown(in KeyCode : Integer, in Shift : Integer) -aturnofilm()xpsimpan.Caption = "&Tambah"tutuptombolEnd SubPrivate Sub xpedit_click()tutuptombolAda1 = TrueSiapIsi1txtnofilm.Enabled = Falsexpsimpan.Caption = "&Simpan"txtnamafilm.SetFocusEnd Sub 12
  • 13. Private Sub xphapus_Click()ckode = Trim(txtnofilm.Text)Rssewa.Find ("nofilm=" & ckode & ""), , adSearchForward, 1Rskembali.Find ("nofilm=" & ckode & ""), , adSearchForward, 1If Not Rssewa.EOF Then X = MsgBox("maaf data film tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnofilm.SetFocus Exit SubElseIf Not Rskembali.EOF Then X = MsgBox("maaf data film tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnofilm.SetFocus Exit SubElse 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 vbNoEnd SelectEnd Ifxpbatal_ClickRsfilm.RequeryTampildataEnd SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate 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 IfEnd IfEnd SubPrivate Sub txtnamafilm_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub dcjenis_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub dtptglmasuk_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtsinopsis_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtaktor_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtaktris_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd Sub 13
  • 14. Private Sub dtptglproduksi_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub cbokeping_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate 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 = cnoEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- Form Biaya Sewa & Denda --- Frmbysewa txtthn txtjenis Up1 txtjml Xpsimpan txtdenda Xpedit Grid1 Xphapus Xpbatal XpkeluarListing FrmbysewaPublic Ada1, Valid As BooleanDim rstampil As New ADODB.RecordsetPrivate Sub blankform1()txtjml.Text = "": txtdenda.Text = ""End SubPrivate Sub tidaksiapisi()txtjml.Enabled = False: txtdenda.Enabled = FalseEnd SubPrivate Sub SiapIsi1()txtjml.Enabled = True: txtdenda.Enabled = TrueEnd SubPrivate Sub isitabelbysewa()Rsbysewa!jenisfilm = txtjenis.Text: Rsbysewa!jmlby = txtjml.Text: Rsbysewa!tahun = txtthn.TextRsbysewa!denda = txtdenda.TextEnd Sub 14
  • 15. Private Sub AktifTombol()xpsimpan.Enabled = True: xpedit.Enabled = Truexphapus.Enabled = True:End SubPrivate Sub tutuptombol()xphapus.Enabled = False: xpedit.Enabled = FalseEnd SubPrivate Sub isiformbysewa()txtjml.Text = Rsbysewa!jmlbytxtdenda.Text = Rsbysewa!dendaEnd SubPrivate Sub Validasi()Valid = FalseIf txtjml.Text = Empty Then X = MsgBox("biaya sewa harus diisi", 0 + 16, "konfirmasi") txtjml.Text = "" txtjml.SetFocus Exit SubElseIf txtdenda.Text = Empty Then X = MsgBox("biaya denda harus diisi", 0 + 16, "konfirmasi") txtdenda.Text = "" txtdenda.SetFocus Exit SubEnd IfValid = TrueEnd SubPrivate Sub Tampildata()Set rstampil = Nothingrstampil.Open "select jenisfilm,jmlby,denda from tblbysewa order by jenisfilm ", Koneksi, adOpenDynamic,adLockOptimisticSet Grid1.DataSource = rstampilGrid1.Columns(0).Width = 1250Grid1.Columns(1).Width = 1250Grid1.Columns(1).Width = 1250Grid1.Columns(0).Alignment = dbgCenterGrid1.Columns(1).Alignment = dbgRightGrid1.Columns(2).Alignment = dbgRightGrid1.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 SubPrivate Sub Form_Activate()frmmnutama.Enabled = FalseEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate Sub Form_Load()BukaDatabaseblankform1up1.Value = Year(Date)txtthn.Text = up1tidaksiapisitutuptombolxpsimpan.Caption = "&Tambah"TampildataEnd SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd SubPrivate Sub txtjenisfilm_Click()blankform1End Sub 15
  • 16. Private Sub txtjenisfilm_KeyPress(KeyAscii As Integer)KeyAscii = Asc(UCase(Chr(KeyAscii)))End SubPrivate Sub txtjenis_Lostfocus()ckode = Trim(txtjenis.Text)If ckode = Empty Then Exit SubEnd IfIf Rsbysewa.RecordCount > 0 Then Rsbysewa.MoveFirstEnd IfSet Rsbysewa = NothingRsbysewa.Open "[tblbysewa] where jenisfilm =" & ckode & " and tahun=" & txtthn & "", Koneksi,adOpenDynamic, adLockOptimisticIf Rsbysewa.EOF Then blankform1 SiapIsi1 txtjml.SetFocus Ada1 = False tutuptombol xpsimpan.Caption = "&Simpan"Else tidaksiapisi isiformbysewa xpedit.Enabled = True xphapus.Enabled = True Ada1 = TrueEnd IfEnd SubPrivate Sub xpsimpan_Click() Static StructurIf xpsimpan.Caption = "&Tambah" Then frmbysewa xpbatal_Click +Ada1 Exit Sub +Valid : BooleanEnd If -rstampil : RecordsetValidasi -blankform1()If Valid = True Then -tidaksiapisi() If Ada1 = False Then -SiapIsi1() Rsbysewa.AddNew -isitabelbysewa() -AktifTombol() isitabelbysewa -tutuptombol() Rsbysewa.Update -isiformbysewa() Else -Validasi() isitabelbysewa -Tampildata() Rsbysewa.Update -Form_Activate() -Up1_Change() End If -Form_Load() xpsimpan.Caption = "&Tambah" -Form_Unload(in Cancel : Integer)Else -txtjenisfilm_Click()xpsimpan.Caption = "&Simpan" -txtjenisfilm_KeyPress(in KeyAscii : Integer)End If -txtjenis_Lostfocus() -xpsimpan_Click()Rsbysewa.Requery -xpbatal_Click()Tampildata -xpedit_click()End Sub -xphapus_Click() -xpkeluar_Click()Private Sub xpbatal_Click() -Grid1_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtjenis_keydown(in KeyCode : Integer, in Shift : Integer)blankform1 -txtjml_keydown(in KeyCode : Integer, in Shift : Integer)tidaksiapisi -txtdenda_keydown(in KeyCode : Integer, in Shift : Integer)txtjenis.Enabled = True -txtjml_KeyPress(in KeyAscii : Integer)txtjenis.SetFocus -txtdenda_KeyPress(in KeyAscii : Integer)xpsimpan.Caption = "&Tambah"tutuptombolEnd SubPrivate Sub xpedit_click()tutuptombolAda1 = TrueSiapIsi1txtjenis.Enabled = Falsexpsimpan.Caption = "&Simpan"txtjml.SetFocusEnd SubPrivate Sub xphapus_Click()ckode = Trim(txtjenis.Text) 16
  • 17. Rsfilm.Find ("jenisfilm=" & ckode & ""), , adSearchForward, 1If Not Rsfilm.EOF Then X = MsgBox("maaf jenis film tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtjenis.SetFocus Exit SubElse 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 vbNoEnd SelectEnd Ifxpbatal_ClickRsbysewa.RequeryTampildataEnd SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate 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 IfEnd IfEnd SubPrivate Sub txtjenis_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtjml_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtdenda_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtjml_KeyPress(KeyAscii As Integer)If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _ KeyAscii = vbKeyBack) Then KeyAscii = 0End IfEnd SubPrivate Sub txtdenda_KeyPress(KeyAscii As Integer)If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _ KeyAscii = vbKeyBack) Then KeyAscii = 0End IfEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- 17
  • 18. Form Karyawan - Frmkaryawan Name objek disesuaikan dengan Listing. Lihat form sebelumnyaListing FrmkaryawanPublic Ada1, Valid As BooleanDim rstampil As New ADODB.RecordsetPrivate Sub blankform1()txtnamakary.Text = "": txtt4.Text = "": optlaki = Falseoptperempuan = False: optbk = False: optm = False: txtalamat.Text = ""txttelp.Text = "": txtnoktp.Text = "": txtstskary.Text = ""txtpassword.Text = "": txtkonfirmasi.Text = ""End SubPrivate Sub tidaksiapisi()txtnamakary.Enabled = False: txtt4.Enabled = False: dtptgllahir.Enabled = False: optlaki.Enabled = Falseoptperempuan.Enabled = False: optbk.Enabled = False: optm.Enabled = False: txtalamat.Enabled = Falsetxttelp.Enabled = False: txtnoktp.Enabled = False: txtstskary.Enabled = False: dtptglkerja.Enabled = Falsetxtpassword.Enabled = False: txtkonfirmasi.Enabled = False: chklihat.Enabled = False: chklihat = FalseEnd SubPrivate Sub SiapIsi1()txtnamakary.Enabled = True: txtt4.Enabled = True: dtptgllahir.Enabled = True: optlaki.Enabled = Trueoptperempuan.Enabled = True: optbk.Enabled = True: optm.Enabled = True: txtalamat.Enabled = Truetxttelp.Enabled = True: txtnoktp.Enabled = True: txtstskary.Enabled = False: dtptglkerja.Enabled = Truetxtpassword.Enabled = True: txtkonfirmasi.Enabled = TrueEnd SubPrivate Sub isitabelkaryawan()If optlaki = True Then ct = "Laki-Laki"Else ct = "Perempuan"End IfIf optbk = True Then ck = "Belum Menikah"Else ck = "Menikah"End IfRskaryawan!nokary = txtnokary.Text: Rskaryawan!namakary = txtnamakary.TextRskaryawan!T4 = txtt4.Text: Rskaryawan!tgllahir = dtptgllahirRskaryawan!jeniskel = ct: Rskaryawan!stskel = ckRskaryawan!alamat = txtalamat.Text: Rskaryawan!notelp = txttelp.TextRskaryawan!noktp = txtnoktp.Text: Rskaryawan!stskary = txtstskary.TextRskaryawan!tglkerja = dtptglkerjaRskaryawan!tahun = txtthn.Text: Rskaryawan!Password = txtpassword.Text 18
  • 19. Rskaryawan!tglubah = DateEnd SubPrivate Sub AktifTombol()xpsimpan.Enabled = Truexpedit.Enabled = Truexphapus.Enabled = TrueEnd SubPrivate Sub tutuptombol()xphapus.Enabled = Falsexpedit.Enabled = FalseEnd SubPrivate Sub isiformanggota()txtnamakary.Text = Rskaryawan!namakarytxtt4.Text = Rskaryawan!T4: dtptgllahir = Rskaryawan!tgllahirIf Rskaryawan!jeniskel = "Laki-Laki" Then optlaki.Value = TrueElse optperempuan.Value = TrueEnd IfIf Rskaryawan!stskel = "Belum Menikah" Then optbk.Value = TrueElse optm.Value = TrueEnd Iftxtalamat.Text = Rskaryawan!alamat: txttelp.Text = Rskaryawan!notelptxtnoktp.Text = Rskaryawan!noktp: txtstskary.Text = Rskaryawan!stskarydtptglkerja = Rskaryawan!tglkerjatxtpassword.Text = Rskaryawan!Password: txtkonfirmasi.Text = Rskaryawan!PasswordEnd SubPrivate Sub Validasi()Valid = FalseIf txtnamakary.Text = Empty Then X = MsgBox("nama karyawan harus diisi", 0 + 16, "konfirmasi") txtnamakary.Text = "" txtnamakary.SetFocus Exit SubElseIf txtt4.Text = Empty Then X = MsgBox("Tempat lahir harus diisi", 0 + 16, "konfirmasi") txtt4.Text = "" txtt4.SetFocus Exit SubElseIf txtalamat.Text = Empty Then X = MsgBox("Alamat harus diisi", 0 + 16, "konfirmasi") txtalamat.Text = "" txtalamat.SetFocus Exit SubElseIf txtpassword.Text = Empty Then X = MsgBox("Password harus diisi", 0 + 16, "konfirmasi") txtpassword.Text = "" txtpassword.SetFocus Exit SubElseIf txtkonfirmasi.Text = Empty Then X = MsgBox("Konfirmasi password harus diisi", 0 + 16, "konfirmasi") txtkonfirmasi.Text = "" txtkonfirmasi.SetFocus Exit SubEnd IfValid = TrueEnd SubPrivate Sub Tampildata()Set rstampil = Nothingrstampil.Open "select nokary,namakary,tglkerja,stskary from tblkaryawan order by nokary ", Koneksi,adOpenDynamic, adLockOptimisticSet Grid1.DataSource = rstampilGrid1.Columns(0).Width = 1100Grid1.Columns(1).Width = 3500Grid1.Columns(2).Width = 1500Grid1.Columns(3).Width = 1250Grid1.Columns(0).Alignment = dbgCenter 19
  • 20. Grid1.Columns(2).Alignment = dbgCenterGrid1.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 SubPrivate Sub chklihat_Click()If chklihat.Value = vbchecked Then lihatpassElse txtpassword.PasswordChar = "?" xpkeluar.SetFocusEnd IfEnd SubPrivate Sub Form_Activate()frmmnutama.Enabled = FalseAturnokaryEnd SubPrivate 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 IfEnd IfEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate Sub Form_Load()BukaDatabaseblankform1up1.Value = Year(Date)txtthn.Text = up1tidaksiapisitutuptombolxpsimpan.Caption = "&Tambah"Tampildatadtptglkerja = Datedtptgllahir = DateEnd SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd SubPrivate Sub txtnokary_Click()blankform1End SubPrivate Sub txtnokary_KeyPress(KeyAscii As Integer)KeyAscii = Asc(UCase(Chr(KeyAscii)))End SubPrivate Sub txtnokary_Lostfocus()ckode = Trim(txtnokary.Text)If ckode = Empty Then Exit SubEnd IfIf Rskaryawan.RecordCount > 0 Then Rskaryawan.MoveFirstEnd IfIf 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 20
  • 21. Exit SubEnd IfSet Rskaryawan = NothingRskaryawan.Open "[tblkaryawan] where nokary =" & ckode & " and tahun=" & txtthn & "", Koneksi,adOpenDynamic, adLockOptimisticIf 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 = TrueEnd If Static StructurEnd Sub frmkaryawan +Ada1Private Sub xpsimpan_Click() +Valid : BooleanIf xpsimpan.Caption = "&Tambah" Then -rstampil : Recordset xpbatal_Click -blankform1() Aturnokary -tidaksiapisi() Exit Sub -SiapIsi1() -isitabelkaryawan()End If -AktifTombol()Validasi -tutuptombol()If Valid = True Then -isiformanggota() If Ada1 = False Then -Validasi() Rskaryawan.AddNew -Tampildata() -chklihat_Click() isitabelkaryawan -Form_Activate() Rskaryawan.Update -txtkonfirmasi_keydown(in KeyCode : Integer, in Shift : Integer) Else -Up1_Change() isitabelkaryawan -Form_Load() Rskaryawan.Update -Form_Unload(in Cancel : Integer) -txtnokary_Click() End If -txtnokary_KeyPress(in KeyAscii : Integer) xpsimpan.Caption = "&Tambah" -txtnokary_Lostfocus()Else -xpsimpan_Click()xpsimpan.Caption = "&Simpan" -xpbatal_Click()End If -xpedit_click() -xphapus_Click()Rskaryawan.Requery -xpkeluar_Click()Tampildata -Grid1_KeyDown(in KeyCode : Integer, in Shift : Integer)Aturnokary -txtnokary_keydown(in KeyCode : Integer, in Shift : Integer)End Sub -txtnamakary_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtt4_keydown(in KeyCode : Integer, in Shift : Integer) -dtptgllahir_keydown(in KeyCode : Integer, in Shift : Integer)Private Sub xpbatal_Click() -txtalamat_keydown(in KeyCode : Integer, in Shift : Integer)Aturnokary -txttelp_keydown(in KeyCode : Integer, in Shift : Integer)blankform1 -dtptglkerja_keydown(in KeyCode : Integer, in Shift : Integer)tidaksiapisi -txtnoktp_keydown(in KeyCode : Integer, in Shift : Integer)txtnokary.Enabled = True -txtpassword_keydown(in KeyCode : Integer, in Shift : Integer) -Aturnokary()txtnokary.SetFocus -lihatpass()xpsimpan.Caption = "&Tambah"tutuptombolEnd SubPrivate Sub xpedit_click()tutuptombolchklihat.Enabled = TrueAda1 = TrueSiapIsi1txtnokary.Enabled = Falsexpsimpan.Caption = "&Simpan"txtnamakary.SetFocusEnd SubPrivate Sub xphapus_Click()ckode = Trim(txtnokary.Text)Rssewa.Find ("nokary=" & ckode & ""), , adSearchForward, 1Rskembali.Find ("nokary=" & ckode & ""), , adSearchForward, 1If Not Rssewa.EOF Then X = MsgBox("maaf data karyawan tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnokary.SetFocus 21
  • 22. Exit SubElseIf Not Rskembali.EOF Then X = MsgBox("maaf data karyawan tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtnokary.SetFocus Exit SubElse 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 SelectEnd Ifxpbatal_ClickRskaryawan.RequeryTampildataEnd SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate 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 IfEnd IfEnd SubPrivate Sub txtnokary_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtnamakary_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtt4_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub dtptgllahir_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtalamat_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txttelp_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub dtptglkerja_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd Sub 22
  • 23. Private Sub txtnoktp_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtpassword_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate 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 + cnoEnd SubPrivate Sub lihatpass()Dim lihat, passlihat = "Masukkan kunci password !"pass = InputBox(lihat, "Masukkan")If pass <> Right(txtnokary, 2) Then MsgBox "Kunci password tersebut salah !", , "Ulangi lagi" Exit SubElse MsgBox "Password berhasil!", , "Konfirmasi" txtpassword.PasswordChar = "" txtpassword.SetFocusEnd IfEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- Form Penyewaan Film - Frmpenyewaan txtthn txtnamaang Up1 txtnoang txtkriteria dtptglsewa cbokriteria txtjamsewa chkcari Label6 Label5 List2 List1 txtbayar lblsinopsis xplagi xpsewa xpbatal xpcetak 23
  • 24. Listing FrmpenyewaanPublic Ada, Ada1, Valid As BooleanPublic sql As StringDim rstampil As New ADODB.RecordsetPublic T1, b1, Th1 As IntegerPrivate Sub cbokriteria_Click()txtkriteria.SetFocusEnd SubPrivate 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 IfElse cbokriteria.Enabled = False txtkriteria.Enabled = False cbokriteria.Text = "" txtkriteria.Text = "" ls1End IfEnd SubPrivate Sub dtptglsewa_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd Sub Static Structur frmpenyewaanPrivate Sub Form_Activate() +Adacbokriteria.Enabled = False +Ada1txtkriteria.Enabled = False +Valid : Booleanfrmmnutama.Enabled = False +sql : String -rstampil : RecordsetEnd Sub +T1 +b1Private Sub Form_Load() +Th1 : IntegerBukaDatabase -cbokriteria_Click()xpsewa.Enabled = False -chkcari_Click()xpbatal.Enabled = False -dtptglsewa_keydown(in KeyCode : Integer, in Shift : Integer) -Form_Activate()xpcetak.Enabled = False -Form_Load()List1.Enabled = False -dtptglsewa_LostFocus()List2.Enabled = False -ls1()cbokriteria.List(0) = "No Film" -List1_Click()cbokriteria.List(1) = "Aktor" -Timer1_Timer() -txtkriteria_Change()cbokriteria.List(2) = "Aktris" -carinofilm()up1.Value = Year(Date) -cariaktor()txtthn.Text = up1 -cariaktris()dtptglsewa = Date -ls2()dtptglsewa_LostFocus -txtnamaang_KeyDown(in KeyCode : Integer, in Shift : Integer) -txtnoang_Lostfocus()ls1 -Form_Unload(in Cancel : Integer)End Sub -Up1_Change() -xpcetak_Click()Private Sub dtptglsewa_LostFocus() -xpkeluar_Click()T1 = Left(dtptglsewa, 2) -xplagi_Click() -xpsewa_Click()b1 = Mid(dtptglsewa, 4, 2) -xpbatal_Click()Th1 = Right(dtptglsewa, 4) -cekbyr()End SubPrivate Sub ls1()Set Rsfilm = NothingRsfilm.Open "Select namafilm from tblfilm where tahun=" & txtthn & " and stsfilm=Ada group by namafilm",Koneksi, adOpenDynamic, adLockOptimisticSet List1.RowSource = RsfilmList1.ListField = "namafilm" 24
  • 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 IfEnd SubPrivate Sub List1_Click()xpsewa.Enabled = TrueSet Rsfilm = NothingRsfilm.Open "[tblfilm] where namafilm =" & List1 & " and tahun=" & txtthn & "", Koneksi, adOpenDynamic,adLockOptimisticIf Rsfilm.RecordCount > 0 Then lblsinopsis.Caption = "Sinopasis : " & vbCrLf & "" + Rsfilm!sinopsisElse lblsinopsis.Caption = "" xpsewa.Enabled = FalseEnd IfEnd SubPrivate Sub Timer1_Timer()txtjamsewa.Text = TimeEnd SubPrivate Sub txtkriteria_Change()If cbokriteria.Text = "Aktor" Then cariaktorElseIf cbokriteria.Text = "Aktris" Then cariaktrisElseIf cbokriteria.Text = "No Film" Then carinofilmEnd IfEnd SubPrivate Sub carinofilm()Set Rsfilm = NothingRsfilm.Open "Select namafilm from tblfilm Where nofilm like " & txtkriteria & "% and tahun=" & txtthn & "and stsfilm=Ada group by namafilm", Koneksi, adOpenDynamic, adLockOptimisticSet List1.RowSource = RsfilmList1.ListField = "namafilm"If Rsfilm.RecordCount > 0 Then xpsewa.Enabled = TrueElse xpsewa.Enabled = FalseEnd IfEnd SubPrivate Sub cariaktor()Set Rsfilm = NothingRsfilm.Open "Select namafilm from tblfilm Where aktor like " & txtkriteria & "% and tahun=" & txtthn & "and stsfilm=Ada group by namafilm", Koneksi, adOpenDynamic, adLockOptimisticSet List1.RowSource = RsfilmList1.ListField = "namafilm"If Rsfilm.RecordCount > 0 Then xpsewa.Enabled = TrueElse xpsewa.Enabled = FalseEnd IfEnd SubPrivate Sub cariaktris()Set Rsfilm = NothingRsfilm.Open "Select namafilm from tblfilm Where aktris like " & txtkriteria & "% and tahun=" & txtthn & "and stsfilm=Ada group by namafilm", Koneksi, adOpenDynamic, adLockOptimisticSet List1.RowSource = RsfilmList1.ListField = "namafilm"If Rsfilm.RecordCount > 0 Then xpsewa.Enabled = TrueElse 25
  • 26. xpsewa.Enabled = FalseEnd IfEnd SubPrivate Sub ls2()Set rstampil = Nothingrstampil.Open "Select tblfilm.namafilm from tblfilm,tblsewa,tblanggota where tblsewa.tahun=" & txtthn & " andtblsewa.stssewa=Sewa and tblsewa.noang=" & txtnoang & " and tblsewa.noang=tblanggota.noang andtblsewa.nofilm=tblfilm.nofilm and tblsewa.tglsewa= #" & b1 & "/" & T1 & "/" & Th1 & "# group bytblfilm.namafilm", Koneksi, adOpenDynamic, adLockOptimisticSet List2.RowSource = rstampilList2.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)" cekbyrElse List2.Enabled = False xpbatal.Enabled = False xpcetak.Enabled = False Label6.Caption = "" cekbyrEnd IfEnd SubPrivate 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 & "% andstsang=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 IfEnd SubPrivate 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 mengubahstatusnya menjadi Tidak Aktif ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes 26
  • 27. Koneksi.Execute "update tblanggota set stsang=Tidak Aktif where noang=" & txtnoang & "andtahun=" & txtthn & "" Case vbNo xplagi_Click End Select End If ls2 cekbyr Ada1 = True End IfEnd SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate 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.RetrieveDataFilescrpcetak1.WindowState = crptMaximizedcrpcetak1.Action = 1crpcetak1.RetrieveDataFilescrpcetak1.WindowState = crptMaximizedcrpcetak1.CopiesToPrinter = 1crpcetak1.Destination = crptToPrintercrpcetak1.Action = 1End SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate Sub xplagi_Click()chkcari.Value = novbcheckedtxtnoang.Text = ""txtnamaang.Text = ""cbokriteria.Text = ""txtkriteria.Text = ""Label6.Caption = ""txtbayar.Text = "Rp. 0"txtnamaang.SetFocusls2cekbyrIf txtnoang.Text = Empty Then xpcetak.Enabled = FalseEnd IfEnd SubPrivate Sub xpsewa_Click()xpsewa.Enabled = Falsecek = frmmnutama.stb.Panels(1).TextIf cek = "???" Then MsgBox "Password yang anda gunakan adalah password ! " & vbCrLf & " yang tidak dapat digunakan untukpenyimpanan !", 0 + 64, "Konfirmasi" xplagi_Click xpkeluar.SetFocus Exit SubEnd IfIf txtnoang.Text = Empty Then MsgBox "Masukkan dulu Data anggota yang menyewa ! " & vbCrLf & " Bantuan tekan F1", 0 + 64,"Konfirmasi" txtnamaang.SetFocus Exit SubEnd IfSet Rsfilm = NothingRsfilm.Open "[tblfilm] where namafilm =" & List1 & " and tahun=" & txtthn & "", Koneksi, adOpenDynamic,adLockOptimisticIf Rsfilm.RecordCount > 0 Then 27
  • 28. ck = Rsfilm!nofilm kk = Rsfilm!jenisfilmEnd IfSet Rssewa = NothingRssewa.Open "[tblsewa] where noang =" & txtnoang & " and nofilm=" & ck & "", Koneksi, adOpenDynamic,adLockOptimisticIf Not Rssewa.EOF Then y = MsgBox("Film dengan judul " & List1 & " sudah disewa sebelumnya ! " & vbCrLf & " Anda inginmenyewanya 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 SelectElse 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 28
  • 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 cekbyrEnd IfEnd SubPrivate Sub xpbatal_Click()Set Rsfilm = NothingRsfilm.Open "[tblfilm] where namafilm =" & List2 & " and tahun=" & txtthn & "", Koneksi, adOpenDynamic,adLockOptimisticIf Rsfilm.RecordCount > 0 Then ck = Rsfilm!nofilmEnd 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 cekbyrEnd SubPrivate Sub cekbyr()Set Rssewa = NothingRssewa.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 IfEnd Sub 29
  • 30. Form Pengembalian Film – Frmpengembalian txtthn txtnamaang Up1 txtnoang cbofisik dtptglkembali dcsewa txtjamkembali Label6 Label5 List2 List1 txtbayar xplagi xpkembali xpbatal xpcetakListing FrmpengembalianPublic Ada, Ada1, Valid As BooleanPublic sql As StringDim rstampil As New ADODB.RecordsetPublic T1, b1, Th1, tgl, bln, thn As IntegerPublic Lama, denda As SinglePrivate Sub dcsewa_Click(Area As Integer)ls1End SubPrivate Sub dtptglkembali_keydown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub Form_Activate()frmmnutama.Enabled = FalseEnd SubPrivate Sub Form_Load()BukaDatabasexpkembali.Enabled = Falsexpbatal.Enabled = Falsexpcetak.Enabled = Falsedcsewa.Enabled = Falsecbofisik.Enabled = FalseList1.Enabled = Falseup1.Value = Year(Date)txtthn.Text = up1dtptglkembali = Datedcsewa = Datedtptglkembali_LostFocuscbofisik.List(0) = "Baik"cbofisik.List(1) = "Rusak"End SubPrivate Sub dtptglkembali_LostFocus()T1 = Left(dtptglkembali, 2)b1 = Mid(dtptglkembali, 4, 2)Th1 = Right(dtptglkembali, 4)End SubPrivate Sub tgsewa()tgl = Left(dcsewa, 2)bln = Mid(dcsewa, 4, 2)thn = Right(dcsewa, 4)End Sub 30
  • 31. Private Sub ls1()tgsewaSet rstampil = Nothingrstampil.Open "Select tblfilm.namafilm from tblfilm,tblsewa where tblsewa.tahun=" & txtthn & " andtblsewa.stssewa=Sewa and tblsewa.nofilm=tblfilm.nofilm and tblsewa.noang=" & txtnoang & " andtblsewa.tglsewa= #" & bln & "/" & tgl & "/" & thn & "# group by tblfilm.namafilm", Koneksi, adOpenDynamic,adLockOptimisticSet List1.RowSource = rstampilList1.ListField = "namafilm"If rstampil.RecordCount > 0 Then Label5.Caption = "Film yang disewa Tgl." + dcsewa List1.Enabled = TrueElse xpkembali.Enabled = False List1.Enabled = False Label5.Caption = "" xplagi.SetFocusEnd IfEnd SubPrivate Sub List1_Click()xpkembali.Enabled = TrueEnd SubPrivate Sub Timer1_Timer() txtjamkembali.Text = TimeEnd SubPrivate Sub caritglsewa()Set Rssewa = NothingRssewa.Open "Select tglsewa from tblsewa Where noang = " & txtnoang & " and tahun=" & txtthn & " andstssewa=Sewa group by tglsewa", Koneksi, adOpenDynamic, adLockOptimisticSet dcsewa.RowSource = Rssewadcsewa.ListField = "tglsewa"End SubPrivate Sub ls2()Set rstampil = Nothingrstampil.Open "Select tblfilm.namafilm from tblfilm,tblkembali where tblkembali.tahun=" & txtthn & " andtblkembali.noang=" & txtnoang & " and tblkembali.nofilm=tblfilm.nofilm and tblkembali.tglkembali= #" & b1& "/" & T1 & "/" & Th1 & "# group by tblfilm.namafilm", Koneksi, adOpenDynamic, adLockOptimisticSet List2.RowSource = rstampilList2.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 = "" cekbyrEnd IfEnd SubPrivate 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 IfEnd Sub 31
  • 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 & "andstssewa=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 IfEnd SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate Sub xpcetak_Click()tgsewaSet Rssewa = NothingRssewa.Open "[tblsewa] where noang=" & txtnoang & " and tglsewa= #" & bln & "/" & tgl & "/" & thn & "#",Koneksi, adOpenDynamic, adLockOptimisticIf Rssewa.RecordCount > 0 Then rr = Rssewa.RecordCountEnd IfIf 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 32
  • 33. End If End If aa = Lama If Val(aa) > Val(rr) Then lm = (Val(aa) - Val(rr)) Else lm = "-" End IfEnd Ifcrpcetak1.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.RetrieveDataFilescrpcetak1.WindowState = crptMaximizedcrpcetak1.Action = 1crpcetak1.RetrieveDataFilescrpcetak1.WindowState = crptMaximizedcrpcetak1.CopiesToPrinter = 1crpcetak1.Destination = crptToPrintercrpcetak1.Action = 1End SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate Sub xplagi_Click()If List1.Text = Empty Theny = MsgBox("Yakin tidak data yang keliru ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case y Case vbYes lagi Case vbNo List2.SetFocus End SelectElselagiEnd IfEnd SubPrivate Sub lagi()txtnoang.Text = ""txtnamaang.Text = ""Label5.Caption = ""Label6.Caption = ""cbofisik.Text = ""dcsewa.Enabled = Falsedcsewa = Datetxtbayar.Text = "Rp. 0"ls1ls2cekbyrtxtnamaang.SetFocusEnd SubPrivate Sub xpkembali_Click()dcsewa = Datexpkembali.Enabled = Falsecek = frmmnutama.stb.Panels(1).TextIf cek = "???" Then MsgBox "Password yang anda gunakan adalah password ! " & vbCrLf & " yang tidak dapat digunakan untukpenyimpanan !", 0 + 64, "Konfirmasi" xplagi_Click xpkeluar.SetFocus Exit SubEnd IfIf txtnoang.Text = Empty Then MsgBox "Masukkan dulu Data anggota yang mengembalikan ! " & vbCrLf & " Bantuan tekan F1", 0 + 64,"Konfirmasi" txtnamaang.SetFocus Exit SubEnd If 33
  • 34. If cbofisik.Text = Empty Then MsgBox "Masukkan dulu keadaan film yang dikembalikan !", 0 + 64, "Konfirmasi" cbofisik.SetFocus Exit SubEnd IfSet Rsfilm = NothingRsfilm.Open "[tblfilm] where namafilm =" & List1 & " and tahun=" & txtthn & "", Koneksi, adOpenDynamic,adLockOptimisticIf Rsfilm.RecordCount > 0 Then ck = Rsfilm!nofilm kk = Rsfilm!jenisfilmEnd IfSet Rsbysewa = NothingRsbysewa.Open "[tblbysewa] where jenisfilm =" & kk & " and tahun=" & txtthn & "", Koneksi,adOpenDynamic, adLockOptimisticIf Rsbysewa.RecordCount > 0 Then ct = Rsbysewa!jmlby dd = Rsbysewa!dendaEnd IftgsewaSet Rssewa = NothingRssewa.Open "[tblsewa] where noang=" & txtnoang & " and tglsewa= #" & bln & "/" & tgl & "/" & thn & "#",Koneksi, adOpenDynamic, adLockOptimisticIf Rssewa.RecordCount > 0 Then ll = Rssewa!jamsewa rr = Rssewa.RecordCountEnd IfIf 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 Ifjj = frmreading.label3.captiontgsewaSet Rskembali = NothingRskembali.Open "[tblkembali] where noang =" & txtnoang & " and tahun=" & txtthn & "", Koneksi,adOpenDynamic, adLockOptimisticIf 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 34
  • 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 Ifls2ls1cekbyrEnd SubPrivate Sub xpbatal_Click()tgsewaSet Rsfilm = NothingRsfilm.Open "[tblfilm] where namafilm =" & List2 & " and tahun=" & txtthn & "", Koneksi, adOpenDynamic,adLockOptimisticIf Rsfilm.RecordCount > 0 Then ck = Rsfilm!nofilmEnd If Koneksi.Execute "delete * from tblkembali where nofilm =" & ck & " and noang =" & txtnoang & "andtahun=" & 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 cekbyrEnd SubPrivate Sub cekbyr()Set Rskembali = NothingRskembali.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 IfEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- Form Cetak Anggota – Frmcetakanggota Up1 optseluruh txtthn cbostatus xpcetak optstatus xpkeluar optdaftar Dtptgl1 Dtptgl2 35
  • 36. Listing FrmcetakanggotaPublic T1, T2, b1, B2, Th1, Th2 As IntegerPrivate Sub Form_Activate()frmmnutama.Enabled = FalseEnd SubPrivate Sub Form_Load() Static StructurBukaDatabase frmcetakanggotaup1.Value = Year(Date) +T1txtthn.Text = up1 +T2dtptgl1 = Date +b1dtptgl2 = Date +B2dtpTgl1_LostFocus +Th1DTPTgl2_LostFocus +Th2 : Integercbostatus.Enabled = False -Form_Activate() -Form_Load()dtptgl1.Enabled = False -dtpTgl1_LostFocus()dtptgl2.Enabled = False -DTPTgl2_LostFocus()cbostatus.List(0) = "Aktif" -Form_Unload(in Cancel : Integer)cbostatus.List(1) = "Tidak Aktif" -optdaftar_Click()End Sub -optseluruh_Click() -optstatus_Click() -xpkeluar_Click()Private Sub dtpTgl1_LostFocus() -Up1_Change() T1 = Left(dtptgl1, 2) -xpcetak_Click() b1 = Mid(dtptgl1, 4, 2) Th1 = Right(dtptgl1, 4) DTPTgl2_LostFocusEnd SubPrivate Sub DTPTgl2_LostFocus() T2 = Left(dtptgl2, 2) B2 = Mid(dtptgl2, 4, 2) Th2 = Right(dtptgl2, 4)End SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd SubPrivate Sub optdaftar_Click()cbostatus.Enabled = Falsedtptgl1.Enabled = Truedtptgl2.Enabled = TrueEnd SubPrivate Sub optseluruh_Click()cbostatus.Enabled = Falsedtptgl1.Enabled = Falsedtptgl2.Enabled = FalseEnd SubPrivate Sub optstatus_Click()cbostatus.Enabled = Truedtptgl1.Enabled = Falsedtptgl2.Enabled = FalseEnd SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate 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 36
  • 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 IfEnd IfIf 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 IfEnd IfIf 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 IfEnd IfEnd Sub 37
  • 38. Form Cetak Film – FrmCetakfilm Up1 optseluruh txtthn cbostatus xpcetak optstatus cbostatusfisik optaktor Dtptgl1 optaktris Dtptgl2 optmasuk xpkeluar optstatusfisikListing FrmcetakfilmPublic T1, T2, b1, B2, Th1, Th2 As IntegerDim rscari As New ADODB.RecordsetPrivate Sub Form_Activate()frmmnutama.Enabled = FalseEnd SubPrivate Sub Form_Load()BukaDatabaseup1.Value = Year(Date)txtthn.Text = up1dtptgl1 = Datedtptgl2 = DatedtpTgl1_LostFocusDTPTgl2_LostFocuscbostatus.Enabled = Falsecbostatusfisik.Enabled = Falsedcaktor.Enabled = Falsedcaktris.Enabled = Falsedtptgl1.Enabled = Falsedtptgl2.Enabled = Falsecbostatus.List(0) = "Ada"cbostatus.List(1) = "Sewa"cbostatusfisik.List(0) = "Baik"cbostatusfisik.List(1) = "Rusak"Set rscari = Nothingrscari.Open "Select aktris from tblfilm where tahun=" & txtthn & " group by aktris", Koneksi, adOpenDynamic,adLockOptimisticSet dcaktris.RowSource = rscaridcaktris.ListField = "aktris"Set rscari = Nothingrscari.Open "Select aktor from tblfilm where tahun=" & txtthn & " group by aktor", Koneksi, adOpenDynamic,adLockOptimisticSet dcaktor.RowSource = rscaridcaktor.ListField = "aktor"End SubPrivate Sub dtpTgl1_LostFocus() T1 = Left(dtptgl1, 2) b1 = Mid(dtptgl1, 4, 2) Th1 = Right(dtptgl1, 4) DTPTgl2_LostFocusEnd SubPrivate Sub DTPTgl2_LostFocus() T2 = Left(dtptgl2, 2) B2 = Mid(dtptgl2, 4, 2) Th2 = Right(dtptgl2, 4)End SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd Sub 38
  • 39. Private Sub optdaftar_Click()cbostatus.Enabled = False: dtptgl1.Enabled = Truedtptgl2.Enabled = TrueEnd SubPrivate Sub optaktor_Click()cbostatus.Enabled = False: cbostatusfisik.Enabled = False Static Structurdtptgl1.Enabled = False: dtptgl2.Enabled = False frmcetakfilmdcaktor.Enabled = True: dcaktris.Enabled = False +T1End Sub +T2 +b1Private Sub optaktris_Click() +B2cbostatus.Enabled = False: cbostatusfisik.Enabled = False +Th1 +Th2 : Integerdtptgl1.Enabled = False: dtptgl2.Enabled = False -rscari : Recordsetdcaktor.Enabled = False: dcaktris.Enabled = True -Form_Activate()End Sub -Form_Load() -dtpTgl1_LostFocus()Private Sub optmasuk_Click() -DTPTgl2_LostFocus()cbostatus.Enabled = False: cbostatusfisik.Enabled = False -Form_Unload(in Cancel : Integer) -optdaftar_Click()dtptgl1.Enabled = True: dtptgl2.Enabled = True -optaktor_Click()dcaktor.Enabled = False: dcaktris.Enabled = False -optaktris_Click()End Sub -optmasuk_Click() -optseluruh_Click()Private Sub optseluruh_Click() -optstatus_Click() -optstatusfisik_Click()cbostatus.Enabled = False: cbostatusfisik.Enabled = False -xpkeluar_Click()dtptgl1.Enabled = False: dtptgl2.Enabled = False -Up1_Change()dcaktor.Enabled = False: dcaktris.Enabled = False -xpcetak_Click()End SubPrivate Sub optstatus_Click()cbostatus.Enabled = True: cbostatusfisik.Enabled = Falsedtptgl1.Enabled = False: dtptgl2.Enabled = Falsedcaktor.Enabled = False: dcaktris.Enabled = FalseEnd SubPrivate Sub optstatusfisik_Click()cbostatus.Enabled = False: cbostatusfisik.Enabled = Truedtptgl1.Enabled = False: dtptgl2.Enabled = Falsedcaktor.Enabled = False: dcaktris.Enabled = FalseEnd SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate 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 IfEnd IfIf optstatus = True Then If cbostatus.Text = Empty Then MsgBox "Masukkan dulu status film !", , "Konfirmasi" cbostatus.SetFocus Exit Sub End If Set Rsfilm = Nothing 39
  • 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 IfEnd IfIf 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 IfEnd IfIf 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 & " tidakada", 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 IfEnd IfIf 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 " & _ 40
  • 41. " Tahun=" & txtthn & "", Koneksi, adOpenDynamic, adLockOptimistic If Rsfilm.EOF Then X = MsgBox("Data film yang aktrisnya " & dcaktris & " " & vbCrLf & " untuk Tahun " & txtthn & " tidakada", 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 IfEnd IfIf 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 & " tidakada", 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 IfEnd IfEnd Sub----------------------------------------------------------------------------------------------------------------------------- -----------Laporan Anggota – crpseluruh_anggota 41
  • 42. Laporan Film – crpseluruh_filmLaporan Bukti Sewa – crpbuktisewaLaporan Bukti Denda – crpbuktidendaMerancang Menu Utama----------------------------------------------------------------------------------------------------------------------------- ----------- 42
  • 43. Form Ubah Status - Frmubahstatus txtthn chkanggota Up1 txtnoang txtnamaang chkkary txtnamakary txtnokary cbostatus Xpubah dtpmsber XpkeluarListing FrmubahstatusPublic Ada, Ada1, Valid As BooleanPublic sql As StringPrivate 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 = TrueElse 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 = FalseEnd IfEnd SubPrivate 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 = FalseElse 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 IfEnd SubPrivate Sub Form_Activate()frmmnutama.Enabled = FalseEnd SubPrivate Sub txtnoang_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub Up1_Change() txtthn.Text = up1End SubPrivate Sub Form_Load()BukaDatabaseup1.Value = Year(Date)Label7.Visible = Falsedtpmsber.Visible = Falsetxtthn.Text = up1cbostatus.List(0) = "Aktif"cbostatus.List(1) = "Tidak Aktif" 43
  • 44. gkaktifdtpmsber = DateEnd SubPrivate Sub Form_Unload(Cancel As Integer)Koneksi.CloseEnd SubPrivate Sub gkaktif()txtnoang.Enabled = Falsetxtnamaang.Enabled = Falsetxtnokary.Enabled = Falsetxtnamakary.Enabled = Falsexpubah.Enabled = Falsecbostatus.Enabled = FalseEnd SubPrivate 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 IfEnd SubPrivate Sub txtnoang_Lostfocus()ckode = Trim(txtnoang.Text)If ckode = Empty Then Exit SubEnd IfIf Rsanggota.RecordCount > 0 Then Rsanggota.MoveFirstEnd IfSet Rsanggota = NothingRsanggota.Open "[tblanggota] where noang =" & ckode & " and tahun=" & txtthn & "", Koneksi,adOpenDynamic, adLockOptimisticIf Rsanggota.EOF Then MsgBox "No anggota tersebut tidak terdaftar ! F1 bantuan", 0 + 64, "Konfirmasi" txtnoang.Text = "" txtnamaang.SetFocus Ada1 = False xpubah.Enabled = FalseElse txtnamaang.Text = Rsanggota!namaang xpubah.Enabled = True xpubah.SetFocus Ada1 = TrueEnd IfEnd SubPrivate 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 44
  • 45. End If If KeyCode = vbKeyReturn Then SendKeys vbTab End IfEnd SubPrivate Sub txtnokary_Lostfocus()ckode = Trim(txtnokary.Text)If ckode = Empty Then Exit SubEnd IfIf Rskaryawan.RecordCount > 0 Then Rskaryawan.MoveFirstEnd IfSet Rskaryawan = NothingRskaryawan.Open "[tblkaryawan] where nokary =" & ckode & " and tahun=" & txtthn & "", Koneksi,adOpenDynamic, adLockOptimisticIf Rskaryawan.EOF Then MsgBox "Karyawan tersebut tidak terdaftar ! F1 bantuan", 0 + 64, "Konfirmasi" txtnokary.Text = "" txtnamakary.SetFocus Ada1 = False xpubah.Enabled = FalseElse txtnamakary.Text = Rskaryawan!namakary xpubah.Enabled = True xpubah.SetFocus Ada1 = TrueEnd IfEnd SubPrivate Sub xpkeluar_Click()Unload Mefrmmnutama.Enabled = TrueEnd SubPrivate Sub xpubah_Click()If cbostatus.Text = Empty Then MsgBox "Pilih dulu status !", 0 + 64, "Konfirmasi" cbostatus.SetFocus Exit SubEnd IfIf chkanggota.Value = vbchecked Then Koneksi.Execute "update tblanggota set stsang=" & cbostatus & ",msber=" & dtpmsber & " where noang ="& txtnoang & " and tahun=" & txtthn & ""End IfIf chkkary.Value = vbchecked Then Koneksi.Execute "update tblkaryawan set stskary=" & cbostatus & " where nokary =" & txtnokary & " andtahun=" & txtthn & ""End IfEnd Sub------------------------------------------------------------------------------------------------------------ ---------------------------- Form Info- Frminfo Grid1 Ado 45
  • 46. Listing FrminfoPublic Kode, Teks As StringPrivate Sub Grid1_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyEscape Then Kode = "" Teks = "" Unload Me Exit SubEnd 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 IfEnd SubPrivate Sub Form_Load()Ado.ConnectionString = KoneksiIf frmfilm.Ada Then Ado.RecordSource = frmfilm.sql Ado.RefreshElseIf frmpenyewaan.Ada Then Ado.RecordSource = frmpenyewaan.sql Ado.RefreshElseIf frmpengembalian.Ada Then Ado.RecordSource = frmpengembalian.sql Ado.RefreshElseIf frmubahstatus.Ada Then Ado.RecordSource = frmubahstatus.sql Ado.RefreshEnd If Grid1.Col = 0 Grid1.Columns(0).Width = 2500 Grid1.Columns(1).Width = 1500 Grid1.Columns(1).Alignment = dbgCenterEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- Form reading password- Frmreading List1 XpKeluar txtPassListing FrmreadingPrivate Sub Form_Activate()frmmnutama.Enabled = FalseEnd SubPrivate Sub Form_Load()BukaDatabasecekkaryfrmmnutama.Showfrmmnutama.Enabled = FalseEnd SubPrivate Sub cekkary()Set Rskaryawan = NothingRskaryawan.Open "Select namakary from tblkaryawan where tahun=" & Year(Date) & " and stskary=Aktifgroup by namakary", Koneksi, adOpenDynamic, adLockOptimistic 46
  • 47. Set List1.RowSource = RskaryawanList1.ListField = "namakary"End SubPrivate Sub List1_Click()txtpass.SetFocusEnd SubPrivate 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 IfEnd IfEnd SubPrivate Sub xpkeluar_Click()EndEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- 47
  • 48. Form Utama - FrmmnUtama ToolbarListing FrmmnUtamaPrivate Sub Form_Load()Frmreading.showstb.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 = 2000stb.Panels(2).Width = 4500 Private Sub mnag_Click()stb.Panels(3).Width = 6000 frmanggota.Showstb.Panels(4).Width = 1500 End SubEnd Sub Private Sub mnctang_Click()Private Sub mnfilm_Click() frmcetakanggota.Showfrmfilm.Show End SubEnd Sub Private Sub mnctkfilm_Click()Private Sub mnjnsfilm_Click() frmcetakfilm.Showfrmbysewa.Show End SubEnd Sub Private Sub mnexit_Click()Private Sub mnkary_Click() pesan = MsgBox("Anda yakin mau keluarfrmkaryawan.Show !", 4 + 256 + 32, "Konfirmasi")End Sub If pesan = 6 Then EndPrivate Sub mnkembali_Click() Elsefrmpengembalian.Show frmmnutama.ShowEnd Sub End If End SubPrivate Sub mnnyewa_Click()frmpenyewaan.ShowEnd SubPrivate Sub mnubah_Click()frmubahstatus.ShowEnd Sub----------------------------------------------------------------------------------------------------------------------------- ----------- 48
  • 49. Database Rental Film – dbsrentalfilm DATABASE RENTAL FILMTblAnggota TblFilmNo. Nam a Field Type Width Keterangan No. Nam a Field Type Width Keterangan 1 Noang C 8 No Anggota 1 NoFilm C 4 Nomor Film 2 Namaang C 50 Nama Anggota 2 Namafilm C 75 Nama Film 3 T4 C 50 Tempat Lahir 3 JenisFilm C 10 Jenis Film 4 Tgllahir D 8 Tanggal Lahir 4 Tglmasuk D 8 Tanggal Masuk 5 Jeniskel C 10 Jenis Kelamin 5 jmlkeping N Byte Jumlah Keping / Piringan 6 Stskel C 12 Status Keluarga 6 sinopsis C 255 Sinopsis 7 Alamat C 50 Alamat / Tempat Tinggal 7 aktor C 50 Nama Aktor 8 Notelp C 13 Nomor Telpon / HP 8 aktris C 50 Nama Aktris 9 NoKtp C 45 Nomor KTP 9 tahun C 4 Tahun Masuk 10 Stsang C 12 Status Anggota 10 tglproduksi D 8 Tanggal produksi 11 Tgldaftar D 8 Tanggal daftar 11 stsfilm C 10 Status Film 12 Msber D 8 Masa berlaku 12 stsfisik C 10 Status Fisik Film 13 Tahun C 4 Tahun Masuk 14 Bydaftar N Single Biaya daftar 15 Tglubah D 8 Tanggal ubah statusTblSewa TblKembaliNo. Nam a Field Type Width Keterangan No. Nam a Field Type Width Keterangan 1 Noang C 8 Nomor Film 1 Noang C 8 Nomor Anggota 2 Nofilm C 4 Nomor Anggota 2 Nofilm C 4 Nomor Film 3 TglSew a D 8 Tanggal Sew a 3 Tglkembali D 8 Tanggal Kembali 4 Jmlbyr N Single Jumlah Bayar Sew a 4 Tahun C 4 Tahun 5 Tahun C 4 Tahun 5 Denda N Single Jumlah Denda 6 Nokary C 10 Nomor Karyaw an 6 Nokary C 10 Nomor Karyaw an 7 Stssew a C 10 Status Sew a 7 Stsfisik C 10 Status Fisik Film 8 Stsfisik C 10 Status Fisik Film 8 JamKembali D 8 Jam mengembalikan 9 Jamsew a D 8 Jam menyew aTblBySewa TblKaryawanNo. Nam a Field Type Width Keterangan No. Nam a Field Type Width Keterangan 1 JenisFilm C 10 Jenis Film 1 Nokary C 10 No Karyaw an 2 Jmlby N Single Jumlah Biaya 2 Namakary C 50 Nama Karyaw an 3 Tahun C 4 Tahun 3 T4 C 50 Tempat Lahir 4 Denda N Single Biaya Denda 4 Tgllahir D 8 Tanggal Lahir 5 Jeniskel C 10 Jenis Kelamin 6 Stskel C 12 Status KeluargaRancangan Laporan / Report 7 Alamat C 50 Alamat / Tempat Tinggal 1 Rptanggota_seluruh 8 Notelp C 13 Nomor Telpon / HP 2 RptDaftar_film 9 NoKtp C 45 Nomor KTP 3 Rptsew a_film 10 Stskary C 12 Status Karyaw an 4 Rptkembali_film 11 Tglkerja D 8 Tanggal Kerja 5 Rptanggota_aktif_tidak 12 Tahun C 8 Masa berlaku 6 Rptjumlah_anggota 13 Passw ord C 4 Passw ord 7 Rptkaryaw an 14 Tglubah D 8 Tanggal ubah status 8 Rptstatus_fisik_filmRancangan Form File Layanan 1 Anggota Anggota Penyew aan 2 Film Film Pengembalian 3 Penyew aan Jenis Film 4 Pengembalian Karyaw an 5 Jenis Film 6 Ubah Status (Anggota, Status Fisik Film, Status Karyaw an) Laporan 7 Karyaw an Cetak Anggota (Keseluruhan, Aktif, Tidak Aktif) 8 Reading Cetak Film (Keseluruhan, Status Fisik) 9 Backup Data Cetak Layanan (Sew a, Pengembalian) 10 Cetak Anggota (Keseluruhan, Aktif, Tidak Aktif) Cetak Rekap Jumlah Anggota dan pembayaran 11 Cetak Film (Keseluruhan, Status Fisik) Cetak Karyaw an (Keseluruhan, Aktif, Keluar) 12 Cetak Layanan (Sew a, Pengembalian) 13 Cetak Rekap Jumlah Anggota Utylity 14 Cetak Karyaw an (Keseluruhan, Aktif, Keluar) BackUp Data Ubah Status (Anggota, Status Karyaw an) Exit 49

×