You are on page 1of 36

frmUtama.frm Private Sub mCari_Click() frmCari.

Show End Sub Private Sub MDIForm_Load() Call mLogin_Click End Sub Private Sub MDIForm_Unload(Cancel As Integer) End End Sub Private Sub mExim_Click() frmExim.Show End Sub Private Sub mKapal_Click() frmKapal.Show End Sub Private Sub mKeluar_Click() End End Sub Private Sub mKunjung_Click() frmKunjung.Show End Sub Private Sub mlExim_Click() Set koneksi = New ADODB.Connection koneksi.Open "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" Set hasil = New ADODB.Recordset hasil.Open "SELECT * FROM tblExim" _ , koneksi, adOpenStatic, adLockOptimistic Set drExim.DataSource = hasil drExim.Sections("Isi").Controls("tKdExim").DataField = "KdExim" drExim.Sections("Isi").Controls("tNmUsaha").DataField = "Nama" drExim.Sections("Isi").Controls("tAlamat").DataField = "Alamat" drExim.Sections("Isi").Controls("tSiup").DataField = "siup" drExim.Sections("Isi").Controls("tTanggal").DataField = "tanggal" drExim.Show Set koneksi = Nothing

Set hasil = Nothing End Sub Private Sub mlKapal_Click() Set koneksi = New ADODB.Connection koneksi.Open "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" Set hasil = New ADODB.Recordset hasil.Open "SELECT * FROM tblKapal" _ , koneksi, adOpenStatic, adLockOptimistic Set drKapal.DataSource = hasil drKapal.Sections("Isi").Controls("tKdKapal").DataField = "KdKapal" drKapal.Sections("Isi").Controls("tNmKapal").DataField = "NmKapal" drKapal.Sections("Isi").Controls("tNegara").DataField = "Negara" drKapal.Sections("Isi").Controls("tNmUsaha").DataField = "NmUsaha" drKapal.Sections("Isi").Controls("tJnsUsaha").DataField = "JnsUsaha" drKapal.Sections("Isi").Controls("tDwt").DataField = "dwt" drKapal.Show Set koneksi = Nothing Set hasil = Nothing End Sub Private Sub mlKunjung_Click() Set koneksi = New ADODB.Connection koneksi.Open "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" Set hasil = New ADODB.Recordset hasil.Open "SELECT `tblkapal`.`nmKapal`, `tblkunjung`.`kdKapal`," & _ "`tblkunjung`.`asal`, `tblkunjung`.`tujuan`, `tblkunjung`.`bongkar`," & _ "`tblkunjung`.`muat`, `tblkunjung`.`tiba`, `tblkunjung`.`berangkat` " & _ "FROM `tblkunjung`, `tblkapal` WHERE (`tblkunjung`.`kdKapal` = " & _ "`tblkapal`.`kdKapal`)", koneksi, adOpenStatic, adLockOptimistic Set drKunjung.DataSource = hasil drKunjung.Sections("Isi").Controls("tKdKapal").DataField = "KdKapal" drKunjung.Sections("Isi").Controls("tNmKapal").DataField = "NmKapal" drKunjung.Sections("Isi").Controls("tAsal").DataField = "Asal" drKunjung.Sections("Isi").Controls("tTujuan").DataField = "Tujuan" drKunjung.Sections("Isi").Controls("tBongkar").DataField = "Bongkar" drKunjung.Sections("Isi").Controls("tMuat").DataField = "Muat" drKunjung.Sections("Isi").Controls("tTiba").DataField = "Tiba" drKunjung.Sections("Isi").Controls("tBerangkat").DataField = "Berangkat" drKunjung.Show

Set koneksi = Nothing Set hasil = Nothing End Sub Private Sub mlMohon_Click() Set koneksi = New ADODB.Connection koneksi.Open "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" Set hasil = New ADODB.Recordset hasil.Open "SELECT `tblkapal`.`nmKapal`, `tblexim`.`nama`," & _ "`tblmohon`.`kdKapal`, `tblmohon`.`kdExim`, `tblmohon`.`asal`," & _ "`tblmohon`.`tujuan`, `tblmohon`.`komoditi`, `tblmohon`.`jumlah`," & _ "`tblmohon`.`tanggal` FROM `tblmohon`, `tblkapal`, `tblexim` " & _ "WHERE ((`tblmohon`.`kdKapal` = `tblkapal`.`kdKapal`) AND " & _ "(`tblmohon`.`kdExim` = `tblExim`.`kdExim`))", koneksi, adOpenStatic, adLockOptimistic Set drMohon.DataSource = hasil drMohon.Sections("Isi").Controls("tKdKapal").DataField = "KdKapal" drMohon.Sections("Isi").Controls("tNmKapal").DataField = "NmKapal" drMohon.Sections("Isi").Controls("tKdExim").DataField = "KdExim" drMohon.Sections("Isi").Controls("tNmUsaha").DataField = "Nama" drMohon.Sections("Isi").Controls("tAsal").DataField = "Asal" drMohon.Sections("Isi").Controls("tTujuan").DataField = "Tujuan" drMohon.Sections("Isi").Controls("tKomoditi").DataField = "Komoditi" drMohon.Sections("Isi").Controls("tJumlah").DataField = "Jumlah" drMohon.Sections("Isi").Controls("tTanggal").DataField = "Tanggal" drMohon.Show Set koneksi = Nothing Set hasil = Nothing End Sub Private Sub mLogin_Click() If mLogin.Caption = "Logout" Then frmExim.Hide frmKapal.Hide frmKunjung.Hide frmMohon.Hide frmUser.Hide frmCari.Hide drExim.Hide drKapal.Hide drKunjung.Hide drMohon.Hide mMaster.Enabled = False

