APLIKASI RENTAL MOBIL - VB.NET

 

 

 

 

 

 

 

 

 

Membuat module

 

Imports System.Data.OleDb

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

 

Module Module1

 

    Public Conn As OleDbConnection

    Public DA As OleDbDataAdapter

    Public DS As DataSet

    Public CMD As OleDbCommand

    Public DR As OleDbDataReader

 

    Public cryRpt As New ReportDocument

    Public crtableLogoninfos As New TableLogOnInfos

    Public crtableLogoninfo As New TableLogOnInfo

    Public crConnectionInfo As New ConnectionInfo

    Public CrTables As Tables

 

    Public Sub setinglaporan()

        With crConnectionInfo

            .ServerName = (Application.StartupPath.ToString & "\rental_mobil.mdb")

            .DatabaseName = (Application.StartupPath.ToString & "\rental_mobil.mdb")

            .UserID = ""

            .Password = ""

        End With

 

        CrTables = cryRpt.Database.Tables

        For Each CrTable In CrTables

            crtableLogoninfo = CrTable.LogOnInfo

            crtableLogoninfo.ConnectionInfo = crConnectionInfo

            CrTable.ApplyLogOnInfo(crtableLogoninfo)

        Next

    End Sub

 

    Public Sub Koneksi()

        Conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=rental_mobil.mdb")

        Conn.Open()

    End Sub

End Module

 

 

 

Imports System.Data.OleDb

 

