Senin, 19 November 2018

UAS_REKAYASA PERANGKAT LUNAK











WEB FROM 1

Imports System.Data
Imports System.Data.OleDb



Public Class WebForm1
    Inherits System.Web.UI.Page

    Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\HERU\Documents\LATIHAN01\dbjoran.accdb"
    Dim objekkoneksi As New OleDb.OleDbConnection(koneksi)
    Dim xReader As OleDb.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 koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\HERU\Documents\LATIHAN01\dbjoran.accdb"
        Dim objekKoneksi As New OleDbConnection(koneksi)
        objekKoneksi.Open()
        Dim tambah As String = "INSERT INTO TabelJoran values ('" & kodejoran.Text & "','" & namabarang.Text & "','" & merk.Text & "','" & joran.Text & "','" & jenis.Text & "','" & harga.Text & "')"
        Dim oCmd = New OleDbCommand(tambah, objekKoneksi)
        oCmd.ExecuteNonQuery()
        objekKoneksi.Close()
        MsgBox("DATA BERHASIL DISIMPAN")

    End Sub



    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Response.Redirect("formtabeljoran.aspx")
    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        kodejoran.Text = ""
        namabarang.Text = ""
        merk.Text = ""
        joran.Text = ""
        jenis.Text = ""
        harga.Text = ""


    End Sub

    Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        If Not Len(kodebarangcari.Text) = 0 Then
            objekkoneksi.Close()
            objekkoneksi.Open()

            Dim ocmd As New OleDb.OleDbCommand(" SELECT * FROM TabelJoran where KODE_Barang='" + kodebarangcari.Text + "'", objekkoneksi)

            xReader = ocmd.ExecuteReader()
            If xReader.HasRows Then
                xReader.Read()
                kodejoran.Text = xReader("KODE_Barang")
                namabarang.Text = xReader("NAMA_Barang")
                merk.Text = xReader("MERK")
                joran.Text = xReader("Panjang_joran")
                jenis.Text = xReader("JENIS")
                harga.Text = xReader("HARGA")

            Else
                kodebarangcari.Text = "Joran tidak ada"

                Exit Sub
            End If
        End If
    End Sub

    Protected Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Response.Redirect("transaksi.aspx")
    End Sub
End Class




TRANSAKSI



Imports System.Data
Imports System.Data.OleDb

Public Class transaksi
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\HERU\Documents\LATIHAN01\dbjoran.accdb"
        Dim objekkoneksi As New OleDb.OleDbConnection(koneksi)
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim bil1, bil2, hasil As Integer

        bil1 = harga2.Text
        bil2 = qty.Text
        hasil = harga2.Text * qty.Text
        total.Text = hasil
    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\HERU\Documents\LATIHAN01\dbjoran.accdb"
        Dim objekKoneksi As New OleDbConnection(koneksi)
        objekKoneksi.Open()
        Dim tambah As String = "INSERT INTO Transaksi values ('" & kodemobil2.Text & "','" & namamobil2.Text & "','" & merk2.Text & "','" & tahun2.Text & "','" & harga2.Text & "','" & qty.Text & "','" & total.Text & "')"
        Dim objCmd = New OleDbCommand(tambah, objekKoneksi)
        objCmd.ExecuteNonQuery()
        objekKoneksi.Close()
        MsgBox("DATA BERHASIL DISIMPAN")

    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Response.Redirect("WebForm1.aspx")
    End Sub

    Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        kodemobil2.Text = ""
        namamobil2.Text = ""
        merk2.Text = ""
        tahun2.Text = ""
        qty.Text = ""
        harga2.Text = ""
        total.Text = ""
    End Sub
End Class

Tidak ada komentar:

Posting Komentar