mnExim.Enabled = False mUser.Enabled = False mLaporan.Enabled = False sbUtama.SimpleText = "User belum login" mLogin.Caption = "Login" Else frmLogin.Show End If End Sub Private Sub mMohon_Click() frmMohon.Show End Sub Private Sub mUser_Click() frmUser.Show End Sub

frmCari.frm Option Explicit Dim koneksi As New ADODB.Connection Dim perintah As New ADODB.Command Dim hasil As New ADODB.Recordset Private Sub cCari_Click() Dim strQry As String On Error Resume Next If oKapal.Value Then Select Case cbKapal.ListIndex Case 0 strQry = "SELECT * FROM tblKapal WHERE kdKapal LIKE '%" & _ Trim(tbCari.Text) & "%'" Case 1 strQry = "SELECT * FROM tblKapal WHERE nmKapal LIKE '%" & _ Trim(tbCari.Text) & "%'" Case 2 strQry = "SELECT * FROM tblKapal WHERE nmUsaha LIKE '%" & _ Trim(tbCari.Text) & "%'" Case 3 strQry = "SELECT * FROM tblKapal WHERE negara LIKE '%" & _ Trim(tbCari.Text) & "%'" End Select dgCari.Columns(0).Caption = "Kode Kapal" dgCari.Columns(1).Caption = "Nama Kapal" dgCari.Columns(2).Caption = "Asal Negara" dgCari.Columns(3).Caption = "Nama Perusahaan" dgCari.Columns(4).Caption = "Jenis Perusahaan" dgCari.Columns(5).Caption = "D W T" Else Select Case cbUsaha.ListIndex Case 0 strQry = "SELECT * FROM tblExim WHERE kdExim LIKE '%" & _ Trim(tbCari.Text) & "%'" Case 1 strQry = "SELECT * FROM tblExim WHERE nama LIKE '%" & _ Trim(tbCari.Text) & "%'" Case 2 strQry = "SELECT * FROM tblExim WHERE alamat LIKE '%" & _ Trim(tbCari.Text) & "%'" End Select

dgCari.Columns(0).Caption = "Kode Perusahaan" dgCari.Columns(1).Caption = "Nama Perusahaan" dgCari.Columns(2).Caption = "Alamat" dgCari.Columns(3).Caption = "Nomor SIUP" dgCari.Columns(4).Caption = "Tanggal SIUP" End If aCari.RecordSource = strQry aCari.Refresh dgCari.Refresh End Sub Private Sub cTutup_Click() Unload Me End Sub Private Sub oKapal_Click() cbKapal.Visible = oKapal.Value cbUsaha.Visible = Not oKapal.Value aCari.RecordSource = "SELECT * FROM tblKapal" aCari.Refresh dgCari.ClearFields dgCari.Columns(0).Caption = "Kode Kapal" dgCari.Columns(1).Caption = "Nama Kapal" dgCari.Columns(2).Caption = "Asal Negara" dgCari.Columns(3).Caption = "Nama Perusahaan" dgCari.Columns(4).Caption = "Jenis Perusahaan" dgCari.Columns(5).Caption = "D W T" dgCari.Refresh End Sub Private Sub oUsaha_Click() cbKapal.Visible = Not oUsaha.Value cbUsaha.Visible = oUsaha.Value aCari.RecordSource = "SELECT * FROM tblExim" aCari.Refresh dgCari.ClearFields dgCari.Columns(0).Caption = "Kode Perusahaan" dgCari.Columns(1).Caption = "Nama Perusahaan" dgCari.Columns(2).Caption = "Alamat" dgCari.Columns(3).Caption = "Nomor SIUP" dgCari.Columns(4).Caption = "Tanggal SIUP" dgCari.Refresh End Sub

