1. Ahmad Mustaqim | 12100408 1
Rental_mobil
txtharga_sewa.Text = ""
txtlama.Text = ""
txttotal.Text = "0"
End Sub
Sub nonaktif()
txtsewa.Enabled = False
txtkdpeminjam.Enabled = False
txtnama_peminjam.Enabled = False
cmbtipe.Enabled = False
txtharga_sewa.Enabled = False
MODUL txtlama.Enabled = False
Public dbado As New ADODB.Connection txttotal.Enabled = False
Public rssewa As New ADODB.Recordset binputlain.Enabled = False
Public rspeminjam As New ADODB.Recordset bsave.Enabled = False
Public rsdetail As New ADODB.Recordset bcancel.Enabled = False
Public Sub koneksi() End Sub
If dbado.State = adStateOpen Then Sub aktif()
dbado.Close txtsewa.Enabled = True
End If txtkdpeminjam.Enabled = True
dbado.ConnectionString = txtnama_peminjam.Enabled = True
"provider=msdasql.1;persist security
cmbtipe.Enabled = True
info=false;data source=rental_mobil"
txtharga_sewa.Enabled = True
dbado.Open
txtlama.Enabled = True
End Sub
txttotal.Enabled = True
LISTING
binputlain.Enabled = True
Sub bersih()
bsave.Enabled = True
txtsewa.Text = ""
bcancel.Enabled = True
txtkdpeminjam.Text = ""
End Sub
txtnama_peminjam.Text = ""
Sub tabel()
cmbtipe.Text = ""
Grid1.ColWidth(0) = 126
2. Ahmad Mustaqim | 12100408 2
Rental_mobil
Grid1.ColWidth(1) = 900 sqldel = "delete from detail_sewa where
no_sewa='" &txtsewa.Text& "'"
Grid1.ColWidth(2) = 900
Set rsdetail = dbado.Execute(sqldel, , adCmdText)
Grid1.ColWidth(3) = 900
tabel
Grid1.ColWidth(4) = 900
nonaktif
sqltabel = "select*from detail_sewa"
bersih
Set rsdetail = dbado.Execute(sqltabel, ,
adCmdText) End Sub
Set Grid1.DataSource = rsdetail
End Sub Private Sub bclose_Click()
Sub no() X = MsgBox("yakinmaukeluar form?", vbYesNo,
"konfirmasi")
Dim sqlno, a, b As String
If X = vbYes Then
sqlno = "select * from sewa"
End
Set rssewa = dbado.Execute(sqlno, , adCmdText)
End If
If rssewa.BOFAndrssewa.EOF Then
End Sub
txtsewa.Text = "W" &Format(Date, "yymm") &
"001" Private Sub binputlain_Click()
Else sqlsv = "insert into detail_sewa()values('"
&txtsewa.Text& "','" &cmbtipe.Text& "','"
a=0 &txtlama.Text& "','" &txtharga_sewa.Text& "')"
rssewa.MoveFirst Set rsdetail = dbado.Execute(sqlsv, , adCmdText)
Do Until rssewa.EOF cmbtipe.Text = ""
a=a+1 txtharga_sewa.Text = ""
rssewa.MoveNext txtlama.Text = ""
Loop cmbtipe.SetFocus
a=a+1 tabel
b = Len(Str(a)) End Sub
txtsewa.Text = "W" &Format(Date, "yymm") &
Mid$("000", 1, 4 - b) & a
Private Sub bnew_Click()
End If
aktif
End Sub
bersih
no
Private Sub bcancel_Click()
3. Ahmad Mustaqim | 12100408 3
Rental_mobil
txtkdpeminjam.SetFocus If cmbtipe.ListIndex = 1 Then
End Sub ck = "select no_sewa from detail_sewa where
no_sewa='" &txtsewa.Text& "' and tipe_mobil='"
&cmbtipe.Text& "'"
Private Sub bsave_Click() Set rsdetail = dbado.Execute(ck, , adCmdText)
sqlsave = "insert into sewa()values('" If rsdetail.BOFAndrsdetail.EOF Then
&txtsewa.Text& "','" &lbltanggal.Caption& "','"
&txttotal.Text& "','" &txtkdpeminjam.Text& "')" txtharga_sewa.Text = "300000"
Set rssewa = dbado.Execute(sqlsave, , txtlama.SetFocus
adCmdText)
Else
sqlsv = "insert into detail_sewa()values('"
&txtsewa.Text& "','" &cmbtipe.Text& "','" MsgBox " TIPE '" &cmbtipe.Text& "' SUDAH
&txtlama.Text& "','" &txtharga_sewa.Text& "')" DIPESAN!"
Set rsdetail = dbado.Execute(sqlsv, , adCmdText) txtharga_sewa.Text = ""
tabel cmbtipe.SetFocus
nonaktif End If
bersih Else
End Sub If cmbtipe.ListIndex = 2 Then
Private Sub cmbtipe_Click() ck = "select no_sewa from detail_sewa where
no_sewa='" &txtsewa.Text& "' and tipe_mobil='"
If cmbtipe.ListIndex = 0 Then &cmbtipe.Text& "'"
ck = "select no_sewa from detail_sewa where Set rsdetail = dbado.Execute(ck, , adCmdText)
no_sewa='" &txtsewa.Text& "' and tipe_mobil='"
&cmbtipe.Text& "'" If rsdetail.BOFAndrsdetail.EOF Then
Set rsdetail = dbado.Execute(ck, , adCmdText) txtharga_sewa.Text = "500000"
If rsdetail.BOFAndrsdetail.EOF Then txtlama.SetFocus
txtharga_sewa.Text = "400000" Else
txtlama.SetFocus MsgBox " TIPE '" &cmbtipe.Text& "' SUDAH
DIPESAN!"
Else
txtharga_sewa.Text = ""
MsgBox " TIPE '" &cmbtipe.Text& "' SUDAH
DIPESAN!" cmbtipe.SetFocus
txtharga_sewa.Text = "" End If
cmbtipe.SetFocus End If
End If End If
Else End If
4. Ahmad Mustaqim | 12100408 4
Rental_mobil
End Sub Private Sub txtlama_Change()
txttotal.Text = (Val(txtharga_sewa.Text) *
Val(txtlama.Text)) + Val(txttotal.Text)
Private Sub Form_Activate()
End Sub
nonaktif
lbltanggal.Caption = Format(Date, "yyyy-mm-dd")
tabel
cmbtipe.AddItem ("inova")
cmbtipe.AddItem ("avanza")
cmbtipe.AddItem ("city")
End Sub
Private Sub Form_Load()
koneksi
End Sub
Private Sub txtkdpeminjam_OnEnter()
sqlkd = "select*from peminjam where
kd_peminjam='" &txtkdpeminjam.Text& "'"
Set rspeminjam = dbado.Execute(sqlkd, ,
adCmdText)
If rspeminjam.BOFAndrspeminjam.EOF Then
MsgBox "KODE '" &txtkdpeminjam.Text& "'
BelumTerdaftar"
txtkdpeminjam.Text = ""
txtkdpeminjam.SetFocus
Else
txtnama_peminjam.Text = rspeminjam!nama
cmbtipe.SetFocus
End If
End Sub