Hello!
Kali ini saya akan memposting tugas LAB SMBD saya tentang Stored Procedure dan Trigger.
Saya menggunakan contoh kasus rumah sakit untuk kali ini.
1. Table
2. Design
3. Coding
Imports System.Data
Imports System.Data.OleDb
Public Class datapasien
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
'Insert
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sql As String = "INSERT INTO TablePasien VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"
Dim oCmd As New OleDbCommand
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Response.Redirect("View.aspx")
End Sub
'Search
Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
oConn.Close()
oConn.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM TablePasien where IDPasien =" + TextBox1.Text + "", oConn)
xReader = Cmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
TextBox2.Text = xReader("Waktu Kunjungan")
TextBox3.Text = xReader("Keluhan")
TextBox4.Text = xReader("Dokter yang menangani")
TextBox5.Text = xReader("Tindakan")
Else
MsgBox("ID Pasien Tidak Ada")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
Exit Sub
End If
xReader.Close()
End Sub
'Update
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim sql As String = " UPDATE TablePasien set Waktu Kunjungan ='" & TextBox2.Text & "', Keluhan = '" & TextBox3.Text & "', Dokter yang menangani = '" & TextBox4.Text & "', Tindakan = '" & TextBox5.Text & "' where IDPasien = " & TextBox1.Text & ""
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
End Class
Demikian Tugas UAS LAB SMBD saya, terima kasih!
Elizabeth Clara Sukma
1506761141
SERENITEA
Jumat, 26 Mei 2017
Kamis, 06 April 2017
NORMALISASI DATABASE PEMINJAMAN BUKU
Saat ini saya akan melakukan normalisasi pada database peminjaman buku di sebuah perusahaan
TableBuku (IDBuku, JudulBuku, TglTerbit, IDPenerbit)
TablePenerbt (IDPenerbit, NamaPenerbit, AlamatPenerbit)
TablePeminjam (IDPeminjam, NamaPeminjam, AlamatPeminjam)
Tahapan Normalisasi
- 1NF
- 2NF
TableBuku (IDBuku, JudulBuku, TglTerbit, IDPenerbit)
TablePenerbt (IDPenerbit, NamaPenerbit, AlamatPenerbit)
TablePeminjam (IDPeminjam, NamaPeminjam, AlamatPeminjam)
- 3NF sama dengan 2NF
Tampilan Tabel dan Web Form
Source Code
Source Code
Imports System.Data
Imports System.Data.OleDb
Public Class WebForm2
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 Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sql As String = "INSERT INTO TABLEPEMINJAMAN VALUES ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "')"
Dim oCmd As New OleDbCommand
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Response.Redirect("WebForm1.aspx")
End Sub
Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button3.Click
oConn.Close()
oConn.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM TABLEPEMINJAMAN where IDBuku =" + TextBox1.Text + "", oConn)
xReader = Cmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
TextBox2.Text = xReader("IDPenerbit")
TextBox3.Text = xReader("IDPeminjam")
TextBox4.Text = xReader("JudulBuku")
TextBox5.Text = xReader("TglPeminjaman")
Else
MsgBox("Kode Buku Tidak Ada")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
Exit Sub
End If
xReader.Close()
End Sub
Protected Sub Button3_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 TABLEPEMINJAMAN where IDBuku =" + TextBox1.Text + ""
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = delet
oCmd.ExecuteNonQuery()
MsgBox("Sudah terhapus", vbArchive)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End If
End Sub
Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim sql As String = " UPDATE TABLEPENYIMPANAN set IDPenerbit ='" & TextBox2.Text & "', IDPeminjam = " & TextBox3.Text & ", JudulBuku = '" & TextBox4.Text & ", TglPeminjaman = '" & TextBox5.Text & "' where IDBuku = " & TextBox1.Text & ""
Dim oCmd As New OleDbCommand
oConn.Close()
oConn.Open()
oCmd.Connection = oConn
oCmd.CommandText = sql
oCmd.ExecuteNonQuery()
End Sub
End Class
Kamis, 15 Desember 2016
UAS Pemograman Bisnis 2
Hi there!
Saya akan menjelaskan aplikasi yang saya buat dengan Visual Basic dan Ms.Access. Aplikasi yang saya buat adalah tentang input data inventory untuk sebuah minimarket yang pada postingan sebelumnya telah saya buat, dan kali ini saya lebih mendetailkan aplikasi tersebut agar dapat digunakan dengan efektif.
Beberapa form yang saya buat:
1. Form Login: aplikasi ini hanya dapat diakses oleh karyawan bagian gudang dan manager cabang
2. Form Loading: untuk transisi proses dari Form Login ke Form Inventory
3. Form Inventory: berisi data-data yang berkaitan dengan inventory yang baru saja diinput
4. Form View: untuk melihat data yang terdapat di Ms.Access melalui data grid view
Fungsi yang terdapat dalam apliksi ini adalah:
1. Add: menambahkan data
2. Find: menampilkan data yang ingin kita cari
3. Edit: mengubah data. mengubah disini dikhususkan untuk jumlah barang
4. Delete: menghapus data
5. New: memulai kembali
6. View: melihat kumpulan data yang terdapat dalam database
7. Exit: keluar dari aplikasi
Berikut adalah form-formnya:
Berikut adalah Source Codenya:
1. Form Login
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class Login
Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\MATERI KULIAH\SMT 3\PB 2\dbpass.accdb"
Dim objekKoneksi As New OleDb.OleDbConnection(koneksi)
Dim xReader As OleDbDataReader
Private Sub btnlogin_Click(sender As Object, e As EventArgs) Handles btnlogin.Click
objekKoneksi.Close()
objekKoneksi.Open()
Dim Cmd As New OleDbCommand("SELECT * FROM Tlogin where Username ='" + username.Text + "'", objekKoneksi)
xReader = Cmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
username.Text = xReader("Username")
Loading.Show()
Else
MsgBox("Username atau Password salah")
username.Text = ""
password.Text = ""
username.Focus()
End If
xReader.Close()
End Sub
Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class
2. Form Loading
Public Class Loading
Private Sub Loading_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Start()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If ProgressBar1.Value < 100 Then
ProgressBar1.Value += 2
Else ProgressBar1.Value = 100
Timer1.Stop()
MessageBox.Show("LOGIN SUKSES! ", "Pemberitahuan", MessageBoxButtons.OK, MessageBoxIcon.Information)
Inventory.Show()
Me.Hide()
End If
End Sub
End Class
3. Form Inventory
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Public Class Inventory
Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\MATERI KULIAH\SMT 3\PB 2\dbminimarket.accdb"
Dim objekKoneksi As New OleDb.OleDbConnection(koneksi)
Dim xReader As OleDbDataReader
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
objekKoneksi.Close()
objekKoneksi.Open()
Dim tambah As String = "INSERT INTO Tinventory values('" & kodebrg.Text & "','" & namabrg.Text & "','" & jmlhbrg.Text & "','" & DateTimePicker1.Text & "','" & ComboBox1.Text & "','" & pengirim.Text & "')"
Dim oCmd = New OleDbCommand(tambah, objekKoneksi)
oCmd.ExecuteNonQuery()
objekKoneksi.Close()
MsgBox("Sukses!")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim kode As String = InputBox("Masukan Kode Barang")
If Not Len(kode) = 0 Then
objekKoneksi.Close()
objekKoneksi.Open()
Dim cari As String = "SELECT * FROM Tinventory where KodeBarang='" + kode + "'"
Dim ocmd = New OleDbCommand(cari, objekKoneksi)
xReader = ocmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
kodebrg.Text = xReader("KodeBarang")
namabrg.Text = xReader("NamaBarang")
jmlhbrg.Text = xReader("JumlahBarang")
DateTimePicker1.Text = xReader("TanggalPenerimaan")
ComboBox1.Text = xReader("Cabang")
pengirim.Text = xReader("NamaPengirimBarang")
'Jika tidak ditemukan tampilkan pesan
Else
MsgBox("Inventory " + kode + " TIDAK ADA")
Exit Sub
End If
xReader.Close()
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
objekKoneksi.Close()
objekKoneksi.Open()
Dim Ubah As String = "update Tinventory set JumlahBarang='" & jmlhbrg.Text & "' where KodeBarang='" & kodebrg.Text & "'"
Dim oCmd = New OleDbCommand(Ubah, objekKoneksi)
oCmd.ExecuteNonQuery()
objekKoneksi.Close()
MsgBox("Sukses")
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim HAPUS As String
HAPUS = MsgBox("Anda Yakin?", vbInformation + vbYesNo, "Konfirmasi")
If HAPUS = vbYes Then
objekKoneksi.Close()
objekKoneksi.Open()
Dim sql As String = "DELETE FROM Tinventory where KodeBarang='" + kodebrg.Text + "'"
Dim Cmd As New OleDbCommand
objekKoneksi.Close()
objekKoneksi.Open()
Cmd.Connection = objekKoneksi
Cmd.CommandText = sql
Cmd.ExecuteNonQuery()
MsgBox("SUKSES")
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim pesan As Integer
pesan = MsgBox("Selesai", vbInformation + vbYesNo, "Keluar")
If pesan = vbYes Then
Me.Close()
End If
Me.Close()
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
View.Show()
End Sub
Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles DateTimePicker1.ValueChanged
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
kodebrg.Text = ""
namabrg.Text = ""
jmlhbrg.Text = ""
ComboBox1.Text = ""
pengirim.Text = ""
kodebrg.Focus()
End Sub
End Class
4. Form View
Public Class View
Private Sub View_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DbminimarketDataSet11.Tinventory' table. You can move, or remove it, as needed.
Me.TinventoryTableAdapter1.Fill(Me.DbminimarketDataSet11.Tinventory)
'TODO: This line of code loads data into the 'DbminimarketDataSet.Tinventory' table. You can move, or remove it, as needed.
End Sub
End Class
Demikian aplikasi mengenai input data yang saya buat. Mohon maaf bila masih ada kekurangan.
Terima kasiiih
Kamis, 17 November 2016
Otomasi Word dan Excel Menggunakan VB.Net
Halo!
Sebelumnyabuat Form VBnya terlebih dahulu
Setelah design form telah selesai, masukan coding berikut ini agar programnya dapat berjalan dengan sempurna:
Imports Microsoft.Office.Interop
Public Class Form1
Private Sub new1_Click(sender As Object, e As EventArgs) Handles new1.Click
ComboBox1.Text = ""
merk.Text = ""
ComboBox2.Text = ""
tgltrans.Text = ""
distributor.Text = ""
ComboBox4.Text = ""
End Sub
Private Sub hitung_Click(sender As Object, e As EventArgs) Handles hitung.Click
jmlharga.Text = jmlhbrg.Text * harga.Text
End Sub
Private Sub new2_Click(sender As Object, e As EventArgs) Handles new2.Click
ComboBox3.Text = ""
merk2.Text = ""
jmlhbrg.Text = ""
harga.Text = ""
jmlharga.Text = ""
End Sub
Private Sub save1_Click(sender As Object, e As EventArgs) Handles save1.Click
Dim wapp As New Word.Application
Dim wdoc As New Word.Document
wdoc = wapp.Documents.Open("D:\MATERI KULIAH\SMT 3\PB 2\OMEGA MINIMARKET.docx")
wdoc.Bookmarks("bkmtanggal").Select()
wapp.Selection.TypeText(tgltrans.Text)
wdoc.Bookmarks("bkmjenis").Select()
wapp.Selection.TypeText(ComboBox1.Text)
wdoc.Bookmarks("bkmmerk").Select()
wapp.Selection.TypeText(merk.Text)
wdoc.Bookmarks("bkmjumlah").Select()
wapp.Selection.TypeText(ComboBox2.Text)
wdoc.Bookmarks("bkmdistributor").Select()
wapp.Selection.TypeText(distributor.Text)
wdoc.Bookmarks("bkmstatus").Select()
wapp.Selection.TypeText(ComboBox4.Text)
wapp.Visible = True
End Sub
Private Sub save2_Click(sender As Object, e As EventArgs) Handles save2.Click
Dim app As New Excel.Application
Dim book As Excel.Workbook
Dim sheet As Excel.Worksheet
Dim row As Long
book = app.Workbooks.Open("D:\MATERI KULIAH\SMT 3\PB 2\Book1.xlsx")
sheet = book.Sheets("Sheet1")
row = sheet.Range("A" & sheet.Rows.Count).End(Excel.XlDirection.xlUp).Row
app.Range("A1").Value = "No."
app.Range("B1").Value = "Jenis Barang"
app.Range("C1").Value = "Merk Barang"
app.Range("D1").Value = "Jumlah"
app.Range("E1").Value = "Harga"
app.Range("F1").Value = "Jumlah Harga"
app.Range("A" & row + 1).Value = CStr(row)
app.Range("B" & row + 1).Value = ComboBox3.Text
app.Range("C" & row + 1).Value = merk2
app.Range("D" & row + 1).Value = jmlhbrg
app.Range("E" & row + 1).Value = harga
app.Range("F" & row + 1).Value = jmlharga
book.Save()
End Sub
End Class
Untuk dapat melakukan Otomasi Word dan Excel, terlebih dahulu kita harus membuat dokumen seperti berikut ini:
Setelah itu, kita masukan sampel data. Tujuannya adalah untuk melihat apakah program berjalan dengan lancar atau tidak
Demikian contoh otomasi Word dan Excel menggunakan VB.Net. Semoga dapat bermanfaat :)
Saat ini saya akan menjelaskan cara membuat otomasi Word dan Excel menggunakan VB.Net, sebagai contoh saya akan membuat data entry untuk sebuah Minimarket. Didalam data ini, terdapat bagian Input dan Output. Input adalah ketika pihak Minimarket melakukan pembelian inventory untuk memenuhi persediaan gudangnya dan bagian Output adalah ketika terjadi transaksi penjualan yang terjadi pada Minimarket tersebut.
Sebelumnyabuat Form VBnya terlebih dahulu
Form Minimarket |
Setelah design form telah selesai, masukan coding berikut ini agar programnya dapat berjalan dengan sempurna:
Imports Microsoft.Office.Interop
Public Class Form1
Private Sub new1_Click(sender As Object, e As EventArgs) Handles new1.Click
ComboBox1.Text = ""
merk.Text = ""
ComboBox2.Text = ""
tgltrans.Text = ""
distributor.Text = ""
ComboBox4.Text = ""
End Sub
Private Sub hitung_Click(sender As Object, e As EventArgs) Handles hitung.Click
jmlharga.Text = jmlhbrg.Text * harga.Text
End Sub
Private Sub new2_Click(sender As Object, e As EventArgs) Handles new2.Click
ComboBox3.Text = ""
merk2.Text = ""
jmlhbrg.Text = ""
harga.Text = ""
jmlharga.Text = ""
End Sub
Private Sub save1_Click(sender As Object, e As EventArgs) Handles save1.Click
Dim wapp As New Word.Application
Dim wdoc As New Word.Document
wdoc = wapp.Documents.Open("D:\MATERI KULIAH\SMT 3\PB 2\OMEGA MINIMARKET.docx")
wdoc.Bookmarks("bkmtanggal").Select()
wapp.Selection.TypeText(tgltrans.Text)
wdoc.Bookmarks("bkmjenis").Select()
wapp.Selection.TypeText(ComboBox1.Text)
wdoc.Bookmarks("bkmmerk").Select()
wapp.Selection.TypeText(merk.Text)
wdoc.Bookmarks("bkmjumlah").Select()
wapp.Selection.TypeText(ComboBox2.Text)
wdoc.Bookmarks("bkmdistributor").Select()
wapp.Selection.TypeText(distributor.Text)
wdoc.Bookmarks("bkmstatus").Select()
wapp.Selection.TypeText(ComboBox4.Text)
wapp.Visible = True
End Sub
Private Sub save2_Click(sender As Object, e As EventArgs) Handles save2.Click
Dim app As New Excel.Application
Dim book As Excel.Workbook
Dim sheet As Excel.Worksheet
Dim row As Long
book = app.Workbooks.Open("D:\MATERI KULIAH\SMT 3\PB 2\Book1.xlsx")
sheet = book.Sheets("Sheet1")
row = sheet.Range("A" & sheet.Rows.Count).End(Excel.XlDirection.xlUp).Row
app.Range("A1").Value = "No."
app.Range("B1").Value = "Jenis Barang"
app.Range("C1").Value = "Merk Barang"
app.Range("D1").Value = "Jumlah"
app.Range("E1").Value = "Harga"
app.Range("F1").Value = "Jumlah Harga"
app.Range("A" & row + 1).Value = CStr(row)
app.Range("B" & row + 1).Value = ComboBox3.Text
app.Range("C" & row + 1).Value = merk2
app.Range("D" & row + 1).Value = jmlhbrg
app.Range("E" & row + 1).Value = harga
app.Range("F" & row + 1).Value = jmlharga
book.Save()
End Sub
End Class
Untuk dapat melakukan Otomasi Word dan Excel, terlebih dahulu kita harus membuat dokumen seperti berikut ini:
untuk Word, tambahkan Bookmarks di tempat yang diinginkan |
tampilan Excel |
Setelah itu, kita masukan sampel data. Tujuannya adalah untuk melihat apakah program berjalan dengan lancar atau tidak
Entry untuk Excel |
Hasil Otomasi Excel |
Entry untuk Word |
Hasil Otomasi Word |
Langganan:
Postingan (Atom)