-----
Database Penjualan Buku
Saya menggunakan asp.net yang digunakan untuk mengelola data penjualan buku, data base ini memiliki 3 tabel, yaitu TableDaftarBuku, TablePelanggan, dan TabelTransaksi.
Screenshoot Desainnya:
Source Code Visual Studio :
Imports System.Data
Imports System.Data.OleDb
Public Class WebForm1
Inherits System.Web.UI.Page
Public constring As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
Public oConn As New OleDbConnection(constring)
Public oTbl As New DataTable
Public xReader As 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
Dim sql As String = "INSERT
INTO TableDaftarBuku VALUES ('" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "')"
Dim oCmd As New OleDbCommand
oConn.Open()
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
Protected Sub
Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim sql As String = "UPDATE
TableDaftarBuku set IDBuku = '" & TextBox1.Text & "', Harga = '" & TextBox3.Text & ""
Dim oCmd As New OleDbCommand
oConn.Close()
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
Dim delete = MsgBox("Konfirmasi", MsgBoxStyle.YesNo, "Delete")
If delete = vbYes Then
oConn.Close()
oConn.Open()
Dim hapus As String = "DELETE
FROM TablePelanggan where IDPelanggan =" + TextBox4.Text + ""
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = hapus
oCmd.ExecuteNonQuery()
MsgBox("Delete Complete", vbArchive)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
End If
End Sub
Protected Sub
Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
oConn.Close()
oConn.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM TableTransaksi where IDPelanggan
=" + TextBox1.Text + "", oConn)
xReader =
Cmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
TextBox1.Text = xReader("NoFaktur")
TextBox2.Text = xReader("IDPelanggan")
TextBox3.Text = xReader("IDBuku")
Else
MsgBox("Data tidak
ditemukan")
TextBox1.Text = ""
TextBox2.Text
= ""
TextBox3.Text = ""
Exit Sub
End If
xReader.Close()
End Sub
End Class