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

1 komentar:

  1. aplikasi yang bagus, semoga indonesia memiliki talenta berbakat seperti saudara arizal ini. tetap semangat dan pantang menyerah.

    -Perjuangan Takkan Membohongi Hasil-

    BalasHapus