Public Class LATIHAN_040B_36109075
Dim BALON As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;datasource=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim CIKY As New DataTable
Public Sub PUTRY()
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG,BARANG.NAMABARANG,DETAILTRANSAKSI.UNIT,DETAILTRANSAKSI.HARGA,DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI,HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & nt075.Text & "'", BALON)
CIKY.Rows.Clear()
Z.Fill(CIKY)
End Sub
Private Sub LATIHAN_040B_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CIKY.Columns("NOTRANS")
CIKY.PrimaryKey = dataPrimary
DGV075.DataSource = CIKY
TOTALJUMLAH()
End Sub
Public Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In CIKY.Rows
TOT = TOT + x("JUMLAH")
Next
tot075.Text = TOT
End Sub
Private Sub DGV075_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV075.CellEndEdit
If DGV075.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
'Cari nama barang'
DGV075.CurrentRow.Cells("NAMABARANG").Value = ""
DGV075.CurrentRow.Cells("UNIT").Value = 0
DGV075.CurrentRow.Cells("HARGA").Value = 0
DGV075.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DGV075.CurrentRow.Cells("KODEBARANG").Value, 1, BALON)
'Menampilkan nama barang jika isi kolom kodebarang ditemukan oleh proses diatas'
If Pencari.JumlanBaris > 0 Then
DGV075.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV075.CurrentRow.Cells("KODEBARANG").Value = ""
If LATIHAN_383940_075.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV075.CurrentRow.Cells("KODEBARANG").Value = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("KODEBARANG").Value
DGV075.CurrentRow.Cells("NAMABARANG").Value = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DGV075.Columns(e.ColumnIndex).Name = "UNIT" Or DGV075.Columns(e.ColumnIndex).Name = "HARGA" Then
'Hitung kolom jumlah'
DGV075.CurrentRow.Cells("JUMLAH").Value = DGV075.CurrentRow.Cells("JUMLAH").Value = DGV075.CurrentRow.Cells("UNIT").Value * DGV075.CurrentRow.Cells("HARGA").Value
End If
TOTALJUMLAH()
End Sub
Private Sub simpan_tambah()
If nt075.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt075.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
Exit Sub
End If
If CIKY.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
Exit Sub
End If
If NO_075.Text <> nt075.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt075.Text, 1, BALON)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt075.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & jt075.Text & "')", BALON)
'Membuka koneksi'
BALON.Open()
'Eksekusi prose penyimpanan'
CM.ExecuteNonQuery()
'Menutup koneksi'
BALON.Close()
'Memeriksa isi jumlah baris dalam object tabel'
For Each X As DataRow In CIKY.Rows
'Mengatur perintah simpan'
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt075.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", BALON)
BALON.Open()
CM.ExecuteNonQuery()
BALON.Close()
CM.Dispose()
Next
NO_075.Text = "-"
nt075.Text = ""
jt075.Text = ""
CIKY.Rows.Clear()
TOTALJUMLAH()
'Prosedur mengambil data dari LATIHAN_040A_36109075'
LATIHAN_040A_36109075.ina()
End Sub
Private Sub simpan_edit()
If nt075.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt075.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
Exit Sub
End If
If CIKY.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
Exit Sub
End If
If NO_075.Text <> nt075.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt075.Text, 1, BALON)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & nt075.Text & "'", BALON)
BALON.Open()
CM.ExecuteNonQuery()
BALON.Close()
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt075.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & jt075.Text & "')", BALON)
BALON.Open()
CM.ExecuteNonQuery()
BALON.Close()
CM = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & nt075.Text & "'", BALON)
BALON.Open()
CM.ExecuteNonQuery()
BALON.Close()
'Memeriksa isi jumlah baris dalam object tabel'
For Each XX As DataRow In CIKY.Rows
'Mengatur perintah simpan'
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt075.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", BALON)
BALON.Open()
CM.ExecuteNonQuery()
BALON.Close()
CM.Dispose()
Next
NO_075.Text = "-"
nt075.Text = ""
jt075.Text = ""
CIKY.Rows.Clear()
TOTALJUMLAH()
LATIHAN_040A_36109075.ina()
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
If NO_075.Text = "-" Then
simpan_tambah()
Else
simpan_edit()
End If
End Sub
End Class
Jumat, 02 Desember 2011
LATIHAN 40A
Public Class LATIHAN_040A_36109075
Dim IAN As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim dt As New DataTable
Dim dt1 As New DataTable
Dim dset As New DataSet 'Deklarasi dataset'
Dim Bsource1 As New BindingSource 'Deklarasi bindingsource'
Dim Bsource2 As New BindingSource
Private Sub ina()
'Membersihkan detailtransaksi lalu mastertransaksi'
dt1.Rows.Clear()
dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter
B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", IAN)
B1.Fill(dt)
B1 = New OleDb.OleDbDataAdapter("Select DETAILTRANSAKSI.NOTRANS, DETAILTRANSAKSI.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG", IAN)
B1.Fill(dt1)
B1.Dispose()
End Sub
Private Sub LATIHAN_040A_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ina()
'Memasukkan datatabel dalam dataset'
dset.Tables.Add(dt)
dset.Tables.Add(dt1)
'Mengganti nama datatabel dalam dataset'
dt.TableName = "T01"
dt1.TableName = "T02"
'Menambahkan relasi dalam dataset'
dset.Relations.Add(New DataRelation("X", dset.Tables("T01").Columns("NOTRANS"), dset.Tables("T02").Columns("NOTRANS")))
'Datasource dan membersource'
Bsource1.DataSource = dset
Bsource1.DataMember = "T01"
Bsource2.DataSource = Bsource1
Bsource2.DataMember = "X"
'Memasukkan datatabel dari bindingsource ke dalam DVG'
DGV1_075.DataSource = Bsource1
DGV2_075.DataSource = Bsource2
End Sub
Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DGV1_075.CurrentRow.Cells("NOTRANS").Value & "'", IAN)
IAN.Open()
CM.ExecuteNonQuery()
IAN.Close()
CM = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DGV2_075.CurrentRow.Cells("NOTRANS").Value & "'", IAN)
IAN.Open()
CM.ExecuteNonQuery()
IAN.Close()
CM.Dispose()
ina()
End Sub
Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit.Click
If LATIHAN_040B_36109075.Visible = False Then
LATIHAN_040B_36109075.Show()
Else
LATIHAN_040B_36109075.Activate()
End If
LATIHAN_040B_36109075.NO_075.Text = DGV1_075.CurrentRow.Cells("NOTRANS").Value
LATIHAN_040B_36109075.nt075.Text = DGV1_075.CurrentRow.Cells("NOTRANS").Value
LATIHAN_040B_36109075.jt075.Text = DGV1_075.CurrentRow.Cells("JENISTRANSAKSI").Value
LATIHAN_040B_36109075.PUTRY()
LATIHAN_040B_36109075.TOTALJUMLAH()
End Sub
Private Sub tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
If LATIHAN_040B_36109075.Visible = False Then
LATIHAN_040B_36109075.Show()
Else
LATIHAN_040B_36109075.Activate()
End If
LATIHAN_040B_36109075.NO_075.Text = "-"
LATIHAN_040B_36109075.nt075.Text = ""
LATIHAN_040B_36109075.jt075.Text = ""
LATIHAN_040B_36109075.PUTRY()
LATIHAN_040B_36109075.TOTALJUMLAH()
End Sub
End Class
Dim IAN As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim dt As New DataTable
Dim dt1 As New DataTable
Dim dset As New DataSet 'Deklarasi dataset'
Dim Bsource1 As New BindingSource 'Deklarasi bindingsource'
Dim Bsource2 As New BindingSource
Private Sub ina()
'Membersihkan detailtransaksi lalu mastertransaksi'
dt1.Rows.Clear()
dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter
B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", IAN)
B1.Fill(dt)
B1 = New OleDb.OleDbDataAdapter("Select DETAILTRANSAKSI.NOTRANS, DETAILTRANSAKSI.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG", IAN)
B1.Fill(dt1)
B1.Dispose()
End Sub
Private Sub LATIHAN_040A_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ina()
'Memasukkan datatabel dalam dataset'
dset.Tables.Add(dt)
dset.Tables.Add(dt1)
'Mengganti nama datatabel dalam dataset'
dt.TableName = "T01"
dt1.TableName = "T02"
'Menambahkan relasi dalam dataset'
dset.Relations.Add(New DataRelation("X", dset.Tables("T01").Columns("NOTRANS"), dset.Tables("T02").Columns("NOTRANS")))
'Datasource dan membersource'
Bsource1.DataSource = dset
Bsource1.DataMember = "T01"
Bsource2.DataSource = Bsource1
Bsource2.DataMember = "X"
'Memasukkan datatabel dari bindingsource ke dalam DVG'
DGV1_075.DataSource = Bsource1
DGV2_075.DataSource = Bsource2
End Sub
Private Sub hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus.Click
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DGV1_075.CurrentRow.Cells("NOTRANS").Value & "'", IAN)
IAN.Open()
CM.ExecuteNonQuery()
IAN.Close()
CM = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DGV2_075.CurrentRow.Cells("NOTRANS").Value & "'", IAN)
IAN.Open()
CM.ExecuteNonQuery()
IAN.Close()
CM.Dispose()
ina()
End Sub
Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit.Click
If LATIHAN_040B_36109075.Visible = False Then
LATIHAN_040B_36109075.Show()
Else
LATIHAN_040B_36109075.Activate()
End If
LATIHAN_040B_36109075.NO_075.Text = DGV1_075.CurrentRow.Cells("NOTRANS").Value
LATIHAN_040B_36109075.nt075.Text = DGV1_075.CurrentRow.Cells("NOTRANS").Value
LATIHAN_040B_36109075.jt075.Text = DGV1_075.CurrentRow.Cells("JENISTRANSAKSI").Value
LATIHAN_040B_36109075.PUTRY()
LATIHAN_040B_36109075.TOTALJUMLAH()
End Sub
Private Sub tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
If LATIHAN_040B_36109075.Visible = False Then
LATIHAN_040B_36109075.Show()
Else
LATIHAN_040B_36109075.Activate()
End If
LATIHAN_040B_36109075.NO_075.Text = "-"
LATIHAN_040B_36109075.nt075.Text = ""
LATIHAN_040B_36109075.jt075.Text = ""
LATIHAN_040B_36109075.PUTRY()
LATIHAN_040B_36109075.TOTALJUMLAH()
End Sub
End Class
LATIHAN 39
Public Class LATIHAN_039_36109075
Dim ALFATIH As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim LORENZO As DataTable
Private Sub LATIHAN_039_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Q As New OleDb.OleDbDataAdapter
Q = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & nt075.Text & "'", ALFATIH)
Q.Fill(LORENZO)
Q.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = LORENZO.Columns("KODEBARANG")
LORENZO.PrimaryKey = dataPrimary
DGV075.DataSource = LORENZO
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each a As DataRow In LORENZO.Rows
TOT = TOT + a("jumlah")
Next
tot075.Text = TOT
End Sub
Private Sub DGV075_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV075.CellEndEdit
If DGV075.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
'Cari nama barang'
DGV075.CurrentRow.Cells("NAMABARANG").Value = ""
DGV075.CurrentRow.Cells("UNIT").Value = 0
DGV075.CurrentRow.Cells("HARGA").Value = 0
DGV075.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DGV075.CurrentRow.Cells("KODEBARANG").Value, 1, ALFATIH)
'Menampilkan nama barang jika isi kolom kodebarang ditemukan oleh proses diatas'
If Pencari.JumlanBaris > 0 Then
DGV075.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV075.CurrentRow.Cells("KODEBARANG").Value = ""
If LATIHAN_383940_075.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV075.CurrentRow.Cells("KODEBARANG").Value = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("KODEBARANG").Value
DGV075.CurrentRow.Cells("NAMABARANG").Value = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DGV075.Columns(e.ColumnIndex).Name = "UNIT" Or DGV075.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV075.CurrentRow.Cells("JUMLAH").Value = DGV075.CurrentRow.Cells("UNIT").Value * DGV075.CurrentRow.Cells("HARGA").Value
TOTALJUMLAH()
End If
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
If nt075.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If LORENZO.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt075.Text, 1, ALFATIH)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt075.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & jt075.Text & "')", ALFATIH)
ALFATIH.Open()
CM.ExecuteNonQuery()
ALFATIH.Close()
For Each X As DataRow In LORENZO.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt075.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", ALFATIH)
ALFATIH.Open()
CM.ExecuteNonQuery()
ALFATIH.Close()
CM.Dispose()
Next
nt075.Text = ""
jt075.Text = ""
LORENZO.Rows.Clear()
End Sub
End Class
Dim ALFATIH As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim LORENZO As DataTable
Private Sub LATIHAN_039_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Q As New OleDb.OleDbDataAdapter
Q = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & nt075.Text & "'", ALFATIH)
Q.Fill(LORENZO)
Q.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = LORENZO.Columns("KODEBARANG")
LORENZO.PrimaryKey = dataPrimary
DGV075.DataSource = LORENZO
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each a As DataRow In LORENZO.Rows
TOT = TOT + a("jumlah")
Next
tot075.Text = TOT
End Sub
Private Sub DGV075_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV075.CellEndEdit
If DGV075.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
'Cari nama barang'
DGV075.CurrentRow.Cells("NAMABARANG").Value = ""
DGV075.CurrentRow.Cells("UNIT").Value = 0
DGV075.CurrentRow.Cells("HARGA").Value = 0
DGV075.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DGV075.CurrentRow.Cells("KODEBARANG").Value, 1, ALFATIH)
'Menampilkan nama barang jika isi kolom kodebarang ditemukan oleh proses diatas'
If Pencari.JumlanBaris > 0 Then
DGV075.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV075.CurrentRow.Cells("KODEBARANG").Value = ""
If LATIHAN_383940_075.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV075.CurrentRow.Cells("KODEBARANG").Value = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("KODEBARANG").Value
DGV075.CurrentRow.Cells("NAMABARANG").Value = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DGV075.Columns(e.ColumnIndex).Name = "UNIT" Or DGV075.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV075.CurrentRow.Cells("JUMLAH").Value = DGV075.CurrentRow.Cells("UNIT").Value * DGV075.CurrentRow.Cells("HARGA").Value
TOTALJUMLAH()
End If
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
If nt075.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If LORENZO.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt075.Text, 1, ALFATIH)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt075.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & jt075.Text & "')", ALFATIH)
ALFATIH.Open()
CM.ExecuteNonQuery()
ALFATIH.Close()
For Each X As DataRow In LORENZO.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt075.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", ALFATIH)
ALFATIH.Open()
CM.ExecuteNonQuery()
ALFATIH.Close()
CM.Dispose()
Next
nt075.Text = ""
jt075.Text = ""
LORENZO.Rows.Clear()
End Sub
End Class
LATIHAN 38
Public Class LATIHAN_038_36109075
Dim PUPUT As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim na As New DataTable
Dim dtr As DataRow
Private Sub LATIHAN_038_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & nt075.Text & "'", PUPUT)
Z.Fill(na)
Z.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = na.Columns("KODEBARANG")
na.PrimaryKey = dataPrimary
DGV075.DataSource = na
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In na.Rows
TOT = TOT + x("JUMLAH")
Next
tot075.Text = TOT
End Sub
Private Sub kb075_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb075.Leave
If kb075.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb075.Text, 1, PUPUT)
If Pencari.JumlanBaris > 0 Then
kb075.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb075.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
If LATIHAN_383940_075.ShowDialog = Windows.Forms.DialogResult.OK Then
kb075.Text = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("KodeBarang").Value
kb075.Text = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("NamaBarang").Value
Else
kb075.Text = ""
End If
End If
End Sub
Private Sub kb075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb075.TextChanged
nb075.Text = ""
unit075.Text = ""
harga075.Text = ""
End Sub
Private Sub unit075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles unit075.TextChanged
jmlh075.Text = Val(unit075.Text) * Val(harga075.Text)
End Sub
Private Sub tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
'a'
If kb075.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb075.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(unit075.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(harga075.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
dtr = na.Rows.Find(kb075.Text)
If dtr Is Nothing Then
dtr = na.NewRow
dtr("KODEBARANG") = kb075.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
dtr = na.NewRow
dtr("KODEBARANG") = kb075.Text
dtr("NAMABARANG") = nb075.Text
dtr("UNIT") = unit075.Text
dtr("HARGA") = harga075.Text
dtr("JUMLAH") = jmlh075.Text
na.Rows.Add(dtr)
'd'
kb075.Text = ""
nb075.Text = ""
unit075.Text = ""
harga075.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
'a'
If nt075.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If na.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt075.Text, 1, PUPUT)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim XY As New OleDb.OleDbCommand
XY = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt075.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & jt075.Text & "')", PUPUT)
PUPUT.Open()
XY.ExecuteNonQuery()
PUPUT.Close()
'e'
For Each Z As DataRow In na.Rows
XY = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt075.Text & "','" & Z("KODEBARANG") & "'," & Z("UNIT") & ", " & Z("HARGA") & ")", PUPUT)
PUPUT.Open()
XY.ExecuteNonQuery()
PUPUT.Close()
XY.Dispose()
Next
'f'
nt075.Text = ""
jt075.Text = ""
jmlh075.Text = ""
'g'
na.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
Public Class LATIHAN_383940_075
Dim AL As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim dtt As New DataTable
Public Sub PUTRY()
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("select * From BARANG", AL)
dtt.Rows.Clear()
Z.Fill(dtt)
Z.Dispose()
End Sub
Private Sub LATIHAN_383940_075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PUTRY()
DGV38_075.DataSource = dtt
End Sub
End Class
Dim PUPUT As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim na As New DataTable
Dim dtr As DataRow
Private Sub LATIHAN_038_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & nt075.Text & "'", PUPUT)
Z.Fill(na)
Z.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = na.Columns("KODEBARANG")
na.PrimaryKey = dataPrimary
DGV075.DataSource = na
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In na.Rows
TOT = TOT + x("JUMLAH")
Next
tot075.Text = TOT
End Sub
Private Sub kb075_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb075.Leave
If kb075.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb075.Text, 1, PUPUT)
If Pencari.JumlanBaris > 0 Then
kb075.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb075.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
If LATIHAN_383940_075.ShowDialog = Windows.Forms.DialogResult.OK Then
kb075.Text = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("KodeBarang").Value
kb075.Text = LATIHAN_383940_075.DGV38_075.CurrentRow.Cells("NamaBarang").Value
Else
kb075.Text = ""
End If
End If
End Sub
Private Sub kb075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb075.TextChanged
nb075.Text = ""
unit075.Text = ""
harga075.Text = ""
End Sub
Private Sub unit075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles unit075.TextChanged
jmlh075.Text = Val(unit075.Text) * Val(harga075.Text)
End Sub
Private Sub tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
'a'
If kb075.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb075.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(unit075.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(harga075.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
dtr = na.Rows.Find(kb075.Text)
If dtr Is Nothing Then
dtr = na.NewRow
dtr("KODEBARANG") = kb075.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
dtr = na.NewRow
dtr("KODEBARANG") = kb075.Text
dtr("NAMABARANG") = nb075.Text
dtr("UNIT") = unit075.Text
dtr("HARGA") = harga075.Text
dtr("JUMLAH") = jmlh075.Text
na.Rows.Add(dtr)
'd'
kb075.Text = ""
nb075.Text = ""
unit075.Text = ""
harga075.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
'a'
If nt075.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If na.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt075.Text, 1, PUPUT)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim XY As New OleDb.OleDbCommand
XY = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt075.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & jt075.Text & "')", PUPUT)
PUPUT.Open()
XY.ExecuteNonQuery()
PUPUT.Close()
'e'
For Each Z As DataRow In na.Rows
XY = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt075.Text & "','" & Z("KODEBARANG") & "'," & Z("UNIT") & ", " & Z("HARGA") & ")", PUPUT)
PUPUT.Open()
XY.ExecuteNonQuery()
PUPUT.Close()
XY.Dispose()
Next
'f'
nt075.Text = ""
jt075.Text = ""
jmlh075.Text = ""
'g'
na.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
LATIHAN 38,39,40_075
Public Class LATIHAN_383940_075
Dim AL As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim dtt As New DataTable
Public Sub PUTRY()
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("select * From BARANG", AL)
dtt.Rows.Clear()
Z.Fill(dtt)
Z.Dispose()
End Sub
Private Sub LATIHAN_383940_075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PUTRY()
DGV38_075.DataSource = dtt
End Sub
End Class
LATIHAN 37
Public Class LATIHAN_037_36109075
Dim PUTE As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim RY As New DataTable
Dim DW As DataRow
Private Sub LATIHAN_037_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim X As New OleDb.OleDbDataAdapter
X = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & Ntrans.Text & "'", PUTE)
X.Fill(RY)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = RY.Columns("KODEBARANG")
RY.PrimaryKey = dataPrimary
DGV075.DataSource = RY
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In RY.Rows
TOT = TOT + x("JUMLAH")
Next
TOT075.Text = TOT
End Sub
Private Sub KBR075_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KBR075.Leave
If KBR075.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KBR075.Text, 1, PUTE)
If Pencari.JumlanBaris > 0 Then
KBR075.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
KBR075.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub KBR075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KBR075.TextChanged
NBR075.Text = ""
U075.Text = ""
HRG075.Text = ""
End Sub
Private Sub U075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles U075.TextChanged
JMLH075.Text = Val(U075.Text) * Val(HRG075.Text)
End Sub
Private Sub TAMBAH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH.Click
'a'
If KBR075.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If NBR075.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(U075.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(HRG075.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
DW = RY.Rows.Find(KBR075.Text)
If DW Is Nothing Then
DW = RY.NewRow
DW("KODEBARANG") = KBR075.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
DW = RY.NewRow
DW("KODEBARANG") = KBR075.Text
DW("NAMABARANG") = NBR075.Text
DW("UNIT") = U075.Text
DW("HARGA") = HRG075.Text
DW("JUMLAH") = JMLH075.Text
RY.Rows.Add(DW)
'd'
KBR075.Text = ""
NBR075.Text = ""
U075.Text = ""
HRG075.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub SIMPAN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN.Click
'a'
If Ntrans.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If RY.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", Ntrans.Text, 1, PUTE)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & Ntrans.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & JT075.Text & "')", PUTE)
PUTE.Open()
CM.ExecuteNonQuery()
PUTE.Close()
'e'
For Each X As DataRow In RY.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & Ntrans.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", PUTE)
PUTE.Open()
CM.ExecuteNonQuery()
PUTE.Close()
CM.Dispose()
Next
'f'
Ntrans.Text = ""
JT075.Text = ""
JMLH075.Text = ""
'g'
RY.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
Private Sub HRG075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HRG075.TextChanged
JMLH075.Text = Val(U075.Text) * Val(HRG075.Text)
End Sub
End Class
Dim PUTE As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim RY As New DataTable
Dim DW As DataRow
Private Sub LATIHAN_037_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim X As New OleDb.OleDbDataAdapter
X = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & Ntrans.Text & "'", PUTE)
X.Fill(RY)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = RY.Columns("KODEBARANG")
RY.PrimaryKey = dataPrimary
DGV075.DataSource = RY
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In RY.Rows
TOT = TOT + x("JUMLAH")
Next
TOT075.Text = TOT
End Sub
Private Sub KBR075_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KBR075.Leave
If KBR075.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KBR075.Text, 1, PUTE)
If Pencari.JumlanBaris > 0 Then
KBR075.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
KBR075.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub KBR075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KBR075.TextChanged
NBR075.Text = ""
U075.Text = ""
HRG075.Text = ""
End Sub
Private Sub U075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles U075.TextChanged
JMLH075.Text = Val(U075.Text) * Val(HRG075.Text)
End Sub
Private Sub TAMBAH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH.Click
'a'
If KBR075.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If NBR075.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(U075.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(HRG075.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
DW = RY.Rows.Find(KBR075.Text)
If DW Is Nothing Then
DW = RY.NewRow
DW("KODEBARANG") = KBR075.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
DW = RY.NewRow
DW("KODEBARANG") = KBR075.Text
DW("NAMABARANG") = NBR075.Text
DW("UNIT") = U075.Text
DW("HARGA") = HRG075.Text
DW("JUMLAH") = JMLH075.Text
RY.Rows.Add(DW)
'd'
KBR075.Text = ""
NBR075.Text = ""
U075.Text = ""
HRG075.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub SIMPAN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN.Click
'a'
If Ntrans.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If RY.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", Ntrans.Text, 1, PUTE)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & Ntrans.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & JT075.Text & "')", PUTE)
PUTE.Open()
CM.ExecuteNonQuery()
PUTE.Close()
'e'
For Each X As DataRow In RY.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & Ntrans.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", PUTE)
PUTE.Open()
CM.ExecuteNonQuery()
PUTE.Close()
CM.Dispose()
Next
'f'
Ntrans.Text = ""
JT075.Text = ""
JMLH075.Text = ""
'g'
RY.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
Private Sub HRG075_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HRG075.TextChanged
JMLH075.Text = Val(U075.Text) * Val(HRG075.Text)
End Sub
End Class
LATIHAN 36
Public Class LATIHAN_036_361_09_075
Dim PUTRY As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim tb As New DataTable
Dim tr As DataRow
Private Sub LATIHAN_036_361_09_075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select KODEBARANG, UNIT, HARGA from DETAILTRANSAKSI WHERE NOTRANS= '" & NT075.Text & "'", PUTRY)
Z.Fill(tb)
Z.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = tb.Columns("KODEBARANG")
tb.PrimaryKey = dataPrimary
DGV075.DataSource = tb
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
'a'
If KB075.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If Val(U075.Text) = 0 Then
MsgBox("Masukkan Harga barang")
Exit Sub
End If
If Val(HRG075.Text) = 0 Then
MsgBox("Masukkan jumlah barang")
Exit Sub
End If
'b'
tr = tb.Rows.Find(KB075.Text)
If tr Is Nothing Then
tr = tb.NewRow
tr("KODEBARANG") = KB075.Text
Else
MsgBox("Maaf kode barang sudah ada")
Exit Sub
End If
'c'
tr = tb.NewRow
tr("KODEBARANG") = KB075.Text
tr("UNIT") = U075.Text
tr("HARGA") = HRG075.Text
tb.Rows.Add(tr)
'd'
KB075.Text = ""
U075.Text = ""
HRG075.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
'a'
If NT075.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If tb.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT075.Text, 1, PUTRY)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim WH As New OleDb.OleDbCommand
WH = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT075.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & JT075.Text & "')", PUTRY)
PUTRY.Open()
WH.ExecuteNonQuery()
PUTRY.Close()
'e'
For Each Z As DataRow In tb.Rows
WH = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT075.Text & "','" & Z("KODEBARANG") & "', " & Z("UNIT") & ", " & Z("HARGA") & ")", PUTRY)
PUTRY.Open()
WH.ExecuteNonQuery()
PUTRY.Close()
WH.Dispose()
Next
'f'
NT075.Text = ""
JT075.Text = ""
'g'
tb.Rows.Clear()
End Sub
End Class
Dim PUTRY As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim tb As New DataTable
Dim tr As DataRow
Private Sub LATIHAN_036_361_09_075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select KODEBARANG, UNIT, HARGA from DETAILTRANSAKSI WHERE NOTRANS= '" & NT075.Text & "'", PUTRY)
Z.Fill(tb)
Z.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = tb.Columns("KODEBARANG")
tb.PrimaryKey = dataPrimary
DGV075.DataSource = tb
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah.Click
'a'
If KB075.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If Val(U075.Text) = 0 Then
MsgBox("Masukkan Harga barang")
Exit Sub
End If
If Val(HRG075.Text) = 0 Then
MsgBox("Masukkan jumlah barang")
Exit Sub
End If
'b'
tr = tb.Rows.Find(KB075.Text)
If tr Is Nothing Then
tr = tb.NewRow
tr("KODEBARANG") = KB075.Text
Else
MsgBox("Maaf kode barang sudah ada")
Exit Sub
End If
'c'
tr = tb.NewRow
tr("KODEBARANG") = KB075.Text
tr("UNIT") = U075.Text
tr("HARGA") = HRG075.Text
tb.Rows.Add(tr)
'd'
KB075.Text = ""
U075.Text = ""
HRG075.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
'a'
If NT075.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If tb.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT075.Text, 1, PUTRY)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim WH As New OleDb.OleDbCommand
WH = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT075.Text & "', #" & DTP075.Value.Month & "/" & DTP075.Value.Day & "/" & DTP075.Value.Year & "#, '" & JT075.Text & "')", PUTRY)
PUTRY.Open()
WH.ExecuteNonQuery()
PUTRY.Close()
'e'
For Each Z As DataRow In tb.Rows
WH = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT075.Text & "','" & Z("KODEBARANG") & "', " & Z("UNIT") & ", " & Z("HARGA") & ")", PUTRY)
PUTRY.Open()
WH.ExecuteNonQuery()
PUTRY.Close()
WH.Dispose()
Next
'f'
NT075.Text = ""
JT075.Text = ""
'g'
tb.Rows.Clear()
End Sub
End Class
LATIHAN 35
Public Class LATIHAN_035_36109075
Dim AL As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim KUCING As DataTable
Private Sub LATIHAN_035_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select KODEBARANG, UNIT, HARGA from DETAILTRANSAKSI WHERE NOTRANS= '" & NT075.Text & "'", AL)
Z.Fill(KUCING)
Z.Dispose()
DGV075.DataSource = KUCING
End Sub
Private Sub TAMBAH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH.Click
'a'
If KB075.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If Val(U075.Text) = 0 Then
MsgBox("Masukkan Harga barang")
Exit Sub
End If
If Val(HRG075.Text) = 0 Then
MsgBox("Masukkan jumlah barang")
Exit Sub
End If
'b'
Dim tr As DataRow
tr = KUCING.NewRow
tr("KODEBARANG") = KB075.Text
tr("UNIT") = U075.Text
tr("HARGA") = HRG075.Text
KUCING.Rows.Add(tr)
'c'
KB075.Text = ""
U075.Text = ""
HRG075.Text = ""
End Sub
Private Sub SIMPAN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN.Click
'a'
If NT075.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If KUCING.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT075.Text, 1, AL)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim AB As New OleDb.OleDbCommand
AB = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT075.Text & "', #" & TGL075.Value.Month & "/" & TGL075.Value.Day & "/" & TGL075.Value.Year & "#, '" & JT075.Text & "')", AL)
AL.Open()
AB.ExecuteNonQuery()
AL.Close()
'e'
For Each Z As DataRow In KUCING.Rows
AB = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT075.Text & "','" & Z("KODEBARANG") & "', " & Z("UNIT") & ", " & Z("HARGA") & ")", AL)
AL.Open()
AB.ExecuteNonQuery()
AL.Close()
AB.Dispose()
Next
'f'
NT075.Text = ""
JT075.Text = ""
'g'
KUCING.Rows.Clear()
End Sub
End Class
Dim AL As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb")
Dim KUCING As DataTable
Private Sub LATIHAN_035_36109075_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select KODEBARANG, UNIT, HARGA from DETAILTRANSAKSI WHERE NOTRANS= '" & NT075.Text & "'", AL)
Z.Fill(KUCING)
Z.Dispose()
DGV075.DataSource = KUCING
End Sub
Private Sub TAMBAH_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH.Click
'a'
If KB075.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If Val(U075.Text) = 0 Then
MsgBox("Masukkan Harga barang")
Exit Sub
End If
If Val(HRG075.Text) = 0 Then
MsgBox("Masukkan jumlah barang")
Exit Sub
End If
'b'
Dim tr As DataRow
tr = KUCING.NewRow
tr("KODEBARANG") = KB075.Text
tr("UNIT") = U075.Text
tr("HARGA") = HRG075.Text
KUCING.Rows.Add(tr)
'c'
KB075.Text = ""
U075.Text = ""
HRG075.Text = ""
End Sub
Private Sub SIMPAN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN.Click
'a'
If NT075.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT075.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If KUCING.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT075.Text, 1, AL)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim AB As New OleDb.OleDbCommand
AB = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT075.Text & "', #" & TGL075.Value.Month & "/" & TGL075.Value.Day & "/" & TGL075.Value.Year & "#, '" & JT075.Text & "')", AL)
AL.Open()
AB.ExecuteNonQuery()
AL.Close()
'e'
For Each Z As DataRow In KUCING.Rows
AB = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT075.Text & "','" & Z("KODEBARANG") & "', " & Z("UNIT") & ", " & Z("HARGA") & ")", AL)
AL.Open()
AB.ExecuteNonQuery()
AL.Close()
AB.Dispose()
Next
'f'
NT075.Text = ""
JT075.Text = ""
'g'
KUCING.Rows.Clear()
End Sub
End Class
Langganan:
Postingan (Atom)