Jumat, 18 November 2011

Latihan 34

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

Latihan 33


Public Class Latihan33A_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 DataTable
Public Sub ambildata()
Dim data As New OleDb.OleDbDataAdapter
data = New OleDb.OleDbDataAdapter("select * from barang", conect)
cari.Rows.Clear()
data.Fill(cari)
data.Dispose()
End Sub
Private Sub Latihan33A_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ambildata()
dgv46109060.DataSource = cari
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Latihan33B_46109060.Visible = False Then
Latihan33B_46109060.Show()
Else
Latihan33B_46109060.Activate()
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan33B_46109060.Visible = False Then
Latihan33B_46109060.Show()
Else
Latihan33B_46109060.Activate()
End If
Latihan33B_46109060.KB.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan33B_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan33B_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("NAMABARANG").Value
Latihan33B_46109060.tb346109060.Text = dgv46109060.CurrentRow.Cells("HARGAJUAL").Value
Latihan33B_46109060.tb446109060.Text = dgv46109060.CurrentRow.Cells("JUMLAHBARANG").Value
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim fadli As New OleDb.OleDbCommand
fadli = New OleDb.OleDbCommand("DELETE * FROM BARANG WHERE KODEBARANG='" & dgv46109060.CurrentRow.Cells("KODEBARANG").Value & "'", conect)
conect.Open()
fadli.ExecuteNonQuery()
conect.Close()
fadli.Dispose()
ambildata()
End Sub
End Class






Public Class Latihan33B_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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
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", "kodebarang", 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 Latihan33B_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class

Latihan 32


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

Latihan 31


Public Class Latihan31A_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 ambil As New DataTable
Public Sub ambildata()
Dim data As New OleDb.OleDbDataAdapter
data = New OleDb.OleDbDataAdapter("SELECT* FROM barang", conect)
ambil.Rows.Clear()
data.Fill(ambil)
data.Dispose()
End Sub
Private Sub Latihan31A_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ambildata()
dgv46109060.DataSource = ambil
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan31B_46109060.Visible = False Then
Latihan31B_46109060.Show()
Else
Latihan31B_46109060.Activate()
End If
Latihan31B_46109060.KB.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan31B_46109060.tb146109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan31B_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("NAMABARANG").Value
Latihan31B_46109060.tb346109060.Text = dgv46109060.CurrentRow.Cells("HARGAJUAL").Value
Latihan31B_46109060.tb446109060.Text = dgv46109060.CurrentRow.Cells("JUMLAHBARANG").Value
End Sub
End Class






Public Class Latihan31B_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 tb146109060.Text.Length = 0 Then
MsgBox("Please insert your text")
Exit Sub
End If
If tb246109060.Text.Length = 0 Then
MsgBox("Please insert your text")
Exit Sub
End If
If Val(tb346109060.Text) = 0 Then
MsgBox("Please insert your text")
Exit Sub
End If
If Val(tb446109060.Text) = 0 Then
MsgBox("Please insert your text")
Exit Sub
End If
If KB.Text <> tb146109060.Text Then
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", tb146109060.Text, 1, conect)
If PENCARI.JumlanBaris > 0 Then
MsgBox("the data has been exist please insert new data")
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Exit Sub
End If
End If
Dim Fadli As New OleDb.OleDbCommand
Fadli = 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()
Fadli.ExecuteNonQuery()
conect.Close()
Fadli.Dispose()
KB.Text = ""
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Latihan31A_46109060.ambildata()
Me.Close()
End Sub
Private Sub Latihan31B_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class

Latihan 30


Public Class Latihan30A_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 ambil As New DataTable
Public Sub ambildata()
Dim data As New OleDb.OleDbDataAdapter
data = New OleDb.OleDbDataAdapter("SELECT* FROM BARANG", conect)
ambil.Rows.Clear()
data.Fill(ambil)
data.Dispose()
End Sub
Private Sub Latihan30A_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ambildata()
dgv46109060.DataSource = ambil
End Sub
Private Sub Button1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Latihan30B_46109060.Visible = False Then
Latihan30B_46109060.Show()
Else
Latihan30B_46109060.Activate()
End If
Latihan30B_46109060.kb46109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan30B_46109060.tb146109060.Text = dgv46109060.CurrentRow.Cells("KODEBARANG").Value
Latihan30B_46109060.tb246109060.Text = dgv46109060.CurrentRow.Cells("NAMABARANG").Value
Latihan30B_46109060.tb346109060.Text = dgv46109060.CurrentRow.Cells("HARGAJUAL").Value
Latihan30B_46109060.tb446109060.Text = dgv46109060.CurrentRow.Cells("JUMLAHBARANG").Value
End Sub
End Class



Public Class Latihan30B_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 tb146109060.Text.Length = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If tb246109060.Text.Length = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If Val(tb346109060.Text) = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If Val(tb446109060.Text) = 0 Then
MsgBox("please insert your text")
Exit Sub
End If
If kb46109060.Text <> tb146109060.Text Then
Dim PENCARI As New ByIskandar.CariKeDataBaseByIskandar
PENCARI.AturPencarianDataBase("BARANG", "KODEBARANG", tb146109060.Text, 1, Conect)
If PENCARI.JumlanBaris > 0 Then
MsgBox("the data has been exist please insert new data")
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Exit Sub
End If
End If
Dim Fadli As New OleDb.OleDbCommand
Fadli = New OleDb.OleDbCommand("update BARANG set KODEBARANG ='" & tb146109060.Text & "', NAMABARANG = '" & tb246109060.Text & "', HARGAJUAL=" & Val(tb346109060.Text) & ", JUMLAHBARANG=" & Val(tb446109060.Text) & " where KODEBARANG='" & kb46109060.Text & "'", Conect)
Conect.Open()
Fadli.Dispose()
kb46109060.Text = ""
tb146109060.Text = ""
tb246109060.Text = ""
tb346109060.Text = ""
tb446109060.Text = ""
Latihan30A_46109060.ambildata()
Me.Close()
End Sub
Private Sub Latihan30B_46109060_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class