Public Class Form31A_36109023
    Dim ts As New DataTable
    Dim cc As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
    Public Sub amelia()
        Dim kl As New OleDb.OleDbDataAdapter
        kl = New OleDb.OleDbDataAdapter("select * from barang", cc)
        ts.Rows.Clear()
        kl.Fill(ts)
        kl.Dispose()
    End Sub
    Private Sub Form31A_36109023_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        amelia()
        dgv36109023.DataSource = ts
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Form31B_36109023.Visible = False Then
            Form31B_36109023.Show()
        Else
            Form31B_36109023.Activate()
        End If
        Form31B_36109023.KB_36109023.Text = dgv36109023.CurrentRow.Cells("kodebarang").Value
        Form31B_36109023.t1_36109023.Text = dgv36109023.CurrentRow.Cells("kodebarang").Value
        Form31B_36109023.t2_36109023.Text = dgv36109023.CurrentRow.Cells("namabarang").Value
        Form31B_36109023.t3_36109023.Text = dgv36109023.CurrentRow.Cells("hargajual").Value
        Form31B_36109023.t4_36109023.Text = dgv36109023.CurrentRow.Cells("jumlahbarang").Value
        Form31B_36109023.Show()
    End Sub
End Class
Public Class Form31B_36109023
    Dim amelia As New ByIskandar.CariKeDataBaseByIskandar
    Dim ame As New OleDb.OleDbCommand
    Dim rr As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Databarang.ACCDB")
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If t1_36109023.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If
        If t2_36109023.Text.Length = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If
        If Val(t3_36109023.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If
        If Val(t4_36109023.Text) = 0 Then
            MsgBox("Isi rong itu yang kosong")
            Exit Sub
        End If
        If t1_36109023.Text <> KB_36109023.Text Then
            amelia.AturPencarianDataBase("Barang", "KodeBarang", t1_36109023.Text, 1, rr)
            If amelia.JumlanBaris > 0 Then
                MsgBox("Adami kode barang seperti itu")
                Exit Sub
            End If
        End If
        ame = New OleDb.OleDbCommand("update barang set kodebarang = '" & t1_36109023.Text & "', namabarang = '" & t2_36109023.Text & "', hargajual = " & Val(t3_36109023.Text) & ", jumlahbarang = " & Val(t4_36109023.Text) & " where kodebarang = '" & t4_36109023.Text & "'", rr)
        rr.Open()
        ame.ExecuteNonQuery()
        rr.Close()
        ame.Dispose()
        t1_36109023.Text = ""
        t2_36109023.Text = ""
        t3_36109023.Text = ""
        t4_36109023.Text = ""
        KB_36109023.Text = "-"
        Form31A_36109023.amelia()
    End Sub
End Class


0 komentar:
Posting Komentar