Selasa, 25 Juli 2017

Tutorial membuat program laundry dengan vb.net


TAMPILAN PROGRAM




Kali ini ane share lg program laundry gan,,program ini hanya basic aja selanjutnya silahkan agan2 kembangin lg supaya bisa lebih memiliki nilai jual gan.. :D
Oke langsung aja ke Koding again..

CODE :

Imports System.Data.OleDb

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

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

    Public Sub tampildata()
        perintah = "select * from tbLaundry"
        dtAdapter = New OleDbDataAdapter(perintah, conn)
        Dim dttable As New DataTable
        dttable.Clear()
        dtAdapter.Fill(dttable)
        DataGridView1.DataSource = dttable
    End Sub

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

    Public Sub caritgl()
        perintah = "select * from tbLaundry where tgl like '%" & txtcari.Text & "%'"
        dtAdapter = New OleDbDataAdapter(perintah, conn)
        Dim dttable As New DataTable
        dttable.Clear()
        dtAdapter.Fill(dttable)
        DataGridView1.DataSource = dttable
    End Sub

    Public Sub kosong()
        txtnama.Text = ""
        cmbbrt.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
        koneksi()
        conn.Open()
        tampildata()
        kosong()
    End Sub

    Private Sub cmbbrt_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbbrt.SelectedIndexChanged
        Select Case cmbbrt.Text
            Case "1 Kg"
                txthrg.Text = "6000"
            Case "2 Kg"
                txthrg.Text = "12000"
            Case "3 Kg"
                txthrg.Text = "18000"
            Case "4 Kg"
                txthrg.Text = "24000"
            Case "5 Kg"
                txthrg.Text = "30000"
        End Select
    End Sub

    Private Sub tmbhbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmbhbtn.Click
        If txtnama.Text = "" Or cmbbrt.Text = "" Or txthrg.Text = "" Then
            MsgBox("Data Belum Lengkap")
            kosong()
            Exit Sub
        Else
            perintah = "insert into tbLaundry values ('" & DateTimePicker1.Value & "','" & txtnama.Text & "','" & cmbbrt.Text & "','" & txthrg.Text & "','" & txtbyr.Text & "','" & txtsisa.Text & "')"
            cmd = New OleDbCommand(perintah, conn)
            cmd.ExecuteNonQuery()
            MsgBox("Data Berhasil di Tambah")
            tampildata()
            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 tbLaundry set tgl = '" & DateTimePicker1.Value & "',brt='" & cmbbrt.Text & "',hrg='" & txthrg.Text & "',byr='" & txtbyr.Text & "',sisa='" & txtsisa.Text & "', nama='" & txtnama.Text & "'"
        cmd = New OleDbCommand(edit, conn)
        cmd.ExecuteNonQuery()
        MsgBox("Data Berhasil di Ubah")
        tampildata()
        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 tbLaundry where nama ='" & txtnama.Text & "'"
        cmd = New OleDbCommand(hapus, conn)
        cmd.ExecuteNonQuery()
        MsgBox("Data Berhasil Dihapus")
        tampildata()
        kosong()
    End Sub

    Private Sub DataGridView1_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentDoubleClick
        Dim i As Integer
        i = Me.DataGridView1.CurrentRow.Index
        With DataGridView1.Rows.Item(i)
            DateTimePicker1.Value = .Cells(0).Value
            txtnama.Text = .Cells(1).Value
            cmbbrt.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

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        caritgl()
    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 e.KeyChar = Chr(13) Then
            If RadioButton1.Checked Then
                carinama()
            ElseIf RadioButton2.Checked Then
                caritgl()
            End If
        End If
    End Sub

    Private Sub btlbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btlbtn.Click
        kosong()
    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
End Class

Tidak ada komentar:

Posting Komentar

Cara Simpel Membuat Chained Dropdown dengan Codeigniter dan MySQL

Sebelum lanjut ke tutorial pembuatannya, saya akan jelaskan apa itu chained dropdown, Chained Dropdown adalah 2 buah dropdown / combo box y...