Penjelasan
Database ini digunakan untuk mengumpulkan data penanggung jawab jadwal touring konser, berikut contohnya
1. Membuat TRIGGER
CREATE TRIGGER TambahJadwal on JadwalKonser
for insert
as
update data set data.TanggalKonser = data.TanggalKonser + mdl.TanggalKonser
from JadwalKonser mdl join inserted data on data.KodePenanggungJawab = mdl.KodePenanggungJawab
2. Membuat STORED PROCEDURE
CREATE PROCEDURE TambahPenanggungJawab
@KodePenanggungJawab Number(50),@Nama Short Text(50),@Alamat Short Text(18,0),@Jabatan Short Text (18,0)
AS
BEGIN
SET NOCOUNT ON
INSERT INTO DataPenanggungJawab
(
KodePenanggungJawab, Nama, Alamat, Jabatan
)
VALUES
(
@KodePenanggungJawab, @Nama, @Alamat, @Jabatan
)
END
Jumat, 26 Mei 2017
Kamis, 06 April 2017
UTS Lab. SMBD Normalisasi Database
1 NF
Faktur(No Faktur, Kode Supplier, Nama Supplier, Kode Barang, Nama Barang, Quantitas, Harga, Jumlah,).
2 NF
TableSupplier(Kode Supplier, Nama Supplier)
TableBarang(Kode Barang, Nama barang, harga)
TableFaktur(No Faktur, Kode Supplier, Kode barang, Quantitas)
SOURCE CODE Web Form Asp.net
Imports System.Data
Imports System.Data.OleDb
Public Class TransaksiBarang
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 Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim sql As String = "INSERT INTO TableBarang VALUES ('" & KodeBarang.Text & "','" & NamaBarang.Text & "','" & Harga.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
Dim sql As String = " UPDATE TableBarang set Nama_Barang ='" & NamaBarang.Text & "', Harga = '" & Harga.Text & "' where Kode_Barang = '" & KodeBarang.Text & "'"
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim hapus = MsgBox("Konfirmasi", MsgBoxStyle.YesNo, "Hapus")
If hapus = vbYes Then
oConn.Close()
oConn.Open()
Dim delet As String = "DELETE FROM TableBarang where Kode_Barang ='" + KodeBarang.Text + "'"
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = delet
oCmd.ExecuteNonQuery()
MsgBox("Sudah terhapus", vbArchive)
KodeBarang.Text = ""
NamaBarang.Text = ""
Harga.Text = ""
End If
End Sub
Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
oConn.Close()
oConn.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM TableBarang where Kode_Barang ='" + KodeBarang.Text + "'", oConn)
xReader = Cmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
KodeBarang.Text = xReader("Kode_Barang")
NamaBarang.Text = xReader("Nama_Barang")
Harga.Text = xReader("Harga")
Else
MsgBox("Kode Barang Tidak Ada")
KodeBarang.Text = ""
NamaBarang.Text = ""
Harga.Text = ""
Exit Sub
End If
xReader.Close()
End Sub
End Class
1 NF
Faktur(No Faktur, Kode Supplier, Nama Supplier, Kode Barang, Nama Barang, Quantitas, Harga, Jumlah,).
2 NF
TableSupplier(Kode Supplier, Nama Supplier)
TableBarang(Kode Barang, Nama barang, harga)
TableFaktur(No Faktur, Kode Supplier, Kode barang, Quantitas)
SOURCE CODE Web Form Asp.net
Imports System.Data
Imports System.Data.OleDb
Public Class TransaksiBarang
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 Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim sql As String = "INSERT INTO TableBarang VALUES ('" & KodeBarang.Text & "','" & NamaBarang.Text & "','" & Harga.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
Dim sql As String = " UPDATE TableBarang set Nama_Barang ='" & NamaBarang.Text & "', Harga = '" & Harga.Text & "' where Kode_Barang = '" & KodeBarang.Text & "'"
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim hapus = MsgBox("Konfirmasi", MsgBoxStyle.YesNo, "Hapus")
If hapus = vbYes Then
oConn.Close()
oConn.Open()
Dim delet As String = "DELETE FROM TableBarang where Kode_Barang ='" + KodeBarang.Text + "'"
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = delet
oCmd.ExecuteNonQuery()
MsgBox("Sudah terhapus", vbArchive)
KodeBarang.Text = ""
NamaBarang.Text = ""
Harga.Text = ""
End If
End Sub
Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
oConn.Close()
oConn.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM TableBarang where Kode_Barang ='" + KodeBarang.Text + "'", oConn)
xReader = Cmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
KodeBarang.Text = xReader("Kode_Barang")
NamaBarang.Text = xReader("Nama_Barang")
Harga.Text = xReader("Harga")
Else
MsgBox("Kode Barang Tidak Ada")
KodeBarang.Text = ""
NamaBarang.Text = ""
Harga.Text = ""
Exit Sub
End If
xReader.Close()
End Sub
End Class
Langganan:
Postingan (Atom)