Public Class Latihan32A_46109060
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=060")
Dim fadli As New DataTable
Private Sub Latihan32A_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Adapter As New OleDb.OleDbDataAdapter
Adapter = New OleDb.OleDbDataAdapter("select* from barang", conect)
Adapter.Fill(fadli)
dgv46109060.DataSource = fadli
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan32C_46109060.Visible = False Then
Latihan32C_46109060.Show()
Else
Latihan32C_46109060.Activate()
End If
Latihan32C_46109060.ToolStripStatusLabel1.Text = "kode barang lama= " & dgv46109060.CurrentRow.Cells("kodebarang").Value
Latihan32C_46109060.tb146109060.Text = dgv46109060.CurrentRow.Cells("kodebarang").Value
Latihan32C_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("namabarang").Value
Latihan32C_46109060.tb346109060.Text = dgv46109060.CurrentRow.Cells("hargajual").Value
Latihan32C_46109060.tb446109060.Text = dgv46109060.CurrentRow.Cells("jumlahbarang").Value
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Latihan32B_46109060.Visible = False Then
Latihan32B_46109060.Show()
Else
Latihan32B_46109060.Activate()
End If
End Sub
End Class
Public Class Latihan32B_46109060
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=060")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Val(tb146109060.Text) = 0 Then
MsgBox("Kode Barang Belum Terisi Pak")
Exit Sub
End If
If tb246109060.Text.Length = 0 Then
MsgBox("Nama Barang Belum Terisi Pak")
Exit Sub
End If
If Val(tb346109060.Text) = 0 Then
MsgBox("Harga Jual Belum Terisi Pak")
Exit Sub
End If
If Val(tb446109060.Text) = 0 Then
MsgBox("Jumlah Barang Belum Terisi Pak")
Exit Sub
End If
Dim fadli As New OleDb.OleDbCommand
fadli = New OleDb.OleDbCommand("TambahBarang", conect)
fadli.CommandType = CommandType.StoredProcedure
fadli.Parameters.Add(New OleDb.OleDbParameter("KodeBarang", tb146109060.Text))
fadli.Parameters.Add(New OleDb.OleDbParameter("NamaBarang", tb246109060.Text))
fadli.Parameters.Add(New OleDb.OleDbParameter("Persawal", Val(tb346109060.Text)))
fadli.Parameters.Add(New OleDb.OleDbParameter("Hargajual", Val(tb446109060.Text)))
conect.Open()
fadli.ExecuteNonQuery()
conect.Close()
fadli.Dispose()
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
End Sub
Private Sub Latihan32B_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Public Class Latihan32C_46109060
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\databarang.accdb;jet OLEDB:database password=060")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Val(tb146109060.Text) = 0 Then
MsgBox("Kode Barang Belum Terisi Pak")
Exit Sub
End If
If tb246109060.Text.Length = 0 Then
MsgBox("Nama Barang Belum Terisi Pak")
Exit Sub
End If
If Val(tb346109060.Text) = 0 Then
MsgBox("Harga Jual Belum Terisi Pak")
Exit Sub
End If
If Val(tb446109060.Text) = 0 Then
MsgBox("Jumlah Barang Belum Terisi Pak")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("UPDATE BARANG SET kodebarang = '" & tb146109060.Text & "', namabarang = '" & tb246109060.Text & "', hargajual = " & Val(tb346109060.Text) & ", jumlahbarang = " & Val(tb446109060.Text) & " where kodebarang ='" & ToolStripStatusLabel1.Text & "'", conect)
conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
End Sub
Private Sub Latihan32C_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Tidak ada komentar:
Posting Komentar