Kamis, 01 Desember 2011

Latihan 38

Public Class Tugas38_36109067
    Dim V As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
    Dim dt1 As New DataTable
    Dim dr1 As DataRow

    Private Sub Latihan38017_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim M As New OleDb.OleDbDataAdapter
        M = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & tb1.Text & "'", V)
        M.Fill(dt1)
        M.Dispose()

        Dim dataPrimary(1) As DataColumn
        dataPrimary(0) = dt1.Columns("KODEBARANG")
        dt1.PrimaryKey = dataPrimary

        dgv1.DataSource = dt1
    End Sub

    Private Sub TOTALJUMLAH()
        Dim TOT As Double = 0
        For Each Y As DataRow In dt1.Rows
            TOT = TOT + Y("JUMLAH")
        Next
        tb8.Text = TOT

    End Sub

    Private Sub tb3_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb3.Leave
        If tb3.Text.Length = 0 Then
            Exit Sub
        End If

        Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
        Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", tb3.Text, 1, V)
        If Pencari.JumlanBaris > 0 Then
            tb3.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
            tb4.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
        Else
            MsgBox("Kode barang tersebut tidak ada")
            If Tugas383940_36109067.ShowDialog = Windows.Forms.DialogResult.OK Then
                tb3.Text = Tugas383940_36109067.DGV38.CurrentRow.Cells("KodeBarang").Value
                tb4.Text = Tugas383940_36109067.DGV38.CurrentRow.Cells("NamaBarang").Value
            Else
                tb3.Text = ""
            End If
        End If
    End Sub

    Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tb3.TextChanged
        tb4.Text = ""
        tb5.Text = ""
        tb6.Text = ""
    End Sub

Tidak ada komentar:

Posting Komentar