frmExim.frm Option Explicit Dim koneksi As New ADODB.Connection Dim perintah As New ADODB.Command Private Sub cTutup_Click() Unload Me End Sub Private Sub Form_Load() koneksi.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" koneksi.CursorLocation = adUseClient koneksi.Open perintah.ActiveConnection = koneksi 'optMakan.Value = True End Sub Private Sub kosong() On Error Resume Next cbKdExim.Text = "" tbNama.Text = "" tbAlamat.Text = "" tbSiup.Text = "" dpTanggal.Value = Date 'cmbKodeMkn.Text = "" 'cmbNamaMkn.Text = "" 'optMakan.Value = True 'optMinum.Value = False 'txtHarga.Text = Format(0, "Rp#.##0") aExim.Refresh dgExim.Refresh End Sub Private Sub buka() On Error Resume Next tbNama.Enabled = True tbAlamat.Enabled = True tbSiup.Enabled = True dpTanggal.Enabled = True 'optMakan.Enabled = True 'optMinum.Enabled = True 'txtHarga.Enabled = True

End Sub Private Sub tutup() On Error Resume Next tbNama.Enabled = False tbAlamat.Enabled = False tbSiup.Enabled = False dpTanggal.Enabled = False 'optMakan.Enabled = False 'optMinum.Enabled = False 'txtHarga.Enabled = False End Sub Private Sub tampil(hasil As ADODB.Recordset) On Error Resume Next 'cbKdExim.Text = hasil.fields(0).Value tbNama.Text = hasil.fields(1).Value tbAlamat.Text = hasil.fields(2).Value tbSiup.Text = hasil.fields(3).Value dpTanggal.Value = hasil.fields(4).Value 'cmbKodeMkn.Text = hasil.fields(0).Value 'optMakan.Value = hasil.fields(2).Value 'optMinum.Value = Not optMakan.Value 'txtHarga.Text = Format(hasil.fields(3).Value, "Rp#") End Sub Private Sub IsiKode() On Error Resume Next Dim hasil As New ADODB.Recordset perintah.CommandType = adCmdText perintah.CommandText = "SELECT kdexim FROM tblExim" Set hasil = perintah.Execute If hasil.RecordCount < 1 Then Exit Sub Dim i As Integer hasil.MoveFirst cbKdExim.Clear For i = 1 To hasil.RecordCount cbKdExim.AddItem hasil.fields(0).Value hasil.MoveNext Next i Set hasil = Nothing

End Sub Private Sub CekIsi() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String namaTabel = "tblExim" ReDim field(1) ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1) field(1) = "*" vars(1) = "kdexim": relasi(1) = "=": vals(1) = cbKdExim.Text perintah.CommandType = adCmdText perintah.CommandText = selec(namaTabel, field, vars, relasi, vals, ops) Set hasil = perintah.Execute If hasil.RecordCount > 0 Then Call tampil(hasil) End If Set hasil = Nothing End Sub Private Sub comGrp_Click() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim nilai() As Variant Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String '___________________________________ namaTabel = "tblExim" '___________________________________ If comGrp.Nama = "&Simpan" Then

ReDim field(5) ReDim nilai(5) field(1) = "kdexim": nilai(1) = cbKdExim.Text field(2) = "nama": nilai(2) = tbNama.Text field(3) = "alamat": nilai(3) = tbAlamat.Text field(4) = "siup": nilai(4) = tbSiup.Text field(5) = "tanggal": nilai(5) = dpTanggal.Year & "-" _ & dpTanggal.Month & "-" & dpTanggal.Day perintah.CommandType = adCmdText perintah.CommandText = insert(namaTabel, field, nilai) Set hasil = perintah.Execute Call kosong Call tutup End If '____________________________________ If comGrp.Nama = "&Data Baru" Then Call kosong Call buka cbKdExim.SetFocus 'cmbNamaMkn.SetFocus End If If comGrp.Nama = "&Edit" Then Call buka End If If comGrp.Nama = "&Update" Then ReDim field(4) ReDim nilai(4) field(1) = "nama": nilai(1) = tbNama.Text field(2) = "alamat": nilai(2) = tbAlamat.Text field(3) = "siup": nilai(3) = tbSiup.Text field(4) = "tanggal": nilai(4) = dpTanggal.Year & "-" _ & dpTanggal.Month & "-" & dpTanggal.Day ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1)

