• selamat datang

Blog yang hanya berisi sekedar informasi-informasi kecil untuk sobat blogger sekalian.

Kamis, 25 Mei 2017

UAS LAB SMBD

Postingan ini digunakan untuk melengkapi UAS SMBD Take Home.
Aplikasi berbasis asp.net ini digunakan agar user dapat mengelola data dengan baik. Maka dari itu diperlukan sebuah sistem manajemen yang baik, agar data dari penyewa sendiri dapat terintegrasi.

Screenshot

Daftar Table



Table Merk



Table Rental Mobil



Table Tingkat Harga



Design








Source Code


Imports System.Data
Imports System.Data.OleDb

Public Class WebForm1
    Inherits System.Web.UI.Page

Koneksi
    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 Table_RentalMobil VALUES ('" & txtIDPenyewa.Text & "','" & txtNamaPenyewa.Text & "','" & txtIDMerk.Text & "','" & txtHarga.Text & "')"
        Dim oCmd As New OleDbCommand
        oConn.Open()
        oCmd.Connection = oConn
        oCmd.CommandText = sql
        oCmd.ExecuteNonQuery()
    End Sub

Delete
    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim hapus = MsgBox("Konfirmasi", MsgBoxStyle.YesNo, "Hapus")

        If hapus = vbYes Then
            oConn.Close()
            oConn.Open()
            Dim delet As String = "DELETE FROM Table_RentalMobil where ID_Penyewa =" + txtIDPenyewa.Text + ""
            Dim oCmd As New OleDbCommand
            oConn.Close()
            oConn.Open()
            oCmd.Connection = oConn
            oCmd.CommandText = delet
            oCmd.ExecuteNonQuery()
            MsgBox("Sudah terhapus", vbArchive)

            txtIDPenyewa.Text = ""
            txtNamaPenyewa.Text = ""
            txtIDMerk.Text = ""
            txtHarga.Text = ""
        End If
    End Sub

Update
    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim sql As String = " UPDATE Table_RentalMobil set Nama_Penyewa  ='" & txtNamaPenyewa.Text & "', ID_Merk = " & txtIDMerk.Text & ", Tingkatan_Harga = '" & txtHarga.Text & "' where ID_Penyewa = " & txtIDPenyewa.Text & ""

        Dim oCmd As New OleDbCommand
        oConn.Close()
        oConn.Open()
        oCmd.Connection = oConn
        oCmd.CommandText = sql

        oCmd.ExecuteNonQuery()

    End Sub

View
    Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        Response.Redirect("WebForm2.aspx")
    End Sub

Search
    Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        oConn.Close()
        oConn.Open()
        Dim Cmd As New OleDbCommand("SELECT * FROM Table_Rental where ID_Penyewa =" + txtIDPenyewa.Text + "", oConn)
        xReader = Cmd.ExecuteReader
        If xReader.HasRows Then
            xReader.Read()
            txtNamaPenyewa.Text = xReader("Nama_Penyewa")
            txtIDMerk.Text = xReader("ID_Merk")
            txtHarga.Text = xReader("Tingkatan_Harga")


        Else
            MsgBox("Data penyewa tidak ada")
            txtIDPenyewa.Text = ""
            txtNamaPenyewa.Text = ""
            txtIDMerk.Text = ""
            txtHarga.Text = ""

            Exit Sub
        End If
        xReader.Close()

    End Sub

End Class

Kamis, 06 April 2017

Mengaplikasikan Database Normalisasi Pada ASP.NET (UTS Lab SMBD)

Tahapan Normalisasi

1NF
Table_RentalMobil (ID_Penyewa, Nama_Penyewa, NamaMobil_Disewa, MerkMobil_Disewa, ID_Merk, Tingkatan_Harga, Sewa_Perhari)

2NF
Table_RentalMobil (ID_Penyewa, Nama_Penyewa, ID_Merk, Tingkatan_Harga)
Table_TingkatHarga (Tingkatan_Harga, Sewa_Hari)
Table_Merk (ID_Merk, MerkMobil_Disewa)


3NF sama dengan 2NF


Screenshot








