Deskripsi
1. Objek textbox
terdapat 4 objek textbox pada form ini. textbox tersebut berfungsi untuk menginput data baru dari data yang di
edit.
2. objek button
terdapat 2 objek button form ini. berfungsi mengeksekusi input pada textbox dan menyimpan data ke access
3. objek datagridview
menampilkan hasil inputan pada textbox
4. objek datetimepicker
terdapat satu objek ini pada form kali ini
even : ButtonClick
Pembuatan Form
1. buka Microsoft Visual Studio anda
2. bukalah file kumpulan latihan anda
3. pilih menu project lalu klik add windows form
4. drag objek dari toolbox anda. susun hingga menjadi form seperti form pada gambar dibawah ini.
5. masukkan script berikut
Public Class Latihan_35_46110008
Dim Jalan As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Application.StartupPath & "\Datamajemuk.ACCDB")
Dim tabel As New DataTable
Private Sub Latihan_35_46110008_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 kodebarang,unit,harga FROM DETAILTRANSAKSI where notrans='" & notr46110008.Text & "'", Jalan)
tabel.Rows.Clear()
adapter.Fill(tabel)
adapter.Dispose()
dgv46110008.DataSource = tabel
End Sub
Private Sub save46110008_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save46110008.Click
If notr46110008.Text.Length = 0 Then
MsgBox("Please, insert the Number of the transaction")
Exit Sub
End If
If jt46110008.Text.Length = 0 Then
MsgBox("Please, insert the type of the transaction")
Exit Sub
End If
If tabel.Rows.Count = 0 Then
MsgBox("the data is none")
Exit Sub
End If
Dim search As New ByIskandar.CariKeDataBaseByIskandar
search.AturPencarianDataBase("mastertransaksi", "notrans", notr46110008.Text, 1, Jalan)
If search.JumlanBaris > 0 Then
MsgBox("the code has been exist")
Exit Sub
End If
Dim power As New OleDb.OleDbCommand
power = New OleDb.OleDbCommand("insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values ('" & notr46110008.Text & "',#" & tgl46110008.Value.Month & "/" & tgl46110008.Value.Day & "/" & tgl46110008.Value.Year & "#,'" & jt46110008.Text & "')", Jalan)
Jalan.Open()
power.ExecuteNonQuery()
Jalan.Close()
For Each master As DataRow In tabel.Rows
power = New OleDb.OleDbCommand("insert into detailtransaksi (notrans,kodebarang,unit,harga) values ('" & notr46110008.Text & "','" & master("kodebarang") & "'," & master("unit") & "," & master("harga") & ")", Jalan)
Jalan.Open()
power.ExecuteNonQuery()
Jalan.Close()
Next
power.Dispose()
notr46110008.Text = ""
jt46110008.Text = ""
tabel.Rows.Clear()
Me.Close()
End Sub
Private Sub tambah46110008_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah46110008.Click
If kob46110008.Text.Length = 0 Then
MsgBox("Please, insert the code of goods")
Exit Sub
End If
If unit46110008.Text.Length = 0 Then
MsgBox("Please, insert the unit of goods")
Exit Sub
End If
If harg46110008.Text.Length = 0 Then
MsgBox("Please, insert the cost of goods")
Exit Sub
End If
tabel.Rows.Add((kob46110008.Text), Val(unit46110008.Text), Val(harg46110008.Text))
kob46110008.Text = ""
unit46110008.Text = ""
harg46110008.Text = ""
End Sub
End Class
Tidak ada komentar:
Posting Komentar