vars(1) = "kdexim": relasi(1) = "=": vals(1) = cbKdExim.Text perintah.CommandType = adCmdText perintah.CommandText = update(namaTabel, field, nilai, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Hapus" Then ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1) vars(1) = "kdexim": relasi(1) = "=": vals(1) = cbKdExim.Text perintah.CommandType = adCmdText perintah.CommandText = delete(namaTabel, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Batal" Then Call kosong Call tutup End If Set hasil = Nothing End Sub Private Sub cbKdExim_Change() Call CekIsi End Sub Private Sub cbKdExim_Click() Call CekIsi End Sub Private Sub cbKdExim_GotFocus() cbKdExim.Clear Call IsiKode End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next koneksi.Close

End Sub

frmKapal.frm Option Explicit Dim koneksi As New ADODB.Connection Dim perintah As New ADODB.Command Private Sub cTutup_Click() Unload Me End Sub Private Sub Form_Load() koneksi.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" koneksi.CursorLocation = adUseClient koneksi.Open perintah.ActiveConnection = koneksi 'optMakan.Value = True End Sub Private Sub kosong() On Error Resume Next cbKdKapal.Text = "" tNmKapal.Text = "" tNegara.Text = "" tNmUsaha.Text = "" tJnsUsaha.Text = "" tDwt.Text = "" 'cbKdExim.Text = "" 'tbNama.Text = "" 'tbAlamat.Text = "" 'tbSiup.Text = "" 'dpTanggal.Value = Date 'cmbKodeMkn.Text = "" 'cmbNamaMkn.Text = "" 'optMakan.Value = True 'optMinum.Value = False 'txtHarga.Text = Format(0, "Rp#.##0") aKapal.Refresh dgKapal.Refresh End Sub Private Sub buka() On Error Resume Next cbKdKapal.Enabled = True

tNmKapal.Enabled = True tNegara.Enabled = True tNmUsaha.Enabled = True tJnsUsaha.Enabled = True tDwt.Enabled = True 'tbNama.Enabled = True 'tbAlamat.Enabled = True 'tbSiup.Enabled = True 'dpTanggal.Enabled = True 'optMakan.Enabled = True 'optMinum.Enabled = True 'txtHarga.Enabled = True End Sub Private Sub tutup() On Error Resume Next 'cbKdKapal.Enabled = False tNmKapal.Enabled = False tNegara.Enabled = False tNmUsaha.Enabled = False tJnsUsaha.Enabled = False tDwt.Enabled = False 'tbNama.Enabled = False 'tbAlamat.Enabled = False 'tbSiup.Enabled = False 'dpTanggal.Enabled = False 'optMakan.Enabled = False 'optMinum.Enabled = False 'txtHarga.Enabled = False End Sub Private Sub tampil(hasil As ADODB.Recordset) On Error Resume Next 'cbKdKapal.Text = "" tNmKapal.Text = hasil.fields(1).Value tNegara.Text = hasil.fields(2).Value tNmUsaha.Text = hasil.fields(3).Value tJnsUsaha.Text = hasil.fields(4).Value tDwt.Text = hasil.fields(5).Value

'cbKdExim.Text = hasil.fields(0).Value 'tbNama.Text = hasil.fields(1).Value 'tbAlamat.Text = hasil.fields(2).Value 'tbSiup.Text = hasil.fields(3).Value 'dpTanggal.Value = hasil.fields(4).Value 'cmbKodeMkn.Text = hasil.fields(0).Value 'optMakan.Value = hasil.fields(2).Value 'optMinum.Value = Not optMakan.Value 'txtHarga.Text = Format(hasil.fields(3).Value, "Rp#") End Sub Private Sub IsiKode() On Error Resume Next Dim hasil As New ADODB.Recordset perintah.CommandType = adCmdText perintah.CommandText = "SELECT kdkapal FROM tblKapal" Set hasil = perintah.Execute If hasil.RecordCount < 1 Then Exit Sub Dim i As Integer hasil.MoveFirst cbKdKapal.Clear For i = 1 To hasil.RecordCount cbKdKapal.AddItem hasil.fields(0).Value hasil.MoveNext Next i Set hasil = Nothing End Sub Private Sub CekIsi() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String namaTabel = "tblKapal" ReDim field(1) ReDim vars(1)

ReDim relasi(1) ReDim vals(1) ReDim ops(1) field(1) = "*" vars(1) = "kdkapal": relasi(1) = "=": vals(1) = cbKdKapal.Text perintah.CommandType = adCmdText perintah.CommandText = selec(namaTabel, field, vars, relasi, vals, ops) Set hasil = perintah.Execute If hasil.RecordCount > 0 Then Call tampil(hasil) End If Set hasil = Nothing End Sub Private Sub comGrp_Click() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim nilai() As Variant Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String '___________________________________ namaTabel = "tblKapal" '___________________________________ If comGrp.Nama = "&Simpan" Then ReDim field(6) ReDim nilai(6) field(1) = "kdkapal": nilai(1) = cbKdKapal.Text field(2) = "nmkapal": nilai(2) = tNmKapal.Text field(3) = "negara": nilai(3) = tNegara.Text field(4) = "nmusaha": nilai(4) = tNmUsaha.Text field(5) = "jnsusaha": nilai(5) = tJnsUsaha.Text field(6) = "dwt": nilai(6) = tDwt.Text

perintah.CommandType = adCmdText perintah.CommandText = insert(namaTabel, field, nilai) Set hasil = perintah.Execute Call kosong

Call tutup End If '____________________________________ If comGrp.Nama = "&Data Baru" Then Call kosong Call buka cbKdKapal.SetFocus 'cmbNamaMkn.SetFocus End If If comGrp.Nama = "&Edit" Then Call buka End If If comGrp.Nama = "&Update" Then ReDim field(5) ReDim nilai(5) 'field(1) = "kdkapal": nilai(1) = cbKdKapal.Text field(1) = "nmkapal": nilai(1) = tNmKapal.Text field(2) = "negara": nilai(2) = tNegara.Text field(3) = "nmusaha": nilai(3) = tNmUsaha.Text field(4) = "jnsusaha": nilai(4) = tJnsUsaha.Text field(5) = "dwt": nilai(5) = tDwt.Text ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1) vars(1) = "kdkapal": relasi(1) = "=": vals(1) = cbKdKapal.Text perintah.CommandType = adCmdText perintah.CommandText = update(namaTabel, field, nilai, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Hapus" Then ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1)

vars(1) = "kdkapal": relasi(1) = "=": vals(1) = cbKdKapal.Text perintah.CommandType = adCmdText perintah.CommandText = delete(namaTabel, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Batal" Then Call kosong Call tutup End If Set hasil = Nothing End Sub Private Sub cbKdKapal_Change() Call CekIsi End Sub Private Sub cbKdKapal_Click() Call CekIsi End Sub Private Sub cbKdKapal_GotFocus() cbKdKapal.Clear Call IsiKode End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next koneksi.Close End Sub

frmKunjung.frm Option Explicit Dim koneksi As New ADODB.Connection Dim perintah As New ADODB.Command Dim tmpKdKapal As String Dim tmpTiba As Date Dim tmpBerangkat As Date Private Sub tampilNama(hasil As ADODB.Recordset) On Error Resume Next tNmKapal.Text = hasil.fields(1).Value End Sub Private Sub CekNama() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String namaTabel = "tblKapal" ReDim field(1) ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1) field(1) = "*" vars(1) = "kdkapal": relasi(1) = "=": vals(1) = dcKdKapal.Text perintah.CommandType = adCmdText perintah.CommandText = selec(namaTabel, field, vars, relasi, vals, ops) Set hasil = perintah.Execute If hasil.RecordCount > 0 Then Call tampilNama(hasil) End If Set hasil = Nothing End Sub Private Sub cTutup_Click() Unload Me End Sub

Private Sub dcKdKapal_Change() Call CekNama End Sub Private Sub dcKdKapal_Click(Area As Integer) Call CekNama End Sub Private Sub dgQryKapalKunjung_Click() dcKdKapal.Text = dgQryKapalKunjung.Columns(1).Value tAsal.Text = dgQryKapalKunjung.Columns(2).Value tTujuan.Text = dgQryKapalKunjung.Columns(3).Value tBongkar.Text = dgQryKapalKunjung.Columns(4).Value tMuat.Text = dgQryKapalKunjung.Columns(5).Value dpTiba.Value = FormatDateTime(dgQryKapalKunjung.Columns(6).Value, vbShortDate) dpBerangkat.Value = FormatDateTime(dgQryKapalKunjung.Columns(7).Value, vbShortDate) tmpKdKapal = dgQryKapalKunjung.Columns(1).Value tmpTiba = Format(dgQryKapalKunjung.Columns(6).Value, "yyyy-MM-dd") tmpBerangkat = Format(dgQryKapalKunjung.Columns(7).Value, "yyyy-MM-dd") End Sub Private Sub Form_Load() koneksi.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" koneksi.CursorLocation = adUseClient koneksi.Open perintah.ActiveConnection = koneksi End Sub Private Sub kosong() On Error Resume Next dcKdKapal.Text = "" tNmKapal.Text = "" tAsal.Text = "" tTujuan.Text = "" tBongkar.Text = "" tMuat.Text = "" dpTiba.Value = Date dpBerangkat.Value = Date aKapal.Refresh aQryKapalKunjung.Refresh dgQryKapalKunjung.Refresh

End Sub Private Sub buka() On Error Resume Next dcKdKapal.Enabled = True tNmKapal.Enabled = True tAsal.Enabled = True tTujuan.Enabled = True tBongkar.Enabled = True tMuat.Enabled = True dpTiba.Enabled = True dpBerangkat.Enabled = True End Sub Private Sub tutup() On Error Resume Next dcKdKapal.Enabled = False tNmKapal.Enabled = False tAsal.Enabled = False tTujuan.Enabled = False tBongkar.Enabled = False tMuat.Enabled = False dpTiba.Enabled = False dpBerangkat.Enabled = False End Sub Private Sub comGrp_Click() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim nilai() As Variant Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String '___________________________________ namaTabel = "tblKunjung" '___________________________________ If comGrp.Nama = "&Simpan" Then ReDim field(7) ReDim nilai(7)

field(1) = "kdkapal": nilai(1) = dcKdKapal.Text field(2) = "asal": nilai(2) = tAsal.Text field(3) = "tujuan": nilai(3) = tTujuan.Text field(4) = "tiba": nilai(4) = dpTiba.Year & "-" & dpTiba.Month & "-" & dpTiba.Day field(5) = "berangkat": nilai(5) = dpBerangkat.Year & "-" & dpBerangkat.Month & "-" & dpBerangkat.Day field(6) = "bongkar": nilai(6) = tBongkar.Text field(7) = "muat": nilai(7) = tMuat.Text perintah.CommandType = adCmdText perintah.CommandText = insert(namaTabel, field, nilai) Set hasil = perintah.Execute Call kosong Call tutup End If '____________________________________ If comGrp.Nama = "&Data Baru" Then Call kosong Call buka dcKdKapal.SetFocus End If If comGrp.Nama = "&Edit" Then Call buka End If If comGrp.Nama = "&Update" Then ReDim field(7) ReDim nilai(7) field(1) = "kdkapal": nilai(1) = dcKdKapal.Text field(2) = "asal": nilai(2) = tAsal.Text field(3) = "tujuan": nilai(3) = tTujuan.Text field(4) = "tiba": nilai(4) = dpTiba.Year & "-" & dpTiba.Month & "-" & dpTiba.Day field(5) = "berangkat": nilai(5) = dpBerangkat.Year & "-" & dpBerangkat.Month & "-" & dpBerangkat.Day field(6) = "bongkar": nilai(6) = tBongkar.Text field(7) = "muat": nilai(7) = tMuat.Text ReDim vars(3) ReDim relasi(3) ReDim vals(3) ReDim ops(2) vars(1) = "kdkapal": relasi(1) = "=": vals(1) = tmpKdKapal

vars(2) = "tiba": relasi(2) = "=": vals(2) = Format(tmpTiba, "yyyy-MM-dd") vars(3) = "berangkat": relasi(3) = "=": vals(3) = Format(tmpBerangkat, "yyyy-MMdd") ops(1) = "AND" ops(2) = "AND" perintah.CommandType = adCmdText perintah.CommandText = update(namaTabel, field, nilai, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Hapus" Then ReDim vars(3) ReDim relasi(3) ReDim vals(3) ReDim ops(2) vars(1) = "kdkapal": relasi(1) = "=": vals(1) = tmpKdKapal vars(2) = "tiba": relasi(2) = "=": vals(2) = Format(tmpTiba, "yyyy-MM-dd") vars(3) = "berangkat": relasi(3) = "=": vals(3) = Format(tmpBerangkat, "yyyy-MMdd") ops(1) = "AND" ops(2) = "AND" perintah.CommandType = adCmdText perintah.CommandText = delete(namaTabel, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Batal" Then Call kosong Call tutup End If Set hasil = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next koneksi.Close End Sub

frmLogin.frm Option Explicit Dim koneksi As New ADODB.Connection Dim perintah As New ADODB.Command Private Sub cbLogin_Click() Call CekPass End Sub Private Sub Form_Activate() tbNama.SetFocus End Sub Private Sub Form_Load() koneksi.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" koneksi.CursorLocation = adUseClient koneksi.Open perintah.ActiveConnection = koneksi End Sub Private Sub CekPass() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String namaTabel = "tblUser" ReDim field(1) ReDim vars(2) ReDim relasi(2) ReDim vals(2) ReDim ops(1) field(1) = "*" vars(1) = "nama": relasi(1) = "=": vals(1) = tbNama.Text vars(2) = "pass": relasi(2) = "=": vals(2) = tbPass.Text ops(1) = "AND" perintah.CommandType = adCmdText perintah.CommandText = selec(namaTabel, field, vars, relasi, vals, ops) Set hasil = perintah.Execute

If hasil.RecordCount > 0 Then frmUtama.mMaster.Enabled = True frmUtama.mnExim.Enabled = True frmUtama.mUser.Enabled = True frmUtama.mLaporan.Enabled = True 'frmUtama.mLogin.Enabled = False frmUtama.mLogin.Caption = "Logout" frmUtama.sbUtama.SimpleText = "User aktif: " & tbNama.Text Me.Hide Else MsgBox "Nama user atau password anda salah", vbOKOnly, "Login Error" tbNama.SetFocus End If Set hasil = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next koneksi.Close End Sub

frmMohon.frm Option Explicit Dim koneksi As New ADODB.Connection Dim perintah As New ADODB.Command Dim tmpKdKapal As String Dim tmpKdExim As String Dim tmpTanggal As Date Private Sub tampilNama(hasil As ADODB.Recordset) On Error Resume Next tbNmkapal.Text = hasil.fields(1).Value End Sub Private Sub CekNama() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String namaTabel = "tblKapal" ReDim field(1) ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1) field(1) = "*" vars(1) = "kdkapal": relasi(1) = "=": vals(1) = dcKdKapal.Text perintah.CommandType = adCmdText perintah.CommandText = selec(namaTabel, field, vars, relasi, vals, ops) Set hasil = perintah.Execute If hasil.RecordCount > 0 Then Call tampilNama(hasil) End If Set hasil = Nothing End Sub Private Sub tampilUsaha(hasil As ADODB.Recordset) On Error Resume Next tbNmUsaha.Text = hasil.fields(1).Value End Sub

Private Sub CekUsaha() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String namaTabel = "tblExim" ReDim field(1) ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1) field(1) = "*" vars(1) = "kdexim": relasi(1) = "=": vals(1) = dcKdExim.Text perintah.CommandType = adCmdText perintah.CommandText = selec(namaTabel, field, vars, relasi, vals, ops) Set hasil = perintah.Execute If hasil.RecordCount > 0 Then Call tampilUsaha(hasil) End If Set hasil = Nothing End Sub Private Sub cTutup_Click() Unload Me End Sub Private Sub dcKdKapal_Change() Call CekNama End Sub Private Sub dcKdKapal_Click(Area As Integer) Call CekNama End Sub Private Sub dcKdExim_Change() Call CekUsaha End Sub

