Akuntansi Manajerial

Akuntansi Manajerial

Minggu, 20 November 2011

Latihan 33(APKOM)


Public Class LATIHAN033A_46109040
    Dim Hubung As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=46109040")
    Dim cari As New DataTable
    Public Sub ambildata()
        Dim data As New OleDb.OleDbDataAdapter
        data = New OleDb.OleDbDataAdapter("select * from barang", Hubung)
        cari.Rows.Clear()
        data.Fill(cari)
        data.Dispose()
    End Sub
    Private Sub Latihan33_A_46109040_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ambildata()
        VIEW_46109040.DataSource = cari
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2_46109040.Click
        If LATIHAN033B_46109040.Visible = False Then
            LATIHAN033B_46109040.Show()
        Else
            LATIHAN033B_46109040.Activate()
        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_46109040.Click
        If LATIHAN033B_46109040.Visible = False Then
            LATIHAN033B_46109040.Show()
        Else
            LATIHAN033B_46109040.Activate()
        End If
        LATIHAN033B_46109040.KB.Text = VIEW_46109040.CurrentRow.Cells("KODEBARANG").Value
        LATIHAN033B_46109040.KB_46109040.Text = VIEW_46109040.CurrentRow.Cells("KODEBARANG").Value
        LATIHAN033B_46109040.NB_46109040.Text = VIEW_46109040.CurrentRow.Cells("NAMABARANG").Value
        LATIHAN033B_46109040.HJ_46109040.Text = VIEW_46109040.CurrentRow.Cells("HARGAJUAL").Value
        LATIHAN033B_46109040.JB_46109040.Text = VIEW_46109040.CurrentRow.Cells("JUMLAHBARANG").Value
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3_46109040.Click
        Dim Ukky As New OleDb.OleDbCommand
        Ukky = New OleDb.OleDbCommand("DELETE * FROM BARANG WHERE KODEBARANG='" & VIEW_46109040.CurrentRow.Cells("KODEBARANG").Value & "'", Hubung)
        Hubung.Open()
        Ukky.ExecuteNonQuery()
        Hubung.Close()
        Ukky.Dispose()
        ambildata()
    End Sub
End Class



Public Class LATIHAN033B_46109040
    Dim Hubung As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=46109040")
    Dim cari As New ByIskandar.CariKeDataBaseByIskandar

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_46109040.Click

        If KB_46109040.Text.Length = 0 Then
            MsgBox("Maaf kode barang belum diisi")
            Exit Sub
        End If

        If NB_46109040.Text.Length = 0 Then
            MsgBox("Maaf nama barang belum diisi")
            Exit Sub
        End If

        If Val(HJ_46109040.Text) = 0 Then
            MsgBox("Maaf harga jual belum diisi")
            Exit Sub
        End If

        If Val(JB_46109040.Text) = 0 Then
            MsgBox("Maaf jumlah barang belum diisi")
            Exit Sub
        End If

        cari.AturPencarianDataBase("barang", "kodebarang", KB_46109040.Text, 1, Hubung)

        If cari.JumlanBaris > 0 Then
            MsgBox("Maaf kode sudah ada")
            Exit Sub
        End If


        Dim com As New OleDb.OleDbCommand
        com = New OleDb.OleDbCommand("insert into barang(kodebarang,namabarang,hargajual,jumlahbarang) Values('" & KB_46109040.Text & "','" & NB_46109040.Text & "'," & Val(HJ_46109040.Text) & "," & Val(JB_46109040.Text) & ")", Hubung)

        Hubung.Open()
        com.ExecuteNonQuery()
        Hubung.Close()
        com.Dispose()

        KB_46109040.Text = ""
        NB_46109040.Text = ""
        HJ_46109040.Text = ""
        JB_46109040.Text = ""

        LATIHAN033A_46109040.ambildata()
    End Sub

    Private Sub Latihan33_B_46109040_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class



Tidak ada komentar:

Posting Komentar