Imports System.Data
Imports System.Data.OleDb
Public Class WebFormHotel
Inherits System.Web.UI.Page
Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\LENOVO\Documents\DBHotel.accdb"
Dim objekKoneksi As New OleDb.OleDbConnection(koneksi)
Dim Xreader As OleDb.OleDbDataReader
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
objekKoneksi.Open()
Dim tambah As String = "INSERT INTO Hotel values('" & TextNo.Text & "','" & TextJenis.Text & "','" & TextFasilitas.Text & "','" & TextLantai.Text & "','" & TextTarif.Text & "')"
Dim oCmd = New OleDbCommand(tambah, objekKoneksi)
oCmd.ExecuteNonQuery()
objekKoneksi.Close()
MsgBox("Selamat Anda Sukses Gan")
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If Not Len(TextNo.Text) = 0 Then
objekKoneksi.Close()
objekKoneksi.Open()
Dim ocmd As New OleDb.OleDbCommand("SELECT * FROM Hotel where NOKAMAR='" + TextNo.Text + "'", objekKoneksi)
Xreader = ocmd.ExecuteReader()
If Xreader.HasRows Then
Xreader.Read()
TextNo.Text = Xreader("NOKAMAR")
TextJenis.Text = Xreader("JENISKAMAR")
TextFasilitas.Text = Xreader("FASILITAS")
TextLantai.Text = Xreader("LANTAIKE")
TextTarif.Text = Xreader("TARIF")
Button4.Enabled = True
Else
TextNo.Text = "Nama Hotel Tidak ada"
Exit Sub
End If
Xreader.Close()
End If
End Sub
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Response.Redirect("WebFormWeb.aspx")
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
objekKoneksi.Open()
Dim Rubah As String = "Update Hotel set TARIF='" + TextTarif.Text + "' where NOKAMAR='" + (TextNo.Text) + "'"
Dim oCmd = New OleDbCommand(Rubah, objekKoneksi)
oCmd.ExecuteNonQuery()
objekKoneksi.Close()
MsgBox("Sukses Gan")
End Sub
Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
TextNo.Text = ""
TextJenis.Text = ""
TextFasilitas.Text = ""
TextLantai.Text = ""
TextTarif.Text = ""
End Sub
End Class