Private Sub dcKdExim_Click(Area As Integer) Call CekUsaha End Sub Private Sub dgQKapalEximMohon_Click() dcKdKapal.Text = dgQKapalEximMohon.Columns(2).Value dcKdExim.Text = dgQKapalEximMohon.Columns(3).Value tbAsal.Text = dgQKapalEximMohon.Columns(4).Value tbTujuan.Text = dgQKapalEximMohon.Columns(5).Value tbKomoditi.Text = dgQKapalEximMohon.Columns(6).Value tbJumlah.Text = dgQKapalEximMohon.Columns(7).Value dpTanggal.Value = FormatDateTime(dgQKapalEximMohon.Columns(8).Value, vbShortDate) tmpKdKapal = dgQKapalEximMohon.Columns(2).Value tmpKdExim = dgQKapalEximMohon.Columns(3).Value tmpTanggal = Format(dgQKapalEximMohon.Columns(8).Value, "yyyy-MM-dd") End Sub Private Sub Form_Load() koneksi.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" koneksi.CursorLocation = adUseClient koneksi.Open perintah.ActiveConnection = koneksi End Sub Private Sub kosong() On Error Resume Next dcKdKapal.Text = "" tbNmkapal.Text = "" dcKdExim.Text = "" tbNmUsaha.Text = "" tbAsal.Text = "" tbTujuan.Text = "" tbKomoditi.Text = "" tbJumlah.Text = "" dpTanggal.Value = Date aKapal.Refresh aExim.Refresh aqKapalEximMohon.Refresh dgQKapalEximMohon.Refresh End Sub Private Sub buka()

