Header Ads

Sistem Informasi Penjualan Kenderaan bermotor


LISTING PROGRAM


MENU UTAMA

Private Sub mnuangsuran_Click()
Form10.Show
End Sub

Private Sub mnudetail_Click()
Form11.Show
End Sub

Private Sub mnuexit_Click()
End
End Sub

Private Sub mnuinfokendaraan_Click()
Form6.Show
End Sub

Private Sub mnuinfopelanggan_Click()
Form7.Show
End Sub

Private Sub mnuinfotransaksi_Click()
Form8.Show
End Sub

Private Sub mnukendaraan_Click()
Form2.Show
End Sub

Private Sub mnukredit_Click()
Report.ReportFileName = App.Path & "\rptjualkredit.rpt"
Report.DataFiles(0) = App.Path & "\penjualan.mdb"
Report.ReplaceSelectionFormula "{penjualan.jns_trans} = 'Kredit'"
Report.WindowState = crptMaximized
Report.Action = 7
Report.Reset
End Sub


Private Sub mnulapangsuranpel_Click()
Form13.Show
End Sub

Private Sub mnulapdetail_Click()
Form12.Show
End Sub

Private Sub mnulapkendaraan_Click()
Report.ReportFileName = App.Path & "\rptkendaraan.rpt"
Report.DataFiles(0) = App.Path & "\penjualan.mdb"
Report.WindowState = crptMaximized
Report.Action = 7
Report.Reset
End Sub

Private Sub mnulappelanggan_Click()
Report.ReportFileName = App.Path & "\rptpelanggan.rpt"
Report.DataFiles(0) = App.Path & "\penjualan.mdb"
Report.WindowState = crptMaximized
Report.Action = 7
Report.Reset
End Sub

Private Sub mnupelanggan_Click()
Form1.Show
End Sub

Private Sub mnuselurus_Click()
Report.ReportFileName = App.Path & "\rpttransaksi.rpt"
Report.DataFiles(0) = App.Path & "\penjualan.mdb"
Report.WindowState = crptMaximized
Report.Action = 7
Report.Reset
End Sub

Private Sub mnutransaksi_Click()
Form3.Show
End Sub

Private Sub mnutunai_Click()
Report.ReportFileName = App.Path & "\rptjualtunai.rpt"
Report.DataFiles(0) = App.Path & "\penjualan.mdb"
Report.ReplaceSelectionFormula "{Penjualan.Jns_Trans}='Tunai'"
Report.WindowState = crptMaximized
Report.Action = 7
Report.Reset
End Sub

Private Sub mnutype_Click()
Form9.Show
End Sub


FORM ENTRY DATA KENDARAAN
Dim pesan As String
Dim status As Boolean
Dim angka As String

Private Sub CmdCancel_Click()
Call bersih
Call cmdenable(False, False, False, False)
End Sub


