Rabu, 14 Desember 2011

Script Visual Basic Apkomp 4 PNUP - FORM30 A & FORM30 B -

Public Class Form30A_36109006
    Dim rr As New DataTable
    Dim muhharun As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

    Public Sub harun36109006()
        Dim hrn36109006 As New OleDb.OleDbDataAdapter
        hrn36109006 = New OleDb.OleDbDataAdapter("select * from barang", muhharun)
        rr.Rows.Clear()
        hrn36109006.Fill(rr)
        hrn36109006.Dispose()
    End Sub

    Private Sub Form30A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        harun36109006()
        DGV_36109006.DataSource = rr
    End Sub

    Private Sub edit_36109006_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109006.Click
        If Form30B_36109006.Visible = False Then
            Form30B_36109006.Show()
        Else
            Form30B_36109006.Activate()
        End If

        Form30B_36109006.kb1_001_36109006.Text = DGV_36109006.CurrentRow.Cells("kodebarang").Value
        Form30B_36109006.kb_001_36109006.Text = DGV_36109006.CurrentRow.Cells("kodebarang").Value
        Form30B_36109006.nb_001_36109006.Text = DGV_36109006.CurrentRow.Cells("namabarang").Value
        Form30B_36109006.hj_001_36109006.Text = DGV_36109006.CurrentRow.Cells("hargajual").Value
        Form30B_36109006.jb_001_36109006.Text = DGV_36109006.CurrentRow.Cells("jumlahbarang").Value

        Form30B_36109006.Show()
    End Sub
End Class









Public Class Form30B_36109006
    Dim harun36109006 As New ByIskandar.CariKeDataBaseByIskandar
    Dim cm As New OleDb.OleDbCommand
    Dim muhharun As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")

    Private Sub simpan_36109006_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109006.Click
        If kb_001_36109006.Text.Length = 0 Then
            MsgBox("Isi yang kosong")
            Exit Sub
        End If

        If nb_001_36109006.Text.Length = 0 Then
            MsgBox("Isi yang kosong")
            Exit Sub
        End If

        If Val(hj_001_36109006.Text) = 0 Then
            MsgBox("Isi yang kosong")
            Exit Sub
        End If

        If Val(jb_001_36109006.Text) = 0 Then
            MsgBox("Isi yang kosong")
            Exit Sub
        End If

        If kb1_001_36109006.Text <> kb_001_36109006.Text Then
            harun36109006.AturPencarianDataBase("Barang", "KodeBarang", kb_001_36109006.Text, 1, muhharun)
            If harun36109006.JumlanBaris > 0 Then
                MsgBox("Adami kode barang seperti itu")
                Exit Sub
            End If
        End If

        cm = New OleDb.OleDbCommand("update barang set kodebarang = '" & kb_001_36109006.Text & "', namabarang = '" & nb_001_36109006.Text & "', hargajual = " & Val(hj_001_36109006.Text) & ", jumlahbarang = " & Val(jb_001_36109006.Text) & " where kodebarang = '" & kb1_001_36109006.Text & "'", muhharun)

        muhharun.Open()
        cm.ExecuteNonQuery()
        muhharun.Close()
        cm.Dispose()

        kb1_001_36109006.Text = ""
        kb_001_36109006.Text = ""
        nb_001_36109006.Text = ""
        hj_001_36109006.Text = ""
        jb_001_36109006.Text = ""

        Form30A_36109006.harun36109006()
    End Sub

End Class

0 komentar:

Posting Komentar

Diberdayakan oleh Blogger.

BTricks