On Error Resume Next dcKdKapal.Enabled = True tbNmkapal.Enabled = True dcKdExim.Enabled = True tbNmUsaha.Enabled = True tbAsal.Enabled = True tbTujuan.Enabled = True tbKomoditi.Enabled = True tbJumlah.Enabled = True dpTanggal.Enabled = True End Sub Private Sub tutup() On Error Resume Next dcKdKapal.Enabled = False tbNmkapal.Enabled = False dcKdExim.Enabled = False tbNmUsaha.Enabled = False tbAsal.Enabled = False tbTujuan.Enabled = False tbKomoditi.Enabled = False tbJumlah.Enabled = False dpTanggal.Enabled = False End Sub Private Sub comGrp_Click() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim nilai() As Variant Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String '___________________________________ namaTabel = "tblMohon" '___________________________________ If comGrp.Nama = "&Simpan" Then ReDim field(7) ReDim nilai(7) field(1) = "kdkapal": nilai(1) = dcKdKapal.Text

field(2) = "kdexim": nilai(2) = dcKdExim.Text field(3) = "asal": nilai(3) = tbAsal.Text field(4) = "tujuan": nilai(4) = tbTujuan.Text field(5) = "komoditi": nilai(5) = tbKomoditi.Text field(6) = "jumlah": nilai(6) = Val(tbJumlah.Text) field(7) = "tanggal": nilai(7) = dpTanggal.Year & "-" & dpTanggal.Month & "-" & dpTanggal.Day perintah.CommandType = adCmdText perintah.CommandText = insert(namaTabel, field, nilai) Set hasil = perintah.Execute Call kosong Call tutup End If '____________________________________ If comGrp.Nama = "&Data Baru" Then Call kosong Call buka dcKdKapal.SetFocus End If If comGrp.Nama = "&Edit" Then Call buka End If If comGrp.Nama = "&Update" Then ReDim field(7) ReDim nilai(7) field(1) = "kdkapal": nilai(1) = dcKdKapal.Text field(2) = "kdexim": nilai(2) = dcKdExim.Text field(3) = "asal": nilai(3) = tbAsal.Text field(4) = "tujuan": nilai(4) = tbTujuan.Text field(5) = "komoditi": nilai(5) = tbKomoditi.Text field(6) = "jumlah": nilai(6) = Val(tbJumlah.Text) field(7) = "tanggal": nilai(7) = dpTanggal.Year & "-" & dpTanggal.Month & "-" & dpTanggal.Day ReDim vars(3) ReDim relasi(3) ReDim vals(3) ReDim ops(2) vars(1) = "kdkapal": relasi(1) = "=": vals(1) = tmpKdKapal vars(2) = "kdexim": relasi(2) = "=": vals(2) = tmpKdExim

