Public Class Latihan34A_46109060
Private Sub DAFTARBARANGToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DAFTARBARANGToolStripMenuItem.Click
If Latihan34B_46109060.Visible = False Then
Latihan34B_46109060.MdiParent = Me.MdiParent
Latihan34B_46109060.Show()
Else
Latihan34B_46109060.Activate()
End If
End Sub
Private Sub INPUTBARANGToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles INPUTBARANGToolStripMenuItem.Click
If Latihan34C_46109060.Visible = False Then
Latihan34C_46109060.MdiParent = Me.MdiParent
Latihan34C_46109060.Show()
Else
Latihan34C_46109060.Activate()
End If
End Sub
Private Sub ToolStripButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
If Latihan34B_46109060.Visible = False Then
Latihan34B_46109060.MdiParent = Me.MdiParent
Latihan34B_46109060.Show()
Else
Latihan34B_46109060.Activate()
End If
End Sub
Private Sub ToolStripButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
If Latihan34C_46109060.Visible = False Then
Latihan34C_46109060.MdiParent = Me.MdiParent
Latihan34C_46109060.Show()
Else
Latihan34C_46109060.Activate()
End If
End Sub
End Class
Public Class Latihan34B_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
Public Sub ambildata()
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("select * from barang", conect)
fadli.Rows.Clear()
adapter.Fill(fadli)
adapter.Dispose()
End Sub
Private Sub Latihan34B_46109060_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
ambildata()
dgv46109060.DataSource = fadli
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
If Latihan34C_46109060.Visible = False Then
Latihan34C_46109060.Show()
Else
Latihan34C_46109060.Activate()
End If
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan34C_46109060.Visible = False Then
Latihan34C_46109060.Show()
Else
Latihan34C_46109060.Activate()
End If
Latihan34C_46109060.KB.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan34C_46109060.tb146109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan34C_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("NAMABARANG").Value
Latihan34C_46109060.tb346109060.Text = dgv46109060.CurrentRow.Cells("HARGAJUAL").Value
Latihan34C_46109060.tb446109060.Text = dgv46109060.CurrentRow.Cells("JUMLAHBARANG").Value()
End Sub
End Class
Public Class Latihan34C_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 cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub TAMBAH()
If tb146109060.Text.Length = 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
cari.AturPencarianDataBase("barang", "kode barang", tb146109060.Text, 1, conect)
If cari.JumlanBaris > 0 Then
MsgBox("Kode Sudah Ada Pak")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into barang(kodebarang,namabarang,hargajual,jumlahbarang) Values('" & tb146109060.Text & "','" & tb246109060.Text & "'," & Val(tb346109060.Text) & "," & Val(tb446109060.Text) & ")", conect)
conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Latihan33A_46109060.ambildata()
End Sub
Private Sub EDIT()
If tb146109060.Text.Length = 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
If KB.Text <> tb146109060.Text Then
cari.AturPencarianDataBase("barang", "kode barang", tb146109060.Text, 1, conect)
If cari.JumlanBaris > 0 Then
MsgBox("Kode Sudah Ada Pak")
Exit Sub
End If
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='" & KB.Text & "'", conect)
conect.Open()
com.ExecuteNonQuery()
conect.Close()
com.Dispose()
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
KB.Text = "-"
Latihan33A_46109060.ambildata()
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If KB.Text = "-" Then
Tambah()
Else
Edit()
End If
End Sub
End Class
Tidak ada komentar:
Posting Komentar