This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Kamis, 05 Juli 2018

Membuat WebForm Database Pemesanan Kamar Hotel dengan vb.net

~Salam

Pada postingan ini saya ingin memberi tahu bagaimana cara membuat sebuah webform yang tersambung dengan database microsoft access dengan vb.net

berikut deskripsi project

Project ini di buat untuk memesan hotel. Dengan design yang sederhana, membuat pengguna lebih mudah dalam menggunakan aplikasi ini. Aplikasi ini berguna untuk memasukan database ke dalam access. Pengguna dapat menambahkan, menghapus menyimpan, mengedit, dan mencari database. Untuk menambahkan database, pengguna hanya harus meng input-identitas pemesan dan jenis kamar yang di pilih serta berapa lama ingin tinggal. Tombol-tombolnya memudahkan dan membantu penggunanya.  Untuk membuat suatu record, pengguna harus memasukan nomor identitas, nama pemesan, jenis kamar yang ingin di pilih sesuai dengan yang disediakan, jumlah kamar, tanggal checkin dan tanggal check out. setelah menekan tombol simpan maka record akan otomatis tersimpan di database. Untuk menghapus dan mengedit data, pengguna harus mencari terlebih dahulu nomor id dari record yang inign di hapus ataupun di edit. Setelah menekan tombol cari, maka record yang sesuai dengan id yang dimasukan tadi akan muncul. Setelah itu pengguna dapat menghapus dengan menekan tombol hapus atau mengedit dengan mengedit data yang telah di cari dan menekan tombol edit. Dengan menekan tombol tampilkan, maka database akan tampil pada layar.


Flowchart





Berikut ini adalah SourceCode nya

Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb

Public Class WebForm_RivalAchmadani161011400853
    Inherits System.Web.UI.Page
    Dim transaksi As OleDbConnection
    Dim constring As String = ConfigurationManager.ConnectionStrings("dbhotelConnectionString").ConnectionString
    Dim oConn As New OleDbConnection(constring)
    'Dim oTbl new database 
    Dim xReader As OleDbDataReader
    Dim Sql As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        txtkode.Text = ""
        txtnama.Text = ""
        txtjenis.Text = ""
        txtcin.Text = ""
        txtcout.Text = ""
        txtkode.Focus()
    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim sql As String = "INSERT INTO hotel VALUES ('" & txtkode.Text & "','" & txtnama.Text & "','" & txtjenis.Text & "','" & txtcin.Text & "','" & txtcout.Text & "');"
        Dim oCmd As New OleDbCommand
        oConn.Open()
        oCmd.Connection = oConn
        oCmd.CommandText = sql
        oCmd.ExecuteNonQuery()
    End Sub

    Protected Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        Response.Redirect("RivalAchmadani161011400853.aspx")
    End Sub

    Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Dim sql As String = "delete from hotel where kode_pemesan=('" & txtkode.Text & "');"
        Dim oCmd As New OleDbCommand
        oConn.Open()
        oCmd.Connection = oConn
        oCmd.CommandText = sql
        oCmd.ExecuteNonQuery()
    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If Not Len(txtkode.Text) = 0 Then
            oConn.Close()
            oConn.Open()
            Dim ocmd As New OleDbCommand("SELECT * FROM hotel where kode_pemesan='" + txtkode.Text + "'", oConn)
            xReader = ocmd.ExecuteReader
            If xReader.HasRows Then
                xReader.Read()
                txtnama.Text = xReader("nama_pemesan")
                txtjenis.Text = xReader("jenis_kamar")
                txtcin.Text = xReader("tanggal_checkin")
                txtcout.Text = xReader("tanggal_checkout")

            Else
                txtnama.Text = "Nama Karyawan Tidak ada"
                Exit Sub
            End If
            xReader.Close()

        End If
    End Sub

    Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim sql As String = "update hotel set kode_pemesan=('" & txtkode.Text & "'),nama_pemesan=('" & txtnama.Text & "'),jenis_kamar=('" & txtjenis.Text & "'),tanggal_checkin=('" & txtcin.Text & "'),tanggal_checkout=('" & txtcout.Text & "') where kode_pemesan=('" & txtkode.Text & "')"
        Dim oCmd As New OleDbCommand
        oConn.Open()
        oCmd.Connection = oConn
        oCmd.CommandText = sql
        oCmd.ExecuteNonQuery()
    End Sub
End Class


Dan Berikut ini bukti screenshoot hasil run









Dan itulah hasil project yang telah saya buat. Simple agar mudah dipergunakan oleh penggunanya. Sekian dan terimakasih semoga bermanfaat.

Salam~