Private Sub CmdDelete_Click()
    pesan = MsgBox("Anda Yakin Ingin Menghapus Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        db.Execute ("delete * from kendaraan where kd_kendaraan = '" & Text1.Text & "'")
        Call bersih
        Call cmdenable(False, False, False, False)
    End If
End Sub

Private Sub CmdExit_Click()
Unload Me
End Sub

Private Sub CmdSave_Click()
Call cek
If status = False Then
    pesan = MsgBox("Anda Yakin Ingin Menyimpan Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        db.Execute ("insert into kendaraan values ('" & Text1.Text & "','" & Text11.Text & "','" & Combo1.Text & "','" & Text9.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text8.Text & "','" & Text7.Text & "'," & Int(Text6.Text) & "," & Int(Text2.Text) & "," & Int(Text10.Text) & ")")
        Call bersih
        Call cmdenable(False, False, False, False)
        Call Form_Load
    End If
End If
End Sub

Private Sub CmdUpdate_Click()
Call cek
If status = False Then
    pesan = MsgBox("Anda Yakin Ingin Mengubah Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        db.Execute ("Update kendaraan set kd_kendaraan = '" & Text1.Text & "',Merk='" & Text11.Text & "',type='" & Combo1.Text & "',nama= '" & Text9.Text & "',tahun='" & Text3.Text & "',No_seri='" & Text4.Text & "',No_mesin='" & Text5.Text & "',No_rangka='" & Text8.Text & "',no_spi='" & Text7.Text & "',harga=" & Int(Text6.Text) & ",bbm=" & Int(Text2.Text) & ",adm=" & Int(Text10.Text) & " where kd_kendaraan = '" & Text1.Text & "'")
        Call bersih
        Call cmdenable(False, False, False, False)
    End If
End If
End Sub

Private Sub Form_Load()
Dim isi As ADODB.Recordset
Set isi = db.Execute("select distinct(type) from kendaraan")
If Not isi.EOF Then
    Combo1.Clear
    isi.MoveFirst
    While Not isi.EOF
        Combo1.AddItem isi(0)
    isi.MoveNext
    Wend
End If
status = False
Call cmdenable(False, False, False, False)
End Sub

Private Sub Label15_Change()
If Not Label15.Caption = "0" Or Not Label15.Caption = "" Then
    If Val(Label15.Caption) > 0 Then
        angka = Format(Label15.Caption, "##,##")
        Label15.Caption = angka
    End If
End If
End Sub

Private Sub Text1_Change()
Dim cari As ADODB.Recordset
Set cari = db.Execute("select * from kendaraan where kd_kendaraan = '" & Text1.Text & "'")
If Not cari.EOF Then
    Text11.Text = cari(1)
    Combo1.Text = cari(2)
    Text9.Text = cari(3)
    Text3.Text = cari(4)
    Text4.Text = cari(5)
    Text5.Text = cari(6)
    Text8.Text = cari(7)
    Text7.Text = cari(8)
    Text6.Text = cari(9)
    Text2.Text = cari(10)
    Text10.Text = cari(11)
    Call cmdenable(False, True, True, True)
Else
    Text11.Text = ""
    Combo1.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = "0"
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Text2.Text = "0"
    Text10.Text = "0"
    Label15.Caption = "0"
    Call cmdenable(True, False, False, True)
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub cmdenable(var1, var2, var3, var4 As Boolean)
CmdSave.Enabled = var1
CmdUpdate.Enabled = var2
CmdDelete.Enabled = var3
CmdCancel.Enabled = var4
End Sub

Private Sub bersih()
Text1.Text = ""
Text11.Text = ""
Combo1.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = "0"
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text2.Text = "0"
Text10.Text = "0"
Label15.Caption = "0"
Text1.SetFocus
End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Sub Text10_Change()
If Not Text10.Text = "0" Or Not Text10.Text = "" Then
    If Val(Text10.Text) > 0 Then
        angka = Format(Text10.Text, "##,##")
        Text10.Text = angka
        Text10.SelStart = Len(Text10.Text)
        Label15.Caption = Int(Text6.Text) + Int(Text2.Text) + Int(Text10.Text)
    End If
End If
End Sub
Private Sub Text10_GotFocus()
If Text10.Text = "0" Then
    Text10.Text = ""
End If
End Sub

Private Sub Text10_LostFocus()
If Text10.Text = "" Then
    Text10.Text = "0"
End If
End Sub

Private Sub Text2_Change()
If Not Text2.Text = "0" Or Not Text2.Text = "" Then
    If Val(Text2.Text) > 0 Then
        angka = Format(Text2.Text, "##,##")
        Text2.Text = angka
        Text2.SelStart = Len(Text2.Text)
        Label15.Caption = Int(Text6.Text) + Int(Text2.Text) + Int(Text10.Text)
    End If
End If
End Sub
Private Sub Text2_GotFocus()
If Text2.Text = "0" Then
    Text2.Text = ""
End If
End Sub

Private Sub Text2_LostFocus()
If Text2.Text = "" Then
    Text2.Text = "0"
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub cek()
For Each teks In Form2.Controls
    If Mid(teks.Name, 1, 4) = "Text" Or Mid(teks.Name, 1, 5) = "Combo" Then
        If teks = "" Then
            MsgBox "Maaf Data Ini Tidak Dapat Disimpan Karena Masih Ada Yang Kosong..!!", vbInformation, "Informasi"
            status = True
            Exit Sub
        End If
    End If
Next
End Sub

Private Sub Text6_Change()
If Not Text6.Text = "0" Or Not Text6.Text = "" Then
    If Val(Text6.Text) > 0 Then
        angka = Format(Text6.Text, "##,##")
        Text6.Text = angka
        Text6.SelStart = Len(Text6.Text)
        Label15.Caption = Int(Text6.Text) + Int(Text2.Text) + Int(Text10.Text)
    End If
End If
End Sub
Private Sub Text6_GotFocus()
If Text6.Text = "0" Then
    Text6.Text = ""
End If
End Sub

Private Sub Text6_LostFocus()
If Text6.Text = "" Then
    Text6.Text = "0"
End If
End Sub

Private Sub Text7_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub Text8_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub Text9_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub


FORM ENTRY DATA PELANGGAN
Dim pesan As String
Dim status As Boolean

Private Sub CmdCancel_Click()
Call bersih
Call cmdenable(False, False, False, False)
End Sub

Private Sub CmdDelete_Click()
    pesan = MsgBox("Anda Yakin Ingin Menghapus Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        db.Execute ("delete * from pelanggan where kd_pel = '" & Text1.Text & "'")
        Call bersih
        Call cmdenable(False, False, False, False)
    End If
End Sub

Private Sub CmdExit_Click()
Unload Me
End Sub

Private Sub CmdSave_Click()
Call cek
If status = False Then
    pesan = MsgBox("Anda Yakin Ingin Menyimpan Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        db.Execute ("insert into pelanggan values ('" & Text1.Text & "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Combo1.Text & "','" & Combo2.Text & "',0)")
        Call bersih
        Call cmdenable(False, False, False, False)
    End If
End If
End Sub

Private Sub CmdUpdate_Click()
Call cek
If status = False Then
    pesan = MsgBox("Anda Yakin Ingin Mengubah Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        db.Execute ("Update pelanggan set Kd_pel = '" & Text1.Text & "',Nm_Pel='" & Text2.Text & "',Alamat ='" & Text3.Text & "',Telp='" & Text4.Text & "',NoID='" & Text5.Text & "',Pekerjaan='" & Combo1.Text & "',Pendapatan = '" & Combo2.Text & "' where kd_pel = '" & Text1.Text & "'")
        Call bersih
        Call cmdenable(False, False, False, False)
    End If
End If
End Sub

Private Sub Form_Load()
status = False
Call cmdenable(False, False, False, False)
End Sub

Private Sub Text1_Change()
Dim cari As ADODB.Recordset
Set cari = db.Execute("select * from pelanggan where kd_pel = '" & Text1.Text & "'")
If Not cari.EOF Then
    Text2.Text = cari(1)
    Text3.Text = cari(2)
    Text4.Text = cari(3)
    Text5.Text = cari(4)
    Combo1.Text = cari(5)
    Combo2.Text = cari(6)
    Call cmdenable(False, True, True, True)
Else
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Combo1.Text = ""
    Combo2.Text = ""
    Call cmdenable(True, False, False, True)
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub


Private Sub cmdenable(var1, var2, var3, var4 As Boolean)
CmdSave.Enabled = var1
CmdUpdate.Enabled = var2
CmdDelete.Enabled = var3
CmdCancel.Enabled = var4
End Sub

Private Sub bersih()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Combo1.Text = ""
Combo2.Text = ""
Text1.SetFocus
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub cek()
For Each teks In Form1.Controls
    If Mid(teks.Name, 1, 4) = "Text" Or Mid(teks.Name, 1, 5) = "Combo" Then
        If teks = "" Then
            MsgBox "Maaf Data Ini Tidak Dapat Disimpan Karena Masih Ada Yang Kosong..!!", vbInformation, "Informasi"
            status = True
            Exit Sub
        End If
    End If
Next
End Sub

FORM ENTRY DATA TRANSAKSI
Dim angka As String

Private Sub cbojenisbayar_Change()
    Call cbojenisbayar_Click
End Sub

Private Sub cbojenisbayar_Click()
Dim cekhrg As ADODB.Recordset
If cbojenisbayar.Text = "Kredit" Then
    'Set cekhrg = db.Execute("select Hrg_OTR from DaftarHarga where type = '" & lbltype.Caption & "'")
    'If Not cekhrg.EOF Then
    '    lbltotal.Caption = cekhrg(0)
    'End If
    Label17.Visible = True
    txtDP.Visible = True
    Combo1.Visible = True
    Label18.Visible = True
    Label19.Visible = True
    Label14.Visible = True
    Label13.Visible = True
Else
    Label17.Visible = False
    txtDP.Visible = False
    Combo1.Visible = False
    Label18.Visible = False
    Label19.Visible = False
    Label14.Visible = False
    Label13.Visible = False
End If
End Sub

Private Sub CmdCancel_Click()
Call bersih
End Sub

Private Sub CmdDelete_Click()
Dim pesan As String
pesan = MsgBox("Anda Yakin Ingin Menghapus Data Ini...???", vbQuestion + vbYesNo, "Yakin")
If pesan = vbYes Then
    db.Execute ("Delete * from penjualan where faktur = '" & txtfaktur.Text & "'")
    Call bersih
    Call cmdenable(False, False, False, False)
End If
End Sub

Private Sub CmdExit_Click()
Unload Me
End Sub

Private Sub CmdSave_Click()
Dim pesan As String
Dim hutang As Currency
Dim awal As ADODB.Recordset
pesan = MsgBox("Anda Yakin Ingin Menyimpan Data Ini...???", vbQuestion + vbYesNo, "Yakin")
If pesan = vbYes Then
    For Each teks In Form3.Controls
        If Not teks.Name = "TxtDP" Then
            If Mid(teks.Name, 1, 4) = "Text" Or Mid(teks.Name, 1, 3) = "txt" Or Mid(teks.Name, 1, 3) = "cbo" Then
                If teks = "" Then
                    MsgBox "Maaf Data Transaksi Tidak Dapat Disimpan Karena Masih Ada Field yang Kosong...", vbInformation, "Informasi"
                    Exit Sub
                End If
            End If
        End If
    Next
    db.Execute ("insert into penjualan values('" & txtfaktur.Text & "','" & DTPicker1.Value & "','" & Text1.Text & "','" & txtkdkendaraan.Text & "','" & cbojenisbayar.Text & "'," & Int(txtDP.Text) & "," & Val(Combo1.Text) & "," & Int(Label14.Caption) & ")")
    If cbojenisbayar.Text = "Kredit" Then
        Set awal = db.Execute("select hutang from pelanggan where kd_pel = '" & Text1.Text & "'")
        If Not awal.EOF Then
            hutang = Int(lbltotal.Caption) - Int(txtDP.Text)
            db.Execute ("update pelanggan set hutang = " & hutang + awal(0) & " where kd_pel = '" & Text1.Text & "'")
        End If
    End If
    Call bersih
    Call cmdenable(False, False, False, False)
End If
End Sub

Private Sub CmdUpdate_Click()
Dim pesan As String
Dim hutang As Currency
Dim pertama As Currency
Dim awal As ADODB.Recordset
pesan = MsgBox("Anda Yakin Ingin Mengubah Data Ini...???", vbQuestion + vbYesNo, "Yakin")
If pesan = vbYes Then
    For Each teks In Form3.Controls
        If Mid(teks.Name, 1, 4) = "Text" Or Mid(teks.Name, 1, 3) = "txt" Or Mid(teks.Name, 1, 3) = "lbl" Or Mid(teks.Name, 1, 3) = "cbo" Then
            If teks = "" Then
                MsgBox "Maaf Data Transaksi Tidak Dapat Diubah Karena Masih Ada Field yang Kosong...", vbInformation, "Informasi"
                Exit Sub
            End If
        End If
    Next
    db.Execute ("update penjualan set faktur = '" & txtfaktur.Text & "',tgl_trans='" & DTPicker1.Value & "',kd_pel='" & Text1.Text & "',kd_kendaraan='" & txtkdkendaraan.Text & "',jns_trans='" & cbojenisbayar.Text & "',DP=" & Int(txtDP.Text) & ",Waktu=" & Val(Combo1.Text) & ",besar_angsuran=" & Int(Label14.Caption) & " where faktur = '" & txtfaktur.Text & "'")
    If cbojenisbayar.Text = "Kredit" Then
        Set awal = db.Execute("select hutang from pelanggan where kd_pel = '" & Text1.Text & "'")
        If Not awal.EOF Then
            If awal(0) <> 0 Then
                pertama = awal(0) - (Int(lbltotal.Caption) - Int(txtDP.Text))
                hutang = Int(lbltotal.Caption) - Int(txtDP.Text) + pertama
                db.Execute ("update pelanggan set hutang = " & hutang & " where kd_pel = '" & Text1.Text & "'")
            Else
                hutang = Int(lbltotal.Caption) - Int(txtDP.Text)
                db.Execute ("update pelanggan set hutang = " & hutang & " where kd_pel = '" & Text1.Text & "'")
            End If
        End If
    End If
    Call bersih
    Call cmdenable(False, False, False, False)
End If
End Sub

Private Sub Combo1_Click()
    Label14.Caption = Pembulatan(Int(lbltotal.Caption), Int(txtDP.Text), Val(Combo1.Text))
End Sub

Private Sub Command1_Click()
Form4.Show
End Sub

Private Sub Command2_Click()
Form5.Show
End Sub

Private Sub Form_Load()
Call cmdenable(False, False, False, False)
End Sub

Private Sub Label14_Change()
If Not Label14.Caption = "" And Not Label14.Caption = "0" Then
    If Val(Label14.Caption) > 0 Then
        angka = Format(Label14.Caption, "##,##")
        Label14.Caption = angka
    End If
End If
End Sub

Private Sub Label19_Change()
If Not Label19.Caption = "" And Not Label19.Caption = "0" Then
    If Val(Label19.Caption) > 0 Then
        angka = Format(Label19.Caption, "##,##")
        Label19.Caption = angka
    End If
End If
End Sub

Private Sub lbltotal_Change()
If Not lbltotal.Caption = "" And Not lbltotal.Caption = "0" Then
    If Val(lbltotal.Caption) > 0 Then
        angka = Format(lbltotal.Caption, "##,##")
        lbltotal.Caption = angka
    End If
End If
End Sub

Private Sub Text1_Change()
Dim cekpel As ADODB.Recordset
Set cekpel = db.Execute("select * from pelanggan where kd_pel = '" & Text1.Text & "'")
If Not cekpel.EOF Then
    Label10.Caption = cekpel(1)
Else
    Label10.Caption = ""
End If
End Sub

Private Sub txtadm_Change()
If Not txtadm.Text = "" And Not txtadm.Text = "0" Then
    If Val(txtadm.Text) > 0 Then
        angka = Format(txtadm.Text, "##,##")
        txtadm.Text = angka
        txtadm.SelStart = Len(txtadm.Text)
        lbltotal.Caption = Int(txtharga.Text) + Int(txtbbn.Text) + Int(txtadm.Text)
    End If
End If
End Sub

Private Sub txtadm_GotFocus()
If txtadm.Text = "" Or txtadm.Text = "0" Then
    txtadm.Text = ""
End If
End Sub

Private Sub txtadm_LostFocus()
If txtadm.Text = "" Or txtadm.Text = "0" Then
    txtadm.Text = "0"
End If
End Sub

Private Sub txtangsuran_GotFocus()
If txtangsuran.Text = "" Or txtangsuran.Text = "0" Then
    txtangsuran.Text = ""
End If
End Sub

Private Sub txtangsuran_LostFocus()
If txtangsuran.Text = "" Or txtangsuran.Text = "0" Then
    txtangsuran.Text = "0"
End If
End Sub

Private Sub txtbbn_Change()
If Not txtbbn.Text = "" And Not txtbbn.Text = "0" Then
    If Val(txtbbn.Text) > 0 Then
        angka = Format(txtbbn.Text, "##,##")
        txtbbn.Text = angka
        txtbbn.SelStart = Len(txtbbn.Text)
        lbltotal.Caption = Int(txtharga.Text) + Int(txtbbn.Text) + Int(txtadm.Text)
    End If
End If
End Sub



Private Sub txtbbn_GotFocus()
If txtbbn.Text = "" Or txtbbn.Text = "0" Then
    txtbbn.Text = ""
End If
End Sub

Private Sub txtbbn_LostFocus()
If txtbbn.Text = "" Or txtbbn.Text = "0" Then
    txtbbn.Text = "0"
End If
End Sub

Private Sub txtDP_Change()
If Not txtDP.Text = "" And Not txtDP.Text = "0" Then
    If Val(txtDP.Text) > 0 Then
        angka = Format(txtDP.Text, "##,##")
        txtDP.Text = angka
        txtDP.SelStart = Len(txtDP.Text)
        'Label19.Caption = Int(lbltotal.Caption) - Int(txtDP.Text)
    End If
End If
End Sub

Private Sub txtDP_GotFocus()
If txtDP.Text = "" Or txtDP.Text = "0" Then
    txtDP.Text = ""
End If
End Sub
Private Sub txtDP_LostFocus()
If txtDP.Text = "" Or txtDP.Text = "0" Then
    txtDP.Text = "0"
End If
End Sub

Private Sub txtfaktur_Change()
Dim faktur As ADODB.Recordset
Set faktur = db.Execute("select * from penjualan where faktur='" & txtfaktur.Text & "'")
If Not faktur.EOF Then
    DTPicker1.Value = Format(faktur(1), "dd MMMM yyyy")
    Text1.Text = faktur(2)
    txtkdkendaraan.Text = faktur(3)
    cbojenisbayar.Text = faktur(4)
    If cbojenisbayar.Text = "Kredit" Then
        txtDP.Text = faktur(5)
        Combo1.Text = faktur(6)
        Label14.Caption = faktur(7)
    End If
    Call cmdenable(False, True, True, True)
Else
    DTPicker1.Value = Format(Date, "dd MMMM yyyy")
    Text1.Text = ""
    txtkdkendaraan.Text = ""
    cbojenisbayar.Text = ""
    lbltotal.Caption = "0"
    txtDP.Text = "0"
    Combo1.Text = ""
    Label14.Caption = "0"
    Call cmdenable(True, False, False, True)
End If
End Sub

Private Sub txtfaktur_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub txtkdkendaraan_Change()
Dim harga As Currency
Dim cek As ADODB.Recordset
Set cek = db.Execute("select * from kendaraan where kd_kendaraan = '" & txtkdkendaraan.Text & "'")
If Not cek.EOF Then
    lblnmkendaraan.Caption = cek(3)
    lbltype.Caption = cek(1)
    lbltahun.Caption = cek(4)
    harga = cek(9) + cek(10) + cek(11)
    lbltotal.Caption = harga
Else
    lblnmkendaraan.Caption = ""
    lbltype.Caption = ""
    lbltahun.Caption = ""
    lbltotal.Caption = "0"
End If
End Sub


Private Sub bersih()
txtfaktur.Text = ""
DTPicker1.Value = Format(Date, "dd MMMM yyyy")
Text1.Text = ""
Label10.Caption = ""
txtkdkendaraan.Text = ""
lblnmkendaraan.Caption = ""
lbltype.Caption = ""
lbltahun.Caption = ""
cbojenisbayar.Text = ""
lbltotal.Caption = "0"
txtDP.Text = "0"
Combo1.Text = ""
Label14.Caption = "0"
txtfaktur.SetFocus
End Sub
Private Sub cmdenable(var1, var2, var3, var4 As Boolean)
CmdSave.Enabled = var1
CmdUpdate.Enabled = var2
CmdDelete.Enabled = var3
CmdCancel.Enabled = var4
End Sub


FORM ENTRY DATA ANGSURAN KREDIT
Dim angka As String
Dim pesan, lagi As String
Dim n, br As Integer
Dim baris As Integer

Private Sub CmdCancel_Click()
    Call bersih
    Call cmdenable(False, False, False, False)
End Sub

Private Sub CmdDelete_Click()
    pesan = MsgBox("Anda Yakin Ingin Menghapus Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        db.Execute ("Delete * from DetailKredit where kd_kendaraan = '" & Combo1.Text & "'")
        Call bersih
        Call cmdenable(False, False, False, False)
    End If
End Sub

Private Sub CmdExit_Click()
Unload Me
End Sub

Private Sub CmdSave_Click()
    pesan = MsgBox("Anda Yakin Ingin Menyimpan Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        For i = 1 To Flex.Rows - 1
            db.Execute ("insert into DetailKredit values ('" & Combo1.Text & "'," & Int(Flex.TextMatrix(i, 1)) & "," & Int(Flex.TextMatrix(i, 2)) & "," & Int(Flex.TextMatrix(i, 3)) & "," & Int(Flex.TextMatrix(i, 4)) & "," & Int(Flex.TextMatrix(i, 5)) & "," & Int(Flex.TextMatrix(i, 6)) & ")")
        Next i
        Call bersih
        Call cmdenable(False, False, False, False)
    End If
End Sub

Private Sub CmdUpdate_Click()
    pesan = MsgBox("Anda Yakin Ingin Mengubah Data Ini...???", vbQuestion + vbYesNo, "Informasi")
    If pesan = vbYes Then
        db.Execute ("delete * from detailkredit where kd_kendaraan = '" & Combo1.Text & "'")
        For i = 1 To Flex.Rows - 1
            db.Execute ("insert into DetailKredit values ('" & Combo1.Text & "'," & Int(Flex.TextMatrix(i, 1)) & "," & Int(Flex.TextMatrix(i, 2)) & "," & Int(Flex.TextMatrix(i, 3)) & "," & Int(Flex.TextMatrix(i, 4)) & "," & Int(Flex.TextMatrix(i, 5)) & "," & Int(Flex.TextMatrix(i, 6)) & ")")
        Next i
        Call bersih
        Call cmdenable(False, False, False, False)
    End If
End Sub

Private Sub Combo1_Click()
Dim cari As ADODB.Recordset
Dim harga As ADODB.Recordset
Set cari = db.Execute("select * from Kendaraan where kd_kendaraan = '" & Combo1.Text & "'")
If Not cari.EOF Then
    Label13.Caption = cari(1)
    Label12.Caption = cari(9) + cari(10) + cari(11)
    Set harga = db.Execute("select * from DetailKredit where kd_kendaraan = '" & Combo1.Text & "'")
    If Not harga.EOF Then
        n = 0
        harga.MoveFirst
        While Not harga.EOF
            n = n + 1
            Flex.Rows = n + 1
            Flex.TextMatrix(n, 1) = harga(1)
            Flex.TextMatrix(n, 2) = harga(2)
            Flex.TextMatrix(n, 3) = harga(3)
            Flex.TextMatrix(n, 4) = harga(4)
            Flex.TextMatrix(n, 5) = harga(5)
            Flex.TextMatrix(n, 6) = harga(6)
            'Call isilist
        harga.MoveNext
        Wend
        Call cmdenable(False, True, True, True)
    Else
        Text1.Text = "0"
        Text3.Text = "0"
        Text4.Text = "0"
        Text5.Text = "0"
        Text6.Text = "0"
        Text7.Text = "0"
        Flex.Clear
        Flex.Rows = 2
        n = 0
        Call cmdenable(True, False, False, True)
    End If
End If
End Sub

Private Sub Combo2_Click()
Dim angsuran As ADODB.Recordset
Set angsuran = db.Execute("select angsuran from Daftarharga where Waktu = '" & Combo2.Text & "' and type = '" & Combo1.Text & "' and DP = " & Int(Text3.Text) & "")
If Not angsuran.EOF Then
    Text1.Text = Format(angsuran(0), "##,##")
End If
End Sub

Private Sub Flex_Click()
    baris = Flex.Row
    Text1.Text = Flex.TextMatrix(baris, 1)
    Text3.Text = Flex.TextMatrix(baris, 2)
    Text4.Text = Flex.TextMatrix(baris, 3)
    Text5.Text = Flex.TextMatrix(baris, 4)
    Text6.Text = Flex.TextMatrix(baris, 5)
    Text7.Text = Flex.TextMatrix(baris, 6)
End Sub

Private Sub Flex_DblClick()
Dim kata As String
    kata = MsgBox("Anda Ingin Membuang Data Ini...??", vbQuestion + vbYesNo, "Yakin")
    If kata = vbYes Then
        Flex.RemoveItem (Flex.Row)
        Flex.Sort = 0
        n = n - 1
        Text1.Text = "0"
        Text3.Text = "0"
        Text4.Text = "0"
        Text5.Text = "0"
        Text6.Text = "0"
        Text7.Text = "0"
        Text1.SetFocus
    End If
End Sub

Private Sub Form_Load()
Flex.ColWidth(0) = 0
Flex.ColWidth(1) = 1480
Flex.ColWidth(2) = 1300
Flex.ColWidth(3) = 1310
Flex.ColWidth(4) = 1380
Flex.ColWidth(5) = 1380
Flex.ColWidth(6) = 1400

Dim kendaraan As ADODB.Recordset
Set kendaraan = db.Execute("select * from kendaraan")
If Not kendaraan.EOF Then
    kendaraan.MoveFirst
    While Not kendaraan.EOF
        Combo1.AddItem kendaraan(0)
    kendaraan.MoveNext
    Wend
End If
n = 0
br = 0
Call cmdenable(False, False, False, False)
End Sub
Private Sub Label12_Change()
If Not Label12.Caption = "" And Not Label12.Caption = "0" Then
    If Val(Label12.Caption) > 0 Then
        angka = Format(Label12.Caption, "##,##")
        Label12.Caption = angka
    End If
End If
End Sub
Private Sub Text1_Change()
If Not Text1.Text = "" And Not Text1.Text = "0" Then
    If Val(Text1.Text) > 0 Then
        angka = Format(Text1.Text, "##,##")
        Text1.Text = angka
        Text1.SelStart = Len(Text1.Text)
    End If
End If
End Sub

Private Sub Text1_GotFocus()
If Text1.Text = "" Or Text1.Text = "0" Then
    Text1.Text = ""
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim pesan As String
If KeyAscii = 13 Then
    SendKeys ("{Tab}")
End If
End Sub

Private Sub Text1_LostFocus()
If Text1.Text = "" Or Text1.Text = "0" Then
    Text1.Text = "0"
End If
End Sub

Private Sub Text2_Change()
If Not Text2.Text = "" And Not Text2.Text = "0" Then
    If Val(Text2.Text) > 0 Then
        angka = Format(Text2.Text, "##,##")
        Text2.Text = angka
    End If
End If
End Sub
Private Sub Text2_GotFocus()
If Text2.Text = "" Or Text2.Text = "0" Then
    Text2.Text = ""
End If
End Sub

Private Sub Text2_LostFocus()
If Text2.Text = "" Or Text2.Text = "0" Then
    Text2.Text = "0"
End If
End Sub

Private Sub Text3_Change()
If Not Text3.Text = "" And Not Text3.Text = "0" Then
    If Val(Text3.Text) > 0 Then
        angka = Format(Text3.Text, "##,##")
        Text3.Text = angka
        Text3.SelStart = Len(Text3.Text)
    End If
End If
End Sub

Private Sub Text3_GotFocus()
If Text3.Text = "" Or Text3.Text = "0" Then
    Text3.Text = ""
End If
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    pesan = MsgBox("Isikan Jumlah Angsuran Untuk Jangka Waktu Ini..??", vbQuestion + vbYesNo, "Jumlah Angsuran")
    If pesan = vbYes Then
        Text3.Text = Pembulatan(Int(Label12.Caption), Int(Text1.Text), 12)
    End If
End If
End Sub

Private Sub Text3_LostFocus()
If Text3.Text = "" Or Text3.Text = "0" Then
    Text3.Text = "0"
End If
End Sub

Private Sub bersih()
Combo1.Text = ""
Label13.Caption = ""
Label13.Caption = "0"
Text1.Text = "0"
Text3.Text = "0"
Text4.Text = "0"
Text5.Text = "0"
Text6.Text = "0"
Text7.Text = "0"
Flex.Clear
Flex.Rows = 2
Combo1.SetFocus
End Sub

Private Sub cmdenable(var1, var2, var3, var4 As Boolean)
CmdSave.Enabled = var1
CmdUpdate.Enabled = var2
CmdDelete.Enabled = var3
CmdCancel.Enabled = var4
End Sub

Private Sub Text4_Change()
If Not Text4.Text = "" And Not Text4.Text = "0" Then
    If Val(Text4.Text) > 0 Then
        angka = Format(Text4.Text, "##,##")
        Text4.Text = angka
        Text4.SelStart = Len(Text4.Text)
    End If
End If
End Sub

Private Sub Text4_GotFocus()
If Text4.Text = "" Or Text4.Text = "0" Then
    Text4.Text = ""
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    pesan = MsgBox("Isikan Jumlah Angsuran Untuk Jangka Waktu Ini..??", vbQuestion + vbYesNo, "Jumlah Angsuran")
    If pesan = vbYes Then
        Text4.Text = Pembulatan(Int(Label12.Caption), Int(Text1.Text), 18)
    End If
End If
End Sub

Private Sub Text4_LostFocus()
If Text4.Text = "" Or Text4.Text = "0" Then
    Text4.Text = "0"
End If
End Sub

Private Sub Text5_Change()
If Not Text5.Text = "" And Not Text5.Text = "0" Then
    If Val(Text5.Text) > 0 Then
        angka = Format(Text5.Text, "##,##")
        Text5.Text = angka
        Text5.SelStart = Len(Text5.Text)
    End If
End If
End Sub

Private Sub Text5_GotFocus()
If Text5.Text = "" Or Text5.Text = "0" Then
    Text5.Text = ""
End If
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    pesan = MsgBox("Isikan Jumlah Angsuran Untuk Jangka Waktu Ini..??", vbQuestion + vbYesNo, "Jumlah Angsuran")
    If pesan = vbYes Then
        Text5.Text = Pembulatan(Int(Label12.Caption), Int(Text1.Text), 24)
    End If
End If
End Sub

Private Sub Text5_LostFocus()
If Text5.Text = "" Or Text5.Text = "0" Then
    Text5.Text = "0"
End If
End Sub

Private Sub Text6_Change()
If Not Text6.Text = "" And Not Text6.Text = "0" Then
    If Val(Text6.Text) > 0 Then
        angka = Format(Text6.Text, "##,##")
        Text6.Text = angka
        Text6.SelStart = Len(Text6.Text)
    End If
End If
End Sub
Private Sub Text6_GotFocus()
If Text6.Text = "" Or Text6.Text = "0" Then
    Text6.Text = ""
End If
End Sub
Private Sub Text6_LostFocus()
If Text6.Text = "" Or Text6.Text = "0" Then
    Text6.Text = "0"
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    pesan = MsgBox("Isikan Jumlah Angsuran Untuk Jangka Waktu Ini..??", vbQuestion + vbYesNo, "Jumlah Angsuran")
    If pesan = vbYes Then
        Text6.Text = Pembulatan(Int(Label12.Caption), Int(Text1.Text), 36)
    End If
End If
End Sub

Private Sub Text7_Change()
If Not Text7.Text = "" And Not Text7.Text = "0" Then
    If Val(Text7.Text) > 0 Then
        angka = Format(Text7.Text, "##,##")
        Text7.Text = angka
        Text7.SelStart = Len(Text7.Text)
    End If
End If
End Sub

Private Sub Text7_GotFocus()
If Text7.Text = "" Or Text7.Text = "0" Then
    Text7.Text = ""
End If
End Sub

Private Sub Text7_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
    pesan = MsgBox("Isikan Jumlah Angsuran Untuk Jangka Waktu Ini..??", vbQuestion + vbYesNo, "Jumlah Angsuran")
    If pesan = vbYes Then
        Text7.Text = Pembulatan(Int(Label12.Caption), Int(Text1.Text), 48)
    Else
        Text7.Text = 0
    End If
    Call isilist
End If
End Sub

Private Sub Text7_LostFocus()
If Text7.Text = "" Or Text7.Text = "0" Then
    Text7.Text = "0"
    Call isilist
End If
End Sub

Private Sub isilist()
If Text1.Text <> "0" And Text1.Text <> "" Then
    For i = 1 To Flex.Rows - 1
        If Text1.Text = Flex.TextMatrix(i, 1) Then
            br = i
            i = Flex.Rows - 1
        End If
    Next i
    If br <> 0 Then
        Flex.TextMatrix(br, 1) = Text1.Text
        Flex.TextMatrix(br, 2) = Text3.Text
        Flex.TextMatrix(br, 3) = Text4.Text
        Flex.TextMatrix(br, 4) = Text5.Text
        Flex.TextMatrix(br, 5) = Text6.Text
        Flex.TextMatrix(br, 6) = Text7.Text
        n = br
    Else
        n = n + 1
        Flex.Rows = n + 1
        Flex.TextMatrix(n, 1) = Text1.Text
        Flex.TextMatrix(n, 2) = Text3.Text
        Flex.TextMatrix(n, 3) = Text4.Text
        Flex.TextMatrix(n, 4) = Text5.Text
        Flex.TextMatrix(n, 5) = Text6.Text
        Flex.TextMatrix(n, 6) = Text7.Text
    End If
    Text1.Text = "0"
    Text3.Text = "0"
    Text4.Text = "0"
    Text5.Text = "0"
    Text6.Text = "0"
    Text7.Text = "0"
    Text1.SetFocus
End If
End Sub

FORM ENTRY DETAIL ANGSURAN
Dim pesan As String

Private Sub cbokdkendaraan_Change()
Dim kendaraan As ADODB.Recordset
Dim nilai As String
Set kendaraan = db.Execute("select nama,harga,bbm,adm from kendaraan where kd_kendaraan = '" & cbokdkendaraan.Text & "'")
If Not kendaraan.EOF Then
    lblnmkendaraan.Caption = kendaraan(0)
    nilai = kendaraan(1) + kendaraan(2) + kendaraan(3)
    lblotr.Caption = Format(nilai, "##,##")
End If
End Sub

Private Sub cboke_Click()
Dim angsuran As ADODB.Recordset
Set angsuran = db.Execute("select * from angsuran where faktur='" & txtfaktur.Text & "' and kd_kendaraan = '" & cbokdkendaraan.Text & "' and ke = '" & cboke.Text & "'")
If Not angsuran.EOF Then
    MsgBox "Angsuran ke : " & cboke.Text & " telah dimasukkan...!!", vbInformation, "Informasi"
    cboke.SetFocus
    CmdDelete.Enabled = True
    CmdSave.Enabled = False
Else
    CmdDelete.Enabled = False
    CmdSave.Enabled = True
End If
End Sub

Private Sub cboke_KeyPress(KeyAscii As Integer)
Dim sisa As String
If KeyAscii = 13 Then
    sisa = Int(lblhutang.Caption) - Int(lblangsuran.Caption)
    lblsisa.Caption = Format(sisa, "##,##")
End If
End Sub
Private Sub CmdCancel_Click()
Call bersih
End Sub
Private Sub CmdDelete_Click()
pesan = MsgBox("Apakan Anda Yakin Ingin Menghapus Data Ini....???", vbQuestion + vbYesNo, "Yakin")
If pesan = vbYes Then
    db.Execute ("Delete * from Angsuran where faktur='" & txtfaktur.Text & "' and kd_kendaraan = '" & cbokdkendaraan.Text & "' and ke = '" & cboke.Text & "'")
    Call bersih
    Call cmdenable(False, False, False)
End If
End Sub

Private Sub CmdExit_Click()
Unload Me
End Sub

Private Sub CmdSave_Click()
pesan = MsgBox("Apakan Anda Yakin Ingin Menyimpan Data Ini....???", vbQuestion + vbYesNo, "Yakin")
If pesan = vbYes Then
    db.Execute ("update pelanggan set hutang = " & Int(lblhutang.Caption) - Int(lblangsuran.Caption) & " where kd_pel = '" & lblkdpel.Caption & "'")
    db.Execute ("Insert into Angsuran values('" & txtfaktur.Text & "','" & cbokdkendaraan.Text & "','" & cboke.Text & "')")
    Call bersih
    Call cmdenable(False, False, False)
End If
End Sub
Private Sub Form_Load()
Call cmdenable(False, False, False)
End Sub
Private Sub lblkdpel_Change()
Dim pelanggan As ADODB.Recordset
Set pelanggan = db.Execute("select nm_pel,hutang from pelanggan where kd_pel = '" & lblkdpel.Caption & "'")
If Not pelanggan.EOF Then
    lblnmpel.Caption = pelanggan(0)
    lblhutang.Caption = Format(pelanggan(1), "##,##")
End If
End Sub
Private Sub txtfaktur_Change()
Dim carifaktur As ADODB.Recordset
Set carifaktur = db.Execute("select tgl_trans,kd_pel,kd_kendaraan,dp,waktu,besar_angsuran from penjualan where faktur = '" & txtfaktur.Text & "' and jns_trans = 'Kredit'")
If Not carifaktur.EOF Then
    cbokdkendaraan.Clear
    cboke.Clear
    Lbltgl.Caption = Format(carifaktur(0), "dd MMMM yyyy")
    lblkdpel.Caption = carifaktur(1)
    cbokdkendaraan.Text = carifaktur(2)
    lbldp.Caption = Format(carifaktur(3), "##,##")
    lblwaktu.Caption = carifaktur(4)
    lblangsuran.Caption = Format(carifaktur(5), "##,##")
    carifaktur.MoveFirst
    For i = 1 To carifaktur(4)
        cboke.AddItem i
    Next i
    While Not carifaktur.EOF
        cbokdkendaraan.AddItem carifaktur(2)
    carifaktur.MoveNext
    Wend
    Call cmdenable(True, False, True)
Else
    Lbltgl.Caption = ""
    lblkdpel.Caption = ""
    lblnmpel.Caption = ""
    lblhutang.Caption = "0"
    lblwaktu.Caption = ""
    lbldp.Caption = "0"
    cbokdkendaraan.Text = ""
    lblnmkendaraan.Caption = ""
    lblotr.Caption = "0"
    lblangsuran.Caption = "0"
    cboke.Text = ""
    lblsisa.Caption = "0"
    Call cmdenable(True, False, True)
End If
End Sub
Private Sub txtfaktur_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Private Sub bersih()
txtfaktur.Text = ""
Lbltgl.Caption = ""
lblkdpel.Caption = ""
lblnmpel.Caption = ""
lblhutang.Caption = "0"
lblwaktu.Caption = ""
lbldp.Caption = "0"
cbokdkendaraan.Text = ""
lblnmkendaraan.Caption = ""
lblotr.Caption = "0"
lblangsuran.Caption = "0"
cboke.Text = ""
lblsisa.Caption = "0"
txtfaktur.SetFocus
End Sub

Private Sub cmdenable(var1, var2, var3 As Boolean)
CmdSave.Enabled = var1
CmdDelete.Enabled = var2
CmdCancel.Enabled = var3
End Sub



FORM INFORMASI DATA KENDARAAN
Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim tampil As ADODB.Recordset
Flex.ColWidth(0) = 600
Flex.ColWidth(1) = 1000
Flex.ColWidth(2) = 3500
Flex.ColWidth(3) = 1000
Flex.ColWidth(4) = 1000
Flex.ColWidth(5) = 1000
Flex.TextMatrix(0, 0) = "No."
Flex.TextMatrix(0, 1) = "Kode"
Flex.TextMatrix(0, 2) = "Nama Kendaraan"
Flex.TextMatrix(0, 3) = "Merk"
Flex.TextMatrix(0, 4) = "Tahun"
Flex.TextMatrix(0, 5) = "Harga"
Flex.ColAlignment(0) = 3
Flex.ColAlignment(1) = 3
Flex.ColAlignment(3) = 3
Flex.ColAlignment(4) = 3
Set tampil = db.Execute("select kd_kendaraan,nama,Merk,tahun,harga,bbm,adm from kendaraan order by kd_kendaraan")
If Not tampil.EOF Then
    n = 0
    tampil.MoveFirst
    While Not tampil.EOF
        n = n + 1
        Flex.Rows = n + 1
        Flex.TextMatrix(n, 0) = n
        Flex.TextMatrix(n, 1) = tampil(0)
        Flex.TextMatrix(n, 2) = tampil(1)
        Flex.TextMatrix(n, 3) = tampil(2)
        Flex.TextMatrix(n, 4) = tampil(3)
        Flex.TextMatrix(n, 5) = tampil(4) + tampil(5) + tampil(6)
    tampil.MoveNext
    Wend
End If
End Sub

Private Sub Text1_Change()
Dim cari As ADODB.Recordset
If Combo1.Text = "Kode Kendaraan" Then
    Set cari = db.Execute("select kd_kendaraan,nama,merk,tahun,harga,bbm,adm from kendaraan where kd_kendaraan like '" & Text1.Text & "%' order by kd_kendaraan")
ElseIf Combo1.Text = "Merk Kendaraan" Then
    Set cari = db.Execute("select kd_kendaraan,nama,merk,tahun,harga,bbm,adm from kendaraan where merk like '" & Text1.Text & "%' order by kd_kendaraan")
ElseIf Combo1.Text = "Tahun Pembuatan" Then
    Set cari = db.Execute("select kd_kendaraan,nama,merk,tahun,harga,bbm,adm from kendaraan where tahun like '" & Text1.Text & "%' order by kd_kendaraan")
End If
    If Not cari.EOF Then
        n = 0
        cari.MoveFirst
        While Not cari.EOF
            n = n + 1
            Flex.Rows = n + 1
            Flex.TextMatrix(n, 0) = n
            Flex.TextMatrix(n, 1) = cari(0)
            Flex.TextMatrix(n, 2) = cari(1)
            Flex.TextMatrix(n, 3) = cari(2)
            Flex.TextMatrix(n, 4) = cari(3)
            Flex.TextMatrix(n, 5) = cari(4) + cari(5) + cari(6)
        cari.MoveNext
        Wend
    Else
        n = 0
        Flex.Clear
        Flex.Rows = 2
        Flex.TextMatrix(0, 0) = "No."
        Flex.TextMatrix(0, 1) = "Kode"
        Flex.TextMatrix(0, 2) = "Nama Kendaraan"
        Flex.TextMatrix(0, 3) = "Merk"
        Flex.TextMatrix(0, 4) = "Tahun"
        Flex.TextMatrix(0, 5) = "Harga"
    End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub


FORM INFORMASI DATA PELANGGAN
Dim n As Integer
Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Form_Load()
Dim tampil As ADODB.Recordset
Flex.ColWidth(0) = 600
Flex.ColWidth(1) = 1000
Flex.ColWidth(2) = 3500
Flex.ColWidth(3) = 3500
Flex.ColWidth(4) = 1200
Flex.ColWidth(5) = 1200
Flex.ColWidth(6) = 1200
Flex.TextMatrix(0, 0) = "No."
Flex.TextMatrix(0, 1) = "Kode"
Flex.TextMatrix(0, 2) = "Nama Pelanggan"
Flex.TextMatrix(0, 3) = "Alamat"
Flex.TextMatrix(0, 4) = "Telepon"
Flex.TextMatrix(0, 5) = "No. ID"
Flex.TextMatrix(0, 6) = "Pekerjaan"
Flex.ColAlignment(0) = 3
Flex.ColAlignment(1) = 3
Flex.ColAlignment(4) = 3
Flex.ColAlignment(5) = 3
Set tampil = db.Execute("select * from pelanggan order by kd_pel")
If Not tampil.EOF Then
    n = 0
    tampil.MoveFirst
    While Not tampil.EOF
        n = n + 1
        Flex.Rows = n + 1
        Flex.TextMatrix(n, 0) = n
        Flex.TextMatrix(n, 1) = tampil(0)
        Flex.TextMatrix(n, 2) = tampil(1)
        Flex.TextMatrix(n, 3) = tampil(2)
        Flex.TextMatrix(n, 4) = tampil(3)
        Flex.TextMatrix(n, 5) = tampil(4)
        Flex.TextMatrix(n, 6) = tampil(5)
    tampil.MoveNext
    Wend
End If
End Sub
Private Sub Text1_Change()
Dim cari As ADODB.Recordset
If Combo1.Text = "Kode Pelanggan" Then
    Set cari = db.Execute("select * from pelanggan where kd_pel like '" & Text1.Text & "%' order by kd_pel")
ElseIf Combo1.Text = "Nama Pelanggan" Then
    Set cari = db.Execute("select * from pelanggan where nm_pel like '" & Text1.Text & "%' order by kd_pel")
ElseIf Combo1.Text = "Pekerjaan" Then
    Set cari = db.Execute("select * from pelanggan where pekerjaan like '" & Text1.Text & "%' order by kd_pel")
End If
    If Not cari.EOF Then
        n = 0
        cari.MoveFirst
        While Not cari.EOF
            n = n + 1
            Flex.Rows = n + 1
            Flex.TextMatrix(n, 0) = n
            Flex.TextMatrix(n, 1) = cari(0)
            Flex.TextMatrix(n, 2) = cari(1)
            Flex.TextMatrix(n, 3) = cari(2)
            Flex.TextMatrix(n, 4) = cari(3)
            Flex.TextMatrix(n, 5) = cari(4)
            Flex.TextMatrix(n, 6) = cari(5)
        cari.MoveNext
        Wend
    Else
        n = 0
        Flex.Clear
        Flex.Rows = 2
        Flex.TextMatrix(0, 0) = "No."
        Flex.TextMatrix(0, 1) = "Kode"
        Flex.TextMatrix(0, 2) = "Nama Pelanggan"
        Flex.TextMatrix(0, 3) = "Alamat"
        Flex.TextMatrix(0, 4) = "Telepon"
        Flex.TextMatrix(0, 5) = "No. ID"
        Flex.TextMatrix(0, 6) = "Pekerjaan"
    End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub






FORM INFORMASI DATA TRANSAKSI
Dim n As Integer

Private Sub Combo2_Click()
If Combo2.Text = "No. Faktur" Then
    Text1.Visible = True
    DTPicker1.Visible = False
Else
    Text1.Visible = False
    DTPicker1.Visible = True
End If
End Sub

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub DTPicker1_Change()
Call Text1_Change
End Sub

Private Sub Form_Load()
Dim tampil As ADODB.Recordset
Dim total As Currency
DTPicker1.Value = Date
Text1.Visible = True
DTPicker1.Visible = False

Flex.ColWidth(0) = 600
Flex.ColWidth(1) = 1000
Flex.ColWidth(2) = 1200
Flex.ColWidth(3) = 3500
Flex.ColWidth(4) = 3500
Flex.ColWidth(5) = 1200
Flex.ColWidth(6) = 1200
Flex.ColWidth(7) = 1200
Flex.ColWidth(8) = 1200
Flex.ColWidth(9) = 1200

Flex.TextMatrix(0, 0) = "No."
Flex.TextMatrix(0, 1) = "Faktur"
Flex.TextMatrix(0, 2) = "Tgl. Transaksi"
Flex.TextMatrix(0, 3) = "Nama Pelanggan"
Flex.TextMatrix(0, 4) = "Nama Kendaraan"
Flex.TextMatrix(0, 5) = "Pembayaran"
Flex.TextMatrix(0, 6) = "Hrg. Kosong"
Flex.TextMatrix(0, 7) = "Biaya BBN"
Flex.TextMatrix(0, 8) = "Biaya ADM"
Flex.TextMatrix(0, 9) = "Total"

Flex.ColAlignment(0) = 3
Flex.ColAlignment(1) = 3
Flex.ColAlignment(2) = 3
Flex.ColAlignment(5) = 3

Set tampil = db.Execute("select penjualan.faktur,penjualan.tgl_trans,pelanggan.nm_pel,kendaraan.nama,penjualan.jns_trans,kendaraan.harga,kendaraan.bbm,kendaraan.adm from penjualan,pelanggan,kendaraan where penjualan.kd_pel=pelanggan.kd_pel and penjualan.kd_kendaraan=kendaraan.kd_kendaraan order by faktur")
If Not tampil.EOF Then
    n = 0
    tampil.MoveFirst
    While Not tampil.EOF
        n = n + 1
        Flex.Rows = n + 1
        Flex.TextMatrix(n, 0) = n
        Flex.TextMatrix(n, 1) = tampil(0)
        Flex.TextMatrix(n, 2) = tampil(1)
        Flex.TextMatrix(n, 3) = tampil(2)
        Flex.TextMatrix(n, 4) = tampil(3)
        Flex.TextMatrix(n, 5) = tampil(4)
        Flex.TextMatrix(n, 6) = Format(tampil(5), "##,##")
        Flex.TextMatrix(n, 7) = Format(tampil(6), "##,##")
        Flex.TextMatrix(n, 8) = Format(tampil(7), "##,##")
        total = Int(tampil(5)) + Int(tampil(6)) + Int(tampil(7))
        Flex.TextMatrix(n, 9) = Format(total, "##,##")
    tampil.MoveNext
    Wend
End If
End Sub

Private Sub Text1_Change()
Dim cari As ADODB.Recordset
Dim total As Currency
If Combo2.Text = "No. Faktur" Then
    Set cari = db.Execute("select penjualan.faktur,penjualan.tgl_trans,pelanggan.nm_pel,kendaraan.nama,penjualan.jns_trans,kendaraan.harga,kendaraan.bbm,kendaraan.adm from penjualan,pelanggan,kendaraan where penjualan.kd_pel=pelanggan.kd_pel and penjualan.kd_kendaraan=kendaraan.kd_kendaraan and faktur like '" & Text1.Text & "%' and jns_trans = '" & Combo1.Text & "' order by faktur")
ElseIf Combo2.Text = "Tgl. Transaksi" Then
    Set cari = db.Execute("select penjualan.faktur,penjualan.tgl_trans,pelanggan.nm_pel,kendaraan.nama,penjualan.jns_trans,kendaraan.harga,kendaraan.bbm,kendaraan.adm from penjualan,pelanggan,kendaraan where penjualan.kd_pel=pelanggan.kd_pel and penjualan.kd_kendaraan=kendaraan.kd_kendaraan and cdate(tgl_trans) ='" & DTPicker1.Value & "' and jns_trans = '" & Combo1.Text & "' order by faktur")
End If
    If Not cari.EOF Then
        n = 0
        cari.MoveFirst
        While Not cari.EOF
            n = n + 1
            Flex.Rows = n + 1
            Flex.TextMatrix(n, 0) = n
            Flex.TextMatrix(n, 1) = cari(0)
            Flex.TextMatrix(n, 2) = cari(1)
            Flex.TextMatrix(n, 3) = cari(2)
            Flex.TextMatrix(n, 4) = cari(3)
            Flex.TextMatrix(n, 5) = cari(4)
            Flex.TextMatrix(n, 6) = Format(cari(5), "##,##")
            Flex.TextMatrix(n, 7) = Format(cari(6), "##,##")
            Flex.TextMatrix(n, 8) = Format(cari(7), "##,##")
            total = Int(cari(5)) + Int(cari(6)) + Int(cari(7))
            Flex.TextMatrix(n, 9) = Format(total, "##,##")
        cari.MoveNext
        Wend
    Else
        n = 0
        Flex.Clear
        Flex.Rows = 2
        Flex.TextMatrix(0, 0) = "No."
        Flex.TextMatrix(0, 1) = "Faktur"
        Flex.TextMatrix(0, 2) = "Tgl. Transaksi"
        Flex.TextMatrix(0, 3) = "Nama Pelanggan"
        Flex.TextMatrix(0, 4) = "Nama Kendaraan"
        Flex.TextMatrix(0, 5) = "Pembayaran"
        Flex.TextMatrix(0, 6) = "Hrg. Kosong"
        Flex.TextMatrix(0, 7) = "Biaya BBN"
        Flex.TextMatrix(0, 8) = "Biaya ADM"
        Flex.TextMatrix(0, 9) = "Total"
    End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub


FORM LAPORAN DETAIL ANGSURAN
Private Sub Command1_Click()
Report.ReportFileName = App.Path & "\rptdetail.rpt"
Report.DataFiles(0) = App.Path & "\penjualan.mdb"
Report.ReplaceSelectionFormula "{DetailKredit.kd_kendaraan} = '" & Text1.Text & "'"
Report.WindowState = crptMaximized
Report.Action = 7
Report.Reset
End Sub


Private Sub Command2_Click()
Unload Me
End Sub


FORM LAPORAN DATA ANGSURAN PELANGGAN

Private Sub Command1_Click()
Report.ReportFileName = App.Path & "\rptangsuranpel.rpt"
Report.DataFiles(0) = App.Path & "\penjualan.mdb"
Report.ReplaceSelectionFormula "{Angsuran.faktur} = '" & Text1.Text & "' and {Angsuran.kd_kendaraan} = '" & Combo1.Text & "'"
Report.WindowState = crptMaximized
Report.Action = 7
Report.Reset
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim kendaraan As ADODB.Recordset
If KeyAscii = 13 Then
    Set kendaraan = db.Execute("select kd_Kendaraan from penjualan where faktur = '" & Text1.Text & "'")
    If Not kendaraan.EOF Then
        Combo1.Clear
        kendaraan.MoveFirst
        While Not kendaraan.EOF
            Combo1.AddItem kendaraan(0)
        kendaraan.MoveNext
        Wend
    End If
End If
End Sub


SUMBER : http://www.yongkiadi.com/2011/01/kumpulan-aplikasi-spk-sistem-penunjang.html








 

Tidak ada komentar:

Diberdayakan oleh Blogger.