Dim nurmuhitha As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=12345") Dim dt As New DataTable Dim dr As DataRow
Private Sub Latihan3746109047_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= '" & nt46109047.Text & "'", nurmuhitha) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DGV46109047.DataSource = dt End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In dt.Rows TOT = TOT + x("JUMLAH") Next Tot46109047.Text = TOT End Sub
Private Sub kb46109047_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109047.Leave If kb46109047.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109047.Text, 1, nurmuhitha) If Pencari.JumlanBaris > 0 Then kb46109047.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb46109047.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109047.TextChanged nb46109047.Text = "" un46109047.Text = "" hr46109047.Text = "" End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109047.TextChanged, hr46109047.TextChanged jm46109047.Text = Val(un46109047.Text) * Val(hr46109047.Text) End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT246109047.Click
If nt46109047.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt46109047.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109047.Text, 1, nurmuhitha) 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 ('" & nt46109047.Text & "', #" & DTP46109047.Value.Month & "/" & DTP46109047.Value.Day & "/" & DTP46109047.Value.Year & "#, '" & jt46109047.Text & "')", nurmuhitha) nurmuhitha.Open() CM.ExecuteNonQuery() nurmuhitha.Close()
For Each X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109047.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", nurmuhitha) nurmuhitha.Open() CM.ExecuteNonQuery() nurmuhitha.Close() CM.Dispose() Next
Private Sub BT246109047_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT246109047.Click If nt46109047.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt46109047.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109047.Text, 1, nurmuhitha) 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 ('" & nt46109047.Text & "', #" & DTP46109047.Value.Month & "/" & DTP46109047.Value.Day & "/" & DTP46109047.Value.Year & "#, '" & jt46109047.Text & "')", nurmuhitha) nurmuhitha.Open() CM.ExecuteNonQuery() nurmuhitha.Close()
For Each X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109047.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", nurmuhitha) nurmuhitha.Open() CM.ExecuteNonQuery() nurmuhitha.Close() CM.Dispose() Next
Public Class LATIHAN037_46109010 Dim faradillah As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46") Dim rivai As DataRow Dim fara As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub LATIHAN037_46109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rossi As New OleDb.OleDbDataAdapter rossi = 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= '" & nt46109010.Text & "'", faradillah) fara.Rows.Clear() rossi.Fill(fara) dgv46109010.DataSource = fara
rossi.Dispose()
Dim farah(1) As DataColumn farah(0) = fara.Columns("KODEBARANG") fara.PrimaryKey = farah
End Sub Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In fara.Rows
TOT = TOT + x("JUMLAH") Next Tot46109010.Text = TOT
End Sub
Private Sub KB46109010_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109010.Leave
If kb46109010.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109010.Text, 1, faradillah)
If Pencari.JumlanBaris > 0 Then kb46109010.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb46109010.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Private Sub KB46109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109010.TextChanged
nb46109010.Text = "" un46109010.Text = "" hr46109010.Text = "" End Sub
Private Sub UN46109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109010.TextChanged, hr46109010.TextChanged
jm46109010.Text = Val(un46109010.Text) * Val(hr46109010.Text) End Sub
Private Sub button346109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button346109010.Click
If nt46109010.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt46109010.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If fara.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109010.Text, 1, faradillah) 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 ('" & nt46109010.Text & "', #" & dtp46109010.Value.Month & "/" & dtp46109010.Value.Day & "/" & dtp46109010.Value.Year & "#, '" & jt46109010.Text & "')", faradillah) faradillah.Open() CM.ExecuteNonQuery() faradillah.Close()
For Each X As DataRow In fara.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109010.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", faradillah)
faradillah.Open() CM.ExecuteNonQuery() faradillah.Close() CM.Dispose() Next
Public Class Latihan037_46109015 Dim qayyimah As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=015") Dim imah As DataRow Dim qn As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Latihan037_46109015_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim ima As New OleDb.OleDbDataAdapter ima = 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= '" & nt46109015.Text & "'", qayyimah) qn.Rows.Clear() ima.Fill(qn) dgv46109015.DataSource = qn
ima.Dispose()
Dim qnh(1) As DataColumn qnh(0) = qn.Columns("KODEBARANG") qn.PrimaryKey = qnh End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In qn.Rows
TOT = TOT + x("JUMLAH") Next Tot46109015.Text = TOT End Sub
Private Sub kb46109015_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109015.Leave If kb46109015.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109015.Text, 1, qayyimah)
If Pencari.JumlanBaris > 0 Then kb46109015.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb46109015.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Private Sub kb46109015_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109015.TextChanged
nb46109015.Text = "" un46109015.Text = "" hr46109015.Text = "" End Sub
Private Sub un46109015_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109015.TextChanged, hr46109015.TextChanged
jm46109015.Text = Val(un46109015.Text) * Val(hr46109015.Text) End Sub
Private Sub T46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T46109015.Click If kb46109015.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nb46109015.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(un46109015.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(hr46109015.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
imah = qn.Rows.Find(kb46109015.Text)
If imah Is Nothing Then imah = qn.NewRow imah("KODEBARANG") = kb46109015.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Lanjutan....... Private Sub S46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S46109015.Click If nt46109015.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt46109015.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If qn.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109015.Text, 1, qayyimah) 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 ('" & nt46109015.Text & "', #" & TGL46109015.Value.Month & "/" & TGL46109015.Value.Day & "/" & TGL46109015.Value.Year & "#, '" & jt46109015.Text & "')", qayyimah) qayyimah.Open() CM.ExecuteNonQuery() qayyimah.Close()
For Each X As DataRow In qn.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109015.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", qayyimah) qayyimah.Open() CM.ExecuteNonQuery() qayyimah.Close() CM.Dispose() Next
Public Class TUGAS37 Dim SRY As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;Jet OLEDB:Database Password=11") Dim REJEKI As New DataTable Dim CARI As New ByIskandar.CariKeDataBaseByIskandar
Private Sub TUGAS37_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*harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans ='" & T146109006.Text & "'", SRY) Q.Fill(REJEKI) Q.Dispose()
DGV46109006.DataSource = REJEKI
Dim KIKI(1) As DataColumn KIKI(0) = REJEKI.Columns("KODEBARANG") REJEKI.PrimaryKey = KIKI End Sub
Private Sub KIKIE() Dim KIKIE1 As Integer = 0 For Each KIKIE2 As DataRow In REJEKI.Rows KIKIE1 += KIKIE2("JUMLAH") Next TOT.Text = KIKIE1 End Sub
Private Sub HR_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HR.TextChanged JM.Text = Val(HR.Text) * Val(UN.Text) End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB.Leave If KB.Text.Length = 0 Then Exit Sub End If CARI.AturPencarianDataBase("barang", "kodebarang", KB.Text, 1, SRY) If CARI.JumlanBaris > 0 Then KB.Text = CARI.DataTablenya.Rows(0).Item("KODEBARANG") NB.Text = CARI.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang itu tidak ada..") Exit Sub End If End Sub
Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB.TextChanged NB.Text = "" UN.Text = "" HR.Text = "" End Sub
Private Sub TOMBOL1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL1.Click If KB.Text.Length = 0 Then MsgBox("Kode Barang belum terisi") Exit Sub End If
If Val(UN.Text) = 0 Then MsgBox("UNIT belum terisi") Exit Sub End If
If Val(HR.Text) = 0 Then MsgBox("HARGA belum terisi") Exit Sub End If
Dim KI2 As DataRow KI2 = REJEKI.Rows.Find(KB.Text) If KI2 Is Nothing Then KI2 = REJEKI.NewRow KI2("KODEBARANG") = KB.Text KI2("NAMABARANG") = NB.Text KI2("UNIT") = UN.Text KI2("HARGA") = HR.Text KI2("JUMLAH") = JM.Text
REJEKI.Rows.Add(KI2)
KB.Text = "" UN.Text = "" HR.Text = "" Else MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain...") End If KIKIE() End Sub
Private Sub TOMBOL2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL2.Click If T146109006.Text.Length = 0 Then MsgBox("no.transaksi belum terisi") Exit Sub End If
If T246109006.Text.Length = 0 Then MsgBox("jenis transaksi belum terisi") Exit Sub End If
Dim CONECT AsNew OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= "& Application.StartupPath &"\DATAMAJEMUK.accdb;jet oledb:database Password=KYKY") Dim dt AsNew DataTable Dim dr As DataRow
PrivateSub Latihan37_46109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load Dim X AsNew 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= '"& NT_46109050.Text &"'", CONECT) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DGV_46109050.DataSource = dt EndSub
PrivateSub TOTALJUMLAH() Dim TOT AsDouble = 0 ForEach x As DataRow In dt.Rows TOT = TOT + x("JUMLAH") Next TOT_46109050.Text = TOT EndSub
PrivateSub kb46109047_Leave(ByVal sender AsObject, ByVal e As System.EventArgs) Handles KB_46109050.Leave If KB_46109050.Text.Length = 0 Then ExitSub EndIf
Dim Pencari AsNew ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KB_46109050.Text, 1, CONECT) If Pencari.JumlanBaris > 0 Then KB_46109050.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") NB_46109050.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") ExitSub EndIf EndSub
PrivateSub KB_46109050_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_46109050.TextChanged NB_46109050.Text = "" UNT_46109050.Text = "" HRG_46109050.Text = "" EndSub
PrivateSub UNT_46109050_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UNT_46109050.TextChanged, HRG_46109050.TextChanged JMLH_46109050.Text = Val(UNT_46109050.Text) * Val(HRG_46109050.Text) EndSub
PrivateSub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BUTTON2_46109050.Click
If NT_46109050.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") ExitSub EndIf
If JT_46109050.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") ExitSub EndIf
If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") ExitSub EndIf
Dim pencari AsNew ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT_46109050.Text, 1, CONECT) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") ExitSub EndIf
Dim CM AsNew OleDb.OleDbCommand CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('"& NT_46109050.Text &"', #"& TGL_46109050.Value.Month &"/"& TGL_46109050.Value.Day &"/"& TGL_46109050.Value.Year &"#, '"& JT_46109050.Text &"')", CONECT) CONECT.Open() CM.ExecuteNonQuery() CONECT.Close()
ForEach X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('"& NT_46109050.Text &"','"& X("KODEBARANG") &"',"& X("UNIT") &", "& X("HARGA") &")", CONECT) CONECT.Open() CM.ExecuteNonQuery() CONECT.Close() CM.Dispose() Next
PrivateSub BUTTON2_46109050_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BUTTON2_46109050.Click If NT_46109050.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") ExitSub EndIf
If JT_46109050.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") ExitSub EndIf
If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") ExitSub EndIf
Dim pencari AsNew ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT_46109050.Text, 1, CONECT) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") ExitSub EndIf
Dim CM AsNew OleDb.OleDbCommand CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('"& NT_46109050.Text &"', #"& TGL_46109050.Value.Month &"/"& TGL_46109050.Value.Day &"/"& TGL_46109050.Value.Year &"#, '"& JT_46109050.Text &"')", CONECT) CONECT.Open() CM.ExecuteNonQuery() CONECT.Close()
ForEach X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('"& NT_46109050.Text &"','"& X("KODEBARANG") &"',"& X("UNIT") &", "& X("HARGA") &")", CONECT) CONECT.Open() CM.ExecuteNonQuery() CONECT.Close() CM.Dispose() Next
Dim tabel As New DataTable Dim ayu As New OleDb.OleDbCommand Dim yayu As New ByIskandar.CariKeDataBaseByIskandar Dim YY As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Latihan_37_46109004_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Y As New OleDb.OleDbDataAdapter Y = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, detailtransaksi.UNIT, detailtransaksi.HARGA, detailtransaksi.unit*harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans ='" & notr081.Text & "'", YY) tabel.Rows.Clear() a.Fill(tabel) a.Dispose()
Dim dc(1) As DataColumn dc(0) = tabel.Columns("kodebarang") tabel.PrimaryKey = dc
dgv46109004.DataSource = tabel End Sub
Private Sub yayuan() Dim yayuan1 As Integer = 0 For Each yayuan2 As DataRow In tabel.Rows yayuan1 += yayuan2("JUMLAH") Next tot46109004.Text = yayuan1 End Sub
Private Sub unt46109004_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles unt46109004.TextChanged, hrg46109004.TextChanged jmlh46109004.Text = Val(unt46109004.Text) * Val(hrg46109004.Text) End Sub
Private Sub kodbar46109004_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kodbar46109004.Leave If kodbar46109004.Text.Length = 0 Then Exit Sub End If yayu.AturPencarYYDataBase("barang", "kodebarang", kodbar46109004.Text, 1, YY) If yayu.JumlanBaris > 0 Then kodbar46109004.Text = yayu.DataTablenya.Rows(0).Item("KODEBARANG") nabar46109004.Text = yayu.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Maaf Kodebarang tersebut tidak ada") Exit Sub End If End Sub
Private Sub kodbar46109004_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodbar46109004.TextChanged nabar46109004.Text = "" unt46109004.Text = "" hrg46109004.Text = "" End Sub Private Sub tbmh46109004_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmbh46109004.Click If kodbar46109004.Text.Length = 0 Then MsgBox("Mohon kolom kode Barangnya diisi") Exit Sub End If
If Val(unt46109004.Text) = 0 Then MsgBox("Mohon kolom Unit diisi") Exit Sub End If
If Val(hrg46109004.Text) = 0 Then MsgBox("mohon kolom harga diisi") Exit Sub End If
Dim aa As DataRow aa = tabel.Rows.Find(kodbar46109004.Text) If dr Is Nothing Then aa = tabel.NewRow aa("KODEBARANG") = kodbar46109004.Text aa("NAMABARANG") = nabar46109004.Text aa("UNIT") = Val(unt46109004.Text) aa("HARGA") = Val(hrg46109004.Text) aa("JUMLAH") = Val(jmlh46109004.Text)
Else MsgBox("Kode barang tersebut sudah ada, mohon diganti") End If yayuan() End Sub
Private Sub save46109004_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save46109004.Click If notr46109004.Text.Length = 0 Then MsgBox("Mohon kolom no. tansaksi diisi") Exit Sub End If
If jetr46109004.Text.Length = 0 Then MsgBox("Mohon kolom Jenis Transaksi diisi") Exit Sub End If
If tabel.Rows.Count = 0 Then MsgBox("Mohon datatable diisi") Exit Sub End If
yayu.AturPencarYYDataBase("mastertransaksi", "notrans", notr46109004.Text, 1, YY) If yayu.JumlanBaris > 0 Then MsgBox("Maaf No.Transaksi tersebut sudah ada.") Exit Sub End If
For Each x As DataRow In tabel.Rows ayu = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & notr46109004.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", YY) YY.Open() ayu.ExecuteNonQuery() YY.Close() Next ayu.Dispose()
Dim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=yusri") Dim DT As New DataTable Dim DR As DataRow
Private Sub Latihan37_46109038_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= '" & NoTrans_46109038.Text & "'", conect) X.Fill(DT) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = DT.Columns("KODEBARANG") DT.PrimaryKey = dataPrimary
DGV_46109038.DataSource = DT End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In DT.Rows TOT = TOT + x("JUMLAH") Next Total_46109038.Text = TOT End Sub
Private Sub Kobar_46109038_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Kobar_46109038.Leave If Kobar_46109038.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", Kobar_46109038.Text, 1, conect) If Pencari.JumlanBaris > 0 Then Kobar_46109038.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") NamBar_46109038.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kobar_46109038.TextChanged NamBar_46109038.Text = "" Unit_46109038.Text = "" Harga_46109038.Text = "" End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Unit_46109038.TextChanged, Harga_46109038.TextChanged Jumlah_46109038.Text = Val(Unit_46109038.Text) * Val(Harga_46109038.Text) End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_46109038.Click
If NoTrans_46109038.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If JenTrans_46109038.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If DT.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NoTrans_46109038.Text, 1, conect) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
Dim Command As New OleDb.OleDbCommand Command = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NoTrans_46109038.Text & "', #" & Tgl_46109038.Value.Month & "/" & Tgl_46109038.Value.Day & "/" & Tgl_46109038.Value.Year & "#, '" & JenTrans_46109038.Text & "')", conect) conect.Open() Command.ExecuteNonQuery() conect.Close()
For Each X As DataRow In DT.Rows Command = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NoTrans_46109038.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", conect) conect.Open() Command.ExecuteNonQuery() conect.Close() Command.Dispose() Next
Private Sub Simpan_46109038_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_46109038.Click If NoTrans_46109038.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If JenTrans_46109038.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If DT.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NoTrans_46109038.Text, 1, conect) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
Dim Command As New OleDb.OleDbCommand Command = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NoTrans_46109038.Text & "', #" & Tgl_46109038.Value.Month & "/" & Tgl_46109038.Value.Day & "/" & Tgl_46109038.Value.Year & "#, '" & JenTrans_46109038.Text & "')", conect) conect.Open() Command.ExecuteNonQuery() conect.Close()
For Each X As DataRow In DT.Rows Command = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NoTrans_46109038.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", conect) conect.Open() Command.ExecuteNonQuery() conect.Close() Command.Dispose() Next NoTrans_46109038.Text = "" JenTrans_46109038.Text = "" Jumlah_46109038.Text = ""
Dim vero As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=allah swt") Dim dt As New DataTable Dim dr As DataRow
Private Sub Latihan3746109052_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= '" & nt46109052.Text & "'", vero) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DGV46109052.DataSource = dt End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In dt.Rows TOT = TOT + x("JUMLAH") Next Tot46109052.Text = TOT End Sub
Private Sub kb46109052_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109052.Leave If kb46109052.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109052.Text, 1, vero) If Pencari.JumlanBaris > 0 Then kb46109052.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb46109052.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109052.TextChanged nb46109052.Text = "" un46109052.Text = "" hr46109052.Text = "" End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109052.TextChanged, hr46109052.TextChanged jm46109052.Text = Val(un46109052.Text) * Val(hr46109052.Text) End Sub Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT246109052.Click
If nt46109052.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt46109052.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109052.Text, 1, vero) 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 ('" & nt46109052.Text & "', #" & DTP46109052.Value.Month & "/" & DTP46109052.Value.Day & "/" & DTP46109052.Value.Year & "#, '" & jt46109052.Text & "')", vero) vero.Open() CM.ExecuteNonQuery() vero.Close()
For Each X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109052.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", vero) vero.Open() CM.ExecuteNonQuery() vero.Close() CM.Dispose() Next
Private Sub BT246109052_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT246109052.Click If nt46109052.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt46109052.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109052.Text, 1, vero) 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 ('" & nt46109052.Text & "', #" & DTP46109052.Value.Month & "/" & DTP46109052.Value.Day & "/" & DTP46109052.Value.Year & "#, '" & jt46109052.Text & "')", vero) vero.Open() CM.ExecuteNonQuery() vero.Close()
For Each X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109052.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", vero) vero.Open() CM.ExecuteNonQuery() vero.Close() CM.Dispose() Next
Public Class LATIHAN037_46109020 Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46") Dim TARI As New DataTable Dim tata As DataRow
Private Sub LATIHAN037_46109020_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim nisa As New OleDb.OleDbDataAdapter nisa = 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= '" & NT46109020.Text & "'", CONECT) TARI.Rows.Clear() nisa.Fill(TARI) DGV46109020.DataSource = TARI
nisa.Dispose() Dim mentarikolom(1) As DataColumn mentarikolom(0) = TARI.Columns("KODEBARANG") TARI.PrimaryKey = mentarikolom
End Sub Private Sub KB46109020_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB46109020.Leave If KB46109020.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KB46109020.Text, 1, CONECT) If Pencari.JumlanBaris > 0 Then KB46109020.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") NB46109020.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Private Sub TAMBAH46109020_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH46109020.Click If KB46109020.Text.Length = 0 Then MsgBox("kode barang belum terisi") Exit Sub End If
If Val(UN46109020.Text) = 0 Then MsgBox("UNIT belum terisi") Exit Sub End If
If Val(HR46109020.Text) = 0 Then MsgBox("HARGA belum terisi") Exit Sub End If
tata = TARI.Rows.Find(KB46109020.Text) If tata Is Nothing Then tata = TARI.NewRow tata("KODEBARANG") = KB46109020.Text Else MsgBox("Maaf kode barang sudah ada") Exit Sub End If
Private Sub SIMPAN46109020_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmbh246109020.Click If NT46109020.Text.Length = 0 Then MsgBox("no.transaksi belum terisi") Exit Sub End If
If JT46109020.Text.Length = 0 Then MsgBox("jenis transaksi belum terisi") Exit Sub End If
If TARI.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT46109020.Text, 1, CONECT) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT46109020.Text & "',#" & DT46109020.Value.Date & "#," & Val(JT46109020.Text) & ")", CONECT)
hajrah() End Sub Private Sub hajrah() Dim manis As Integer For Each r As DataRow In TARI.Rows manis = manis + r("JUMLAH") Next TOT46109020.Text = manis
End Sub
Private Sub KB46109020_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB46109020.TextChanged NB46109020.Text = "" UN46109020.Text = "" HR46109020.Text = "" End Sub
Private Sub tmbh246109020_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmbh246109020.Click If NT46109020.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If JT46109020.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If TARI.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT46109020.Text, 1, CONECT) 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 ('" & NT46109020.Text & "', #" & DT46109020.Value.Month & "/" & DT46109020.Value.Day & "/" & DT46109020.Value.Year & "#, '" & JT46109020.Text & "')", CONECT) CONECT.Open() CM.ExecuteNonQuery() CONECT.Close()
For Each X As DataRow In TARI.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT46109020.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", CONECT) CONECT.Open() CM.ExecuteNonQuery() CONECT.Close() CM.Dispose() Next
Private Sub HR46109020_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HR46109020.TextChanged JM46109020.Text = Val(UN46109020.Text) * Val(HR46109020.Text) End Sub End Class
Dim n As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=8") Dim dt As New DataTable Dim dr As DataRow
Private Sub Form37_46109042_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= '" & nt46109042.Text & "'", n) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
dgv46109042.DataSource = dt End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In dt.Rows TOT = TOT + x("JUMLAH") Next Tot46109042.Text = TOT End Sub
Private Sub kb46109042_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109042.Leave If kb46109042.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109042.Text, 1, n) If Pencari.JumlanBaris > 0 Then kb46109042.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb46109042.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Public Class latihan_37_46109044 Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=1234")
Dim DT As New DataTable Dim DR As DataRow Private Sub LATIHAN037_46109044_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= '" & nomor46109044.Text & "'", CONECT) X.Fill(DT) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = DT.Columns("KODEBARANG") DT.PrimaryKey = dataPrimary
data46109044.DataSource = DT End Sub Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In DT.Rows TOT = TOT + x("JUMLAH") Next total46109044.Text = TOT End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If kode46109044.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nama46109044.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(unit46109044.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(harga46109044.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
DR = DT.Rows.Find(kode46109044.Text)
If DR Is Nothing Then DR = DT.NewRow DR("KODEBARANG") = kode46109044.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Private Sub Button146109046_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109046.Click If kb46109046.Text.Length = 0 Then MsgBox("Isi Kode Barang nya") Exit Sub End If
If Val(un46109046.Text) = 0 Then MsgBox("Isi Unit nya") Exit Sub End If
If Val(hr46109046.Text) = 0 Then MsgBox("Isi Harga nya") Exit Sub End If
Dim dr As DataRow dr = dt.Rows.Find(kb46109046.Text) If dr Is Nothing Then dr = dt.NewRow dr("KODEBARANG") = kb46109046.Text dr("NAMABARANG") = nb46109046.Text dr("UNIT") = un46109046.Text dr("HARGA") = hr46109046.Text dr("JUMLAH") = jm46109046.Text
Else MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain") End If asmianti() End Sub
Private Sub Button246109046_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button246109046.Click If nt46109046.Text.Length = 0 Then MsgBox("Isi rong itu No Transaksi na..") Exit Sub End If
If jt46109046.Text.Length = 0 Then MsgBox("Isi rong itu Jenis Transaksi na..") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Isi rong itu datatable na..") Exit Sub End If
amhy.AturPencarianDataBase("mastertransaksi", "notrans", nt46109046.Text, 1, asmi) If amhy.JumlanBaris > 0 Then MsgBox("Adami No Transaksi seperti itu..") Exit Sub End If
For Each x As DataRow In dt.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109046.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", asmi) asmi.Open() cm.ExecuteNonQuery() asmi.Close() Next cm.Dispose()
Public Class LATIHAN3746109026 Dim n As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=26") Dim dt As New DataTable Dim dr As DataRow
Private Sub LATIHAN3746109026_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= '" & nt46109026.Text & "'", n) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
dgv46109026.DataSource = dt End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In dt.Rows TOT = TOT + x("JUMLAH") Next Tot46109026.Text = TOT
End Sub Private Sub kb46109026_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109026.Leave If kb46109026.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109026.Text, 1, n) If Pencari.JumlanBaris > 0 Then kb46109026.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb46109026.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Private Sub kb46109026_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109026.TextChanged nb46109026.Text = "" un46109026.Text = "" hr46109026.Text = ""
End Sub
Private Sub un46109026_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109026.TextChanged, hr46109026.TextChanged jm46109026.Text = Val(un46109026.Text) * Val(hr46109026.Text)
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If nt46109026.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt46109026.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109026.Text, 1, n) 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 ('" & nt46109026.Text & "', #" & dtp46109026.Value.Month & "/" & dtp46109026.Value.Day & "/" & dtp46109026.Value.Year & "#, '" & jt46109026.Text & "')", n) n.Open() CM.ExecuteNonQuery() n.Close()
For Each X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109026.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", n) n.Open() CM.ExecuteNonQuery() n.Close() CM.Dispose() Next
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If kb46109026.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nb46109026.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(un46109026.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(hr46109026.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
dr = dt.Rows.Find(kb46109026.Text)
If dr Is Nothing Then dr = dt.NewRow dr("KODEBARANG") = kb46109026.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If nt46109026.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt46109026.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109026.Text, 1, n) 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 ('" & nt46109026.Text & "', #" & DTP46109026.Value.Month & "/" & DTP46109026.Value.Day & "/" & DTP46109026.Value.Year & "#, '" & jt46109026.Text & "')", n) n.Open() CM.ExecuteNonQuery() n.Close()
For Each X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109026.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", n) n.Open() CM.ExecuteNonQuery() n.Close() CM.Dispose() Next
Komentar ini telah dihapus oleh pengarang.
BalasHapusKomentar ini telah dihapus oleh pengarang.
BalasHapusKomentar ini telah dihapus oleh pengarang.
BalasHapusKomentar ini telah dihapus oleh pengarang.
BalasHapusPublic Class Latihan3746109047
BalasHapusDim nurmuhitha As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=12345")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub Latihan3746109047_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= '" & nt46109047.Text & "'", nurmuhitha)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DGV46109047.DataSource = dt
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In dt.Rows
TOT = TOT + x("JUMLAH")
Next
Tot46109047.Text = TOT
End Sub
Private Sub kb46109047_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109047.Leave
If kb46109047.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109047.Text, 1, nurmuhitha)
If Pencari.JumlanBaris > 0 Then
kb46109047.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb46109047.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109047.TextChanged
nb46109047.Text = ""
un46109047.Text = ""
hr46109047.Text = ""
End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109047.TextChanged, hr46109047.TextChanged
jm46109047.Text = Val(un46109047.Text) * Val(hr46109047.Text)
End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT246109047.Click
BalasHapusIf nt46109047.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt46109047.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109047.Text, 1, nurmuhitha)
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 ('" & nt46109047.Text & "', #" & DTP46109047.Value.Month & "/" & DTP46109047.Value.Day & "/" & DTP46109047.Value.Year & "#, '" & jt46109047.Text & "')", nurmuhitha)
nurmuhitha.Open()
CM.ExecuteNonQuery()
nurmuhitha.Close()
For Each X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109047.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", nurmuhitha)
nurmuhitha.Open()
CM.ExecuteNonQuery()
nurmuhitha.Close()
CM.Dispose()
Next
nt46109047.Text = ""
jt46109047.Text = ""
jm46109047.Text = ""
dt.Rows.Clear()
TOTALJUMLAH()
End Sub
Private Sub BT146109047_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT146109047.Click
BalasHapusIf kb46109047.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb46109047.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un46109047.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr46109047.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
dr = dt.Rows.Find(kb46109047.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = kb46109047.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
dr = dt.NewRow
dr("KODEBARANG") = kb46109047.Text
dr("NAMABARANG") = nb46109047.Text
dr("UNIT") = un46109047.Text
dr("HARGA") = hr46109047.Text
dr("JUMLAH") = jm46109047.Text
dt.Rows.Add(dr)
kb46109047.Text = ""
nb46109047.Text = ""
un46109047.Text = ""
hr46109047.Text = ""
TOTALJUMLAH()
End Sub
Private Sub BT246109047_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT246109047.Click
If nt46109047.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt46109047.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109047.Text, 1, nurmuhitha)
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 ('" & nt46109047.Text & "', #" & DTP46109047.Value.Month & "/" & DTP46109047.Value.Day & "/" & DTP46109047.Value.Year & "#, '" & jt46109047.Text & "')", nurmuhitha)
nurmuhitha.Open()
CM.ExecuteNonQuery()
nurmuhitha.Close()
For Each X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109047.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", nurmuhitha)
nurmuhitha.Open()
CM.ExecuteNonQuery()
nurmuhitha.Close()
CM.Dispose()
Next
nt46109047.Text = ""
jt46109047.Text = ""
jm46109047.Text = ""
dt.Rows.Clear()
TOTALJUMLAH()
End Sub
End Class
FARADILLAH AMALIA RIVAI
BalasHapusPublic Class LATIHAN037_46109010
Dim faradillah As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46")
Dim rivai As DataRow
Dim fara As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub LATIHAN037_46109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim rossi As New OleDb.OleDbDataAdapter
rossi = 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= '" & nt46109010.Text & "'", faradillah)
fara.Rows.Clear()
rossi.Fill(fara)
dgv46109010.DataSource = fara
rossi.Dispose()
Dim farah(1) As DataColumn
farah(0) = fara.Columns("KODEBARANG")
fara.PrimaryKey = farah
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In fara.Rows
TOT = TOT + x("JUMLAH")
Next
Tot46109010.Text = TOT
End Sub
Private Sub KB46109010_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109010.Leave
If kb46109010.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109010.Text, 1, faradillah)
If Pencari.JumlanBaris > 0 Then
kb46109010.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb46109010.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub KB46109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109010.TextChanged
nb46109010.Text = ""
un46109010.Text = ""
hr46109010.Text = ""
End Sub
Private Sub UN46109010_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109010.TextChanged, hr46109010.TextChanged
jm46109010.Text = Val(un46109010.Text) * Val(hr46109010.Text)
End Sub
LANJUTAN LATIHAN 37 BY FARADILLAH AMALIA RIVAI
BalasHapusPrivate Sub button146109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109010.Click
If kb46109010.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb46109010.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un46109010.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr46109010.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
rivai = fara.Rows.Find(kb46109010.Text)
If rivai Is Nothing Then
rivai = fara.NewRow
rivai("KODEBARANG") = kb46109010.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
rivai = fara.NewRow
rivai("KODEBARANG") = kb46109010.Text
rivai("NAMABARANG") = nb46109010.Text
rivai("UNIT") = un46109010.Text
rivai("HARGA") = hr46109010.Text
rivai("JUMLAH") = jm46109010.Text
fara.Rows.Add(rivai)
kb46109010.Text = ""
nb46109010.Text = ""
un46109010.Text = ""
hr46109010.Text = ""
TOTALJUMLAH()
End Sub
Private Sub button346109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button346109010.Click
If nt46109010.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt46109010.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If fara.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109010.Text, 1, faradillah)
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 ('" & nt46109010.Text & "', #" & dtp46109010.Value.Month & "/" & dtp46109010.Value.Day & "/" & dtp46109010.Value.Year & "#, '" & jt46109010.Text & "')", faradillah)
faradillah.Open()
CM.ExecuteNonQuery()
faradillah.Close()
For Each X As DataRow In fara.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109010.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", faradillah)
faradillah.Open()
CM.ExecuteNonQuery()
faradillah.Close()
CM.Dispose()
Next
nt46109010.Text = ""
jt46109010.Text = ""
jm46109010.Text = ""
fara.Rows.Clear()
TOTALJUMLAH()
End Sub
End Class
Public Class Latihan037_46109015
BalasHapusDim qayyimah As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=015")
Dim imah As DataRow
Dim qn As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Latihan037_46109015_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ima As New OleDb.OleDbDataAdapter
ima = 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= '" & nt46109015.Text & "'", qayyimah)
qn.Rows.Clear()
ima.Fill(qn)
dgv46109015.DataSource = qn
ima.Dispose()
Dim qnh(1) As DataColumn
qnh(0) = qn.Columns("KODEBARANG")
qn.PrimaryKey = qnh
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In qn.Rows
TOT = TOT + x("JUMLAH")
Next
Tot46109015.Text = TOT
End Sub
Private Sub kb46109015_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109015.Leave
If kb46109015.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109015.Text, 1, qayyimah)
If Pencari.JumlanBaris > 0 Then
kb46109015.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb46109015.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub kb46109015_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109015.TextChanged
nb46109015.Text = ""
un46109015.Text = ""
hr46109015.Text = ""
End Sub
Private Sub un46109015_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109015.TextChanged, hr46109015.TextChanged
jm46109015.Text = Val(un46109015.Text) * Val(hr46109015.Text)
End Sub
Private Sub T46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T46109015.Click
If kb46109015.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb46109015.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un46109015.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr46109015.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
imah = qn.Rows.Find(kb46109015.Text)
If imah Is Nothing Then
imah = qn.NewRow
imah("KODEBARANG") = kb46109015.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
imah = qn.NewRow
imah("KODEBARANG") = kb46109015.Text
imah("NAMABARANG") = nb46109015.Text
imah("UNIT") = un46109015.Text
imah("HARGA") = hr46109015.Text
imah("JUMLAH") = jm46109015.Text
qn.Rows.Add(imah)
kb46109015.Text = ""
nb46109015.Text = ""
un46109015.Text = ""
hr46109015.Text = ""
TOTALJUMLAH()
End Sub
Lanjutan.......
BalasHapusPrivate Sub S46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S46109015.Click
If nt46109015.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt46109015.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If qn.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109015.Text, 1, qayyimah)
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 ('" & nt46109015.Text & "', #" & TGL46109015.Value.Month & "/" & TGL46109015.Value.Day & "/" & TGL46109015.Value.Year & "#, '" & jt46109015.Text & "')", qayyimah)
qayyimah.Open()
CM.ExecuteNonQuery()
qayyimah.Close()
For Each X As DataRow In qn.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109015.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", qayyimah)
qayyimah.Open()
CM.ExecuteNonQuery()
qayyimah.Close()
CM.Dispose()
Next
nt46109015.Text = ""
jt46109015.Text = ""
jm46109015.Text = ""
qn.Rows.Clear()
TOTALJUMLAH()
End Sub
End Class
Public Class TUGAS37
BalasHapusDim SRY As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;Jet OLEDB:Database Password=11")
Dim REJEKI As New DataTable
Dim CARI As New ByIskandar.CariKeDataBaseByIskandar
Private Sub TUGAS37_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*harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans ='" & T146109006.Text & "'", SRY)
Q.Fill(REJEKI)
Q.Dispose()
DGV46109006.DataSource = REJEKI
Dim KIKI(1) As DataColumn
KIKI(0) = REJEKI.Columns("KODEBARANG")
REJEKI.PrimaryKey = KIKI
End Sub
Private Sub KIKIE()
Dim KIKIE1 As Integer = 0
For Each KIKIE2 As DataRow In REJEKI.Rows
KIKIE1 += KIKIE2("JUMLAH")
Next
TOT.Text = KIKIE1
End Sub
Private Sub HR_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HR.TextChanged
JM.Text = Val(HR.Text) * Val(UN.Text)
End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB.Leave
If KB.Text.Length = 0 Then
Exit Sub
End If
CARI.AturPencarianDataBase("barang", "kodebarang", KB.Text, 1, SRY)
If CARI.JumlanBaris > 0 Then
KB.Text = CARI.DataTablenya.Rows(0).Item("KODEBARANG")
NB.Text = CARI.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang itu tidak ada..")
Exit Sub
End If
End Sub
Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB.TextChanged
NB.Text = ""
UN.Text = ""
HR.Text = ""
End Sub
Private Sub TOMBOL1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL1.Click
If KB.Text.Length = 0 Then
MsgBox("Kode Barang belum terisi")
Exit Sub
End If
If Val(UN.Text) = 0 Then
MsgBox("UNIT belum terisi")
Exit Sub
End If
If Val(HR.Text) = 0 Then
MsgBox("HARGA belum terisi")
Exit Sub
End If
Dim KI2 As DataRow
KI2 = REJEKI.Rows.Find(KB.Text)
If KI2 Is Nothing Then
KI2 = REJEKI.NewRow
KI2("KODEBARANG") = KB.Text
KI2("NAMABARANG") = NB.Text
KI2("UNIT") = UN.Text
KI2("HARGA") = HR.Text
KI2("JUMLAH") = JM.Text
REJEKI.Rows.Add(KI2)
KB.Text = ""
UN.Text = ""
HR.Text = ""
Else
MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain...")
End If
KIKIE()
End Sub
LANJUTAN TUGAS 37
BalasHapusPrivate Sub TOMBOL2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL2.Click
If T146109006.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If T246109006.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
CARI.AturPencarianDataBase("mastertransaksi", "notrans", T146109006.Text, 1, SRY)
If CARI.JumlanBaris > 0 Then
MsgBox("NO.TRANSAKSI sudah ada")
Exit Sub
End If
If REJEKI.Rows.Count = 0 Then
MsgBox("Data tidak tersedia")
End If
Dim QI As New OleDb.OleDbCommand
QI = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & T146109006.Text & "',#" & DATE46109006.Value.Date & "#," & Val(T246109006.Text) & ")", SRY)
SRY.Open()
QI.ExecuteNonQuery()
SRY.Close()
For Each r As DataRow In REJEKI.Rows
QI = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & T146109006.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", SRY)
SRY.Open()
QI.ExecuteNonQuery()
SRY.Close()
QI.Dispose()
Next
REJEKI.Rows.Clear()
KIKIE()
T146109006.Text = ""
T246109006.Text = ""
End Sub
End Class
PublicClass Latihan37_46109050
BalasHapusDim CONECT AsNew OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= "& Application.StartupPath &"\DATAMAJEMUK.accdb;jet oledb:database Password=KYKY")
Dim dt AsNew DataTable
Dim dr As DataRow
PrivateSub Latihan37_46109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Dim X AsNew 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= '"& NT_46109050.Text &"'", CONECT)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DGV_46109050.DataSource = dt
EndSub
PrivateSub TOTALJUMLAH()
Dim TOT AsDouble = 0
ForEach x As DataRow In dt.Rows
TOT = TOT + x("JUMLAH")
Next
TOT_46109050.Text = TOT
EndSub
PrivateSub kb46109047_Leave(ByVal sender AsObject, ByVal e As System.EventArgs) Handles KB_46109050.Leave
If KB_46109050.Text.Length = 0 Then
ExitSub
EndIf
Dim Pencari AsNew ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KB_46109050.Text, 1, CONECT)
If Pencari.JumlanBaris > 0 Then
KB_46109050.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
NB_46109050.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
ExitSub
EndIf
EndSub
PrivateSub KB_46109050_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB_46109050.TextChanged
NB_46109050.Text = ""
UNT_46109050.Text = ""
HRG_46109050.Text = ""
EndSub
PrivateSub UNT_46109050_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UNT_46109050.TextChanged, HRG_46109050.TextChanged
JMLH_46109050.Text = Val(UNT_46109050.Text) * Val(HRG_46109050.Text)
EndSub
PrivateSub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BUTTON2_46109050.Click
If NT_46109050.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
ExitSub
EndIf
If JT_46109050.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
ExitSub
EndIf
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
ExitSub
EndIf
Dim pencari AsNew ByIskandar.CariKeDataBaseByIskandar
BalasHapuspencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT_46109050.Text, 1, CONECT)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
ExitSub
EndIf
Dim CM AsNew OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('"& NT_46109050.Text &"', #"& TGL_46109050.Value.Month &"/"& TGL_46109050.Value.Day &"/"& TGL_46109050.Value.Year &"#, '"& JT_46109050.Text &"')", CONECT)
CONECT.Open()
CM.ExecuteNonQuery()
CONECT.Close()
ForEach X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('"& NT_46109050.Text &"','"& X("KODEBARANG") &"',"& X("UNIT") &", "& X("HARGA") &")", CONECT)
CONECT.Open()
CM.ExecuteNonQuery()
CONECT.Close()
CM.Dispose()
Next
NT_46109050.Text = ""
JT_46109050.Text = ""
JMLH_46109050.Text = ""
dt.Rows.Clear()
TOTALJUMLAH()
EndSub
PrivateSub button1_46109050_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BUTTON1_46109050.Click
If KB_46109050.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
ExitSub
EndIf
If NB_46109050.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
EndIf
If Val(UNT_46109050.Text) = 0 Then
MsgBox("Masukkan unit barang")
ExitSub
EndIf
If Val(HRG_46109050.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
ExitSub
EndIf
dr = dt.Rows.Find(KB_46109050.Text)
If dr IsNothingThen
dr = dt.NewRow
dr("KODEBARANG") = KB_46109050.Text
Else
MsgBox("Maaf kodebarang sudah ada")
ExitSub
EndIf
dr = dt.NewRow
BalasHapusdr("KODEBARANG") = KB_46109050.Text
dr("NAMABARANG") = NB_46109050.Text
dr("UNIT") = UNT_46109050.Text
dr("HARGA") = HRG_46109050.Text
dr("JUMLAH") = JMLH_46109050.Text
dt.Rows.Add(dr)
KB_46109050.Text = ""
NB_46109050.Text = ""
UNT_46109050.Text = ""
HRG_46109050.Text = ""
TOTALJUMLAH()
EndSub
PrivateSub BUTTON2_46109050_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BUTTON2_46109050.Click
If NT_46109050.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
ExitSub
EndIf
If JT_46109050.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
ExitSub
EndIf
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
ExitSub
EndIf
Dim pencari AsNew ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT_46109050.Text, 1, CONECT)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
ExitSub
EndIf
Dim CM AsNew OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('"& NT_46109050.Text &"', #"& TGL_46109050.Value.Month &"/"& TGL_46109050.Value.Day &"/"& TGL_46109050.Value.Year &"#, '"& JT_46109050.Text &"')", CONECT)
CONECT.Open()
CM.ExecuteNonQuery()
CONECT.Close()
ForEach X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('"& NT_46109050.Text &"','"& X("KODEBARANG") &"',"& X("UNIT") &", "& X("HARGA") &")", CONECT)
CONECT.Open()
CM.ExecuteNonQuery()
CONECT.Close()
CM.Dispose()
Next
NT_46109050.Text = ""
JT_46109050.Text = ""
JMLH_46109050.Text = ""
dt.Rows.Clear()
TOTALJUMLAH()
EndSub
EndClass
Public Class Latihan_37_46109004
BalasHapusDim tabel As New DataTable
Dim ayu As New OleDb.OleDbCommand
Dim yayu As New ByIskandar.CariKeDataBaseByIskandar
Dim YY As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Latihan_37_46109004_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Y As New OleDb.OleDbDataAdapter
Y = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, detailtransaksi.UNIT, detailtransaksi.HARGA, detailtransaksi.unit*harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans ='" & notr081.Text & "'", YY)
tabel.Rows.Clear()
a.Fill(tabel)
a.Dispose()
Dim dc(1) As DataColumn
dc(0) = tabel.Columns("kodebarang")
tabel.PrimaryKey = dc
dgv46109004.DataSource = tabel
End Sub
Private Sub yayuan()
Dim yayuan1 As Integer = 0
For Each yayuan2 As DataRow In tabel.Rows
yayuan1 += yayuan2("JUMLAH")
Next
tot46109004.Text = yayuan1
End Sub
Private Sub unt46109004_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles unt46109004.TextChanged, hrg46109004.TextChanged
jmlh46109004.Text = Val(unt46109004.Text) * Val(hrg46109004.Text)
End Sub
Private Sub kodbar46109004_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kodbar46109004.Leave
If kodbar46109004.Text.Length = 0 Then
Exit Sub
End If
yayu.AturPencarYYDataBase("barang", "kodebarang", kodbar46109004.Text, 1, YY)
If yayu.JumlanBaris > 0 Then
kodbar46109004.Text = yayu.DataTablenya.Rows(0).Item("KODEBARANG")
nabar46109004.Text = yayu.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Maaf Kodebarang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub kodbar46109004_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodbar46109004.TextChanged
BalasHapusnabar46109004.Text = ""
unt46109004.Text = ""
hrg46109004.Text = ""
End Sub
Private Sub tbmh46109004_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmbh46109004.Click
If kodbar46109004.Text.Length = 0 Then
MsgBox("Mohon kolom kode Barangnya diisi")
Exit Sub
End If
If Val(unt46109004.Text) = 0 Then
MsgBox("Mohon kolom Unit diisi")
Exit Sub
End If
If Val(hrg46109004.Text) = 0 Then
MsgBox("mohon kolom harga diisi")
Exit Sub
End If
Dim aa As DataRow
aa = tabel.Rows.Find(kodbar46109004.Text)
If dr Is Nothing Then
aa = tabel.NewRow
aa("KODEBARANG") = kodbar46109004.Text
aa("NAMABARANG") = nabar46109004.Text
aa("UNIT") = Val(unt46109004.Text)
aa("HARGA") = Val(hrg46109004.Text)
aa("JUMLAH") = Val(jmlh46109004.Text)
tabel.Rows.Add(dr)
kodbar46109004.Text = ""
unt46109004.Text = ""
hrg46109004.Text = ""
Else
MsgBox("Kode barang tersebut sudah ada, mohon diganti")
End If
yayuan()
End Sub
Private Sub save46109004_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save46109004.Click
If notr46109004.Text.Length = 0 Then
MsgBox("Mohon kolom no. tansaksi diisi")
Exit Sub
End If
If jetr46109004.Text.Length = 0 Then
MsgBox("Mohon kolom Jenis Transaksi diisi")
Exit Sub
End If
If tabel.Rows.Count = 0 Then
MsgBox("Mohon datatable diisi")
Exit Sub
End If
yayu.AturPencarYYDataBase("mastertransaksi", "notrans", notr46109004.Text, 1, YY)
If yayu.JumlanBaris > 0 Then
MsgBox("Maaf No.Transaksi tersebut sudah ada.")
Exit Sub
End If
ayu = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & notr46109004.Text & "',#" & tgl46109004.Value.Month & "/" & tgl46109004.Value.Day & "/" & tgl46109004.Value.Year & "#,'" & jetr46109004.Text & "')", YY)
YY.Open()
ayu.ExecuteNonQuery()
YY.Close()
For Each x As DataRow In tabel.Rows
ayu = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & notr46109004.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", YY)
YY.Open()
ayu.ExecuteNonQuery()
YY.Close()
Next
ayu.Dispose()
notr46109004.Text = ""
jetr46109004.Text = ""
tabel.Rows.Clear()
yayuan()
End Sub
End Class
Andi Muh. Yusri
BalasHapusPublic Class Latihan37_46109038
Dim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=yusri")
Dim DT As New DataTable
Dim DR As DataRow
Private Sub Latihan37_46109038_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= '" & NoTrans_46109038.Text & "'", conect)
X.Fill(DT)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = DT.Columns("KODEBARANG")
DT.PrimaryKey = dataPrimary
DGV_46109038.DataSource = DT
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In DT.Rows
TOT = TOT + x("JUMLAH")
Next
Total_46109038.Text = TOT
End Sub
Private Sub Kobar_46109038_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Kobar_46109038.Leave
If Kobar_46109038.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", Kobar_46109038.Text, 1, conect)
If Pencari.JumlanBaris > 0 Then
Kobar_46109038.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
NamBar_46109038.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
sambungan
BalasHapusAndi muh. Yusri
Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kobar_46109038.TextChanged
NamBar_46109038.Text = ""
Unit_46109038.Text = ""
Harga_46109038.Text = ""
End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Unit_46109038.TextChanged, Harga_46109038.TextChanged
Jumlah_46109038.Text = Val(Unit_46109038.Text) * Val(Harga_46109038.Text)
End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_46109038.Click
If NoTrans_46109038.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JenTrans_46109038.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NoTrans_46109038.Text, 1, conect)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim Command As New OleDb.OleDbCommand
Command = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NoTrans_46109038.Text & "', #" & Tgl_46109038.Value.Month & "/" & Tgl_46109038.Value.Day & "/" & Tgl_46109038.Value.Year & "#, '" & JenTrans_46109038.Text & "')", conect)
conect.Open()
Command.ExecuteNonQuery()
conect.Close()
For Each X As DataRow In DT.Rows
Command = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NoTrans_46109038.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", conect)
conect.Open()
Command.ExecuteNonQuery()
conect.Close()
Command.Dispose()
Next
NoTrans_46109038.Text = ""
JenTrans_46109038.Text = ""
Jumlah_46109038.Text = ""
DT.Rows.Clear()
TOTALJUMLAH()
End Sub
sambungan2
BalasHapusandi muh. yusri
Private Sub Tambah_46109038_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tambah_46109038.Click
If Kobar_46109038.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If NamBar_46109038.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(Unit_46109038.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(Harga_46109038.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
DR = DT.Rows.Find(Kobar_46109038.Text)
If DR Is Nothing Then
DR = DT.NewRow
DR("KODEBARANG") = Kobar_46109038.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
DR = DT.NewRow
DR("KODEBARANG") = Kobar_46109038.Text
DR("NAMABARANG") = NamBar_46109038.Text
DR("UNIT") = Unit_46109038.Text
DR("HARGA") = Harga_46109038.Text
DR("JUMLAH") = Jumlah_46109038.Text
DT.Rows.Add(DR)
Kobar_46109038.Text = ""
NamBar_46109038.Text = ""
Unit_46109038.Text = ""
Harga_46109038.Text = ""
TOTALJUMLAH()
End Sub
Private Sub Simpan_46109038_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_46109038.Click
If NoTrans_46109038.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JenTrans_46109038.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NoTrans_46109038.Text, 1, conect)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim Command As New OleDb.OleDbCommand
Command = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NoTrans_46109038.Text & "', #" & Tgl_46109038.Value.Month & "/" & Tgl_46109038.Value.Day & "/" & Tgl_46109038.Value.Year & "#, '" & JenTrans_46109038.Text & "')", conect)
conect.Open()
Command.ExecuteNonQuery()
conect.Close()
For Each X As DataRow In DT.Rows
Command = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NoTrans_46109038.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", conect)
conect.Open()
Command.ExecuteNonQuery()
conect.Close()
Command.Dispose()
Next
NoTrans_46109038.Text = ""
JenTrans_46109038.Text = ""
Jumlah_46109038.Text = ""
DT.Rows.Clear()
TOTALJUMLAH()
End Sub
End Class
Public Class Latihan3746109052
BalasHapusDim vero As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=allah swt")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub Latihan3746109052_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= '" & nt46109052.Text & "'", vero)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DGV46109052.DataSource = dt
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In dt.Rows
TOT = TOT + x("JUMLAH")
Next
Tot46109052.Text = TOT
End Sub
Private Sub kb46109052_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109052.Leave
If kb46109052.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109052.Text, 1, vero)
If Pencari.JumlanBaris > 0 Then
kb46109052.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb46109052.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub KB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109052.TextChanged
nb46109052.Text = ""
un46109052.Text = ""
hr46109052.Text = ""
End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109052.TextChanged, hr46109052.TextChanged
jm46109052.Text = Val(un46109052.Text) * Val(hr46109052.Text)
End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT246109052.Click
If nt46109052.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt46109052.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
BalasHapuspencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109052.Text, 1, vero)
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 ('" & nt46109052.Text & "', #" & DTP46109052.Value.Month & "/" & DTP46109052.Value.Day & "/" & DTP46109052.Value.Year & "#, '" & jt46109052.Text & "')", vero)
vero.Open()
CM.ExecuteNonQuery()
vero.Close()
For Each X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109052.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", vero)
vero.Open()
CM.ExecuteNonQuery()
vero.Close()
CM.Dispose()
Next
nt46109052.Text = ""
jt46109052.Text = ""
jm46109052.Text = ""
dt.Rows.Clear()
TOTALJUMLAH()
End Sub
Private Sub BT146109052_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT146109052.Click
If kb46109052.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb46109052.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un46109052.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr46109052.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
dr = dt.Rows.Find(kb46109052.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = kb46109052.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
dr = dt.NewRow
dr("KODEBARANG") = kb46109052.Text
dr("NAMABARANG") = nb46109052.Text
dr("UNIT") = un46109052.Text
dr("HARGA") = hr46109052.Text
dr("JUMLAH") = jm46109052.Text
dt.Rows.Add(dr)
kb46109052.Text = ""
nb46109052.Text = ""
un46109052.Text = ""
hr46109052.Text = ""
TOTALJUMLAH()
End Sub
Private Sub BT246109052_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT246109052.Click
If nt46109052.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt46109052.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
BalasHapuspencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109052.Text, 1, vero)
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 ('" & nt46109052.Text & "', #" & DTP46109052.Value.Month & "/" & DTP46109052.Value.Day & "/" & DTP46109052.Value.Year & "#, '" & jt46109052.Text & "')", vero)
vero.Open()
CM.ExecuteNonQuery()
vero.Close()
For Each X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109052.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", vero)
vero.Open()
CM.ExecuteNonQuery()
vero.Close()
CM.Dispose()
Next
nt46109052.Text = ""
jt46109052.Text = ""
jm46109052.Text = ""
dt.Rows.Clear()
TOTALJUMLAH()
End Sub
End Class
Public Class LATIHAN037_46109020
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46")
Dim TARI As New DataTable
Dim tata As DataRow
Private Sub LATIHAN037_46109020_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim nisa As New OleDb.OleDbDataAdapter
nisa = 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= '" & NT46109020.Text & "'", CONECT)
TARI.Rows.Clear()
nisa.Fill(TARI)
DGV46109020.DataSource = TARI
nisa.Dispose()
Dim mentarikolom(1) As DataColumn
mentarikolom(0) = TARI.Columns("KODEBARANG")
TARI.PrimaryKey = mentarikolom
End Sub
Private Sub KB46109020_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB46109020.Leave
If KB46109020.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KB46109020.Text, 1, CONECT)
If Pencari.JumlanBaris > 0 Then
KB46109020.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
NB46109020.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub TAMBAH46109020_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH46109020.Click
If KB46109020.Text.Length = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If
If Val(UN46109020.Text) = 0 Then
MsgBox("UNIT belum terisi")
Exit Sub
End If
If Val(HR46109020.Text) = 0 Then
MsgBox("HARGA belum terisi")
Exit Sub
End If
tata = TARI.Rows.Find(KB46109020.Text)
If tata Is Nothing Then
tata = TARI.NewRow
tata("KODEBARANG") = KB46109020.Text
Else
MsgBox("Maaf kode barang sudah ada")
Exit Sub
End If
tata = TARI.NewRow
tata("KODEBARANG") = KB46109020.Text
tata("NAMABARANG") = NB46109020.Text
tata("UNIT") = UN46109020.Text
tata("HARGA") = HR46109020.Text
tata("JUMLAH") = JM46109020.Text
TARI.Rows.Add(tata)
hajrah()
KB46109020.Text = ""
NB46109020.Text = ""
UN46109020.Text = ""
HR46109020.Text = ""
JM46109020.Text = ""
End Sub
Lanjutannya....
BalasHapusPrivate Sub SIMPAN46109020_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmbh246109020.Click
If NT46109020.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If JT46109020.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
If TARI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT46109020.Text, 1, CONECT)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT46109020.Text & "',#" & DT46109020.Value.Date & "#," & Val(JT46109020.Text) & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In TARI.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & NT46109020.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
TARI.Rows.Clear()
NT46109020.Text = ""
JT46109020.Text = ""
JM46109020.Text = ""
hajrah()
End Sub
Private Sub hajrah()
Dim manis As Integer
For Each r As DataRow In TARI.Rows
manis = manis + r("JUMLAH")
Next
TOT46109020.Text = manis
End Sub
Private Sub KB46109020_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB46109020.TextChanged
NB46109020.Text = ""
UN46109020.Text = ""
HR46109020.Text = ""
End Sub
Lanjutannya......
BalasHapusPrivate Sub tmbh246109020_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmbh246109020.Click
If NT46109020.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT46109020.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If TARI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT46109020.Text, 1, CONECT)
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 ('" & NT46109020.Text & "', #" & DT46109020.Value.Month & "/" & DT46109020.Value.Day & "/" & DT46109020.Value.Year & "#, '" & JT46109020.Text & "')", CONECT)
CONECT.Open()
CM.ExecuteNonQuery()
CONECT.Close()
For Each X As DataRow In TARI.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT46109020.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", CONECT)
CONECT.Open()
CM.ExecuteNonQuery()
CONECT.Close()
CM.Dispose()
Next
NT46109020.Text = ""
JT46109020.Text = ""
JM46109020.Text = ""
TARI.Rows.Clear()
hajrah()
End Sub
Private Sub HR46109020_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HR46109020.TextChanged
JM46109020.Text = Val(UN46109020.Text) * Val(HR46109020.Text)
End Sub
End Class
Public Class Form37_46109042
BalasHapusDim n As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=8")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub Form37_46109042_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= '" & nt46109042.Text & "'", n)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
dgv46109042.DataSource = dt
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In dt.Rows
TOT = TOT + x("JUMLAH")
Next
Tot46109042.Text = TOT
End Sub
Private Sub kb46109042_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109042.Leave
If kb46109042.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109042.Text, 1, n)
If Pencari.JumlanBaris > 0 Then
kb46109042.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb46109042.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Public Class latihan_37_46109044
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=1234")
Dim DT As New DataTable
Dim DR As DataRow
Private Sub LATIHAN037_46109044_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= '" & nomor46109044.Text & "'", CONECT)
X.Fill(DT)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = DT.Columns("KODEBARANG")
DT.PrimaryKey = dataPrimary
data46109044.DataSource = DT
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In DT.Rows
TOT = TOT + x("JUMLAH")
Next
total46109044.Text = TOT
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
BalasHapusIf kode46109044.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nama46109044.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(unit46109044.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(harga46109044.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
DR = DT.Rows.Find(kode46109044.Text)
If DR Is Nothing Then
DR = DT.NewRow
DR("KODEBARANG") = kode46109044.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
DR = DT.NewRow
DR("KODEBARANG") = kode46109044.Text
DR("NAMABARANG") = nama46109044.Text
DR("UNIT") = unit46109044.Text
DR("HARGA") = harga46109044.Text
DR("JUMLAH") = jumlah46109044.Text
DT.Rows.Add(DR)
kode46109044.Text = ""
nama46109044.Text = ""
unit46109044.Text = ""
harga46109044.Text = ""
TOTALJUMLAH()
End Sub
End Class
Private Sub Button146109046_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109046.Click
BalasHapusIf kb46109046.Text.Length = 0 Then
MsgBox("Isi Kode Barang nya")
Exit Sub
End If
If Val(un46109046.Text) = 0 Then
MsgBox("Isi Unit nya")
Exit Sub
End If
If Val(hr46109046.Text) = 0 Then
MsgBox("Isi Harga nya")
Exit Sub
End If
Dim dr As DataRow
dr = dt.Rows.Find(kb46109046.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = kb46109046.Text
dr("NAMABARANG") = nb46109046.Text
dr("UNIT") = un46109046.Text
dr("HARGA") = hr46109046.Text
dr("JUMLAH") = jm46109046.Text
dt.Rows.Add(dr)
kb46109046.Text = ""
un46109046.Text = ""
hr46109046.Text = ""
Else
MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain")
End If
asmianti()
End Sub
Private Sub Button246109046_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button246109046.Click
If nt46109046.Text.Length = 0 Then
MsgBox("Isi rong itu No Transaksi na..")
Exit Sub
End If
If jt46109046.Text.Length = 0 Then
MsgBox("Isi rong itu Jenis Transaksi na..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Isi rong itu datatable na..")
Exit Sub
End If
amhy.AturPencarianDataBase("mastertransaksi", "notrans", nt46109046.Text, 1, asmi)
If amhy.JumlanBaris > 0 Then
MsgBox("Adami No Transaksi seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanhr46109043altransaksi, jenistransaksi) values ('" & nt46109046.Text & "',#" & dtp46109046.Value.Month & "/" & dtp46109046.Value.Day & "/" & dtp46109046.Value.Year & "#,'" & jt46109046.Text & "')", asmi)
asmi.Open()
cm.ExecuteNonQuery()
asmi.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109046.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", asmi)
asmi.Open()
cm.ExecuteNonQuery()
asmi.Close()
Next
cm.Dispose()
nt46109046.Text = ""
jt46109046.Text = ""
dt.Rows.Clear()
asmianti()
End Sub
End Class
Public Class LATIHAN3746109026
BalasHapusDim n As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=26")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub LATIHAN3746109026_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= '" & nt46109026.Text & "'", n)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
dgv46109026.DataSource = dt
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In dt.Rows
TOT = TOT + x("JUMLAH")
Next
Tot46109026.Text = TOT
End Sub
Private Sub kb46109026_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb46109026.Leave
If kb46109026.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb46109026.Text, 1, n)
If Pencari.JumlanBaris > 0 Then
kb46109026.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb46109026.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub kb46109026_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb46109026.TextChanged
nb46109026.Text = ""
un46109026.Text = ""
hr46109026.Text = ""
End Sub
Private Sub un46109026_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un46109026.TextChanged, hr46109026.TextChanged
jm46109026.Text = Val(un46109026.Text) * Val(hr46109026.Text)
End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
BalasHapusIf nt46109026.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt46109026.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109026.Text, 1, n)
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 ('" & nt46109026.Text & "', #" & dtp46109026.Value.Month & "/" & dtp46109026.Value.Day & "/" & dtp46109026.Value.Year & "#, '" & jt46109026.Text & "')", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
For Each X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109026.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
CM.Dispose()
Next
nt46109026.Text = ""
jt46109026.Text = ""
jm46109026.Text = ""
dt.Rows.Clear()
TOTALJUMLAH()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If kb46109026.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb46109026.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un46109026.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr46109026.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
dr = dt.Rows.Find(kb46109026.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = kb46109026.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
dr = dt.NewRow
dr("KODEBARANG") = kb46109026.Text
dr("NAMABARANG") = nb46109026.Text
dr("UNIT") = un46109026.Text
dr("HARGA") = hr46109026.Text
dr("JUMLAH") = jm46109026.Text
dt.Rows.Add(dr)
kb46109026.Text = ""
nb46109026.Text = ""
un46109026.Text = ""
hr46109026.Text = ""
TOTALJUMLAH()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
BalasHapusIf nt46109026.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt46109026.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109026.Text, 1, n)
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 ('" & nt46109026.Text & "', #" & DTP46109026.Value.Month & "/" & DTP46109026.Value.Day & "/" & DTP46109026.Value.Year & "#, '" & jt46109026.Text & "')", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
For Each X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109026.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
CM.Dispose()
Next
nt46109026.Text = ""
jt46109026.Text = ""
jm46109026.Text = ""
dt.Rows.Clear()
TOTALJUMLAH()
End Sub
End Class