Public Class Login

 

    Dim hitung As Integer

 

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        Call Koneksi()

        CMD = New OleDbCommand("select * from tblmuser where nama_user='" & Tnama.Text & "' and pwd_user='" & tpassword.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Me.Visible = False

            MenuUtama.Show()

            MenuUtama.panel1.Text = DR.Item(0)

            MenuUtama.panel2.Text = DR.Item(1)

            MenuUtama.panel3.Text = UCase(DR.Item(3))

        Else

            MsgBox("Login gagal")

            Tnama.Clear()

            tpassword.Clear()

            Tnama.Focus()

            hitung = hitung + 1

            If hitung = 3 Then

                MsgBox("Login sudah 3x salah")

                End

            End If

        End If

 

    End Sub

 

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

        End

    End Sub

 

    Private Sub tnama_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Tnama.KeyDown

        If e.KeyCode = Keys.Enter Then

            tpassword.Focus()

        End If

    End Sub

 

    Private Sub tpassword_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tpassword.KeyDown

        If e.KeyCode = Keys.Enter Then

            OK.Focus()

        End If

    End Sub

End Class

 

 

 

 

 

Imports System.Data.OleDb

 

Public Class User

 

    Sub Kosongkan()

        txtkodeuser.Clear()

        txtnamauser.Clear()

        cbostatus.Text = ""

        txtpassword.Clear()

        txtcaridata.Clear()

        txtkodeuser.Focus()

        Call TampilStatus_user()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        txtnamauser.Clear()

        cbostatus.Text = ""

        txtpassword.Clear()

        txtcaridata.Clear()

        txtnamauser.Focus()

    End Sub

 

    Sub Ketemu()

        txtnamauser.Text = DR.Item("nama_User")

        txtpassword.Text = DR.Item("pwd_User")

        cbostatus.Text = DR.Item("Status_user")

        txtnamauser.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblmuser", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub TampilStatus_user()

        CMD = New OleDbCommand("select distinct Status_user from tblmuser", Conn)

        DR = CMD.ExecuteReader

        cbostatus.Items.Clear()

        Do While DR.Read

            cbostatus.Items.Add(DR.Item("Status_user"))

        Loop

    End Sub

 

    Private Sub MasterUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.StartPosition = FormStartPosition.CenterScreen

        Call Koneksi()

        Call Kosongkan()

    End Sub

 

    Private Sub combobox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cbostatus.KeyPress

        If ((e.KeyChar >= "0" And e.KeyChar <= "9") And e.KeyChar <> vbBack) Then e.Handled = True

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntutup.Click

        Me.Close()

    End Sub

 

    Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbostatus.LostFocus

        cbostatus.Text = UCase(cbostatus.Text)

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click

        CMD = New OleDbCommand("select * from tblmuser where kode_User='" & txtkodeuser.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                Dim simpan As String = "insert into tblmuser values ('" & txtkodeuser.Text & "','" & txtnamauser.Text & "','" & txtpassword.Text & "','" & cbostatus.Text & "')"

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

            Else

                Dim edit As String = "update tblmuser set nama_User='" & txtnamauser.Text & "',Status_user='" & cbostatus.Text & "',pwd_User='" & txtpassword.Text & "' where kode_User='" & txtkodeuser.Text & "'"

                CMD = New OleDbCommand(edit, Conn)

                CMD.ExecuteNonQuery()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

        Call Kosongkan()

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        txtkodeuser.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        txtnamauser.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        txtpassword.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        cbostatus.Text = DGV.Rows(e.RowIndex).Cells(3).Value

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click

        If txtkodeuser.Text = "" Then

            MsgBox("Kode User harus diisi")

            txtkodeuser.Focus()

            Exit Sub

        End If

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from tblmuser where kode_User='" & txtkodeuser.Text & "'"

            CMD = New OleDbCommand(hapus, Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtkodeuser.LostFocus

        CMD = New OleDbCommand("select * from tblmuser where kode_User='" & txtkodeuser.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            Call DataBaru()

        Else

            Call Ketemu()

        End If

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcaridata.TextChanged

        DA = New OleDbDataAdapter("select * from tblmuser where nama_User like '%" & txtcaridata.Text & "%'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class Supir

 

    Sub Kosongkan()

        txtkode.Clear()

        txtnama.Clear()

        txttelp.Text = ""

        txtalamat.Clear()

        txtcaridata.Clear()

        txtkode.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        txtnama.Clear()

        txttelp.Text = ""

        txtalamat.Clear()

        txtcaridata.Clear()

        txtnama.Focus()

    End Sub

 

    Sub Ketemu()

        txtnama.Text = DR.Item("nama_supir")

        txtalamat.Text = DR.Item("alamat_supir")

        txttelp.Text = DR.Item("telp_Supir")

        txtnama.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblmsupir", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub Supir_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.StartPosition = FormStartPosition.CenterScreen

        Call Koneksi()

        Call Kosongkan()

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntutup.Click

        Me.Close()

    End Sub

 

    Private Sub ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txttelp.LostFocus

        txttelp.Text = UCase(txttelp.Text)

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click

        CMD = New OleDbCommand("select * from tblmsupir where kode_supir='" & txtkode.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                Dim simpan As String = "insert into tblmsupir values ('" & txtkode.Text & "','" & txtnama.Text & "','" & txtalamat.Text & "','" & txttelp.Text & "','ADA')"

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

            Else

                Dim edit As String = "update tblmsupir set nama_supir='" & txtnama.Text & "',ALAMAT_SUPIR='" & txtalamat.Text & "',telp_supir='" & txttelp.Text & "' where kode_supir='" & txtkode.Text & "'"

                CMD = New OleDbCommand(edit, Conn)

                CMD.ExecuteNonQuery()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

        Call Kosongkan()

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        txtkode.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        txtnama.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        txtalamat.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        txttelp.Text = DGV.Rows(e.RowIndex).Cells(3).Value

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click

        If txtkode.Text = "" Then

            MsgBox("Kode supir harus diisi")

            txtkode.Focus()

            Exit Sub

        End If

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from tblmsupir where kode_supir='" & txtkode.Text & "'"

            CMD = New OleDbCommand(hapus, Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtkode.LostFocus

        CMD = New OleDbCommand("select * from tblmsupir where kode_supir='" & txtkode.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            Call DataBaru()

        Else

            Call Ketemu()

        End If

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcaridata.TextChanged

        DA = New OleDbDataAdapter("select * from tblmsupir where nama_supir like '%" & txtcaridata.Text & "%'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

End Class

 

 

 

 

Imports System.Data.OleDb

 

Public Class Mobil

 

    Sub Kosongkan()

        txtkode.Clear()

        txtnama.Clear()

        txttarifjam.Text = ""

        txttarifhari.Clear()

        txttarifsupirjam.Clear()

        txttarifsupirhari.Clear()

        txtcaridata.Clear()

        txtkode.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        txtnama.Clear()

        txttarifjam.Text = ""

        txttarifhari.Clear()

        txttarifsupirjam.Clear()

        txttarifsupirhari.Clear()

        txtcaridata.Clear()

        txtnama.Focus()

    End Sub

 

    Sub Ketemu()

        txtnama.Text = DR.Item("nama_mobil")

        txttarifhari.Text = DR.Item("tarif_per_jam")

        txttarifjam.Text = DR.Item("tarif_per_hari")

        txttarifsupirjam.Text = DR.Item("tarif_supir_jam")

        txttarifsupirhari.Text = DR.Item("tarif_supir_hari")

        txtnama.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblmmobil", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub Mobil_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

               Me.StartPosition = FormStartPosition.CenterScreen

        Call Koneksi()

        Call Kosongkan()

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntutup.Click

        Me.Close()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click

        CMD = New OleDbCommand("select * from tblmmobil where kode_mobil='" & txtkode.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                Dim simpan As String = "insert into tblmmobil values ('" & txtkode.Text & "','" & txtnama.Text & "','" & txttarifjam.Text & "','" & txttarifhari.Text & "','" & txttarifsupirjam.Text & "','" & txttarifsupirhari.Text & "','ADA')"

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

            Else

                Dim edit As String = "update tblmmobil set nama_mobil='" & txtnama.Text & "',tarif_per_jam='" & txttarifjam.Text & "',tarif_per_hari='" & txttarifhari.Text & "',tarif_supir_per_jam='" & txttarifsupirjam.Text & "',tarif_supir_per_hari='" & txttarifsupirhari.Text & "' where kode_mobil='" & txtkode.Text & "'"

                CMD = New OleDbCommand(edit, Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        txtkode.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        txtnama.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        txttarifjam.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        txttarifhari.Text = DGV.Rows(e.RowIndex).Cells(3).Value

        txttarifsupirjam.Text = DGV.Rows(e.RowIndex).Cells(4).Value

        txttarifsupirhari.Text = DGV.Rows(e.RowIndex).Cells(5).Value

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click

        If txtkode.Text = "" Then

            MsgBox("Kode mobil harus diisi")

            txtkode.Focus()

            Exit Sub

        End If

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from tblmmobil where kode_mobil='" & txtkode.Text & "'"

            CMD = New OleDbCommand(hapus, Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtkode.LostFocus

        CMD = New OleDbCommand("select * from tblmmobil where kode_mobil='" & txtkode.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            Call DataBaru()

        Else

            Call Ketemu()

        End If

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcaridata.TextChanged

        DA = New OleDbDataAdapter("select * from tblmmobil where nama_Mobil like '%" & txtcaridata.Text & "%'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class Peminjaman

 

    Sub IdPinjamotomatis()

        CMD = New OleDbCommand("select kode_pinjam from tbltpinjam order by kode_pinjam desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            LBLKodePinjam.Text = "P0001"

        Else

            LBLKodePinjam.Text = "P" + Format(Microsoft.VisualBasic.Right(DR.Item("kode_pinjam"), 4) + 1, "0000")

        End If

    End Sub

 

    Sub Kosongkan()

        TglPinjam.Text = Today

        TglBerangkat.Text = Today

        TXTKTP.Clear()

        TXTNama.Clear()

        TXTAlamat.Clear()

        TXTTelpHP.Clear()

        TXTUangMuka.Clear()

        LBLTotalBiaya.Text = ""

        LBLKodeMobil.Text = ""

        LBLKodeSupir.Text = ""

        LBLSisa.Text = ""

        'TextBox6.Clear()

        CBOJenis.Text = ""

        CBOKK.Text = ""

        CBOMobil.Text = ""

        CBOSupir.Text = ""

        CBORencana.Text = ""

        CBODurasi.Text = ""

        CBOStatus.Text = ""

        TjamBerangkat.Clear()

        DGV1.Columns.Clear()

    End Sub

 

    Sub Ketemu()

        'On Error Resume Next

        LBLKodePinjam.Text = DR("KODE_PINJAM")

        TglPinjam.Text = DR("TANGGAL_PINJAM")

        CBOKK.Text = DR("kartu_keluarga")

        TXTKTP.Text = DR("ktp")

        TXTNama.Text = DR("nama_customer")

        TXTAlamat.Text = DR("alamat")

        TXTTelpHP.Text = DR("telp_hp")

        CBOJenis.Text = DR("jenis_PINJAM")

        TglBerangkat.Text = DR("tanggal_berangkat")

        TjamBerangkat.Text = DR("jam_berangkat")

        LBLKodeMobil.Text = DR("kode_mobil")

        LBLKodeSupir.Text = DR("kode_supir")

        CBORencana.Text = DR("rencana_lama_PINJAM")

        CBODurasi.Text = DR("durasi")

        LBLTotalBiaya.Text = DR("total_biaya")

        TXTUangMuka.Text = DR("uang_muka")

        LBLSisa.Text = DR("SISA")

        CBOStatus.Text = DR("status_pinjam")

 

        CMD = New OleDbCommand("select * from tblmsupir where kode_supir='" & LBLKodeSupir.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            CBOSupir.Text = DR("nama_supir")

        End If

 

        CMD = New OleDbCommand("select * from tblmmobil where kode_mobil='" & LBLKodeMobil.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            CBOMobil.Text = DR("nama_mobil")

        End If

    End Sub

 

    Sub CariKodepinjam()

        CMD = New OleDbCommand("SELECT * FROM tbltpinjam WHERE KODE_PINJAM='" & LBLKodePinjam.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Sub Tampilgrid()

        DA = New OleDbDataAdapter("select kode_pinjam,tanggal_pinjam,nama_customer,kode_mobil,total_biaya,uang_muka,sisa from tbltpinjam", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

        '--------- format angka ribuan

        DGV.Columns(4).DefaultCellStyle.Format = "##,0"

        DGV.Columns(5).DefaultCellStyle.Format = "##,0"

        DGV.Columns(6).DefaultCellStyle.Format = "##,0"

        '----------- posisi angka di tengah kanan

        DGV.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

    End Sub

 

    Sub Tampilmobil()

        CMD = New OleDbCommand("select * from tblmmobil WHERE status_MOBIL='ADA'", Conn)

        DR = CMD.ExecuteReader

        CBOMobil.Items.Clear()

        Do While DR.Read

            CBOMobil.Items.Add(DR.Item(1))        Loop

    End Sub

 

    Sub Tampilsupir()

        CMD = New OleDbCommand("select *from tblmsupir WHERE status_supir='ADA'", Conn)

        DR = CMD.ExecuteReader

        CBOSupir.Items.Clear()

        Do While DR.Read

            CBOSupir.Items.Add(DR.Item(1))

        Loop

    End Sub

 

    Sub tampilLamaPinjam()

        For lama As Integer = 1 To 30

            CBORencana.Items.Add(lama)

        Next

    End Sub

 

    Sub Mobilsiappakai()

        DA = New OleDbDataAdapter("select tblmmobil.kode_mobil,nama_mobil,status_mobil,tbltpinjam.tanggal_berangkat,tbltpinjam.jam_berangkat,Status_pinjam from tblmmobil left join tbltpinjam on tblmmobil.kode_mobil=tbltpinjam.kode_mobil", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV2.DataSource = DS.Tables(0)

        DGV2.ReadOnly = True

        DGV2.Columns(4).DefaultCellStyle.Format = "HH:MM"

    End Sub

 

    Private Sub Pinjam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        Call IdPinjamotomatis()

        Call Tampilmobil()

        Call Tampilsupir()

        Call tampilLamaPinjam()

        Call Tampilgrid()

        Call Mobilsiappakai()

    End Sub

 

    Private Sub CBOMobil_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles CBOMobil.GotFocus

        TXTUangMuka.Clear()

        LBLSisa.Text = ""

        Dim EDITMOBIL1 As String = "update tblmmobil set status_mobIl='ADA' WHERE kode_mobil='" & LBLKodeMobil.Text & "'"

        CMD = New OleDbCommand(EDITMOBIL1, Conn)

        CMD.ExecuteNonQuery()

    End Sub

 

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBOMobil.SelectedIndexChanged

        CMD = New OleDbCommand("select * from tblmmobil where nama_mobil='" & CBOMobil.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            LBLKodeMobil.Text = DR.Item(0)

                    End If

 

       On Error Resume Next

 

        If CBODurasi.Text = "JAM" And CBOSupir.Text = "" Then

            LBLTotalBiaya.Text = Val(CBORencana.Text) * DGV1.Rows(0).Cells(2).Value

        ElseIf CBODurasi.Text = "JAM" And CBOSupir.Text <> "" Then

            LBLTotalBiaya.Text = (Val(CBORencana.Text) * DGV1.Rows(0).Cells(2).Value) + (Val(CBORencana.Text) * DGV1.Rows(0).Cells(4).Value)

        ElseIf CBODurasi.Text = "HARI" And CBOSupir.Text = "" Then

            LBLTotalBiaya.Text = Val(CBORencana.Text) * DGV1.Rows(0).Cells(3).Value

        ElseIf CBODurasi.Text = "HARI" And CBOSupir.Text <> "" Then

            LBLTotalBiaya.Text = (Val(CBORencana.Text) * DGV1.Rows(0).Cells(3).Value) + (Val(CBORencana.Text) * DGV1.Rows(0).Cells(5).Value)

        End If

    End Sub

 

    Private Sub CBOSupir_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles CBOSupir.GotFocus

        TXTUangMuka.Clear()

        LBLSisa.Text = ""

        Dim EDITsupir1 As String = "update tblmsupir set status_supir='ADA' WHERE kode_supir='" & LBLKodeSupir.Text & "'"

        CMD = New OleDbCommand(EDITsupir1, Conn)

        CMD.ExecuteNonQuery()

    End Sub

 

    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBOSupir.SelectedIndexChanged

        CMD = New OleDbCommand("select *from tblmsupir where nama_supir='" & CBOSupir.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            LBLKodeSupir.Text = DR.Item(0)

        End If

 

        'On Error Resume Next

 

        If CBODurasi.Text = "JAM" And CBOSupir.Text = "" Then

            LBLTotalBiaya.Text = Val(CBORencana.Text) * DGV1.Rows(0).Cells(2).Value

        ElseIf CBODurasi.Text = "JAM" And CBOSupir.Text <> "" Then

            LBLTotalBiaya.Text = (Val(CBORencana.Text) * DGV1.Rows(0).Cells(2).Value) + (Val(CBORencana.Text) * DGV1.Rows(0).Cells(4).Value)

        ElseIf CBODurasi.Text = "HARI" And CBOSupir.Text = "" Then

            LBLTotalBiaya.Text = Val(CBORencana.Text) * DGV1.Rows(0).Cells(3).Value

        ElseIf CBODurasi.Text = "HARI" And CBOSupir.Text <> "" Then

            LBLTotalBiaya.Text = (Val(CBORencana.Text) * DGV1.Rows(0).Cells(3).Value) + (Val(CBORencana.Text) * DGV1.Rows(0).Cells(5).Value)

        End If

    End Sub

 

    Private Sub ComboBox7_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBOJenis.SelectedIndexChanged

        If CBOJenis.Text = "PLUS SUPIR" Then

            CBOSupir.Enabled = True

        Else

            CBOSupir.Enabled = False

            CBOSupir.Text = ""

            LBLKodeSupir.Text = ""

        End If

        TXTUangMuka.Clear()

        LBLSisa.Text = ""

    End Sub

 

    Private Sub CBOJamHari_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBODurasi.SelectedIndexChanged

        'On Error Resume Next

 

        If CBODurasi.Text = "JAM" And CBOSupir.Text = "" Then

            LBLTotalBiaya.Text = Val(CBORencana.Text) * DGV1.Rows(0).Cells(2).Value

        ElseIf CBODurasi.Text = "JAM" And CBOSupir.Text <> "" Then

            LBLTotalBiaya.Text = (Val(CBORencana.Text) * DGV1.Rows(0).Cells(2).Value) + (Val(CBORencana.Text) * DGV1.Rows(0).Cells(4).Value)

        ElseIf CBODurasi.Text = "HARI" And CBOSupir.Text = "" Then

            LBLTotalBiaya.Text = Val(CBORencana.Text) * DGV1.Rows(0).Cells(3).Value

        ElseIf CBODurasi.Text = "HARI" And CBOSupir.Text <> "" Then

            LBLTotalBiaya.Text = (Val(CBORencana.Text) * DGV1.Rows(0).Cells(3).Value) + (Val(CBORencana.Text) * DGV1.Rows(0).Cells(5).Value)

        End If

    End Sub

 

    Private Sub CBORencana_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBORencana.SelectedIndexChanged

        CBODurasi.Text = ""

        LBLTotalBiaya.Text = ""

    End Sub

 

    Private Sub TXTUangMuka_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TXTUangMuka.KeyDown

        If e.KeyCode = Keys.Enter Then

            If Val(TXTUangMuka.Text) >= Val(LBLTotalBiaya.Text) Then

                LBLSisa.Text = 0

            Else

                LBLSisa.Text = Val(Microsoft.VisualBasic.Str(LBLTotalBiaya.Text)) - Val(Microsoft.VisualBasic.Str(TXTUangMuka.Text))

                LBLSisa.Text = FormatNumber(LBLSisa.Text, 0)

            End If

        End If

    End Sub

 

    Private Sub btnbatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub btntutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntutup.Click

        Me.Close()

    End Sub

 

    Sub KetemuKTP()

        TXTNama.Text = DR.Item("nama_customer")

        TXTAlamat.Text = DR.Item("alamat")

        TXTTelpHP.Text = DR.Item("telp_hp")

    End Sub

 

    Private Sub TXTKTP_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TXTKTP.KeyDown

        If e.KeyCode = Keys.Enter Then

            CMD = New OleDbCommand("select * from tbltpinjam where ktp='" & TXTKTP.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                Call KetemuKTP()

            End If

        End If

    End Sub

 

    Private Sub CBOStatus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBOStatus.SelectedIndexChanged

        If CBOStatus.Text = "BOOKING" Then

            CMD = New OleDbCommand("select * from tbltpinjam where cdate(tanggal_pinjam)='" & TglPinjam.Text & "' and kode_mobil='" & LBLKodeMobil.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                MsgBox("Booking tidak tersedia, waktu bentrok")

            End If

        End If

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

        UjiSql.Show()

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        LBLKodePinjam.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        Call CariKodepinjam()

        If DR.HasRows Then

            Call Ketemu()

        End If

 

        If CBOStatus.Text = "BOOKING" Then

            CBOStatus.Enabled = True

        Else

            CBOStatus.Enabled = False

        End If

    End Sub

 

    Private Sub LBLKodeMobil_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LBLKodeMobil.TextChanged

        DA = New OleDbDataAdapter("select * from tblmmobil where kode_mobil='" & LBLKodeMobil.Text & "'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV1.DataSource = DS.Tables(0)

        DGV1.ReadOnly = True

 

        DGV1.Columns(2).DefaultCellStyle.Format = "##,0"

        DGV1.Columns(3).DefaultCellStyle.Format = "##,0"

        DGV1.Columns(4).DefaultCellStyle.Format = "##,0"

        DGV1.Columns(5).DefaultCellStyle.Format = "##,0"

    End Sub

 

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)

        UjiSql.Show()

    End Sub

 

    Private Sub LBLTotalBiaya_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LBLTotalBiaya.TextChanged

        On Error Resume Next

        LBLTotalBiaya.Text = FormatNumber(LBLTotalBiaya.Text, 0)

   End Sub

 

    Private Sub TXTUangMuka_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TXTUangMuka.TextChanged

        On Error Resume Next

        TXTUangMuka.Text = FormatNumber(TXTUangMuka.Text, 0)

        TXTUangMuka.SelectionStart = Len(TXTUangMuka.Text)

    End Sub

 

    Private Sub LBLSisa_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LBLSisa.TextChanged

        On Error Resume Next

        LBLSisa.Text = FormatNumber(LBLSisa.Text, 0)

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class Pengembalian

 

    Sub idkembaliotomatis()

        CMD = New OleDbCommand("select kode_kembali from tbltkembali order by kode_kembali desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            LBLKodeKembali.Text = "K0001"

        Else

            LBLKodeKembali.Text = "K" + Format(Microsoft.VisualBasic.Right(DR.Item("kode_KEMBALI"), 4) + 1, "0000")

        End If

    End Sub

 

    Sub Kosongkan()

        Tglkembali.Text = Today

        TglBerangkat.Text = Today

        TXTKTP.Clear()

        TXTNama.Clear()

        TXTAlamat.Clear()

        TXTTelpHP.Clear()

        TXTUangMuka.Clear()

        LBLTotalBiaya.Text = ""

        LBLKodeMobil.Text = ""

        LBLKodeSupir.Text = ""

        LBLSisa.Text = ""

        TextBox6.Clear()

        CBOJenis.Text = ""

        CBOKodePinjam.Text = ""

        CBOMobil.Text = ""

        CBOSupir.Text = ""

        CBORencana.Text = ""

        CBODurasi.Text = ""

        CBOStatus.Text = ""

        thilang.Text = "-"

        trusak.Text = "-"

        tterlambat.Text = "-"

        tdendahilang.Text = 0

        tdendarusak.Text = 0

        tdendaterlambat.Text = 0

        TjamBerangkat.Clear()

        ttotalharga.Text = 0

        tdibayar.Text = 0

        tuangkembali.Text = 0

    End Sub

 

    Sub Tampilkembalian()

        LBLKodeKembali.Text = DR("KODE_KEMBALI")

        Tglkembali.Text = DR("TANGGAL_kembali")

        thilang.Text = DR("berita_hilang")

        tdendahilang.Text = DR("denda_hilang")

        trusak.Text = DR("berita_rusak")

        tdendarusak.Text = DR("denda_rusak")

        tterlambat.Text = DR("berita_terlambat")

        tdendaterlambat.Text = DR("denda_terlambat")

        ttotalharga.Text = DR("total_harga")

        tdibayar.Text = DR("pelunasan")

        tuangkembali.Text = DR("kembali")

    End Sub

 

    Sub TampilPinjaman()

        CBOKodePinjam.Text = DR("KODE_PINJAM")

        CMD = New OleDbCommand("select * from tbltpinjam where kode_pinjam='" & CBOKodePinjam.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            TXTKTP.Text = DR("ktp")

            TXTNama.Text = DR("nama_customer")

            TXTAlamat.Text = DR("alamat")

            TXTTelpHP.Text = DR("telp_hp")

            CBOJenis.Text = DR("jenis_PINJAM")

            TglBerangkat.Text = DR("tanggal_berangkat")

            TjamBerangkat.Text = DR("jam_berangkat")

            LBLKodeMobil.Text = DR("kode_mobil")

            LBLKodeSupir.Text = DR("kode_supir")

            CBORencana.Text = DR("rencana_lama_PINJAM")

            CBODurasi.Text = DR("durasi")

            LBLTotalBiaya.Text = FormatNumber(DR("total_biaya"), 0)

            TXTUangMuka.Text = FormatNumber(DR("uang_muka"), 0)

            LBLSisa.Text = FormatNumber(DR("SISA"), 0)

            CBOStatus.Text = DR("status_pinjam")

 

            CMD = New OleDbCommand("select * from tblmsupir where kode_supir='" & LBLKodeSupir.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                CBOSupir.Text = DR("nama_supir")

            End If

 

            CMD = New OleDbCommand("select * from tblmmobil where kode_mobil='" & LBLKodeMobil.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                CBOMobil.Text = DR("nama_mobil")

            End If

 

        End If

    End Sub

 

    Sub CariKodeKembali()

        CMD = New OleDbCommand("SELECT * FROM tbltkembali WHERE kode_kembali='" & LBLKodeKembali.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Sub TampilKodepinjam()

        CMD = New OleDbCommand("SELECT kode_pinjam FROM tbltpinjam WHERE status_pinjam='JALAN'", Conn)

        DR = CMD.ExecuteReader

        CBOKodePinjam.Items.Clear()

        Do While DR.Read

            CBOKodePinjam.Items.Add(DR(0))

        Loop

    End Sub

 

    Sub Tampilgrid()

        DA = New OleDbDataAdapter("select * from tbltkembali", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

        '--------- format angka ribuan

        DGV.Columns(4).DefaultCellStyle.Format = "##,0"

        DGV.Columns(6).DefaultCellStyle.Format = "##,0"

        DGV.Columns(7).DefaultCellStyle.Format = "##,0"

        DGV.Columns(8).DefaultCellStyle.Format = "##,0"

        DGV.Columns(9).DefaultCellStyle.Format = "##,0"

        '----------- posisi angka di tengah kanan

        DGV.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

    End Sub

 

    Sub Tampilmobil()

        CMD = New OleDbCommand("select * from tblmmobil WHERE status_MOBIL='ADA'", Conn)

        DR = CMD.ExecuteReader

        CBOMobil.Items.Clear()

        Do While DR.Read

            CBOMobil.Items.Add(DR.Item(1))

        Loop

    End Sub

 

    Sub Tampilsupir()

        CMD = New OleDbCommand("select *from tblmsupir WHERE status_supir='ADA'", Conn)

        DR = CMD.ExecuteReader

        CBOSupir.Items.Clear()

        Do While DR.Read

            CBOSupir.Items.Add(DR.Item(1))

        Loop

    End Sub

 

    Sub tampilLamaPinjam()

        For lama As Integer = 1 To 30

            CBORencana.Items.Add(lama)

        Next

    End Sub

 

    Sub BukaTutup()

 

        Dim X1 As Control

        For Each X1 In Me.GroupBox1.Controls

            If TypeOf X1 Is ComboBox Or TypeOf X1 Is TextBox Then

                X1.Enabled = False

            End If

            CBOKodePinjam.Enabled = True

            TglBerangkat.Enabled = False

        Next X1

 

        ttotalharga.Enabled = False

        tuangkembali.Enabled = False

    End Sub

 

 

    Private Sub Pinjam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        Call Kosongkan()

        Call idkembaliotomatis()

        Call Tampilmobil()

        Call Tampilsupir()

        Call tampilLamaPinjam()

        Call Tampilgrid()

        Call TampilKodepinjam()

        Call BukaTutup()

    End Sub

 

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBOMobil.SelectedIndexChanged

        CMD = New OleDbCommand("select * from tblmmobil where nama_mobil='" & CBOMobil.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            LBLKodeMobil.Text = DR.Item(0)

        End If

    End Sub

 

    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBOSupir.SelectedIndexChanged

        CMD = New OleDbCommand("select *from tblmsupir where nama_supir='" & CBOSupir.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            LBLKodeSupir.Text = DR.Item(0)

        End If

    End Sub

 

    Private Sub btnbatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub btntutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntutup.Click

        Me.Close()

    End Sub

 

    Sub KetemuKTP()

        TXTNama.Text = DR.Item("nama_customer")

        TXTAlamat.Text = DR.Item("alamat")

        TXTTelpHP.Text = DR.Item("telp_hp")

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        LBLKodeKembali.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        Call CariKodeKembali()

        If DR.HasRows Then

            Call Tampilkembalian()

            Call TampilPinjaman()

        End If

    End Sub

 

    Private Sub CBOKodePinjam_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBOKodePinjam.SelectedIndexChanged

        'On Error Resume Next

        CMD = New OleDbCommand("select * from tbltpinjam where kode_pinjam='" & CBOKodePinjam.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Call TampilPinjaman()

            ttotalharga.Text = Val(Microsoft.VisualBasic.Str(LBLSisa.Text)) + Val(Microsoft.VisualBasic.Str(tdendahilang.Text)) + Val(Microsoft.VisualBasic.Str(tdendarusak.Text)) + Val(Microsoft.VisualBasic.Str(tdendaterlambat.Text))

        End If

    End Sub

 

    Private Sub tdendahilang_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tdendahilang.TextChanged

        On Error Resume Next

        tdendahilang.Text = FormatNumber(tdendahilang.Text, 0)

        tdendahilang.SelectionStart = Len(tdendahilang.Text)

        ttotalharga.Text = Val(Microsoft.VisualBasic.Str(LBLSisa.Text)) + Val(Microsoft.VisualBasic.Str(tdendahilang.Text)) + Val(Microsoft.VisualBasic.Str(tdendarusak.Text)) + Val(Microsoft.VisualBasic.Str(tdendaterlambat.Text))

    End Sub

 

    Private Sub ttotalsisa_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ttotalharga.TextChanged

        On Error Resume Next

        ttotalharga.Text = FormatNumber(ttotalharga.Text, 0)

        ttotalharga.SelectionStart = Len(ttotalharga.Text)

    End Sub

 

    Private Sub tdendarusak_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tdendarusak.TextChanged

        On Error Resume Next

        tdendarusak.Text = FormatNumber(tdendarusak.Text, 0)

        tdendarusak.SelectionStart = Len(tdendarusak.Text)

        ttotalharga.Text = Val(Microsoft.VisualBasic.Str(LBLSisa.Text)) + Val(Microsoft.VisualBasic.Str(tdendahilang.Text)) + Val(Microsoft.VisualBasic.Str(tdendarusak.Text)) + Val(Microsoft.VisualBasic.Str(tdendaterlambat.Text))

    End Sub

 

    Private Sub tdendaterlambat_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tdendaterlambat.TextChanged

        On Error Resume Next

        tdendaterlambat.Text = FormatNumber(tdendaterlambat.Text, 0)

        tdendaterlambat.SelectionStart = Len(tdendaterlambat.Text)

        ttotalharga.Text = Val(Microsoft.VisualBasic.Str(LBLSisa.Text)) + Val(Microsoft.VisualBasic.Str(tdendahilang.Text)) + Val(Microsoft.VisualBasic.Str(tdendarusak.Text)) + Val(Microsoft.VisualBasic.Str(tdendaterlambat.Text))

    End Sub

 

    Private Sub tdibayar_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tdibayar.TextChanged

        On Error Resume Next

        tdibayar.Text = FormatNumber(tdibayar.Text, 0)

        tdibayar.SelectionStart = Len(tdibayar.Text)

        tuangkembali.Text = Val(Microsoft.VisualBasic.Str(tdibayar.Text)) - Val(Microsoft.VisualBasic.Str(ttotalharga.Text))

        tuangkembali.Text = FormatNumber(tuangkembali.Text, 0)

        tuangkembali.SelectionStart = Len(tuangkembali.Text)

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class Biaya

 

    Sub NomorBiaya()

        CMD = New OleDbCommand("select nomor from tbltlabarugi where left(nomor,1)='B' order by nomor desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            Lnomor.Text = "B0001"

        Else

            Lnomor.Text = "B" + Format(Microsoft.VisualBasic.Right(DR.Item("nomor"), 4) + 1, "0000")

        End If

    End Sub

 

    Private Sub Biaya_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        Call NomorBiaya()

    End Sub

 

    Private Sub DGV_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV.CellEndEdit

        If e.ColumnIndex = 1 Then

            DGV.Rows(e.RowIndex).Cells(1).Value = UCase(DGV.Rows(e.RowIndex).Cells(1).Value)

            DGV.Rows(e.RowIndex).Cells(0).Value = TglBiaya.Text

            DGV.CurrentCell = DGV(2, DGV.CurrentCell.RowIndex)

            SendKeys.Send("{UP}")

        End If

 

        If e.ColumnIndex = 2 Then

            DGV.CurrentCell = DGV(1, DGV.CurrentCell.RowIndex)

 

        End If

 

        DGV.Rows(e.RowIndex).Cells("jumlah").Value = FormatNumber(DGV.Rows(e.RowIndex).Cells("jumlah").Value, 0)

        DGV.Columns("jumlah").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        DGV.Rows.Clear()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

 

    Private Sub DGV_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DGV.KeyPress

        On Error Resume Next

 

        If e.KeyChar = Chr(27) Then

            DGV.Rows.Remove(DGV.CurrentRow)

        End If

    End Sub

End Class

 

 

 

 

Imports System.Data.OleDb

 

Public Class LaporanPeminjaman

 

    Private Sub LaporanPeminjaman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        CMD = New OleDbCommand("select distinct tanggal_pinjam from tbltpinjam", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            Listharian.Items.Add(DR("tanggal_pinjam"))

            cboawal.Items.Add(DR("tanggal_pinjam"))

            cboakhir.Items.Add(DR("tanggal_pinjam"))

        Loop

 

        CMD = New OleDbCommand("select distinct year(cdate(tanggal_pinjam)) from tbltpinjam", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            listtahunan.Items.Add(DR(0))

        Loop

 

        CMD = New OleDbCommand("select kode_pinjam  from tbltpinjam", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            listkodepinjam.Items.Add(DR("kode_pinjam"))

        Loop

 

        CMD = New OleDbCommand("select distinct nama_supir from tblmsupir,tbltpinjam where tblmsupir.kode_supir=tbltpinjam.kode_supir", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            listsupir.Items.Add(DR("nama_supir"))

        Loop

 

        CMD = New OleDbCommand("select distinct status_pinjam from tbltpinjam", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            liststatus.Items.Add(DR("status_pinjam"))

        Loop

 

        CMD = New OleDbCommand("select distinct kode_mobil from tbltpinjam", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            listkodemobil.Items.Add(DR("kode_mobil"))

        Loop

 

    End Sub

 

    Private Sub Listharian_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Listharian.SelectedIndexChanged

        CRV.SelectionFormula = "totext({tbltpinjam.tanggal_pinjam}) = '" & Listharian.Text & "'"

        cryRpt.Load("peminjaman mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub cboakhir_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboakhir.SelectedIndexChanged

        CRV.SelectionFormula = "totext({tbltpinjam.tanggal_pinjam}) >= '" & cboawal.Text & "' and totext({tbltpinjam.tanggal_pinjam}) <= '" & cboakhir.Text & "'"

        cryRpt.Load("peminjaman mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        CRV.SelectionFormula = "month({tbltpinjam.tanggal_pinjam}) = (" & Month(dtpbulanan.Text) & ") and year({tbltpinjam.tanggal_pinjam}) = (" & Year(dtpbulanan.Text) & ")"

        cryRpt.Load("peminjaman mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub listtahunan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listtahunan.SelectedIndexChanged

        CRV.SelectionFormula = "year({tbltpinjam.tanggal_pinjam}) = (" & Val(listtahunan.Text) & ")"

        cryRpt.Load("peminjaman mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub listkodepinjam_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listkodepinjam.SelectedIndexChanged

        CRV.SelectionFormula = "{tbltpinjam.kode_pinjam} = '" & listkodepinjam.Text & "'"

        cryRpt.Load("peminjaman mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub listsupir_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listsupir.SelectedIndexChanged

        CRV.SelectionFormula = "{tblmsupir.nama_supir} = '" & listsupir.Text & "'"

        cryRpt.Load("peminjaman mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub liststatus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles liststatus.SelectedIndexChanged

        CRV.SelectionFormula = "{tbltpinjam.status_pinjam} = '" & liststatus.Text & "'"

        cryRpt.Load("peminjaman mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub listkodemobil_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listkodemobil.SelectedIndexChanged

        CRV.SelectionFormula = "{tbltpinjam.kode_mobil} = '" & listkodemobil.Text & "'"

        cryRpt.Load("peminjaman mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class LaporanPengembalian

 

    Private Sub Laporanpengembalian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        CMD = New OleDbCommand("select distinct tanggal_kembali from tbltkembali", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            Listharian.Items.Add(DR("tanggal_kembali"))

            cboawal.Items.Add(DR("tanggal_kembali"))

            cboakhir.Items.Add(DR("tanggal_kembali"))

        Loop

 

        CMD = New OleDbCommand("select distinct year(cdate(tanggal_kembali)) from tbltkembali", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            listtahunan.Items.Add(DR(0))

        Loop

 

        CMD = New OleDbCommand("select kode_kembali  from tbltkembali", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            listkodekembali.Items.Add(DR("kode_kembali"))

        Loop

 

        CMD = New OleDbCommand("select distinct tblmmobil.kode_mobil from tblmmobil,tbltpinjam,tbltkembali where tblmmobil.kode_mobil=tbltpinjam.kode_mobil and tbltkembali.kode_pinjam=tbltpinjam.kode_pinjam", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            listkodemobil.Items.Add(DR("kode_mobil"))

        Loop

 

    End Sub

 

    Private Sub Listharian_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Listharian.SelectedIndexChanged

        CRV.SelectionFormula = "totext({tbltkembali.tanggal_kembali}) = '" & Listharian.Text & "'"

        cryRpt.Load("pengembalian mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub cboakhir_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboakhir.SelectedIndexChanged

        CRV.SelectionFormula = "totext({tbltkembali.tanggal_kembali}) >= '" & cboawal.Text & "' and totext({tbltkembali.tanggal_kembali}) <= '" & cboakhir.Text & "'"

        cryRpt.Load("pengembalian mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        CRV.SelectionFormula = "month({tbltkembali.tanggal_kembali}) = (" & Month(dtpbulanan.Text) & ") and year({tbltkembali.tanggal_kembali}) = (" & Year(dtpbulanan.Text) & ")"

        cryRpt.Load("pengembalian mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub listtahunan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listtahunan.SelectedIndexChanged

        CRV.SelectionFormula = "year({tbltkembali.tanggal_kembali}) = (" & Val(listtahunan.Text) & ")"

        cryRpt.Load("pengembalian mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub listkodekembali_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listkodekembali.SelectedIndexChanged

        CRV.SelectionFormula = "{tbltkembali.kode_kembali} = '" & listkodekembali.Text & "'"

        cryRpt.Load("pengembalian mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

 

    Private Sub listkodemobil_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listkodemobil.SelectedIndexChanged

        CRV.SelectionFormula = "{tblmmobil.kode_mobil} = '" & listkodemobil.Text & "'"

        cryRpt.Load("pengembalian mobil.rpt")

        Call setinglaporan()

        CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        CRV.RefreshReport()

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

Public Class LabaRugi

 

    Private Sub LabaRugi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        CMD = New OleDbCommand("select distinct tanggal from tbltlabarugi", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListHarian.Items.Add(DR.Item(0))

        Loop

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

        'tampilkan rincian pendapatan di dgv1

        DA = New OleDbDataAdapter("Select Tanggal,Keterangan,Pemasukan from tbltlabarugi where pemasukan>0 and month(tanggal)='" & Month(BulanTahun.Text) & "' and year(tanggal)='" & Year(BulanTahun.Text) & "'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV1.DataSource = DS.Tables(0)

        DGV1.Columns("tanggal").DefaultCellStyle.Format = "dd-MMMM-yyyy"

        DGV1.Columns("pemasukan").DefaultCellStyle.Format = "#,###"

        DGV1.Columns("Pemasukan").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

 

        'tampilkan rincian biaya dalam dgv2

        DA = New OleDbDataAdapter("Select Tanggal,Keterangan,Pengeluaran from tbltlabarugi where pengeluaran>0 and month(tanggal)='" & Month(BulanTahun.Text) & "' and year(tanggal)='" & Year(BulanTahun.Text) & "'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV2.DataSource = DS.Tables(0)

        DGV2.Columns("tanggal").DefaultCellStyle.Format = "dd-MMMM-yyyy"

        DGV2.Columns("pengeluaran").DefaultCellStyle.Format = "#,###"

        DGV2.Columns("pengeluaran").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        Call HitungTransaksi()

    End Sub

 

    Sub HitungTransaksi()

 

        LBLPendapatan.Text = 0

        LBLBiaya.Text = 0

        LBLSaldo.Text = 0

 

        Dim hitung1 As Double

        For baris1 As Integer = 0 To DGV1.RowCount - 1

            hitung1 = hitung1 + DGV1.Rows(baris1).Cells("pemasukan").Value

        Next

        LBLPendapatan.Text = FormatNumber(hitung1, 0)

 

        Dim hitung2 As Double

        For baris2 As Integer = 0 To DGV2.RowCount - 1

            hitung2 = hitung2 + DGV2.Rows(baris2).Cells("pengeluaran").Value

        Next

        LBLBiaya.Text = FormatNumber(hitung2, 0)

 

 

        LBLSaldo.Text = Val(Microsoft.VisualBasic.Str(LBLPendapatan.Text)) - Val(Microsoft.VisualBasic.Str(LBLBiaya.Text))

        LBLSaldo.Text = FormatNumber(LBLSaldo.Text, 0)

        If Val(LBLSaldo.Text) < 0 Then

            LBLKeterangan.Text = "RUGI"

        Else

            LBLKeterangan.Text = "LABA"

        End If

    End Sub

 

    Private Sub listharian_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListHarian.SelectedIndexChanged

        'tampilkan rincian pendapatan di dgv1

        DA = New OleDbDataAdapter("Select Tanggal,Keterangan,Pemasukan from tbltlabarugi where pemasukan>0 and  cdate(tanggal)='" & ListHarian.Text & "'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV1.DataSource = DS.Tables(0)

        DGV1.Columns("tanggal").DefaultCellStyle.Format = "dd-MMMM-yyyy"

 

        DGV1.Columns("pemasukan").DefaultCellStyle.Format = "#,###"

        DGV1.Columns("pemasukan").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

 

        'tampilkan rincian biaya dalam dgv2

        DA = New OleDbDataAdapter("Select Tanggal,Keterangan,Pengeluaran  from tbltlabarugi where pengeluaran>0 and cdate(tanggal)='" & ListHarian.Text & "'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV2.DataSource = DS.Tables(0)

        DGV2.Columns("tanggal").DefaultCellStyle.Format = "dd-MMMM-yyyy"

 

        DGV2.Columns("pengeluaran").DefaultCellStyle.Format = "#,###"

        DGV2.Columns("pengeluaran").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

 

        Call HitungTransaksi()

    End Sub

 

    Private Sub BTNPrintbulanan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNPrintbulanan.Click

        Cetak.Show()

        Cetak.CRV.SelectionFormula = "month({tbltlabarugi.tanggal})=(" & Month(BulanTahun.Text) & ") and year({tbltlabarugi.tanggal})=(" & Year(BulanTahun.Text) & ")"

        cryRpt.Load("laba rugi.rpt")

        Call setinglaporan()

        Cetak.CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        Cetak.CRV.RefreshReport()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If ListHarian.Text = "" Then

            MsgBox("Pilih tanggal terlebih dahulu...!")

            ListHarian.Focus()

            Exit Sub

        End If

 

        Cetak.Show()

        Cetak.CRV.SelectionFormula = "totext({tbltlabarugi.tanggal})='" & ListHarian.Text & "'"

        cryRpt.Load("laba rugi.rpt")

        Call setinglaporan()

        Cetak.CRV.ReportSource = cryRpt

        cryRpt.Refresh()

        Cetak.CRV.RefreshReport()

    End Sub

 

    Private Sub BTNTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTutup.Click

        Me.Close()

    End Sub

End Class