Ebooktiketkapal

436 views

Published on

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

  • Be the first to like this

No Downloads
Views
Total views
436
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ebooktiketkapal

  1. 1. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 1 EBOOK PANDUAN PEMROGRAMAN VISUAL BASIC “PEMBUATAN APLICATION PENJUALAN TIKET KAPAL” 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 dbstiket_kapal (databasenya ada di hal. 37 - 38). 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. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 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
  3. 3. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 3 2. Penulisan Listing – Frmbytiket Modul1 – Modul1 Public Koneksi As New ADODB.Connection Public Rsbytiket As New ADODB.Recordset Public Rsnotempat As New ADODB.Recordset Public Rspesant4 As New ADODB.Recordset Public Rsbeli As New ADODB.Recordset Public Rskasir As New ADODB.Recordset Sub BukaDatabase() Set Koneksi = Nothing Koneksi.CursorLocation = adUseClient Koneksi.Open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "dbstiket_kapal.mdb;jet OLEDB:Database Password=;" Rsbytiket.Open "[tblbytiket]", Koneksi, adOpenDynamic, adLockOptimistic Rsnotempat.Open "[tblnotempat]", Koneksi, adOpenDynamic, adLockOptimistic Rspesant4.Open "[tblpesant4]", Koneksi, adOpenDynamic, adLockOptimistic Rsbeli.Open "[tblbeli]", Koneksi, adOpenDynamic, adLockOptimistic Rskasir.Open "[tblkasir]", Koneksi, adOpenDynamic, adLockOptimistic End Sub ----------------------------------------------------------------------------------------------------------------------------------- Form Entry Tarif Tiket – Frmbytiket xpsimpan txtjnstiket xpedit Txtanak2 txtpelajar xphapus txtumum xpbatal txtfasilitas txpkeluar Grid1
  4. 4. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 4 Listing Frmbytiket Public Ada1, Valid As Boolean Dim RsTampil As New ADODB.Recordset Private Sub Form_Activate() frmmenuutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase tdkaktif kosong Tampildata tutuptombol xpsimpan.Caption = "&Tambah" End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub tdkaktif() txtanak2.Enabled = False: txtpelajar.Enabled = False: txtumum.Enabled = False: txtfasilitas.Enabled = False End Sub Private Sub aktif() txtanak2.Enabled = True: txtpelajar.Enabled = True: txtumum.Enabled = True: txtfasilitas.Enabled = True End Sub Private Sub xpkeluar_Click() Unload Me frmmenuutama.Enabled = True End Sub Private Sub txtjnstiket_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtanak2_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtpelajar_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtumum_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtfasilitas_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub kosong() txtanak2.Text = "": txtpelajar.Text = "": txtumum.Text = "": txtfasilitas.Text = "" End Sub Private Sub isiformtarif() txtanak2.Text = Rsbytiket!Anak2: txtpelajar.Text = Rsbytiket!Pelajar txtumum.Text = Rsbytiket!umum: txtfasilitas.Text = Rsbytiket!fasilitas End Sub Private Sub isitblbytarif() Rsbytiket!jnstiket = txtjnstiket.Text: Rsbytiket!Anak2 = txtanak2.Text: Rsbytiket!Pelajar = txtpelajar.Text Rsbytiket!umum = txtumum.Text: Rsbytiket!fasilitas = txtfasilitas.Text End Sub Private Sub xpsimpan_Click() If xpsimpan.Caption = "&Tambah" Then
  5. 5. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 5 xpbatal_Click Exit Sub End If Validasi If Valid = True Then If Ada1 = False Then Rsbytiket.AddNew isitblbytarif Rsbytiket.Update Else isitblbytarif Rsbytiket.Update End If xpsimpan.Caption = "&Tambah" Else xpsimpan.Caption = "&Simpan" End If Rsbytiket.Requery Tampildata End Sub Private Sub xphapus_Click() ckode = Trim(txtjnstiket.Text) Rsnotempat.Find ("jnstiket='" & ckode & "'"), , adSearchForward, 1 If Not Rsnotempat.EOF Then x = MsgBox("jenis tiket tersebut tidak dapat dihapus", 0 + 16, "konfirmasi") txtjnstiket.SetFocus Exit Sub Else Y = MsgBox("Benar anda ingin hapus ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case Y Case vbYes Koneksi.Execute "delete * from tblbytiket where jnstiket='" & ckode & "'" Case vbNo End Select End If xpbatal_Click Rsbytiket.Requery Tampildata End Sub Private Sub Validasi() Valid = False If txtanak2.Text = Empty Then x = MsgBox("tarif untuk anak-anak harus diisi", 0 + 16, "konfirmasi") txtanak2.Text = "" txtanak2.SetFocus Exit Sub ElseIf txtpelajar.Text = Empty Then x = MsgBox("tarif untuk pelajar harus diisi", 0 + 16, "konfirmasi") txtpelajar.Text = "" txtpelajar.SetFocus Exit Sub ElseIf txtumum.Text = Empty Then x = MsgBox("tarif untuk penumpang umum harus diisi", 0 + 16, "konfirmasi") txtumum.Text = "" txtumum.SetFocus Exit Sub ElseIf txtfasilitas.Text = Empty Then x = MsgBox("fasilitas harus diisi", 0 + 16, "konfirmasi") txtfasilitas.Text = "" txtfasilitas.SetFocus Exit Sub End If Valid = True End Sub Private Sub xpbatal_Click()
  6. 6. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 6 kosong tdkaktif txtjnstiket.Enabled = True txtjnstiket.SetFocus xpsimpan.Caption = "&Tambah" tutuptombol End Sub Private Sub xpedit_click() tutuptombol Ada1 = True aktif txtjnstiket.Enabled = True xpsimpan.Caption = "&Simpan" txtanak2.SetFocus End Sub Private Sub Tampildata() Set RsTampil = Nothing RsTampil.Open "select * from tblbytiket order by jnstiket ", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = RsTampil Grid1.Columns(0).Width = 2000 Grid1.Columns(1).Width = 1000 Grid1.Columns(2).Width = 1000 Grid1.Columns(3).Width = 1000 Grid1.Columns(4).Width = 1250 Grid1.Columns(1).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(3).Alignment = dbgCenter Grid1.Columns(0).Caption = "Tiket" Grid1.Columns(1).Caption = "Anak-anak" Grid1.Columns(2).Caption = "Remaja" Grid1.Columns(3).Caption = "Dewasa" Grid1.Columns(4).Caption = "Fasilitas" Grid1.Columns(1).NumberFormat = "#,###,### " Grid1.Columns(2).NumberFormat = "#,###,### " Grid1.Columns(3).NumberFormat = "#,###,### " If RsTampil.RecordCount > 0 Then Grid1.Caption = "Biaya Tiket Kapal " Else Grid1.Caption = "ga ada tu datanya " End If End Sub Private Sub txtanak2_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 txtpelajar_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 txtumum_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 txtjnstiket_Lostfocus() ckode = Trim(txtjnstiket.Text) If ckode = Empty Then Exit Sub End If If Rsbytiket.RecordCount > 0 Then
  7. 7. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 7 Rsbytiket.MoveFirst End If Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & ckode & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsbytiket.EOF Then kosong aktif txtanak2.SetFocus Ada1 = False tutuptombol xpsimpan.Caption = "&Simpan" Else tdkaktif isiformtarif xpedit.Enabled = True xphapus.Enabled = True Ada1 = True End If End Sub Private Sub tutuptombol() xpedit.Enabled = False xphapus.Enabled = False End Sub ----------------------------------------------------------------------------------------------------------------------------------- Form Entry No Tempat – Frmnot4 Listing Frmnot4 Public Ada1, Valid As Boolean Dim RsTampil As New ADODB.Recordset Dim rscari As New ADODB.Recordset Private Sub dcjnstiket_LostFocus() txtnot4.Enabled = True txtstatus.Enabled = True txtnot4.SetFocus End Sub Private Sub Form_Activate() frmmenuutama.Enabled = False End Sub xpsimpan xpedit xphapus xpkeluar xpbatal txtstatus Txtnot4 dcjnstiket Grid1 txtjml
  8. 8. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 8 Private Sub Form_Load() BukaDatabase tdkaktif Tampildata xpsimpan.Caption = "&Tambah" tutuptombol Set rscari = Nothing rscari.Open "Select jnstiket from tblbytiket group by jnstiket", Koneksi, adOpenDynamic, adLockOptimistic Set dcjnstiket.RowSource = rscari dcjnstiket.ListField = "jnstiket" End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub tdkaktif() txtnot4.Enabled = False: txtstatus.Enabled = False End Sub Private Sub aktif() txtnot4.Enabled = True: txtstatus.Enabled = True End Sub Private Sub xpkeluar_Click() Unload Me frmmenuutama.Enabled = True End Sub Private Sub dcjnstiket_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtnot4_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtstatus_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub isiformnot4() txtnot4.Text = Rsnotempat!no4: txtstatus.Text = Rsnotempat!Status End Sub Private Sub isitabelnot4() Rsnotempat!jnstiket = dcjnstiket.Text: Rsnotempat!no4 = txtnot4.Text: Rsnotempat!Status = txtstatus.Text End Sub Private Sub xpsimpan_Click() If xpsimpan.Caption = "&Tambah" Then txtstatus.Text = "" txtnot4.Enabled = True txtnot4.SetFocus Exit Sub End If Validasi If Valid = True Then If Ada1 = False Then Rsnotempat.AddNew isitabelnot4 Rsnotempat.Update Else isitabelnot4 Rsnotempat.Update End If xpsimpan.Caption = "&Tambah" Else xpsimpan.Caption = "&Simpan"
  9. 9. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 9 End If Rsnotempat.Requery Tampildata End Sub Private Sub xphapus_Click() ckode = Trim(txtnot4.Text) Rsbeli.Find ("no4='" & ckode & "'"), , adSearchForward, 1 If Not Rsbeli.EOF Then x = MsgBox("no tempat tsb tidak dapat dihapus", 0 + 16, "konfirmasi") txtnot4.Enabled = True txtnot4.SetFocus Exit Sub Else Y = MsgBox("Benar anda ingin hapus ???", vbYesNo + vbQuestion + vbDefaultButton2, "konfirmasi") Select Case Y Case vbYes Koneksi.Execute "delete * from tblnotempat where jnstiket='" & dcjnstiket & "'and no4='" & ckode & "'" Case vbNo End Select End If xpbatal_Click Rsnotempat.Requery Tampildata End Sub Private Sub Validasi() Valid = False If txtstatus.Text = Empty Then x = MsgBox("status tidak boleh kosong, harus diisi", 0 + 16, "konfirmasi") txtstatus.Text = "Kosong" txtstatus.SetFocus Exit Sub End If Valid = True End Sub Private Sub xpbatal_Click() tdkaktif dcjnstiket.Enabled = True dcjnstiket.SetFocus xpsimpan.Caption = "&Tambah" tutuptombol txtnot4.Text = "": txtstatus.Text = "" End Sub Private Sub xpedit_click() tutuptombol Ada1 = True aktif txtstatus.Enabled = True xpsimpan.Caption = "&Simpan" txtstatus.SetFocus End Sub Private Sub Tampildata() Set RsTampil = Nothing RsTampil.Open "select * from tblnotempat order by jnstiket,no4 ", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = RsTampil Grid1.Columns(0).Width = 2000 Grid1.Columns(1).Width = 1000 Grid1.Columns(2).Width = 1000 Grid1.Columns(1).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(0).Caption = " Kelas" Grid1.Columns(1).Caption = " Nomor" Grid1.Columns(2).Caption = " Status" If RsTampil.RecordCount > 0 Then Grid1.Caption = "Data Nomor Tempat di Kapal "
  10. 10. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 10 txtjml.Text = RsTampil.RecordCount Else Grid1.Caption = "ga ada tu datanya " txtjml.Text = RsTampil.RecordCount End If End Sub Private Sub txtnot4_KeyPress(KeyAscii As Integer) KeyAscii = Asc(UCase(Chr(KeyAscii))) End Sub Private Sub cekno() ckode = Trim(txtnot4.Text) Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] where no4 ='" & ckode & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsnotempat.EOF Then kk = Rsnotempat!jnstiket MsgBox "No tersebut sudah dipakai pada kelas '" & kk & "' !", 0 + 64, "Konfirmasi" txtnot4.Text = "": txtnot4.SetFocus Exit Sub Else aktif txtstatus.SetFocus txtstatus.Text = "Kosong" tutuptombol xpsimpan.Caption = "&Simpan" End If End Sub Private Sub txtnot4_Lostfocus() ckode = Trim(txtnot4.Text) If ckode = Empty Then Exit Sub End If If Rsnotempat.RecordCount > 0 Then Rsnotempat.MoveFirst End If Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] where jnstiket ='" & dcjnstiket & "'and no4 ='" & ckode & "'", Koneksi, adOpenDynamic, adLockOptimistic If Rsnotempat.EOF Then cekno Ada1 = False Else tdkaktif isiformnot4 xpedit.Enabled = True xphapus.Enabled = True Ada1 = True End If End Sub Private Sub tutuptombol() xpedit.Enabled = False xphapus.Enabled = False End Sub -----------------------------------------------------------------------------------------------------------------------------------
  11. 11. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 11 Form Entry Pesan Tempat – Frmpesant4 Listing Frmpesant4 Public Ada, Ada1, Valid As Boolean Public sql As String Dim rscari As New ADODB.Recordset Public T1, B1, Th1 As Integer Private Sub cek_Click() If cek.Value = vbChecked Then frmpesant4.Refresh txtnama.Visible = False dccek.Visible = True dccek.Text = "" dccek.SetFocus Else frmpesant4.Refresh txtnama.Visible = True dccek.Visible = False txtnama.Text = "" txtnama.SetFocus End If End Sub Private Sub dccek_Click(Area As Integer) aktif Ls2 End Sub Private Sub dctiket_Click(Area As Integer) Ls1 End Sub Private Sub Ls1() Set rscari = Nothing rscari.Open "Select no4 from tblnotempat where jnstiket='" & dctiket & "'and status='Kosong' group by no4 Order by no4", Koneksi, adOpenDynamic, adLockOptimistic Set List1.RowSource = rscari List1.ListField = "no4" If rscari.RecordCount > 0 Then List1.Enabled = True Else List1.Enabled = False End If End Sub Private Sub Ls2() If cek.Value = vbChecked Then dtptglpesan txtjampesan xpkeluar xplagi xpbatal xppesan List1 List2 dctiket cbotujuan cbodari txtnotelp txtnama cek dccek
  12. 12. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 12 Set rscari = Nothing rscari.Open "Select no4 from tblpesant4 where nama='" & dccek & "'and status='Pesan' and tglpesan = #" & B1 & "/" & T1 & "/" & Th1 & "# group by no4", Koneksi, adOpenDynamic, adLockOptimistic Set List2.RowSource = rscari List2.ListField = "no4" If rscari.RecordCount > 0 Then List2.Enabled = True txtnotelp.Text = Rspesant4!notelp cbodari.Text = Rspesant4!dari cbotujuan.Text = Rspesant4!tujuan Else List2.Enabled = False End If Else Set rscari = Nothing rscari.Open "Select no4 from tblpesant4 where nama='" & txtnama & "'and status='Pesan' and tglpesan = #" & B1 & "/" & T1 & "/" & Th1 & "# group by no4", Koneksi, adOpenDynamic, adLockOptimistic Set List2.RowSource = rscari List2.ListField = "no4" If rscari.RecordCount > 0 Then List2.Enabled = True Else List2.Enabled = False End If End If End Sub Private Sub cekpesan() Set rscari = Nothing rscari.Open "Select nama from tblpesant4 where status='Pesan' group by nama", Koneksi, adOpenDynamic, adLockOptimistic Set dccek.RowSource = rscari dccek.ListField = "nama" If rscari.RecordCount > 0 Then cek.Enabled = True Else cek.Enabled = False End If End Sub Private Sub dctiket_LostFocus() Ls1 End Sub Private Sub Form_Activate() frmmenuutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase tdkaktif tutuptombol dccek.Visible = False dtptglpesan = Date dtptglpesan_LostFocus cekpesan Set rscari = Nothing rscari.Open "Select jnstiket from tblbytiket group by jnstiket", Koneksi, adOpenDynamic, adLockOptimistic Set dctiket.RowSource = rscari dctiket.ListField = "jnstiket" cbodari.List(0) = "Banggai" cbodari.List(1) = "Luwuk" cbotujuan.List(0) = "Luwuk" cbotujuan.List(1) = "Banggai" End Sub Private Sub dtptglpesan_LostFocus() T1 = Left(dtptglpesan, 2) B1 = Mid(dtptglpesan, 4, 2) Th1 = Right(dtptglpesan, 4)
  13. 13. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 13 End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub tdkaktif() txtnotelp.Enabled = False: cbodari.Enabled = False: cbotujuan.Enabled = False dtptglpesan.Enabled = False: List1.Enabled = False: List2.Enabled = False: dctiket.Enabled = False End Sub Private Sub aktif() txtnotelp.Enabled = True: cbodari.Enabled = True: cbotujuan.Enabled = True dtptglpesan.Enabled = True: dctiket.Enabled = True End Sub Private Sub tutuptombol() xppesan.Enabled = False: xpbatal.Enabled = False End Sub Private Sub List1_Click() xppesan.Enabled = True End Sub Private Sub List2_Click() xpbatal.Enabled = True End Sub Private Sub Timer1_Timer() txtjampesan.Text = Time End Sub Private Sub txtnama_Lostfocus() ckode = Trim(txtnama.Text) If ckode = Empty Then Exit Sub End If If Rspesant4.RecordCount > 0 Then Rspesant4.MoveFirst End If Set Rspesant4 = Nothing Rspesant4.Open "[tblpesant4] where nama='" & txtnama & "'and status='Pesan' and tglpesan = #" & B1 & "/" & T1 & "/" & Th1 & "# ", Koneksi, adOpenDynamic, adLockOptimistic If Rspesant4.EOF Then aktif txtnotelp.SetFocus Ada1 = False Else aktif txtnotelp.Text = Rspesant4!notelp cbodari.Text = Rspesant4!dari cbotujuan.Text = Rspesant4!tujuan Ls2 Ada1 = True End If End Sub Private Sub txtnama_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub dtptglpesan_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub txtnotelp_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab
  14. 14. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 14 End If End Sub Private Sub cbodari_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub cbotujuan_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub dctiket_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub xpbatal_Click() If cek.Value = vbChecked Then xpbatal.Enabled = False Koneksi.Execute "update tblpesant4 set status='Batal' where no4 ='" & List2 & "' and nama ='" & dccek & "'and tglpesan = #" & B1 & "/" & T1 & "/" & Th1 & "# " Koneksi.Execute "update tblnotempat set status='Kosong' where no4='" & List2 & "'" Ls1 Ls2 Else xpbatal.Enabled = False Koneksi.Execute "update tblpesant4 set status='Batal' where no4 ='" & List2 & "' and nama ='" & txtnama & "'and tglpesan = #" & B1 & "/" & T1 & "/" & Th1 & "# " Koneksi.Execute "update tblnotempat set status='Kosong' where no4='" & List2 & "'" Ls1 Ls2 End If End Sub Private Sub xpkeluar_Click() Unload Me frmmenuutama.Enabled = True End Sub Private Sub xplagi_Click() tdkaktif: cekpesan: cek.Value = novbchecked: Ls1: Ls2 txtnotelp.Text = "": cbodari.Text = "": cbotujuan.Text = "": txtnama.SetFocus: txtnama.Text = "": dctiket.Text = "" cekpesan End Sub Private Sub xppesan_Click() gg = Login.TxtNamap.Text If cek.Value = vbChecked Then xppesan.Enabled = False Set Rspesant4 = Nothing Rspesant4.Open "[tblpesant4] where nama ='" & dccek & "' and tglpesan = #" & B1 & "/" & T1 & "/" & Th1 & "# ", Koneksi, adOpenDynamic, adLockOptimistic If Rspesant4.EOF Then Rspesant4.AddNew Rspesant4!no4 = List1.Text Rspesant4!tglpesan = dtptglpesan Rspesant4!nama = dccek.Text Rspesant4!notelp = txtnotelp.Text Rspesant4!Status = "Pesan" Rspesant4!jampesan = txtjampesan.Text Rspesant4!dari = cbodari.Text Rspesant4!tujuan = cbotujuan.Text Rspesant4!Kasir = gg Rspesant4.Update Koneksi.Execute "update tblnotempat set status='Pesan' where no4='" & List1 & "'"
  15. 15. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 15 Else Rspesant4.AddNew Rspesant4!no4 = List1.Text Rspesant4!tglpesan = dtptglpesan Rspesant4!nama = dccek.Text Rspesant4!notelp = txtnotelp.Text Rspesant4!Status = "Pesan" Rspesant4!jampesan = txtjampesan.Text Rspesant4!dari = cbodari.Text Rspesant4!tujuan = cbotujuan.Text Rspesant4!Kasir = gg Rspesant4.Update Koneksi.Execute "update tblnotempat set status='Pesan' where no4='" & List1 & "'" End If Ls1 Ls2 cekpesan Else xppesan.Enabled = False Set Rspesant4 = Nothing Rspesant4.Open "[tblpesant4] where nama ='" & txtnama & "' and tglpesan = #" & B1 & "/" & T1 & "/" & Th1 & "# ", Koneksi, adOpenDynamic, adLockOptimistic If Rspesant4.EOF Then Rspesant4.AddNew Rspesant4!no4 = List1.Text Rspesant4!tglpesan = dtptglpesan Rspesant4!nama = txtnama.Text Rspesant4!notelp = txtnotelp.Text Rspesant4!Status = "Pesan" Rspesant4!jampesan = txtjampesan.Text Rspesant4!dari = cbodari.Text Rspesant4!tujuan = cbotujuan.Text Rspesant4!Kasir = gg Rspesant4.Update Koneksi.Execute "update tblnotempat set status='Pesan' where no4='" & List1 & "'" Else Rspesant4.AddNew Rspesant4!no4 = List1.Text Rspesant4!tglpesan = dtptglpesan Rspesant4!nama = txtnama.Text Rspesant4!notelp = txtnotelp.Text Rspesant4!Status = "Pesan" Rspesant4!jampesan = txtjampesan.Text Rspesant4!dari = cbodari.Text Rspesant4!tujuan = cbotujuan.Text Rspesant4!Kasir = gg Rspesant4.Update Koneksi.Execute "update tblnotempat set status='Pesan' where no4='" & List1 & "'" End If Ls1 Ls2 cekpesan End If End Sub -----------------------------------------------------------------------------------------------------------------------------------
  16. 16. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 16 Form Penjualan Tiket - Frmjualtiket Listing Frmjualtiket Public Ada, Ada1, Valid As Boolean Public sql As String Dim rscari As New ADODB.Recordset Public T1, B1, Th1 As Integer Dim RsTampil As New ADODB.Recordset Private Sub cbopenumpang_Click() cekbiaya End Sub Private Sub cek_Click() If cek.Value = vbChecked Then txtnot4.SetFocus Else txtnot4.SetFocus End If End Sub Private Sub edit_Click() If edit.Value = vbChecked Then aksesedit Else xpsimpan.Enabled = False tdkaktif xplagi.SetFocus End If End Sub Private Sub Form_Activate() frmmenuutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase Crpcetak1 xpkeluar xplagi xpbatal xpsimpan xpcetak Grid1 txtbayar txtjamjual dtptgljual cbopenumpang cbotujuan cbodari cbojnskel txtalamat txtnama Txtnot4 cek edit stb
  17. 17. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 17 tdkaktif edit.Visible = False dtptgljual = Date dtptgljual_LostFocus cbojnskel.List(0) = "Laki-laki" cbojnskel.List(1) = "Perempuan" cbodari.List(0) = "Banggai" cbodari.List(1) = "Luwuk" cbotujuan.List(0) = "Luwuk" cbotujuan.List(1) = "Banggai" cbopenumpang.List(0) = "Dewasa" cbopenumpang.List(1) = "Remaja" cbopenumpang.List(2) = "Anak-Anak" Tampildata xpcetak.Enabled = False xpsimpan.Enabled = False xpbatal.Enabled = False cekjmltiket End Sub Private Sub Tampildata() Set RsTampil = Nothing RsTampil.Open "select namapen,no4,tglbeli,jambeli,asal from tblbeli where statust4='Terisi' and tglbeli= #" & B1 & "/" & T1 & "/" & Th1 & "# order by no4,namapen", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = RsTampil Grid1.Refresh Grid1.Columns(0).Width = 2500 Grid1.Columns(1).Width = 1000 Grid1.Columns(2).Width = 1000 Grid1.Columns(3).Width = 1000 Grid1.Columns(4).Width = 2000 Grid1.Columns(1).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(3).Alignment = dbgCenter Grid1.Columns(0).Caption = " Nama Penumpang" Grid1.Columns(1).Caption = " No.T4" Grid1.Columns(2).Caption = " Tgl.Beli" Grid1.Columns(3).Caption = " Jam.Beli" Grid1.Columns(4).Caption = " Asal" If RsTampil.RecordCount > 0 Then Grid1.Enabled = True Grid1.Caption = "Data Penumpang Tanggal " + Format(dtptgljual) Else Grid1.Enabled = False Grid1.Caption = " ga ada tu datanya " End If End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub Grid1_Click() akseshps End Sub Private Sub Timer1_Timer() txtjamjual.Text = Time End Sub Private Sub txtnot4_Lostfocus() If cek.Value = vbChecked Then ckode = Trim(txtnot4.Text) If ckode = Empty Then Exit Sub End If
  18. 18. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 18 If Rspesant4.RecordCount > 0 Then Rspesant4.MoveFirst End If Set Rspesant4 = Nothing Rspesant4.Open "[tblpesant4] where no4 ='" & ckode & "' and status='Ok'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rspesant4.EOF Then cekpenum End If Set Rspesant4 = Nothing Rspesant4.Open "[tblpesant4] where no4 ='" & ckode & "' and status='Pesan'", Koneksi, adOpenDynamic, adLockOptimistic If Rspesant4.EOF Then MsgBox "Nomor tempat tersebut tidak dalam status dipesan!", 0 + 64, "Konfirmasi" xpcetak.Enabled = False xpsimpan.Enabled = False Exit Sub Else kosong aktif txtnama.Enabled = True txtnama.SetFocus Ada1 = False xpsimpan.Enabled = True End If Else ckode = Trim(txtnot4.Text) If ckode = Empty Then Exit Sub End If If Rsnotempat.RecordCount > 0 Then Rsnotempat.MoveFirst End If Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] where no4 ='" & ckode & "'and status='Pesan'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsnotempat.EOF Then MsgBox "nomor tempat tersebut sudah 'dipesan'!", 0 + 64, "Konfirmasi" txtnot4.Text = "" xpcetak.Enabled = False xpsimpan.Enabled = False 'txtnot4.SetFocus Exit Sub End If Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] where no4 ='" & ckode & "'and status='Terisi'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsnotempat.EOF Then cekpenum edit.Visible = True Else Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] where no4 ='" & ckode & "' and status='Kosong'", Koneksi, adOpenDynamic, adLockOptimistic If Rsnotempat.EOF Then MsgBox "Nomor tempat tersebut 'tidak terdaftar'!", 0 + 64, "Konfirmasi" txtnot4.Text = "" txtnot4.SetFocus Exit Sub Else kosong aktif
  19. 19. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 19 txtnama.Enabled = True txtnama.SetFocus Ada1 = False xpsimpan.Enabled = True End If End If End If End Sub Private Sub xpbatal_Click() xpbatal.Enabled = False kk = Grid1.Columns(1) Set Rsbeli = Nothing Rsbeli.Open "[tblbeli] where no4 ='" & kk & "' and statust4='Terisi' and tglbeli = #" & B1 & "/" & T1 & "/" & Th1 & "# ", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbeli.EOF Then byr = Rsbeli!bayar / 2 End If Koneksi.Execute "update tblbeli set statust4='Batal',statuspen='Batal',bayar='" & byr & "' where no4 ='" & kk & "'and tglbeli = #" & B1 & "/" & T1 & "/" & Th1 & "# " Koneksi.Execute "update tblnotempat set status='Kosong' where no4 ='" & kk & "'" txtnot4.SetFocus: Tampildata: cekjmltiket End Sub Private Sub xpcetak_Click() crpcetak1.ReportFileName = App.Path & "" & "rpttiket.rpt" crpcetak1.Formulas(0) = "nama ='" & txtnama & "'" crpcetak1.Formulas(1) = "dari ='" & cbodari & "'" crpcetak1.Formulas(2) = "tujuan ='" & cbotujuan & "'" crpcetak1.Formulas(3) = "ket ='No.: " & txtnot4 & "'" crpcetak1.Formulas(4) = "kategori ='" & cbopenumpang & "'" crpcetak1.Formulas(5) = "tgl ='" & dtptgljual & "'" crpcetak1.Formulas(6) = "tarif ='Rp. " & Format(txtbayar, "#,###,###.#0") & "'" crpcetak1.Formulas(7) = "menerima ='" & Login.TxtNamap.Text & "'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.CopiesToPrinter = 1 crpcetak1. Destination = crptToPrinter crpcetak1.Action = 1 End Sub Private Sub xpkeluar_Click() Unload Me frmmenuutama.Enabled = True End Sub Private Sub dtptgljual_LostFocus() T1 = Left(dtptgljual, 2) B1 = Mid(dtptgljual, 4, 2) Th1 = Right(dtptgljual, 4) End Sub Private Sub tdkaktif() txtalamat.Enabled = False: cbojnskel.Enabled = False: cbodari.Enabled = False: cbotujuan.Enabled = False dtptgljual.Enabled = False: txtnama.Enabled = False: txtbayar.Enabled = False: cbopenumpang.Enabled = False End Sub Private Sub aktif() txtalamat.Enabled = True: cbojnskel.Enabled = True: cbodari.Enabled = True: cbotujuan.Enabled = True dtptgljual.Enabled = True: txtnama.Enabled = True: txtbayar.Enabled = False: cbopenumpang.Enabled = True End Sub Private Sub dccek_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab aktif End If
  20. 20. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 20 End Sub Private Sub txtnama_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab aktif End If End Sub Private Sub dtptgljual_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 cbojnskel_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub cbodari_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub cbotujuan_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub cbopenumpang_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab cekbiaya End If End Sub Private Sub kosong() txtalamat.Text = "": cbojnskel.Text = "": cbodari.Text = "": cbotujuan.Text = "" txtnama.Text = "": txtbayar.Text = "": cbopenumpang.Text = "" End Sub Private Sub xplagi_Click() Tampildata: xpbatal.Enabled = False edit.Value = novbchecked: edit.Visible = False: cekjmltiket: txtnot4.Enabled = True txtnama.Text = "": cek.Value = novbchecked: tdkaktif: kosong: txtnot4.SetFocus End Sub Private Sub txtnot4_KeyDown(KeyCode As Integer, Shift As Integer) If cek.Value = vbChecked Then If KeyCode = vbKeyF1 Then 'txtnot4.Text = "" sql="Select tblpesant4.nama,tblpesant4.no4,tblpesant4.tglpesan,tblnotempat.jnstiket from tblpesant4,tblnotempat where tblpesant4.no4 like '" & txtnot4 & "%' and tblpesant4.status='Pesan' and tblpesant4.no4=tblnotempat.no4 and tblpesant4.tglpesan > #" & B1 & "/" & T1 & "/" & Th1 & "# order by tblpesant4.nama,tblpesant4.no4" Ada = True frminfo.Caption = ">>> Info Data Pemesan Tiket <<<" frminfo.Grid1.Columns(0).Width = 1500 frminfo.Grid1.Columns(1).Width = 1000 frminfo.Grid1.Columns(2).Width = 1500 frminfo.Grid1.Columns(3).Width = 1000 frminfo.Show vbModal, Me Ada = False txtnot4.Text = frminfo.Kode txtnot4_Lostfocus
  21. 21. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 21 End If If KeyCode = vbKeyReturn Then SendKeys vbTab End If Else If KeyCode = vbKeyF1 Then 'txtnot4.Text = "" sql = "Select jnstiket,no4,status from tblnotempat where no4 like '" & txtnot4 & "%' and status='Kosong' order by jnstiket,no4" Ada = True frminfo.Caption = ">>> Info Nomor Tempat <<<" frminfo.Grid1.Columns(0).Width = 1500 frminfo.Grid1.Columns(1).Width = 1000 frminfo.Grid1.Columns(2).Width = 1500 frminfo.Show vbModal, Me Ada = False txtnot4.Text = frminfo.Kode txtnot4_Lostfocus End If If KeyCode = vbKeyReturn Then SendKeys vbTab End If End If End Sub Private Sub txtbayar_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 cekpenum() ckode = Trim(txtnot4.Text) If ckode = Empty Then Exit Sub End If If Rsbeli.RecordCount > 0 Then Rsbeli.MoveFirst End If Set Rsbeli = Nothing Rsbeli.Open "[tblbeli] where no4='" & ckode & "' and statust4='Terisi' and statuspen='Ok' and tglbeli= #" & B1 & "/" & T1 & "/" & Th1 & "#", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbeli.EOF Then tdkaktif isiformbeli xpsimpan.Enabled = False Ada1 = True End If End Sub Private Sub isiformbeli() txtalamat.Text = Rsbeli!asal: cbodari.Text = Rsbeli!dari: cbotujuan.Text = Rsbeli!tujuan: txtnama.Text = Rsbeli!namapen cbojnskel.Text = Rsbeli!jnskel: cbopenumpang.Text = Rsbeli!jenispen: txtbayar.Text = Rsbeli!bayar End Sub Private Sub cekbiaya() If cek.Value = vbChecked Then ckode = Trim(txtnot4.Text) Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] where no4 ='" & ckode & "'and status='Pesan'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsnotempat.EOF Then jns = Rsnotempat!jnstiket End If If cbopenumpang.Text = "Dewasa" Then Set Rsbytiket = Nothing
  22. 22. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 22 Rsbytiket.Open "[tblbytiket] where jnstiket ='" & jns & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!umum End If ElseIf cbopenumpang.Text = "Remaja" Then Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & jns & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!Pelajar End If ElseIf cbopenumpang.Text = "Anak-Anak" Then Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & jns & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!Anak2 End If End If txtbayar.Text = byt1 xpcetak.Enabled = True xpsimpan.Enabled = True 'xpcetak.SetFocus Else If edit.Value = vbChecked Then ckode = Trim(txtnot4.Text) Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] where no4 ='" & ckode & "' and status='Terisi'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsnotempat.EOF Then ll = Rsnotempat!jnstiket End If If cbopenumpang.Text = "Dewasa" Then Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & ll & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!umum End If ElseIf cbopenumpang.Text = "Remaja" Then Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & ll & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!Pelajar End If ElseIf cbopenumpang.Text = "Anak-Anak" Then Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & ll & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!Anak2 End If End If txtbayar.Text = byt1 xpcetak.Enabled = True xpsimpan.Enabled = True 'xpcetak.SetFocus Else ckode = Trim(txtnot4.Text) Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] where no4 ='" & ckode & "' and status='Kosong'", Koneksi, adOpenDynamic, adLockOptimistic
  23. 23. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 23 If Not Rsnotempat.EOF Then ll = Rsnotempat!jnstiket End If If cbopenumpang.Text = "Dewasa" Then Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & ll & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!umum End If ElseIf cbopenumpang.Text = "Remaja" Then Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & ll & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!Pelajar End If ElseIf cbopenumpang.Text = "Anak-Anak" Then Set Rsbytiket = Nothing Rsbytiket.Open "[tblbytiket] where jnstiket ='" & ll & "'", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbytiket.EOF Then byt1 = Rsbytiket!Anak2 End If End If txtbayar.Text = byt1 xpcetak.Enabled = True xpsimpan.Enabled = True 'xpcetak.SetFocus End If End If End Sub Private Sub xpsimpan_Click() gg = Login.TxtNamap.Text If edit.Value = vbChecked Then xpsimpan.Enabled = False Set Rsbeli = Nothing Rsbeli.Open "[tblbeli] where no4 ='" & txtnot4 & "' and statust4='Terisi' and tglbeli = #" & B1 & "/" & T1 & "/" & Th1 & "# ", Koneksi, adOpenDynamic, adLockOptimistic If Not Rsbeli.EOF Then Koneksi.Execute "update tblbeli set namapen='" & txtnama & "',jnskel='" & cbojnskel & "',asal='" & txtalamat & "',dari='" & cbodari & "',tujuan='" & cbotujuan & "',jenispen='" & cbopenumpang & "',bayar='" & txtbayar & "' where no4 ='" & txtnot4 & "'and statust4='Terisi' and statuspen='Ok' and tglbeli = #" & B1 & "/" & T1 & "/" & Th1 & "# " Tampildata cekjmltiket End If Else If txtnama.Text = Empty Then MsgBox "Nama penumpang tidak boleh kosong!", 0 + 64, "Konfirmasi" txtnama.SetFocus Exit Sub ElseIf txtalamat.Text = Empty Then MsgBox "alamat penumpang tidak boleh kosong!", 0 + 64, "Konfirmasi" txtalamat.SetFocus Exit Sub ElseIf cbojnskel.Text = Empty Then MsgBox "Jenis kelamin tidak boleh kosong!", 0 + 64, "Konfirmasi" cbojnskel.SetFocus Exit Sub ElseIf cbodari.Text = Empty Then MsgBox "tempat keberangkatan tidak boleh kosong!", 0 + 64, "Konfirmasi" cbodari.SetFocus
  24. 24. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 24 Exit Sub ElseIf cbotujuan.Text = Empty Then MsgBox "tujuan keberangkatan tidak boleh kosong!", 0 + 64, "Konfirmasi" cbotujuan.SetFocus Exit Sub ElseIf cbopenumpang.Text = Empty Then MsgBox "kategori penumpang tidak boleh kosong!", 0 + 64, "Konfirmasi" cbopenumpang.SetFocus Exit Sub Else xpsimpan.Enabled = False Set Rsbeli = Nothing Rsbeli.Open "[tblbeli] where no4 ='" & txtnot4 & "' and tglbeli = #" & B1 & "/" & T1 & "/" & Th1 & "# ", Koneksi, adOpenDynamic, adLockOptimistic If Rsbeli.EOF Then Rsbeli.AddNew Rsbeli!no4 = txtnot4.Text Rsbeli!tglbeli = dtptgljual Rsbeli!namapen = txtnama.Text Rsbeli!asal = txtalamat.Text Rsbeli!jnskel = cbojnskel.Text Rsbeli!Statust4 = "Terisi" Rsbeli!jambeli = txtjamjual.Text Rsbeli!dari = cbodari.Text Rsbeli!tujuan = cbotujuan.Text Rsbeli!jenispen = cbopenumpang.Text Rsbeli!bayar = txtbayar.Text Rsbeli!statuspen = "Ok" Rsbeli!Kasir = gg Rsbeli.Update Koneksi.Execute "update tblnotempat set status='Terisi' where no4='" & txtnot4 & "'" Koneksi.Execute "update tblpesant4 set status='Ok' where no4='" & txtnot4 & "'and status='Pesan'" Else Rsbeli.AddNew Rsbeli!no4 = txtnot4.Text Rsbeli!tglbeli = dtptgljual Rsbeli!namapen = txtnama.Text Rsbeli!asal = txtalamat.Text Rsbeli!jnskel = cbojnskel.Text Rsbeli!Statust4 = "Terisi" Rsbeli!jambeli = txtjamjual.Text Rsbeli!dari = cbodari.Text Rsbeli!tujuan = cbotujuan.Text Rsbeli!jenispen = cbopenumpang.Text Rsbeli!bayar = txtbayar.Text Rsbeli!statuspen = "Ok" Rsbeli!Kasir = gg Rsbeli.Update Koneksi.Execute "update tblnotempat set status='Terisi' where no4='" & txtnot4 & "'" Koneksi.Execute "update tblpesant4 set status='Ok' where no4='" & txtnot4 & "'and status='Pesan'" End If Rsbeli.Requery Tampildata cekjmltiket End If End If End Sub Private Sub cekjmltiket() Set Rsnotempat = Nothing Rsnotempat.Open "[tblnotempat] ", Koneksi, adOpenDynamic, adLockOptimistic tjml = 0 ks = 0 pesan = 0 jual = 0
  25. 25. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 25 If Rsnotempat.RecordCount > 0 Then tjml = Rsnotempat.RecordCount Rsnotempat.MoveFirst Do While Not Rsnotempat.EOF If Rsnotempat!Status = "Kosong" Then ks = ks + 1 ElseIf Rsnotempat!Status = "Pesan" Then pesan = pesan + 1 ElseIf Rsnotempat!Status = "Terisi" Then jual = jual + 1 End If Rsnotempat.MoveNext Loop End If stb.Panels(1).Width = 2050 stb.Panels(2).Width = 2050 stb.Panels(3).Width = 2050 stb.Panels(4).Width = 2050 stb.Panels(1).Text = "All Tempat : " + Format(tjml, "###,##0") stb.Panels(2).Text = "T4 yg kosong : " + Format(ks, "###,##0") stb.Panels(3).Text = "T4 yg Dipesan : " + Format(pesan, "###,##0") stb.Panels(4).Text = "T4 yg Terisi : " + Format(jual, "###,##0") End Sub Private Sub aksesedit() Dim lihat, pass lihat = "Masukkan Hak Akses Edit !" pass = InputBox(lihat, "Masukkan") If pass <> txtnot4.Text Then MsgBox "Hak akses anda tidak sesuai !", , "Ulangi lagi" edit.Value = novbchecked Exit Sub Else MsgBox "Hak akses terbuka!", , "Konfirmasi" Ada1 = True txtnot4.Enabled = False xpsimpan.Enabled = True aktif txtnama.SetFocus End If End Sub Private Sub akseshps() Dim lihat, pass lihat = "Masukkan Hak Akses Pembatalan !" pass = InputBox(lihat, "Masukkan") If pass <> Grid1.Columns(1) Then MsgBox "Hak akses anda tidak sesuai !", , "Ulangi lagi" xpbatal.Enabled = False Exit Sub Else MsgBox "Hak akses pembatalan terbuka!", , "Konfirmasi" xpbatal.Enabled = True xpbatal.SetFocus Ada1 = True End If End Sub -----------------------------------------------------------------------------------------------------------------------------------
  26. 26. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 26 Form Info – FrmInfo 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 frmjualtiket.Ada Then Ado.RecordSource = frmjualtiket.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 ----------------------------------------------------------------------------------------------------------------------------------- Grid1 Ado
  27. 27. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 27 Desain Tiket pada Cystal Report Hasil Ketika pencetakkan : ----------------------------------------------------------------------------------------------------------------------------------- Form Laporan Penumpang – Frmcetakpen Listing Frmcetakpen Dim RsTampil As New ADODB.Recordset Public T1, T2, B1, B2, Th1, Th2 As Integer Private Sub Form_Activate() frmmenuutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase dtptgl1 = Date dtptgl2 = Date dtpTgl1_LostFocus xptampil xpcetak xpkeluar lbljml Dtptgl2 Dtptgl1 optbatal optok Grid1
  28. 28. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 28 DTPTgl2_LostFocus xpcetak.Enabled = False End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close 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 Tampildata() Set RsTampil = Nothing RsTampil.Open "select namapen,no4,tglbeli,jambeli,asal from tblbeli where statuspen='Ok' and (Tglbeli >= #" & B1 & "-" & T1 & "-" & Th1 & "# " & _ "and Tglbeli <= #" & B2 & "-" & T2 & "-" & Th2 & "# ) order by no4,namapen", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = RsTampil Grid1.Columns(0).Width = 2000 Grid1.Columns(1).Width = 750 Grid1.Columns(2).Width = 1000 Grid1.Columns(3).Width = 1250 Grid1.Columns(4).Width = 1500 Grid1.Columns(1).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(3).Alignment = dbgCenter Grid1.Columns(0).Caption = " Nama Penumpang" Grid1.Columns(1).Caption = " No.T4" Grid1.Columns(2).Caption = "Tgl.Beli Tiket" Grid1.Columns(3).Caption = "Jam Beli Tiket" Grid1.Columns(4).Caption = " Asal" If dtptgl1 = dtptgl2 Then gg = Format(dtptgl1) Else gg = Format(dtptgl1) + " s/d " + Format(dtptgl2) End If If RsTampil.RecordCount > 0 Then Grid1.Enabled = True xpcetak.Enabled = True Grid1.Caption = "Penumpang Yg Jadi Berangkat Tgl. " + gg lbljml.Caption = RsTampil.RecordCount Else Grid1.Enabled = False xpcetak.Enabled = False lbljml.Caption = RsTampil.RecordCount End If End Sub Private Sub optbatal_Click() xpcetak.Enabled = False End Sub Private Sub optok_Click() xpcetak.Enabled = False End Sub Private Sub xpcetak_Click() If optok = True Then crpcetak1.ReportFileName = App.Path & "" & "rptcetakpen.rpt" crpcetak1.SelectionFormula = " {tblbeli.statuspen} ='Ok' and {tblbeli.tglbeli} >= #" & B1 & "-" & T1 & "-" & Th1 & "# " & _ "and {tblbeli.tglbeli} <= #" & B2 & "-" & T2 & "-" & Th2 & "#"
  29. 29. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 29 If dtptgl1 = dtptgl2 Then tt = Format(dtptgl1) Else tt = Format(dtptgl1) + " s/d " + Format(dtptgl2) End If crpcetak1.Formulas(0) = "tgl ='" & tt & "'" crpcetak1.Formulas(1) = "status ='Jadi Berangkat'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If If optbatal = True Then crpcetak1.ReportFileName = App.Path & "" & "rptcetakpen.rpt" crpcetak1.SelectionFormula = " {tblbeli.statuspen} ='Batal' and {tblbeli.tglbeli} >= #" & B1 & "-" & T1 & "-" & Th1 & "# " & _ "and {tblbeli.tglbeli} <= #" & B2 & "-" & T2 & "-" & Th2 & "#" If dtptgl1 = dtptgl2 Then tt = Format(dtptgl1) Else tt = Format(dtptgl1) + " s/d " + Format(dtptgl2) End If crpcetak1.Formulas(0) = "tgl ='" & tt & "'" crpcetak1.Formulas(1) = "status ='Batal Berangkat'" crpcetak1.RetrieveDataFiles crpcetak1.WindowState = crptMaximized crpcetak1.Action = 1 End If End Sub Private Sub xpkeluar_Click() Unload Me frmmenuutama.Enabled = True End Sub Private Sub xptampil_Click() If optok = True Then Tampildata End If If optbatal = True Then Tampildata1 End If End Sub Private Sub Tampildata1() Set RsTampil = Nothing RsTampil.Open "select namapen,no4,tglbeli,jambeli,asal from tblbeli where statuspen='Batal' and (Tglbeli >= #" & B1 & "-" & T1 & "-" & Th1 & "# " & _ "and Tglbeli <= #" & B2 & "-" & T2 & "-" & Th2 & "# ) order by no4,namapen", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = RsTampil Grid1.Columns(0).Width = 2000 Grid1.Columns(1).Width = 750 Grid1.Columns(2).Width = 1000 Grid1.Columns(3).Width = 1250 Grid1.Columns(4).Width = 1500 Grid1.Columns(1).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(3).Alignment = dbgCenter Grid1.Columns(0).Caption = " Nama Penumpang" Grid1.Columns(1).Caption = " No.T4" Grid1.Columns(2).Caption = "Tgl.Beli Tiket" Grid1.Columns(3).Caption = "Jam Beli Tiket" Grid1.Columns(4).Caption = " Asal" If dtptgl1 = dtptgl2 Then gg = Format(dtptgl1) Else gg = Format(dtptgl1) + " s/d " + Format(dtptgl2) End If
  30. 30. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 30 If RsTampil.RecordCount > 0 Then Grid1.Enabled = True xpcetak.Enabled = True Grid1.Caption = "Penumpang Yg Batal Berangkat Tgl. " + gg lbljml.Caption = RsTampil.RecordCount Else Grid1.Enabled = False xpcetak.Enabled = False lbljml.Caption = RsTampil.RecordCount End If End Sub ----------------------------------------------------------------------------------------------------------------------------------- Desain Laporan Penumpang pada Crystal Report seperti gambar berikut ini : ----------------------------------------------------------------------------------------------------------------------------------- Form Kosongkan Tempat – Frmubahstst4 Listing Frmubahstst4 Public T1, B1, Th1 As Integer Dim RsTampil As New ADODB.Recordset Private Sub edit_Click() If edit.Value = vbChecked Then aksesedit Else tdkaktif xpubah xpkeluar xprefresh Grid1 edit cbostatus Opt1 Opt2
  31. 31. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 31 xpkeluar.SetFocus End If End Sub Private Sub Form_Activate() frmmenuutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase Tampildata tdkaktif cbostatus.List(0) = "Terisi" cbostatus.List(1) = "Pesan" Grid1.Enabled = False xpubah.Enabled = False End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub Tampildata() T1 = Left(Date, 2) B1 = Mid(Date, 4, 2) Th1 = Right(Date, 4) If cbostatus.Text = "Pesan" Then Set RsTampil = Nothing RsTampil.Open "select tblnotempat.jnstiket,tblpesant4.no4,tblpesant4.tglpesan from tblnotempat,tblpesant4 where tblpesant4.no4=tblnotempat.no4 and tblpesant4.status='Pesan' and tblpesant4.tglpesan < #" & B1 & "/" & T1 & "/" & Th1 & "# order by tblpesant4.no4 ", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = RsTampil Grid1.Columns(0).Width = 2000 Grid1.Columns(1).Width = 750 Grid1.Columns(2).Width = 1000 Grid1.Columns(1).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(0).Caption = " Jenis Tiket" Grid1.Columns(1).Caption = " No.T4" Grid1.Columns(2).Caption = " Tgl.Pesan" If RsTampil.RecordCount > 0 Then Grid1.Caption = "Data Tempat yang berstatus " + cbostatus Grid1.Enabled = True xpubah.Enabled = True Else Grid1.Caption = "ga ada tu datanya " Grid1.Enabled = False xpubah.Enabled = False End If End If If cbostatus.Text = "Terisi" Then Set RsTampil = Nothing RsTampil.Open "select tblnotempat.jnstiket,tblbeli.no4,tblbeli.tglbeli from tblnotempat,tblbeli where tblbeli.no4=tblnotempat.no4 and tblbeli.statust4='Terisi' and tblbeli.tglbeli < #" & B1 & "/" & T1 & "/" & Th1 & "# order by tblbeli.no4 ", Koneksi, adOpenDynamic, adLockOptimistic Set Grid1.DataSource = RsTampil Grid1.Columns(0).Width = 2000 Grid1.Columns(1).Width = 750 Grid1.Columns(2).Width = 1000 Grid1.Columns(1).Alignment = dbgCenter Grid1.Columns(2).Alignment = dbgCenter Grid1.Columns(0).Caption = " Jenis Tiket" Grid1.Columns(1).Caption = " No.T4" Grid1.Columns(2).Caption = " Tgl.Terisi" If RsTampil.RecordCount > 0 Then Grid1.Caption = "Data Tempat yang berstatus " + cbostatus Grid1.Enabled = True xpubah.Enabled = True
  32. 32. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 32 Else Grid1.Caption = "ga ada tu datanya " Grid1.Enabled = False xpubah.Enabled = False End If End If End Sub Private Sub Grid1_Click() xpubah.Enabled = True End Sub Private Sub xpkeluar_Click() Unload Me frmmenuutama.Enabled = True End Sub Private Sub xprefresh_Click() Tampildata End Sub Private Sub cbostatus_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub xprefresh_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then SendKeys vbTab End If End Sub Private Sub xpubah_Click() If cbostatus.Text = Empty Then MsgBox "Pilih pilih status tempat!", , "Konfirmasi" cbostatus.SetFocus Exit Sub End If xpubah.Enabled = False kk = Grid1.Columns(1) If opt1 = True Then If cbostatus.Text = "Terisi" Then Koneksi.Execute "update tblnotempat set status='Kosong' where no4='" & kk & "'and status='Terisi'" Koneksi.Execute "update tblbeli set statust4='Ok' where no4='" & kk & "'and statust4='Terisi'" End If If cbostatus.Text = "Pesan" Then Koneksi.Execute "update tblnotempat set status='Kosong' where no4='" & kk & "'and status='Pesan'" Koneksi.Execute "update tblpesant4 set status='Batal' where no4='" & kk & "'and status='Pesan'" End If End If If opt2 = True Then If cbostatus.Text = "Terisi" Then Koneksi.Execute "update tblnotempat set status='Kosong' where status='Terisi'" Koneksi.Execute "update tblbeli set statust4='Ok' where statust4='Terisi'" End If If cbostatus.Text = "Pesan" Then Koneksi.Execute "update tblnotempat set status='Kosong'where status='Pesan'" Koneksi.Execute "update tblpesant4 set status='Batal' where status='Pesan'" End If End If Tampildata End Sub Private Sub aksesedit() Dim lihat, pass lihat = "Masukkan Hak Akses Edit !" pass = InputBox(lihat, "Masukkan") If pass <> Login.TxtPass Then MsgBox "Hak akses anda tidak sesuai !", , "Ulangi lagi" edit.Value = novbchecked Exit Sub
  33. 33. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 33 Else MsgBox "Hak akses terbuka!", , "Konfirmasi" edit.Visible = False aktif cbostatus.SetFocus Ada1 = True End If End Sub Private Sub tdkaktif() cbostatus.Enabled = False: xprefresh.Enabled = False: xpubah.Enabled = False End Sub Private Sub aktif() cbostatus.Enabled = True: xprefresh.Enabled = True: xpubah.Enabled = True End Sub ----------------------------------------------------------------------------------------------------------------------------------- Form Ubah / Tambah Password - Frmubahpass Listing Frmubahpass Dim RsTampil As New ADODB.Recordset Private Sub CmdBatal_Click() txtnm.Text = "" txtpas.Text = "" Cmdsimpan.Enabled = False Cmdhapus.Enabled = False txtnm.SetFocus End Sub Private Sub CmdHapus_Click() Cmdhapus.Enabled = False Rskasir.MoveFirst Rskasir.Find ("kasir = '" & Trim(txtnm.Text) & "'") If Rskasir.EOF Then Y = MsgBox("Nama kasir & Password tidak dikenal ???", vbOKOnly, "Konfirmasi") CmdBatal_Click Exit Sub Else If Rskasir.RecordCount = 1 Then Y = MsgBox("Maaf Password tidak dapat dihapus ?", vbOKOnly, "Konfirmasi") CmdBatal_Click Exit Sub Else Y = MsgBox("Benar Anda Ingin Hapus ???", vbYesNo + vbQuestion + vbDefaultButton2, "Hapus Password") Select Case Y Case vbYes Rskasir.Delete Case vbNo End Select End If End If CmdBatal_Click End Sub Private Sub cmdkeluar_Click() Unload Me TxtNm TxtPas cmdbatal cmdkeluar cmdhapus cmdsimpan
  34. 34. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 34 frmmenuutama.Enabled = True End Sub Private Sub CmdSimpan_Click() IsiTabel CmdBatal_Click End Sub Private Sub Form_Activate() frmmenuutama.Enabled = False End Sub Private Sub Form_Load() BukaDatabase txtnm.Text = "" txtpas.Text = "" Cmdsimpan.Enabled = False Cmdhapus.Enabled = False End Sub Private Sub IsiTabel() Rskasir.MoveFirst Rskasir.Find ("kasir = '" & Trim(txtnm.Text) & "'") If Rskasir.EOF Then Rskasir.AddNew Rskasir!Kasir = txtnm Rskasir!Pss = txtpas.Text Rskasir.Update Else Rskasir.Requery Rskasir!Kasir = txtnm Rskasir!Pss = txtpas.Text Rskasir.Update End If End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close End Sub Private Sub txtpas_Change() If Len(txtnm.Text) > 1 And Len(txtpas.Text) > 1 Then Cmdsimpan.Enabled = True Cmdhapus.Enabled = True Else Cmdsimpan.Enabled = False Cmdhapus.Enabled = False End If End Sub ----------------------------------------------------------------------------------------------------------------------------------- Form Menu Utama – Frmmenuutama Stb Timer1
  35. 35. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 35 Menu dan Sub Menu Listing FrmMenuutama Dim jdl As String Private Sub Form_Activate() stb.Panels(1).Text = "Kasir : " + Login.TxtNamap.Text stb.Panels(4).Text = "Aplikasi Penjualan Tiket Kapal" End Sub Private Sub Form_Load() Me.Caption = "<<< Aplikasi Penjualan Tiket Kapal >>>" jdl = Me.Caption Login.Show Login.TxtNamap.SetFocus stb.Panels(1).Text = "Kasir : " + Login.TxtNamap.Text stb.Panels(1).Width = 2500 stb.Panels(2).Text = Format(Date, "Dddd, dd Mmmm yyyy") stb.Panels(2).Width = 2700 stb.Panels(4).Text = "Aplikasi Penjualan Tiket Kapal" stb.Panels(4).Width = 4500 stb.Panels(5).Width = 1000 stb.Panels(5).Text = "Admin" End Sub Private Sub mnexit_Click() Y = MsgBox("Benar Anda Ingin Keluar Dari Sistem ?", vbYesNo + vbQuestion + vbDefaultButton1, "Konfirmasi") Select Case Y Case vbYes End Case vbNo End Select End Sub Private Sub mnjual_Click() frmjualtiket.Show End Sub Private Sub mnnot4_Click() frmnot4.Show End Sub mnberkas mntiket mnnot4 mnlayanan mnpesantiket mnjual mnlap mnpen mnutility ubahnosts mnubahpass mnexit mnbackup
  36. 36. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 36 Private Sub mnpen_Click() frmcetakpen.Show End Sub Private Sub mnpesantiket_Click() frmpesant4.Show End Sub Private Sub mntiket_Click() frmbytiket.Show End Sub Private Sub mnubahpass_Click() FrmUbahPass.Show End Sub Private Sub Timer1_Timer() jdl = Mid(jdl, 2, Len(jdl) - 1) & Mid(jdl, 1, 1) Me.Caption = jdl stb.Panels(3).Text = Format(Time, "hh:mm:ss AM/PM") stb.Panels(3).Width = 1800 End Sub Private Sub ubahnosts_Click() frmubahstst4.Show End Sub ----------------------------------------------------------------------------------------------------------------------------------- Form Login Kasir – FrmLogin Listing FrmLogin Private Sub Form_Load() BukaDatabase frmmenuutama.Enabled = False frmmenuutama.Show End Sub Private Sub CmdBatal_Click() End End Sub Private Sub cmdok_Click() Rskasir.MoveFirst Rskasir.Find ("Kasir = '" & Trim(TxtNamap.Text) & "'") If Rskasir.EOF Then x = MsgBox("Maaf !, Nama Kasir Salah Ulangi Lagi ", 0 + 16, "Konfirmasi") TxtNamap.SetFocus Exit Sub End If If TxtNamap = Rskasir!Kasir And TxtPass = Rskasir!Pss Then Login.Hide Koneksi.Close frmmenuutama.Enabled = True frmmenuutama.Show Else x = MsgBox("Maaf !, Password Salah Ulangi Lagi ", 0 + 16, "Konfirmasi") TxtPass.SetFocus Exit Sub End If End Sub Private Sub Form_Unload(Cancel As Integer) Koneksi.Close Txtnamap Txtpass cmdok cmdbatal
  37. 37. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 37 TblpesanT4 TblBeli No. Nama Field Type Width Keterangan No. Nama Field Type Width Keterangan 1 No4 C 4 No tempat 1 No4 C 4 Nomor tempat 2 Tglpesan D Date Tanggal pesan tiket 2 Tglbeli D Date Tanggal beli 3 Nama C 50 Nama pemesan 3 Jambeli T Time Jam beli 4 Notelp C 13 No telpon / hp 4 Namapen C 50 Nama penumpang 5 Status C 15 Status tempat 5 Asal C 50 Asal penumpang 6 Jampesan T Time Jam pesan 6 Jnskel C 15 Jenis kelamin 7 Dari C 30 Tempat keberangkatan 7 Statust4 C 15 Status tempat 8 Tujuan C 30 Tujuan Kapal 8 Bayar N Single Bayaran 9 Kasir C 25 Nama Kasir 9 Statuspen C 15 Status penumpang 10 Dari C 30 Tempat keberangkatan 11 Tujuan C 30 Tujuan Kapal 12 Jenispen C 10 Jenis Penumpang 13 Kasir C 25 Nama Kasir TblByTiket TblNotempat No. Nama Field Type Width Keterangan No. Nama Field Type Width Keterangan 1 Jnstiket * C 15 Jenis Tiket 1 Jnstiket C 15 Jenis Tiket 2 Anak2 N Single Tiket Anak 2 No4 * C 4 No Tempat 3 Pelajar N Single Tiket Pelajar 3 Status C 15 Status tempat 4 Umum N Single Tiket Umum 5 Fasilitas C 150 Fasilitas Tblkasir No. Nama Field Type Width Keterangan 1 Kasir C 25 Nama kasir 2 Pss C 10 Passw ord DATABASE PENJUALAN TIKET KAPAL BANGKEP End Sub Private Sub TxtNamap_GotFocus() TxtNamap.SelStart = 0 TxtNamap.SelLength = Len(TxtNamap) End Sub Private Sub TxtNamap_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then SendKeys vbTab End If End Sub Private Sub TxtPass_GotFocus() TxtPass.SelStart = 0 TxtPass.SelLength = Len(TxtPass) End Sub Private Sub TxtPass_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdok_Click End If End Sub ----------------------------------------------------------------------------------------------------------------------------------- Database Penjualan Tiket – dbsTiket_kapal
  38. 38. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 38 Untuk pembuatan Database dapat anda gunakan Ms. Access, seperti tampilan gambar berikut ini : Jika direlasikan, maka akan menjadi :
  39. 39. Ebook Pembuatan Aplikasi Tiket Kapal Menggunakan Visual Basic 6.0 Mudah dipelajari dan dikembangkan --------------------- 39 MULAI TEMPAT PENJUALAN TIKET DIBUKA BELI TIKET ? BUAT TIKET CETAK TIKET SUDAH PESAN T4? PERIKSA T4 KOSONG CEK T4 YANG DIPESAN INGIN PESAN T4? INPUT LAYANAN KELUAR PERIKSA T4 KOSONG DATABASE INPUT TEMPAT CETAK PENUMPANG SELESAI YA TIDAK TIDAK YA YA BELUM BATALKAN TIKET ? TIDAK CEK T4 YANG DIPAKAIBATALKAN TEMPAT ADA ? YA TIDAK YA ADA ? YA TIDAK BATALKAN TEMPAT ?YA TIDAK PROSES LAYANAN PENJUALAN TIKET KAPAL DELLSA SECARA UMUM

×