Source Code Manipulasi Data

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 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 Table_RentalMobil VALUES ('" & TxtIDPenyewa.Text & "','" & txtNama.Text & "','" & txtIDMerk.Text & "','" & txtTingkatHarga.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
    'Delete
    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim hapus = MsgBox("Konfirmasi", MsgBoxStyle.YesNo, "Hapus")

        If hapus = vbYes Then
            oConn.Close()
            oConn.Open()
            Dim delet As String = "DELETE FROM Table_RentalMobil where ID_Penyewa =" + TxtIDPenyewa.Text + ""
            Dim oCmd As New OleDbCommand
            oConn.Close()
            oConn.Open()
            oCmd.Connection = oConn
            oCmd.CommandText = delet
            oCmd.ExecuteNonQuery()
            MsgBox("Sudah terhapus", vbArchive)

            TxtIDPenyewa.Text = ""
            txtNama.Text = ""
            txtIDMerk.Text = ""
            txtTingkatHarga.Text = ""

        End If

    End Sub
    'Search
    Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        oConn.Close()
        oConn.Open()
        Dim Cmd As New OleDbCommand("SELECT * FROM Table_Rental where ID_Penyewa =" + TxtIDPenyewa.Text + "", oConn)
        xReader = Cmd.ExecuteReader
        If xReader.HasRows Then
            xReader.Read()
            txtNama.Text = xReader("Nama_Penyewa")
            txtIDMerk.Text = xReader("ID_Merk")
            txtTingkatHarga.Text = xReader("Tingkatan_Harga")


        Else
            MsgBox("Kode Buku Tidak Ada")
            TxtIDPenyewa.Text = ""
            txtNama.Text = ""
            txtIDMerk.Text = ""
            txtTingkatHarga.Text = ""

            Exit Sub
        End If
        xReader.Close()


    End Sub
    'Update
    Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim sql As String = " UPDATE Table_RentalMobil set Nama_Penyewa  ='" & txtNama.Text & "', ID_Merk = " & txtIDMerk.Text & ", Tingkatan_Harga = '" & txtTingkatHarga.Text & "' where ID_Penyewa = " & TxtIDPenyewa.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

Aplikasi Perpustakaan Sederhana (UAS Lab Pemrograman Bisnis 2)

Aplikasi ini bertujuan untuk mempermudah orang-orang pada zaman sekarang. Baik ini user maupun admin itu sendiri. Berikut adalah penjelasan aplikasinya.



Penjelasan terkait aplikasi ini :

Silahkan pilih anda ingin masuk sebagai apa


Jika anda masuk sebagai mahasiswa, maka akan muncul form untuk melakukan pencarian buku.
Ketikkan judul buku yang ingin anda cari, maka jika buku tersebut ada. Maka akan muncul buku yang anda inginkan, atau yang judul yang sejenis.


Namun, jika anda masuk sebagai Petugas. Maka akan muncul form login khusus untuk Admin.


Jika anda telah masuk sebagai Admin, maka form utama untuk admin akan muncul.


Admin diberikan Hak untuk mengubah ataupun menghapus database yang ada.


Source Code :

Imports System.Data
Imports System.Data.OleDb

Public Class FormData
    Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\Kuliah\Konsep Pemrograman Bisnis 2\UAS\UAS\DBPerpustakaan.accdb"
    Dim objekkoneksi As New OleDb.OleDbConnection(koneksi)
    Dim xReader As OleDbDataReader

    Private Sub FormData_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        


    End Sub

    Private Sub btnTambah_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        objekkoneksi.Close()
        objekkoneksi.Open()
        Dim tambahbuku As String = "INSERT INTO Table_Buku VALUES('" & txtKode.Text & "' , '" & txtJudul.Text & "' , '" & txtPenulis.Text & "' , '" & txtPenerbit.Text & "')"

        Dim oCmd = New OleDbCommand(tambahbuku, objekkoneksi)

        oCmd.ExecuteNonQuery()

        objekkoneksi.Close()
        MsgBox("Sukses")

    End Sub

    Private Sub BtnEdit_Click(sender As Object, e As EventArgs) Handles BtnEdit.Click
        Dim sql As String = " UPDATE Table_Buku set Judul_Buku  ='" & txtJudul.Text & "', Penulis = '" & txtPenulis.Text & "', Penerbit = '" & txtPenerbit.Text & "' where Kode_Buku = '" & txtKode.Text & "'"

        Dim oCmd As New OleDbCommand
        objekkoneksi.Close()
        objekkoneksi.Open()
        oCmd.Connection = objekkoneksi
        oCmd.CommandText = Sql
        
        oCmd.ExecuteNonQuery()
    End Sub

    Private Sub btnFind_Click(sender As Object, e As EventArgs) Handles btnFind.Click
        Dim VKode = InputBox("Masukkan Kode Buku")

        objekkoneksi.Close()
        objekkoneksi.Open()
        Dim Cmd As New OleDbCommand("SELECT * FROM Table_Buku where Kode_Buku ='" + VKode + "'", objekkoneksi)
        xReader = Cmd.ExecuteReader
        If xReader.HasRows Then
            xReader.Read()
            txtKode.Text = xReader("Kode_Buku")
            txtJudul.Text = xReader("Judul_Buku")
            txtPenulis.Text = xReader("Penulis")
            txtPenerbit.Text = xReader("Penerbit")

        Else
            MsgBox("Kode Buku Tidak Ada")
            txtKode.Text = ""
            txtJudul.Text = ""
            txtPenulis.Text = ""
            txtPenerbit.Text = ""
            txtKode.Focus()
            Exit Sub
        End If
        xReader.Close()
    End Sub

    Private Sub btnView_Click(sender As Object, e As EventArgs) Handles btnView.Click
        FormTableBuku.Show()
    End Sub

    Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
        FormPrint.Show()
    End Sub

    Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click

        Dim hapus = MsgBox("Konfirmasi", MsgBoxStyle.YesNo, "Hapus")

        If hapus = vbYes Then
            objekkoneksi.Close()
            objekkoneksi.Open()
            Dim delet As String = "DELETE FROM Table_Buku where Kode_Buku='" + txtKode.Text + "'"
            Dim oCmd As New OleDbCommand
            objekkoneksi.Close()
            objekkoneksi.Open()
            oCmd.Connection = objekkoneksi
            oCmd.CommandText = delet
            oCmd.ExecuteNonQuery()
            MsgBox("Sudah terhapus", vbArchive)

            txtKode.Text = ""
            txtJudul.Text = ""
            txtPenulis.Text = ""
            txtPenerbit.Text = ""
            txtKode.Focus()
        End If
    End Sub

    Private Sub txtKode_LostFocus(sender As Object, e As EventArgs) Handles txtKode.LostFocus
        objekkoneksi.Close()
        objekkoneksi.Open()
        Dim Cmd As New OleDbCommand("SELECT * FROM Table_Buku where Kode_Buku ='" + txtKode.Text + "'", objekkoneksi)

        xReader = Cmd.ExecuteReader
        If xReader.HasRows Then
            Dim MKode = MsgBox("Kode Sudah Ada!", vbCritical, "Perhatian")
        End If

    End Sub

    Private Sub txtKode_TextChanged(sender As Object, e As EventArgs) Handles txtKode.TextChanged

    End Sub
End Class