Selasa, 15 November 2011

LATIHAN 20 - 26 APKOM 4

ANDI WAHYUNI
36109019
3AD3

FORM 20
Public Class Form20
    Dim nyai As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Private Sub Form20_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim OD As New OleDb.OleDbDataAdapter
        OD = New OleDb.OleDbDataAdapter("select * from query3", uni)
        nyai.Rows.Clear()
        OD.Fill(nyai)
        DGV36109019.DataSource = nyai
        OD.Dispose()
    End Sub
End Class

FORM 21
Public Class Form21
    Dim UNI As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Dim dt1 As New DataTable
    Dim dt2 As New DataTable
    Dim ds As New DataSet
    Dim bs1 As New BindingSource
    Dim bs2 As New BindingSource
    Private Sub Form21_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As New OleDb.OleDbDataAdapter
        Dim b As New OleDb.OleDbDataAdapter
        a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", UNI)
        a.Fill(dt1)
        a.Dispose()

        b = New OleDb.OleDbDataAdapter("select * from detailtransaksi", UNI)
        b.Fill(dt2)
        b.Dispose()
        ds.Tables.Add(dt1)
        ds.Tables.Add(dt2)
        dt1.TableName = "nyai1"
        dt2.TableName = "nyai2"
        ds.Relations.Add(New DataRelation("unyi", ds.Tables("nyai1").Columns("notrans"), ds.Tables("nyai2").Columns("notrans")))
        bs1.DataSource = ds
        bs1.DataMember = "nyai1"
        bs2.DataSource = bs1
        bs2.DataMember = "unyi"
        DGV136109019.DataSource = bs1
        DGV236109019.DataSource = bs2
    End Sub
End Class


FORM 22
Public Class Form22
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Dim dt1 As New DataTable
    Dim dt2 As New DataTable
    Dim ds As New DataSet
    Dim bs1 As New BindingSource
    Dim bs2 As New BindingSource
    Private Sub Form22_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As New OleDb.OleDbDataAdapter
        Dim b As New OleDb.OleDbDataAdapter
        a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", uni)
        a.Fill(dt1)
        a.Dispose()
        b = New OleDb.OleDbDataAdapter("select * from Query4", uni)
        b.Fill(dt2)
        b.Dispose()
        ds.Tables.Add(dt1)
        ds.Tables.Add(dt2)
        dt1.TableName = "nyai1"
        dt2.TableName = "nyai2"
        ds.Relations.Add(New DataRelation("unyi", ds.Tables("nyai1").Columns("notrans"), ds.Tables("nyai2").Columns("notrans")))
        bs1.DataSource = ds
        bs1.DataMember = "nyai1"
        bs2.DataSource = bs1
        bs2.DataMember = "unyi"
        DGV136109019.DataSource = bs1
        DGV236109019.DataSource = bs2
    End Sub
End Class

FORM 23A
Public Class Form23A
    Dim dt As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Private Sub KLIK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KLIK.Click
        If Form23B.Visible = False Then
            Form23B.Show()
        Else
            Form23B.Activate()
        End If
        Form23B.A36109019.Text = DGV36109019.CurrentRow.Cells("notrans").Value
        Form23B.B36109019.Text = DGV36109019.CurrentRow.Cells("tanggaltransaksi").Value
        Form23B.C36109019.Text = DGV36109019.CurrentRow.Cells("jenistransaksi").Value
        Form23B.UNYI(Form23B.A36109019.Text)
    End Sub
    Private Sub Form23A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As New OleDb.OleDbDataAdapter
        a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", uni)
        a.Fill(dt)
        a.Dispose()
        DGV36109019.DataSource = dt
    End Sub
End Class

FORM 23B
Public Class Form23B
    Dim dt As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Private Sub Form23B_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DGV36109019.DataSource = dt
    End Sub
    Public Sub UNYI(ByVal ical As String)
        Dim a As New OleDb.OleDbDataAdapter
        Dim b As String
        b = "select id, kodebarang, unit, harga from detailtransaksi where notrans = '" & ical & "'"
        a = New OleDb.OleDbDataAdapter(b, uni)
        a.Fill(dt)
    End Sub
End Class

FORM 24A
Public Class Form24A
    Dim dt As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Private Sub Form24A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As New OleDb.OleDbDataAdapter
        a = New OleDb.OleDbDataAdapter("select * from barang", uni)
        a.Fill(dt)
        a.Dispose()
        DGV36109019.DataSource = dt
    End Sub
    Private Sub DT36109019_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DT36109019.Click
        If Form24B.Visible = False Then
            Form24B.Show()
        Else
            Form24B.Activate()
        End If
        Form24B.A36109019.Text = DGV36109019.CurrentRow.Cells("kodebarang").Value
        Form24B.B36109019.Text = DGV36109019.CurrentRow.Cells("namabarang").Value
        Form24B.C36109019.Text = DGV36109019.CurrentRow.Cells("hargajual").Value
        Form24B.D36109019.Text = DGV36109019.CurrentRow.Cells("persediaanawal").Value
        Form24B.UNYI(Form24B.A36109019.Text)
    End Sub
