Akuntansi Manajerial

Akuntansi Manajerial

Minggu, 20 November 2011

Latihan 31(APKOM)


Public Class Latihan031A_46109040
    Dim jembatan As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=46109040")
    Dim ambil As New DataTable
    Public Sub ambildata()
        Dim data As New OleDb.OleDbDataAdapter
        data = New OleDb.OleDbDataAdapter("SELECT* FROM barang", jembatan)
        ambil.Rows.Clear()
        data.Fill(ambil)
        data.Dispose()
    End Sub
    Private Sub Latihan31_A_46109040_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ambildata()
        VIEW_46109040.DataSource = ambil
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_46109040.Click
        If Latihan031B_46109040.Visible = False Then
            Latihan031B_46109040.Show()
        Else
            Latihan031B_46109040.Activate()
        End If
        Latihan031B_46109040.KB.Text = VIEW_46109040.CurrentRow.Cells("KODEBARANG").Value
        Latihan031B_46109040.KB_46109040.Text = VIEW_46109040.CurrentRow.Cells("KODEBARANG").Value
        Latihan031B_46109040.NB_46109040.Text = VIEW_46109040.CurrentRow.Cells("NAMABARANG").Value
        Latihan031B_46109040.HJ_46109040.Text = VIEW_46109040.CurrentRow.Cells("HARGAJUAL").Value
        Latihan031B_46109040.JB_46109040.Text = VIEW_46109040.CurrentRow.Cells("JUMLAHBARANG").Value
    End Sub
End Class



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

    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("Tolong Masukkan Text Anda")
            Exit Sub
        End If
        If NB_46109040.Text.Length = 0 Then
            MsgBox("Tolong Masukkan Text Anda")
            Exit Sub
        End If
        If Val(HJ_46109040.Text) = 0 Then
            MsgBox("Tolong Masukkan Text Anda")
            Exit Sub
        End If
        If Val(JB_46109040.Text) = 0 Then
            MsgBox("Tolong Masukkan Text Anda")
            Exit Sub
        End If

        If KB.Text <> KB_46109040.Text Then
            Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
            PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", KB_46109040.Text, 1, jembatan)
            If PENCARI.JumlanBaris > 0 Then
                MsgBox("Data yang Anda masukkan sudah ada,tolong masukkan data baru")
                KB_46109040.Text = ""
                NB_46109040.Text = ""
                HJ_46109040.Text = ""
                JB_46109040.Text = ""
                Exit Sub
            End If
        End If

        Dim Perintah As New OleDb.OleDbCommand
        Perintah = New OleDb.OleDbCommand("update BARANG set KODEBARANG ='" & KB_46109040.Text & "', NAMABARANG = '" & NB_46109040.Text & "', HARGAJUAL=" & Val(HJ_46109040.Text) & ", JUMLAHBARANG=" & Val(JB_46109040.Text) & " where KODEBARANG='" & KB.Text & "'", jembatan)
        jembatan.Open()
        Perintah.ExecuteNonQuery()
        jembatan.Close()
        Perintah.Dispose()

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

        Latihan031A_46109040.ambildata()
        Me.Close()
    End Sub
End Class




Tidak ada komentar:

Posting Komentar