vars(3) = "tanggal": relasi(3) = "=": vals(3) = Format(tmpTanggal, "yyyy-MM-dd") ops(1) = "AND" ops(2) = "AND" perintah.CommandType = adCmdText perintah.CommandText = update(namaTabel, field, nilai, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Hapus" Then ReDim vars(3) ReDim relasi(3) ReDim vals(3) ReDim ops(2) vars(1) = "kdkapal": relasi(1) = "=": vals(1) = tmpKdKapal vars(2) = "kdexim": relasi(2) = "=": vals(2) = tmpKdExim vars(3) = "tanggal": relasi(3) = "=": vals(3) = Format(tmpTanggal, "yyyy-MM-dd") ops(1) = "AND" ops(2) = "AND" perintah.CommandType = adCmdText perintah.CommandText = delete(namaTabel, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Batal" Then Call kosong Call tutup End If Set hasil = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) On Error Resume Next koneksi.Close End Sub

frmUser.frm Option Explicit Dim koneksi As New ADODB.Connection Dim perintah As New ADODB.Command Private Sub cTutup_Click() Unload Me End Sub Private Sub Form_Load() koneksi.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;" & _ "Data Source=dbexim" koneksi.CursorLocation = adUseClient koneksi.Open perintah.ActiveConnection = koneksi 'optMakan.Value = True End Sub Private Sub kosong() On Error Resume Next cbNama.Text = "" tbPass.Text = "" aUser.Refresh dgUser.Refresh End Sub Private Sub buka() On Error Resume Next cbNama.Enabled = True tbPass.Enabled = True End Sub Private Sub tutup() On Error Resume Next tbPass.Enabled = False End Sub Private Sub tampil(hasil As ADODB.Recordset) On Error Resume Next tbPass.Text = hasil.fields(1).Value End Sub Private Sub IsiNama() On Error Resume Next

