Friday, March 27, 2015

TAMPILAN PROGRAM



















Kali ini ane mau share program untuk rental mobil gan..Ane pake VB.Net 2008 dan database Access 2003..
Program ini bisa agan2 kembangin lagi jd lebih komplit lg..
oke langsung aja ke koding nya gan.. :D

CODE :

Imports System.Data.OleDb

Public Class Form1
    Public conn As New OleDbConnection
    Public dtadap As New OleDbDataAdapter
    Public cmd As OleDbCommand
    Public perintah, alamat As String

    Public Sub konek()
        alamat = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Application.StartupPath & "\DbRental.mdb"
        conn = New OleDbConnection(alamat)
    End Sub

    Public Sub tampildt()
        perintah = "select * from tbRental"
        dtadap = New OleDbDataAdapter(perintah, conn)
        Dim dtTable As New DataTable
        dtTable.Clear()
        dtadap.Fill(dtTable)
        DataGridView1.DataSource = dtTable
    End Sub

    Public Sub carinama()
        perintah = "select * from tbRental where nama like '%" & txtcari.Text & "%'"
        dtadap = New OleDbDataAdapter(perintah, conn)
        Dim dtTable As New DataTable
        dtTable.Clear()
        dtadap.Fill(dtTable)
        DataGridView1.DataSource = dtTable
    End Sub

    Public Sub carijns()
        perintah = "select * from tbRental where jenis like '%" & txtcari.Text & "%'"
        dtadap = New OleDbDataAdapter(perintah, conn)
        Dim dtTable As New DataTable
        dtTable.Clear()
        dtadap.Fill(dtTable)
        DataGridView1.DataSource = dtTable
    End Sub

    Public Sub kosong()
        txtnama.Text = ""
        cmbjns.Text = ""
        txthrg.Text = ""
        txtbyr.Text = ""
        txtsisa.Text = ""
        txtnama.Focus()
        ubhbtn.Enabled = False
        hpsbtn.Enabled = False
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        konek()
        conn.Open()
        tampildt()
        kosong()
    End Sub

    Private Sub tmbhbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmbhbtn.Click
        If txtnama.Text = "" Or cmbjns.Text = "" Or txthrg.Text = "" Then
            MsgBox("Data Belum Lengkap")
            kosong()
            Exit Sub
        Else
            perintah = "insert into tbRental values ('" & DateTimePicker1.Value & "','" & txtnama.Text & "','" & cmbjns.Text & "','" & txthrg.Text & "','" & txtbyr.Text & "','" & txtsisa.Text & "')"
            cmd = New OleDbCommand(perintah, conn)
            cmd.ExecuteNonQuery()
            MsgBox("Data Berhasil di Tambah")
            tampildt()
            kosong()
        End If
    End Sub

    Private Sub ubhbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ubhbtn.Click
        Dim edit As String
        edit = "update tbRental set tgl = '" & DateTimePicker1.Value & "',jenis='" & cmbjns.Text & "',harga='" & txthrg.Text & "',bayar='" & txtbyr.Text & "',sisa='" & txtsisa.Text & "' , nama='" & txtnama.Text & "'"
        cmd = New OleDbCommand(edit, conn)
        cmd.ExecuteNonQuery()
        MsgBox("Data Berhasil di Ubah")
        tampildt()
        kosong()
    End Sub

    Private Sub hpsbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hpsbtn.Click
        Dim hapus As String = "Delete from tbRental where nama ='" & txtnama.Text & "'"
        cmd = New OleDbCommand(hapus, conn)
        cmd.ExecuteNonQuery()
        MsgBox("Data Berhasil Dihapus")
        tampildt()
        kosong()
    End Sub

    Private Sub btlbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btlbtn.Click
        kosong()
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        carijns()
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        carinama()
    End Sub

    Private Sub txtcari_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtcari.KeyPress
        If RadioButton1.Checked Then
            carinama()
        ElseIf RadioButton2.Checked Then
            carijns()
        End If
    End Sub

    Private Sub cmbjns_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbjns.SelectedIndexChanged
        Select Case cmbjns.Text
            Case "SEDAN"
                txthrg.Text = "200000"
            Case "KELUARGA"
                txthrg.Text = "300000"
            Case "APV"
                txthrg.Text = "400000"
            Case "JEEP"
                txthrg.Text = "500000"
            Case "RV"
                txthrg.Text = "600000"
        End Select
    End Sub

    Private Sub txtbyr_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbyr.TextChanged
        txtsisa.Text = Val(txtbyr.Text) - Val(txthrg.Text)
    End Sub

    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        Dim i As Integer
        i = Me.DataGridView1.CurrentRow.Index
        With DataGridView1.Rows.Item(i)
            DateTimePicker1.Value = .Cells(0).Value
            txtnama.Text = .Cells(1).Value
            cmbjns.Text = .Cells(2).Value
            txthrg.Text = .Cells(3).Value
            txtbyr.Text = .Cells(4).Value
            txtsisa.Text = .Cells(5).Value
            DateTimePicker1.Focus()
        End With
        ubhbtn.Enabled = True
        hpsbtn.Enabled = True
    End Sub
End Class

Untuk download Project nya silahkan download di bawah gan..

Zippyshare
Download
Mirror Download
4Shared
Download
Mirror Download
Mediafire
Download
Mirror Download


0 comments:

Post a Comment

Mohon kritik dan saran nya..