End Class

FORM 24B
Public Class Form24B
    Dim dt As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Private Sub Form24B_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DGV36109019.DataSource = dt
    End Sub
    Public Sub UNYI(ByVal ical As String)
        Dim a As New OleDb.OleDbDataAdapter
        Dim b As String
        b = "select id, notrans, unit, harga from detailtransaksi where kodebarang = '" & ical & "'"
        a = New OleDb.OleDbDataAdapter(b, uni)
        a.Fill(dt)
    End Sub
End Class

FORM 25A
Public Class Form25A
    Dim dt As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Private Sub Form25A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As New OleDb.OleDbDataAdapter
        a = New OleDb.OleDbDataAdapter("select * from barang", uni)
        a.Fill(dt)
        a.Dispose()
        DGV36109019.DataSource = dt
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Form25B.Visible = False Then
            Form25B.Show()
        Else
            Form25B.Activate()
        End If
        Form25B.A36109019.Text = DGV36109019.CurrentRow.Cells("kodebarang").Value
        Form25B.B36109019.Text = DGV36109019.CurrentRow.Cells("namabarang").Value
        Form25B.C36109019.Text = DGV36109019.CurrentRow.Cells("hargajual").Value
        Form25B.D36109019.Text = DGV36109019.CurrentRow.Cells("persediaanawal").Value
        Form25B.UNYI(Form25B.A36109019.Text)
    End Sub
End Class

FORM 25B
Public Class Form25B
    Dim dt As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Private Sub Form25B_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DGV36109019.DataSource = dt
    End Sub
    Public Sub UNYI(ByVal ical As String)
        Dim a As New OleDb.OleDbDataAdapter
        a = New OleDb.OleDbDataAdapter("select * from Query5", uni)
        dt.Rows.Clear()
        a.Fill(dt)
        DGV36109019.DataSource = dt
    End Sub
End Class

FORM 26A
Public Class Form26A
    Dim dt As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")

    Private Sub Form26A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim a As New OleDb.OleDbDataAdapter
        a = New OleDb.OleDbDataAdapter("select * from barang", uni)
        a.Fill(dt)
        a.Dispose()
        dgva36109019.DataSource = dt
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109019.Click
        If Form26B.Visible = False Then
            Form26B.Show()
        Else
            Form26B.Activate()
        End If
        Form26B.aa36109019.Text = dgva36109019.CurrentRow.Cells("kodebarang").Value
        Form26B.bb36109019.Text = dgva36109019.CurrentRow.Cells("namabarang").Value
        Form26B.cc36109019.Text = dgva36109019.CurrentRow.Cells("hargajual").Value
        Form26B.dd36109019.Text = dgva36109019.CurrentRow.Cells("persediaanawal").Value
        Form26B.unhi(Form26B.aa36109019.Text)
    End Sub
End Class

FORM 26B
Public Class Form26B
    Dim dt As New DataTable
    Dim uni As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source =" & Application.StartupPath & "\DataTransaksiJualBeli.accdb")
    Private Sub Form26B_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        dgvb36109019.DataSource = dt
    End Sub
    Public Sub unhi(ByVal C As String)
        Dim a As New OleDb.OleDbDataAdapter
        Dim b As String
        b = "SELECT MASTERTRANSAKSI.NOTRANS, MASTERTRANSAKSI.TANGGALTRANSAKSI, MASTERTRANSAKSI.JENISTRANSAKSI, MASTERTRANSAKSI.KETERANGAN, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, [DETAILTRANSAKSI]![UNIT]*[DETAILTRANSAKSI]![HARGA] AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN MASTERTRANSAKSI ON DETAILTRANSAKSI.NOTRANS = MASTERTRANSAKSI.NOTRANS WHERE KODEBARANG = '" & C & "'"
        a = New OleDb.OleDbDataAdapter(b, uni)
        a.Fill(dt)
        Dim unhi1 As Integer = 0
        Dim unhi2 As Integer = 0
        For Each unhi3 As DataRow In dt.Rows
            unhi1 += unhi3("Unit")
            unhi2 += unhi3("Jumlah")
        Next
        ee36109019.Text = unhi1
        ff36109019.Text = unhi2
    End Sub
End Class



Tidak ada komentar:

Posting Komentar