Kamis, 15 Desember 2016

Dalam kesempatan ini, saya akan membuat aplikasi database penjualan tiket cinema. Aplikasi ini dapat menginput, merubah, dan menghapus data yang berada didalamnya, sehingga akan memudahkan penjual untuk keep in track dengan penjualannya.

Berikut adalah bentuk formnya;

1. 
Form Log In
2. 
Form Penjualan dan Penyimpanan Database


3. 
Form Database Penjualan Tiket


Source Code

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If TextBox1.Text = "Lukman" Then
            TextBox2.Text = "lukman"
            Form2.Show()
            Me.Hide()


        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Hide()
    End Sub

End Class



Imports System.Data
Imports System.Data.Sql
Imports System.Data.OleDb
Public Class Form2
    Dim connection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Lukman Hakim\Documents\Lukman.accdb"
    Dim objekkoneksi As New OleDb.OleDbConnection(connection)
    Dim xreader As OleDbDataReader
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        objekkoneksi.Close()
        objekkoneksi.Open()
        Dim add As String = "INSERT INTO TablePenjualan values('" & TextBox1.Text & "','" & ComboBox1.Text & "','" & ComboBox2.Text & "','" & ComboBox3.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "', '" & TextBox4.Text & "')"
        Dim ocmd = New OleDbCommand(add, objekkoneksi)
        ocmd.ExecuteNonQuery()
        objekkoneksi.Close()
        MsgBox("Berhasil")

        Form3.Show()


    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim DELETE As Integer
        DELETE = MsgBox("Confirmation", MsgBoxStyle.OkCancel)
        If vbOK Then

            objekkoneksi.Close()
            objekkoneksi.Open()
            Dim sql As String = "DELETE from TablePenjualan where NamaPembeli = '" + TextBox1.Text + "'"
            Dim ocmd As New OleDbCommand
            objekkoneksi.Close()
            objekkoneksi.Open()
            ocmd.Connection = objekkoneksi
            ocmd.CommandText = sql
            ocmd.ExecuteNonQuery()
            TextBox1.Text = ""
            ComboBox1.Text = ""
            ComboBox2.Text = ""
            ComboBox3.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
        End If
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim Vkode = InputBox("Enter Code")

        objekkoneksi.Close()
        objekkoneksi.Open()
        Dim Cmd As New OleDbCommand("SELECT * FROM TablePenjualan where NamaPembeli ='" + Vkode + "'", objekkoneksi)
        xreader = Cmd.ExecuteReader

        If xreader.HasRows Then
            xreader.Read()
            TextBox1.Text = xreader("NamaPembeli")
            ComboBox1.Text = xreader("NamaFilm")
            ComboBox2.Text = xreader("Ruangan")
            ComboBox3.Text = xreader("JamTayang")
            TextBox2.Text = xreader("NomerKursi")
            TextBox3.Text = xreader("JumlahTiket")
            TextBox4.Text = xreader("Harga")
        Else
            MsgBox("Code not Found")
            TextBox1.Text = ""
            ComboBox1.Text = ""
            ComboBox2.Text = ""
            ComboBox3.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
            TextBox4.Text = ""
            TextBox1.Focus()
            Exit Sub
        End If
        xreader.Close()

    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim sql As String = " Update TablePenjualan set NamaPembeli='" + TextBox1.Text + "', NamaFilm = '" + ComboBox1.Text + "', Ruangan ='" + ComboBox2.Text + "', JamTayang ='" + ComboBox3.Text + "', NomerKursi = '" + TextBox2.Text + "', JumlahTiket ='" + TextBox3.Text + "',  Harga ='" + TextBox4.Text + "'where NamaPembeli = '" + TextBox1.Text + "'"
        Dim oCmd As New OleDbCommand
        objekkoneksi.Close()
        objekkoneksi.Open()
        oCmd.Connection = objekkoneksi
        oCmd.CommandText = sql
        oCmd.ExecuteNonQuery()
    End Sub

    Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged
        TextBox4.Text = Val(TextBox3.Text) * 35000
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Form3.Show()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Form4.Show()
    End Sub
End Class

Tidak ada komentar:

Posting Komentar