Dim hasil As New ADODB.Recordset perintah.CommandType = adCmdText perintah.CommandText = "SELECT nama FROM tbluser" Set hasil = perintah.Execute If hasil.RecordCount < 1 Then Exit Sub Dim i As Integer hasil.MoveFirst cbNama.Clear For i = 1 To hasil.RecordCount cbNama.AddItem hasil.fields(0).Value hasil.MoveNext Next i Set hasil = Nothing End Sub Private Sub CekIsi() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String namaTabel = "tblUser" ReDim field(1) ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1) field(1) = "*" vars(1) = "nama": relasi(1) = "=": vals(1) = cbNama.Text perintah.CommandType = adCmdText perintah.CommandText = selec(namaTabel, field, vars, relasi, vals, ops) Set hasil = perintah.Execute If hasil.RecordCount > 0 Then Call tampil(hasil) End If Set hasil = Nothing End Sub

Private Sub comGrp_Click() On Error Resume Next Dim hasil As New ADODB.Recordset Dim namaTabel As String Dim field() As String Dim nilai() As Variant Dim vars() As String Dim relasi() As String Dim vals() As Variant Dim ops() As String '___________________________________ namaTabel = "tblUser" '___________________________________ If comGrp.Nama = "&Simpan" Then ReDim field(2) ReDim nilai(2) field(1) = "nama": nilai(1) = cbNama.Text field(2) = "pass": nilai(2) = tbPass.Text perintah.CommandType = adCmdText perintah.CommandText = insert(namaTabel, field, nilai) Set hasil = perintah.Execute Call kosong Call tutup End If '____________________________________ If comGrp.Nama = "&Data Baru" Then Call kosong Call buka cbNama.SetFocus End If If comGrp.Nama = "&Edit" Then Call buka End If If comGrp.Nama = "&Update" Then ReDim field(1) ReDim nilai(1) field(1) = "pass": nilai(1) = tbPass.Text ReDim vars(1)

ReDim relasi(1) ReDim vals(1) ReDim ops(1) vars(1) = "nama": relasi(1) = "=": vals(1) = cbNama.Text perintah.CommandType = adCmdText perintah.CommandText = update(namaTabel, field, nilai, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Hapus" Then ReDim vars(1) ReDim relasi(1) ReDim vals(1) ReDim ops(1) vars(1) = "nama": relasi(1) = "=": vals(1) = cbNama.Text perintah.CommandType = adCmdText perintah.CommandText = delete(namaTabel, vars, relasi, vals, ops) Set hasil = perintah.Execute Call kosong Call tutup End If If comGrp.Nama = "&Batal" Then Call kosong Call tutup End If Set hasil = Nothing End Sub Private Sub cbNama_Change() Call CekIsi End Sub Private Sub cbNama_Click() Call CekIsi End Sub Private Sub cbNama_GotFocus() cbNama.Clear Call IsiNama End Sub

Private Sub Form_Unload(Cancel As Integer) On Error Resume Next koneksi.Close End Sub