Private Sub B236108001_Click(ByVal sender As System.Object, ByVal AULIA As System.EventArgs) Handles B236108001.Click If T136108001.Text.Length = 0 Then MsgBox("Nomor transaksi belum terisi") Exit Sub End If
If T236108001.Text.Length = 0 Then MsgBox("Jenis transaksi belum terisi") Exit Sub End If
If LOVE.Rows.Count = 0 Then MsgBox("Data tidak terisi") Exit Sub End If
Dim B As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=2422") Dim DT As New DataTable Dim DR As DataRow
Private Sub Latihan37017_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= '" & nt_36109056.Text & "'", B) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DataGridView1.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 Tot_36109056.Text = TOT End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb_36109056.Leave If kb_36109056.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb_36109056.Text, 1, B) If Pencari.JumlanBaris > 0 Then kb_36109056.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb_36109056.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 kb_36109056.TextChanged nb_36109056.Text = "" un_36109056.Text = "" hr_36109056.Text = "" End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un_36109056.TextChanged, hr_36109056.TextChanged jm_36109056.Text = Val(un_36109056.Text) * Val(hr_36109056.Text) End Sub Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'a' If kb_36109056.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nb_36109056.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(un_36109056.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(hr_36109056.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
'b' DR = DT.Rows.Find(kb_36109056.Text)
If DR Is Nothing Then DR = DT.NewRow DR("KODEBARANG") = kb_36109056.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'a' If nt_36109056.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt_36109056.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If DT.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_36109056.Text, 1, B) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim CM As New OleDb.OleDbCommand CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_36109056.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt_36109056.Text & "')", B) B.Open() CM.ExecuteNonQuery() B.Close()
'e' For Each X As DataRow In DT.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_36109056.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", B) B.Open() CM.ExecuteNonQuery() B.Close() CM.Dispose() Next
Public Class LATIHAN03736109033 Dim CONECT As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=tahir") Dim data As New DataTable Dim tiwi As DataRow
Private Sub LATIHAN03736109033_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim pratiwi As New OleDb.OleDbDataAdapter pratiwi = 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= '" & nt36109033.Text & "'", CONECT) pratiwi.Fill(data) pratiwi.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = data.Columns("KODEBARANG") data.PrimaryKey = dataPrimary
DataGridView1.DataSource = data End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each t As DataRow In data.Rows TOT = TOT + t("JUMLAH") Next Tot36109033.Text = TOT End Sub
Private Sub KB36109033_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb36109033.Leave If kb36109033.Text.Length = 0 Then Exit Sub End If
Dim browse As New ByIskandar.CariKeDataBaseByIskandar browse.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109033.Text, 1, CONECT) If browse.JumlanBaris > 0 Then kb36109033.Text = browse.DataTablenya.Rows(0).Item("KODEBARANG") nb36109033.Text = browse.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub Private Sub kb36109033_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109033.TextChanged nb36109033.Text = "" un36109033.Text = "" hr36109033.Text = "" End Sub Private Sub un36109033_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109033.TextChanged jm36109033.Text = Val(un36109033.Text) * Val(hr36109033.Text) End Sub
Private Sub Button136109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109033.Click 'a' If kb36109033.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nb36109033.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(un36109033.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(hr36109033.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
'b' tiwi = data.Rows.Find(kb36109033.Text)
If tiwi Is Nothing Then tiwi = data.NewRow tiwi("KODEBARANG") = kb36109033.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Private Sub Button336109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109033.Click 'a' If nt36109033.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt36109033.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If data.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim browse As New ByIskandar.CariKeDataBaseByIskandar browse.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt36109033.Text, 1, CONECT) If browse.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim Coba As New OleDb.OleDbCommand Coba = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt36109033.Text & "', #" & DateTimePicker136109033.Value.Month & "/" & DateTimePicker136109033.Value.Day & "/" & DateTimePicker136109033.Value.Year & "#, '" & jt36109033.Text & "')", CONECT) CONECT.Open() Coba.ExecuteNonQuery() CONECT.Close()
'e' For Each t As DataRow In data.Rows Coba = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt36109033.Text & "','" & t("KODEBARANG") & "'," & t("UNIT") & ", " & t("HARGA") & ")", CONECT) CONECT.Open() Coba.ExecuteNonQuery() CONECT.Close() Coba.Dispose() Next
Public Class LATIHAN037_36109037 Dim n As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=2901911691") Dim dt As New DataTable Dim dr As DataRow
Private Sub Latihan37_36109037_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Juni As New OleDb.OleDbDataAdapter Juni = 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= '" & nt36109037.Text & "'", n) Juni.Fill(dt) Juni.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DataGridView1.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 Tot36109037.Text = TOT End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb36109037.Leave If kb36109037.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109037.Text, 1, n) If Pencari.JumlanBaris > 0 Then kb36109037.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb36109037.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub
Private Sub KB36109037_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109037.TextChanged nb36109037.Text = "" un36109037.Text = "" hr36109037.Text = "" End Sub
Public Class Latih37_36109034 Dim n As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=miss") Dim dt As New DataTable Dim dr As DataRow
Private Sub Latih37_36109034_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= '" & nt_36109034.Text & "'", n) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary DataGridView1.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 Tot_36109034.Text = TOT End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb_36109034.Leave If kb_36109034.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb_36109034.Text, 1, n) If Pencari.JumlanBaris > 0 Then kb_36109034.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb_36109034.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 kb_36109034.TextChanged nb_36109034.Text = "" un_36109034.Text = "" hr_36109034.Text = "" End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un_36109034.TextChanged, hr_36109034.TextChanged jm_36109034.Text = Val(un_36109034.Text) * Val(hr_36109034.Text) End Sub Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH.Click 'a' If kb_36109034.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nb_36109034.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(un_36109034.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(hr_36109034.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
'b' dr = dt.Rows.Find(kb_36109034.Text)
If dr Is Nothing Then dr = dt.NewRow dr("KODEBARANG") = kb_36109034.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN.Click 'a' If nt_36109034.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt_36109034.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_36109034.Text, 1, n) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim CM As New OleDb.OleDbCommand CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_36109034.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt_36109034.Text & "')", n) n.Open() CM.ExecuteNonQuery() n.Close()
'e' For Each X As DataRow In dt.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_36109034.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", n) n.Open() CM.ExecuteNonQuery() n.Close() CM.Dispose() Next
Public Class Latihan_037_36109045 'DEKLARASI CONECTION Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;jet OLEDB:database password=florista") 'deklarasi data tabel Dim DT As New DataTable Dim kolom(3) As DataColumn Dim cari As New ByIskandar.CariKeDataBaseByIskandar Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109045.Click kolom(0) = DT.Columns("kodebarang") DT.PrimaryKey = kolom Dim sary As DataRow sary = DT.Rows.Find(kb36109045.Text) If sary Is Nothing Then sary = DT.NewRow ' menambah baris sary("KODEBARANG") = kb36109045.Text sary("NAMABARANG") = nb36109045.Text sary("UNIT") = un36109045.Text sary("HARGA") = hr36109045.Text sary("JUMLAH") = jm36109045.Text DT.Rows.Add(sary)
Else MsgBox("baris sudah ada") kb36109045.Text = "" End If If kb36109045.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("kode barang belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If Val(un36109045.Text) = 0 Then 'untuk pencarian yang bersifat angka MsgBox("UNIT belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If Val(hr36109045.Text) = 0 Then 'untuk pencarian yang bersifat angka MsgBox("HARGA belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If kb36109045.Text = "" un36109045.Text = "" hr36109045.Text = "" nb36109045.Text = "" jm36109045.Text = "" lara() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap If nt36109045.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("no.transaksi belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If jt36109045.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("jenis transaksi belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada cari.AturPencarianDataBase("mastertransaksi", "notrans", nt36109045.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then MsgBox("NO.TRANS sudah ada") Exit Sub End If
If DT.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
'untuk memasukkan data dari visual basc ke dlm acces Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt36109045.Text & "',#" & DateTimePicker136109045.Value.Date & "#,'" & jt36109045.Text & "')", CONECT)
nt36109045.Text = "" jt36109045.Text = "" lara() End Sub Private Sub LATIHAN036012_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim chaca As New OleDb.OleDbDataAdapter chaca = New OleDb.OleDbDataAdapter("select detailtransaksi.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, (detailtransaksi.unit * detailtransaksi.harga) as jumlah from detailtransaksi inner join barang on detailtransaksi.kodebarang=barang.kodebarang WHERE detailtransaksi.NOTRANS='" & kb36109045.Text & "'", CONECT) 'memunculkan semua data dari tabel barang dlm acces DT.Rows.Clear() 'membersihkan data table chaca.Fill(DT) 'mengisi database ke dlm data table DataGridView1.DataSource = DT 'memunculkan dlm datagridview
chaca.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
End Sub
Private Sub NB_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nb36109045.Click cari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109045.Text, 1, CONECT) If cari.JumlanBaris > 0 Then nb36109045.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang baru") nb36109045.ReadOnly = False Exit Sub End If End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109045.TextChanged, hr36109045.TextChanged jm36109045.Text = Val(un36109045.Text) * Val(hr36109045.Text) End Sub Public Sub lara() Dim total As Double For Each x As DataRow In DT.Rows total = total + x("jumlah") Next Tot36109045.Text = total End Sub End Class
Dim Mt As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=150991") Dim DT As New DataTable Dim DR As DataRow
Private Sub Latihan37017_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= '" & nt_36109040.Text & "'", B) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DataGridView1.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 Tot_36109040.Text = TOT End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb_36109056.Leave If kb_36109040.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb_36109056.Text, 1, B) If Pencari.JumlanBaris > 0 Then kb_36109040.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb_36109040.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 kb_36109040.TextChanged nb_36109040.Text = "" un_36109040.Text = "" hr_36109040.Text = "" End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un_36109040.TextChanged, hr_36109040.TextChanged jm_36109040.Text = Val(un_36109040.Text) * Val(hr_36109040.Text) End Sub Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'a' If kb_36109040.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nb_36109040.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(un_36109040.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(hr_36109040.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
'b' DR = DT.Rows.Find(kb_36109040.Text)
If DR Is Nothing Then DR = DT.NewRow DR("KODEBARANG") = kb_36109040.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'a' If nt_36109040.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt_36109040.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If DT.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_36109040.Text, 1, Mt) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim CM As New OleDb.OleDbCommand CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_36109040.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt_36109040.Text & "')", Mt) Mt.Open() CM.ExecuteNonQuery() Mt.Close()
'e' For Each X As DataRow In DT.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_36109056.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", Mt) Mt.Open() CM.ExecuteNonQuery() Mt.Close() CM.Dispose() Next
Public Class LATIHAN037035 Dim Jalan As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Application.StartupPath & "\Datamajemuk.ACCDB") Dim gitik As New DataTable Private Sub botto() Dim ttotal As Integer For Each hasil As DataRow In gitik.Rows ttotal += hasil("Jumlah") Next Tot035.Text = ttotal End Sub Private Sub Latihan037035_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'mendeklarasikan kendaraan Dim bojel As New OleDb.OleDbDataAdapter
'Mengatur data yang akan di angkut bojel = New OleDb.OleDbDataAdapter("SELECT detailtransaksi.kodebarang,barang.namabarang,detailtransaksi.unit,detailtransaksi.harga, detailtransaksi.unit * detailtransaksi.harga as jumlah FROM DETAILTRANSAKSI inner join barang on detailtransaksi.kodebarang=barang.kodebarang where detailtransaksi.notrans='" & nt035.Text & "'", Jalan)
'bersihkan data gitik.Rows.Clear()
'untuk memasukkan data yg telah di angkut ke dalam datatable bojel.Fill(gitik)
'untuk menampilkan isi datatable ke data grid view bojel.Dispose() DataGridView1035.DataSource = gitik
'perintah primarykey Dim kabotcibay(2) As DataColumn kabotcibay(0) = gitik.Columns("Kodebarang") gitik.PrimaryKey = kabotcibay End Sub Private Sub kb035_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb035.Leave If kb035.Text.Length = 0 Then Exit Sub End If
'mencari data yang ada di tabel Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("barang", "kodebarang", kb035.Text, 1, Jalan) If Pencari.JumlanBaris > 0 Then nb035.Text = Pencari.DataTablenya.Rows(0).Item(1) Else MsgBox("the data is not exist") kb035.Text = "" nb035.Text = "" Exit Sub End If
End Sub Private Sub Button1035_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1035.Click 'Memeriksa isi textbox If kb035.Text.Length = 0 Then MsgBox("Please, insert the code of goods") Exit Sub End If
If un035.Text.Length = 0 Then MsgBox("Please, insert the unit of goods") Exit Sub End If
If hr035.Text.Length = 0 Then MsgBox("Please, insert the cost of goods") Exit Sub End If
'perintah pencarian data Dim dr As DataRow dr = gitik.Rows.Find(kb035.Text) If Not dr Is Nothing Then MsgBox("Sorry, the data has been exist!!! Please insert new data") Exit Sub End If
'penyimpanan data ke datatable gitik.Rows.Add(kb035.Text, nb035.Text, Val(un035.Text), Val(hr035.Text), jm035.Text)
botto()
'mengosongkan textbox kb035.Text = "" nb035.Text = "" un035.Text = "" hr035.Text = "" jm035.Text = "" End Sub
Private Sub un035_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un035.TextChanged, hr035.TextChanged jm035.Text = Val(un035.Text) * Val(hr035.Text) End Sub Private Sub Button3035_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3035.Click 'Memeriksa isi textbox If nt035.Text.Length = 0 Then MsgBox("Please, insert the Number of the transaction") Exit Sub End If
If jt035.Text.Length = 0 Then MsgBox("Please, insert the type of the transaction") Exit Sub End If
If gitik.Rows.Count = 0 Then MsgBox("the data is none") Exit Sub End If
'Memeriksa nomor transaksi pd master transaksi Dim search As New ByIskandar.CariKeDataBaseByIskandar search.AturPencarianDataBase("mastertransaksi", "notrans", nt035.Text, 1, Jalan) If search.JumlanBaris > 0 Then MsgBox("the code has been exist") Exit Sub End If
'Proses Penyimpanan ke tabel master transaksi Dim kacci As New OleDb.OleDbCommand kacci = New OleDb.OleDbCommand("insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values ('" & nt035.Text & "',#" & DateTimePicker1035.Value.Month & "/" & DateTimePicker1035.Value.Day & "/" & DateTimePicker1035.Value.Year & "#,'" & jt035.Text & "')", Jalan) Jalan.Open() kacci.ExecuteNonQuery() Jalan.Close()
'penyimpanan isi datatable ke detail transaksi For Each nhana As DataRow In gitik.Rows kacci = New OleDb.OleDbCommand("insert into detailtransaksi (notrans,kodebarang,unit,harga) values ('" & nt035.Text & "','" & nhana("kodebarang") & "'," & nhana("unit") & "," & nhana("harga") & ")", Jalan) Jalan.Open() kacci.ExecuteNonQuery() Jalan.Close()
Next kacci.Dispose()
'Mengosongkan isi text box nt035.Text = "" jt035.Text = ""
Dim conect As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=wirda") Dim dt As New DataTable Dim dr As DataRow
Private Sub Latihan037_36109049_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim wirda As New OleDb.OleDbDataAdapter wirda = 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= '" & TextBox1_36109049.Text & "'", conect) wirda.Fill(dt) wirda.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DGV1_36109049.DataSource = dt End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double For Each x As DataRow In dt.Rows TOT = TOT + x("JUMLAH") Next Tot1.Text = TOT End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB_36109049.Leave If KB_36109049.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KB_36109049.Text, 1, conect) If Pencari.JumlanBaris > 0 Then KB_36109049.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") NB_36109049.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 KB_36109049.TextChanged NB_36109049.Text = "" UN_36109049.Text = "" HR_36109049.Text = "" End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UN_36109049.TextChanged, HR_36109049.TextChanged JM_36109049.Text = Val(UN_36109049.Text) * Val(HR_36109049.Text) End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'a' If TextBox1_36109049.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If TextBox2_36109049.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If dt.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox1_36109049.Text, 1, conect) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim wirdapaulus As New OleDb.OleDbCommand wirdapaulus = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & TextBox1_36109049.Text & "', #" & DTP1_36109049.Value.Month & "/" & DTP1_36109049.Value.Day & "/" & DTP1_36109049.Value.Year & "#, '" & TextBox2_36109049.Text & "')", conect) conect.Open() wirdapaulus.ExecuteNonQuery() conect.Close()
'e' For Each X As DataRow In dt.Rows wirdapaulus = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox1_36109049.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", conect) conect.Open() wirdapaulus.ExecuteNonQuery() conect.Close() wirdapaulus.Dispose() Next
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'a' If KB_36109049.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If NB_36109049.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(UN_36109049.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(HR_36109049.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
'b' dr = dt.Rows.Find(KB_36109049.Text)
If dr Is Nothing Then dr = dt.NewRow dr("KODEBARANG") = KB_36109049.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Public Class LATIHAN03736109038 Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=icha") Dim DT As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub LATIHAN03736109038_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim Azizah As New OleDb.OleDbDataAdapter Azizah = New OleDb.OleDbDataAdapter("select detailtransaksi.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= '" & KB36109038.Text & "'", CONECT) DT.Rows.Clear() Azizah.Fill(DT)
Azizah.Dispose()
Dim dcp(1) As DataColumn dcp(0) = DT.Columns("kodebarang") DT.PrimaryKey = dcp
DataGridView136109038.DataSource = DT End Sub
Private Sub hitung() Dim cantik As Integer For Each r As DataRow In DT.Rows cantik = cantik + r("JUMLAH") Next Tot36109038.Text = cantik End Sub
Private Sub UN36109038_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles UN36109038.TextChanged, HR36109038.TextChanged JM36109038.Text = Val(UN36109038.Text) * Val(HR36109038.Text) End Sub
Private Sub KB36109038_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB36109038.Leave If KB36109038.Text.Length = 0 Then Exit Sub End If
If cari.JumlanBaris > 0 Then KB36109038.Text = cari.DataTablenya.Rows(0).Item("KodeBarang") NB36109038.Text = cari.DataTablenya.Rows(0).Item("namabarang") Else MsgBox("Kode barang tersebut tidak ada") KB36109038.Text = "" Exit Sub End If End Sub
Private Sub KB36109038_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB36109038.TextChanged NB36109038.Text = "" UN36109038.Text = "" HR36109038.Text = "" End Sub
Private Sub Button136109038_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button136109038.Click If KB36109038.Text.Length = 0 Then MsgBox("kode barang belum terisi") Exit Sub End If
If Val(UN36109038.Text) = 0 Then MsgBox("UNIT belum terisi") Exit Sub End If
If Val(HR36109038.Text) = 0 Then MsgBox("HARGA belum terisi") Exit Sub End If
Dim Reza As DataRow Reza = DT.Rows.Find(KB36109038.Text) If Reza Is Nothing Then
Reza = DT.NewRow Reza("kodebarang") = KB36109038.Text Reza("namabarang") = NB36109038.Text Reza("unit") = UN36109038.Text Reza("harga") = HR36109038.Text Reza("jumlah") = JM36109038.Text DT.Rows.Add(Reza) Else MsgBox("nomor sudah ada") End If
Private Sub Button336109038_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button336109038.Click If NT36109038.Text.Length = 0 Then MsgBox("no.transaksi belum terisi") Exit Sub End If
If JT36109038.Text.Length = 0 Then MsgBox("jenis transaksi belum terisi") Exit Sub End If
If DT.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
If cari.JumlanBaris > 0 Then MsgBox("NO.TRANS sudah ada") Exit Sub End If
Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT36109038.Text & "',#" & DateTimePicker136109038.Value.Date & "#," & Val(JT36109038.Text) & ")", CONECT)
Dim sambung As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=jayapura") Dim toshiba As New DataTable Dim nokia As DataRow
Private Sub LATIHAN03736109032_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim laptop As New OleDb.OleDbDataAdapter laptop = 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.Text & "'", sambung) laptop.Fill(toshiba) laptop.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = toshiba.Columns("KODEBARANG") toshiba.PrimaryKey = dataPrimary
DataGridView1.DataSource = toshiba
End Sub
Private Sub TOTALJUMLAH() Dim TOTJUM As Double For Each x As DataRow In toshiba.Rows TOTJUM = TOTJUM + x("JUMLAH") Next TOT.Text = TOTJUM 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
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KB.Text, 1, sambung)
If Pencari.JumlanBaris > 0 Then KB.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") NB.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 KB.TextChanged NB.Text = "" UN.Text = "" HR.Text = "" End Sub
Private Sub UN_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UN.TextChanged, HR.TextChanged JM.Text = Val(UN.Text) * Val(HR.Text) End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'a' If KB.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If NB.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(UN.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(HR.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
'b' nokia = toshiba.Rows.Find(KB.Text)
If nokia Is Nothing Then nokia = toshiba.NewRow nokia("KODEBARANG") = KB.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 'a' If NT.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If JT.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If toshiba.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim angka As New ByIskandar.CariKeDataBaseByIskandar angka.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT.Text, 1, sambung) If angka.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim huruf As New OleDb.OleDbCommand huruf = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & JT.Text & "')", sambung) sambung.Open() huruf.ExecuteNonQuery() sambung.Close()
'e' For Each X As DataRow In toshiba.Rows huruf = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", sambung) sambung.Open() huruf.ExecuteNonQuery() sambung.Close() huruf.Dispose() Next
Public Class LATIHAN037041 'DEKLARASI CONECTION Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb; Jet OLEDB:Database Password=12") 'deklarasi data tabel Dim DT As New DataTable Dim kolom(3) As DataColumn Dim cari As New ByIskandar.CariKeDataBaseByIskandar Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109041.Click kolom(0) = DT.Columns("kodebarang") DT.PrimaryKey = kolom Dim drzany As DataRow drzany = DT.Rows.Find(kb36109041.Text) If drzany Is Nothing Then drzany = DT.NewRow ' menambah baris drzany("KODEBARANG") = kb36109041.Text drzany("NAMABARANG") = nb36109041.Text drzany("UNIT") = un36109041.Text drzany("HARGA") = hr36109041.Text drzany("JUMLAH") = jm36109041.Text DT.Rows.Add(drzany)
Else MsgBox("baris sudah ada") kb36109041.Text = "" End If If kb36109041.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("kode barang belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If Val(un36109041.Text) = 0 Then 'untuk pencarian yang bersifat angka MsgBox("UNIT belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If Val(hr36109041.Text) = 0 Then 'untuk pencarian yang bersifat angka MsgBox("HARGA belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If kb36109041.Text = "" un36109041.Text = "" hr36109041.Text = "" nb36109041.Text = "" jm36109041.Text = "" farid() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109041.Click 'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap If nt36109041.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("no.transaksi belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If jt36109041.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("jenis transaksi belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada cari.AturPencarianDataBase("mastertransaksi", "notrans", nt36109041.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then MsgBox("NO.TRANS sudah ada") Exit Sub End If
If DT.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
'untuk memasukkan data dari visual basc ke dlm acces Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt36109041.Text & "',#" & DTP136109041.Value.Date & "#,'" & jt36109041.Text & "')", CONECT)
nt36109041.Text = "" jt36109041.Text = "" farid() End Sub Private Sub LATIHAN036012_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 detailtransaksi.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, (detailtransaksi.unit * detailtransaksi.harga) as jumlah from detailtransaksi inner join barang on detailtransaksi.kodebarang=barang.kodebarang WHERE detailtransaksi.NOTRANS='" & kb36109041.Text & "'", CONECT) 'memunculkan semua data dari tabel barang dlm acces DT.Rows.Clear() 'membersihkan data table nisa.Fill(DT) 'mengisi database ke dlm data table DataGridView1.DataSource = DT 'memunculkan dlm datagridview
nisa.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
End Sub
Private Sub NB_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nb36109041.Click cari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109041.Text, 1, CONECT) If cari.JumlanBaris > 0 Then nb36109041.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang baru") nb36109041.ReadOnly = False Exit Sub End If End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109041.TextChanged, hr36109041.TextChanged jm36109041.Text = Val(un36109041.Text) * Val(hr36109041.Text) End Sub Public Sub farid() Dim total As Double For Each x As DataRow In DT.Rows total = total + x("jumlah") Next Tot36109041.Text = total End Sub
Private Sub Button336109048_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button336109048.Click If NT36109048.Text.Length = 0 Then MsgBox("no.transaksi belum terisi") Exit Sub End If
If JT36109048.Text.Length = 0 Then MsgBox("jenis transaksi belum terisi") Exit Sub End If
If DT.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
If cari.JumlanBaris > 0 Then MsgBox("NO.TRANS sudah ada") Exit Sub End If
Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT36109048.Text & "',#" & DateTimePicker136109048.Value.Date & "#," & Val(JT36109048.Text) & ")", CONECT)
Dim F As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=2312") Dim DT As New DataTable Dim DR As DataRow
Private Sub Latihan_3736109055_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= '" & nt36109055.Text & "'", F) X.Fill(dt) X.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = dt.Columns("KODEBARANG") dt.PrimaryKey = dataPrimary
DataGridView136109055.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 Tot36109055.Text = TOT End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb36109055.Leave If kb36109055.Text.Length = 0 Then Exit Sub End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109055.Text, 1, F) If Pencari.JumlanBaris > 0 Then kb36109055.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG") nb36109055.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 kb36109055.TextChanged nb36109055.Text = "" un36109055.Text = "" hr36109055.Text = "" End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109055.TextChanged, hr36109055.TextChanged jm36109055.Text = Val(un36109055.Text) * Val(hr36109055.Text) End Sub Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'a' If kb36109055.Text.Length = 0 Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nb36109055.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(un36109055.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(hr36109055.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
'b' DR = DT.Rows.Find(kb36109055.Text)
If DR Is Nothing Then DR = DT.NewRow DR("KODEBARANG") = kb36109055.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'a' If nt36109055.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt36109055.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If DT.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt36109055.Text, 1, F) If pencari.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim CM As New OleDb.OleDbCommand CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt36109055.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109055.Text & "')", F) F.Open() CM.ExecuteNonQuery() F.Close()
'e' For Each X As DataRow In DT.Rows CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt36109055.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", F) F.Open() CM.ExecuteNonQuery() F.Close() CM.Dispose() Next
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= D:\berbagi\LATIHAN 35-40 DATA MAJEMUK\DataMajemuk.accdb;Jet OLEDB:Database Password=salam") Dim DT As New DataTable Dim kolom(3) As DataColumn Dim cari As New ByIskandar.CariKeDataBaseByIskandar Private Sub Button136109054_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109054.Click kolom(0) = DT.Columns("kodebarang") DT.PrimaryKey = kolom Dim drzany As DataRow drzany = DT.Rows.Find(kb36109054.Text) If drzany Is Nothing Then drzany = DT.NewRow drzany("KODEBARANG") = kb36109054.Text drzany("NAMABARANG") = nb36109054.Text drzany("UNIT") = un36109054.Text drzany("HARGA") = hr36109054.Text drzany("JUMLAH") = jm36109054.Text DT.Rows.Add(drzany)
Else MsgBox("baris sudah ada") kb36109054.Text = "" End If If kb36109054.Text.Length = 0 Then MsgBox("kode barang belum terisi") Exit Sub End If
If Val(un36109054.Text) = 0 Then MsgBox("UNIT belum terisi") Exit Sub End If
If Val(hr36109054.Text) = 0 Then MsgBox("HARGA belum terisi") Exit Sub End If kb36109054.Text = "" un36109054.Text = "" hr36109054.Text = "" nb36109054.Text = "" jm36109054.Text = "" wawan() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109054.Click If nt36109054.Text.Length = 0 Then MsgBox("no.transaksi belum terisi") Exit Sub End If
If jt36109054.Text.Length = 0 Then MsgBox("jenis transaksi belum terisi") Exit Sub End If
If cari.JumlanBaris > 0 Then MsgBox("NO.TRANS sudah ada") Exit Sub End If
If DT.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt36109054.Text & "',#" & DTP136109054.Value.Date & "#,'" & jt36109054.Text & "')", CONECT)
Part 2 CONECT.Open() com.ExecuteNonQuery() CONECT.Close() com.Dispose()
Next
DT.Rows.Clear()
nt36109054.Text = "" jt36109054.Text = "" wawan() End Sub Private Sub LATIHAN036012_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 detailtransaksi.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, (detailtransaksi.unit * detailtransaksi.harga) as jumlah from detailtransaksi inner join barang on detailtransaksi.kodebarang=barang.kodebarang WHERE detailtransaksi.NOTRANS='" & kb36109054.Text & "'", CONECT) 'memunculkan semua data dari tabel barang dlm acces DT.Rows.Clear() nisa.Fill(DT) ' DGV136109054.DataSource = DT
nisa.Dispose()
End Sub
Private Sub label4_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click cari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109054.Text, 1, CONECT) If cari.JumlanBaris > 0 Then nb36109054.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang baru") nb36109054.ReadOnly = False Exit Sub End If End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109054.TextChanged, hr36109054.TextChanged jm36109054.Text = Val(un36109054.Text) * Val(hr36109054.Text) End Sub Public Sub wawan() Dim total As Double For Each x As DataRow In DT.Rows total = total + x("jumlah") Next Tot36109054.Text = total End Sub End Class
Public Class Form3736109050 Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=nideria") Dim data As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Form3736109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim adapt As New OleDb.OleDbDataAdapter adapt = New OleDb.OleDbDataAdapter("select detailtransaksi.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= '" & kb.Text & "'", CONECT) 'memunculkan semua data dari tabel barang dlm acces data.Rows.Clear() adapt.Fill(data) adapt.Dispose() Dim dcp(1) As DataColumn dcp(0) = data.Columns("kodebarang") data.PrimaryKey = dcp DataGridView1.DataSource = data End Sub
Private Sub hitung() Dim intr As Integer For Each r As DataRow In data.Rows intr = intr + r("JUMLAH") Next Tot.Text = intr End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un.TextChanged, hr.TextChanged jm.Text = Val(un.Text) * Val(hr.Text) 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 kb_Leave(ByVal sender As System.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, CONECT) 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 tersebut tidak ada") kb.Text = "" Exit Sub End If End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.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 simpan As DataRow simpan = data.Rows.Find(kb.Text) If simpan Is Nothing Then simpan = data.NewRow simpan("kodebarang") = kb.Text simpan("namabarang") = nb.Text simpan("unit") = un.Text simpan("harga") = hr.Text simpan("jumlah") = jm.Text data.Rows.Add(simpan) Else MsgBox("nomor sudah ada") End If
kb.Text = "" un.Text = "" hr.Text = "" hitung() End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If nt.Text.Length = 0 Then MsgBox("no.transaksi belum terisi") Exit Sub End If
If jt.Text.Length = 0 Then MsgBox("jenis transaksi belum terisi") Exit Sub End If
If data.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
If cari.JumlanBaris > 0 Then MsgBox("NO.TRANS sudah ada") Exit Sub End If
Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt.Text & "',#" & DateTimePicker1.Value.Date & "#," & Val(jt.Text) & ")", CONECT) CONECT.Open() com.ExecuteNonQuery() CONECT.Close()
For Each r As DataRow In data.Rows com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & nt.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT) CONECT.Open() com.ExecuteNonQuery() CONECT.Close() com.Dispose() Next
nt.Text = "" jt.Text = "" jm.Text = "" Tot.Text = "" data.Rows.Clear() hitung() End Sub End Class
'DEKLARASI CONECTION Dim CONNECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;jet oledb:database password = hapsari") 'deklarasi data tabel Dim DT As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub LATIHAN03736109029_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'deklarasi adapter Dim CUTE As New OleDb.OleDbDataAdapter CUTE = New OleDb.OleDbDataAdapter("select detailtransaksi.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= '" & kb36109029.Text & "'", CONNECT) 'memunculkan semua data dari tabel barang dlm acces DT.Rows.Clear() 'membersihkan data table CUTE.Fill(DT) 'mengisi database ke dlm data table
CUTE.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
'rumus dibwh ini untuk membuat primary key dimana dcp adalah nama sembarangji Dim dcp(1) As DataColumn dcp(0) = DT.Columns("kodebarang") DT.PrimaryKey = dcp
DataGridView1.DataSource = DT 'memunculkan dlm datagridview End Sub
Private Sub hitung() Dim INDAH As Integer For Each r As DataRow In DT.Rows INDAH = INDAH + r("JUMLAH") Next Tot36109029.Text = INDAH
End Sub
Private Sub un36109029_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109029.TextChanged, hr36109029.TextChanged jm36109029.Text = Val(un36109029.Text) * Val(hr36109029.Text) End Sub
Private Sub kb36109029_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109029.TextChanged nb36109029.Text = "" un36109029.Text = "" hr36109029.Text = ""
End Sub 'moment mencari saat kursor meninggalkan texbox Private Sub kb36109029_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109029.Leave If kb36109029.Text.Length = 0 Then 'jika kodebarang tidak diisi jgn lanjutkan perintah selanjutnya Exit Sub End If
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada cari.AturPencarianDataBase("barang", "kodebarang", kb36109029.Text, 1, CONNECT) '1 untuk huruf
If cari.JumlanBaris > 0 Then 'jika barang yg kita cari ada dlm table kb36109029.Text = cari.DataTablenya.Rows(0).Item("KodeBarang") nb36109029.Text = cari.DataTablenya.Rows(0).Item("namabarang") Else MsgBox("Kode barang tersebut tidak ada") kb36109029.Text = "" Exit Sub End If End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109029.Click 'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap If kb36109029.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("kode barang belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If If Val(un36109029.Text) = 0 Then 'untuk pencarian yang bersifat angka MsgBox("UNIT belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If Val(hr36109029.Text) = 0 Then 'untuk pencarian yang bersifat angka MsgBox("HARGA belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
'UNTUK MENYMPAN DATA YG DIMASUKKAN KE DALAM DATAGRIDVIEW Dim INDAH As DataRow INDAH = DT.Rows.Find(kb36109029.Text) 'untuk mencari apakah ada no.pembelian sdh ada agar tdak double If INDAH Is Nothing Then 'jika tidak ad ji maka lanjutkan penyimpanan
INDAH = DT.NewRow ' menambah baris INDAH("kodebarang") = kb36109029.Text INDAH("namabarang") = nb36109029.Text INDAH("unit") = un36109029.Text INDAH("harga") = hr36109029.Text INDAH("jumlah") = jm36109029.Text DT.Rows.Add(INDAH) Else MsgBox("nomor sudah ada") End If
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap If nt36109029.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("no.transaksi belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If jt36109029.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("jenis transaksi belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If DT.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada cari.AturPencarianDataBase("mastertransaksi", "notrans", nt36109029.Text, 1, CONNECT)
If cari.JumlanBaris > 0 Then MsgBox("NO.TRANS sudah ada") Exit Sub End If
'untuk memasukkan data dari visual basc ke dlm acces Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt36109029.Text & "',#" & DateTimePicker1.Value.Date & "#," & Val(jt36109029.Text) & ")", CONNECT)
ublic Class LATIHAN03736109036 Dim CONECT As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=100191") Dim data As New DataTable Dim iben As DataRow
Private Sub LATIHAN03736109036_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim ibnu As New OleDb.OleDbDataAdapter ibnu = 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= '" & nt36109036.Text & "'", CONECT) ibnu.Fill(data) ibnu.Dispose()
Dim dataPrimary(1) As DataColumn dataPrimary(0) = data.Columns("KODEBARANG") data.PrimaryKey = dataPrimary
DataGridView1.DataSource = data End Sub
Private Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each t As DataRow In data.Rows TOT = TOT + t("JUMLAH") Next Tot36109036.Text = TOT End Sub
Private Sub KB36109036_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb36109036.Leave If kb36109036.Text.Length = 0 Then Exit Sub End If
Dim browse As New ByIskandar.CariKeDataBaseByIskandar browse.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109036.Text, 1, CONECT) If browse.JumlanBaris > 0 Then kb36109036.Text = browse.DataTablenya.Rows(0).Item("KODEBARANG") nb36109036.Text = browse.DataTablenya.Rows(0).Item("NAMABARANG") Else MsgBox("Kode barang tersebut tidak ada") Exit Sub End If End Sub Private Sub kb36109036_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109036.TextChanged nb36109036.Text = "" un36109036.Text = "" hr36109036.Text = "" End Sub Private Sub un36109036_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109036.TextChanged, hr36109036.TextChanged jm36109036.Text = Val(un36109036.Text) * Val(hr36109036.Text) End Sub
Private Sub Button136109036_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109036.Click 'a' If kb36109036.Text.Length Then MsgBox("Kode barang sudah ada") Exit Sub End If
If nb36109036.Text.Length = 0 Then MsgBox("Nama barang sudah ada") End If
If Val(un36109036.Text) = 0 Then MsgBox("Masukkan unit barang") Exit Sub End If
If Val(hr36109036.Text) = 0 Then MsgBox("Masukkan harga barang barang") Exit Sub End If
'b' iben = data.Rows.Find(kb36109036.Text)
If iben Is Nothing Then iben = data.NewRow iben("KODEBARANG") = kb36109036.Text Else MsgBox("Maaf kodebarang sudah ada") Exit Sub End If
Private Sub Button366109036_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button366109036.Click 'a' If nt36109036.Text.Length = 0 Then MsgBox("No. transaksi sudah ada") Exit Sub End If
If jt36109036.Text.Length = 0 Then MsgBox("Jenis transaksi sudah ada") Exit Sub End If
'b' If data.Rows.Count = 0 Then MsgBox("Jumlah baris tidak terisi") Exit Sub End If
'c' Dim browse As New ByIskandar.CariKeDataBaseByIskandar browse.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt36109036.Text, 1, CONECT) If browse.JumlanBaris > 0 Then MsgBox("data tersebut sudah ada") Exit Sub End If
'd' Dim Coba As New OleDb.OleDbCommand Coba = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt36109036.Text & "', #" & DateTimePicker136109036.Value.Month & "/" & DateTimePicker136109036.Value.Day & "/" & DateTimePicker136109036.Value.Year & "#, '" & jt36109036.Text & "')", CONECT) CONECT.Open() Coba.ExecuteNonQuery() CONECT.Close()
'e' For Each t As DataRow In data.Rows Coba = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt36109036.Text & "','" & t("KODEBARANG") & "'," & t("UNIT") & ", " & t("HARGA") & ")", CONECT) CONECT.Open() Coba.ExecuteNonQuery() CONECT.Close() Coba.Dispose() Next
Public Class Form3736108001 Dim INCE As New OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb;Jet OLEDB:Database Password=36108001") Dim LOVE As New DataTable Dim AYI As New ByIskandar.CariKeDataBaseByIskandar Public Sub AI() Dim YNK As New OleDb.OleDbDataAdapter YNK = New OleDb.OleDbDataAdapter("Select BARANG.KodeBarang, BARANG.NamaBarang, DETAILTRANSAKSI.unit, DETAILTRANSAKSI.Harga, DETAILTRANSAKSI.Unit * DETAILTRANSAKSI.harga AS Jumlah FROM BARANG INNER JOIN detailtransaksi ON BARANG.KODEBARANG=DETAILTRANSAKSI.KODEBARANG Where notrans='" & T136108001.Text & "' ", INCE) LOVE.Rows.Clear() YNK.Fill(LOVE) YNK.Dispose()
DGV36108001.DataSource = LOVE End Sub Private Sub Form3736108001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AI() Dim PK(1) As DataColumn PK(0) = LOVE.Columns("KODEBARANG") LOVE.PrimaryKey = PK End Sub Private Sub TOTAL() Dim LO As Integer For Each VE As DataRow In LOVE.Rows LO = LO + VE("Jumlah") Next T836108001.Text = LO End Sub Private Sub T536108001_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T536108001.TextChanged, T636108001.TextChanged T736108001.Text = Val(T536108001.Text) * Val(T636108001.Text) End Sub Private Sub T336108001_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T336108001.TextChanged T436108001.Text = "" T536108001.Text = "" T636108001.Text = "" End Sub Private Sub T336108001_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T336108001.Leave If T336108001.Text.Length = 0 Then Exit Sub End If Dim IA As New ByIskandar.CariKeDataBaseByIskandar IA.AturPencarianDataBase("barang", "kodebarang", T336108001.Text, 1, INCE) If IA.JumlanBaris > 0 Then T336108001.Text = IA.DataTablenya.Rows(0).Item("KodeBarang") T436108001.Text = IA.DataTablenya.Rows(0).Item("NamaBarang") T636108001.Text = IA.DataTablenya.Rows(0).Item("HargaJual") Else MsgBox("Kode barang tersbut tidak ada") Exit Sub End If End Sub
Private Sub B136108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B136108001.Click If T336108001.Text.Length = 0 Then MsgBox("Kode Barang belum terisi") Exit Sub End If
If Val(T536108001.Text) = 0 Then MsgBox("Unit belum terisi") Exit Sub End If
If Val(T636108001.Text) = 0 Then MsgBox("Harga belum terisi") Exit Sub End If
If LOVE.Rows.Find(T336108001.Text) Is Nothing Then LOVE.Rows.Add(T336108001.Text, T436108001.Text, Val(T536108001.Text), Val(T636108001.Text), Val(T736108001.Text)) Else MsgBox("Kode barang sudah ada") End If
T336108001.Text = "" T536108001.Text = "" T636108001.Text = "" TOTAL() End Sub Private Sub B236108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B236108001.Click If T136108001.Text.Length = 0 Then MsgBox("Nomor transaksi belum terisi") Exit Sub End If
If T236108001.Text.Length = 0 Then MsgBox("Jenis transaksi belum terisi") Exit Sub End If
If LOVE.Rows.Count = 0 Then MsgBox("Data tidak terisi") Exit Sub End If
Private Sub Button336109044_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109044.Click If NT36109044.Text.Length = 0 Then MsgBox("no.transaksi belum terisi") Exit Sub End If
If JT36109044.Text.Length = 0 Then MsgBox("jenis transaksi belum terisi") Exit Sub End If
If DT.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
If cari.JumlanBaris > 0 Then MsgBox("NO.TRANS sudah ada") Exit Sub End If
Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT36109044.Text & "',#" & DateTimePicker136109044.Value.Date & "#," & Val(JT36109044.Text) & ")", CONECT)
lanjutan..
BalasHapusPrivate Sub B236108001_Click(ByVal sender As System.Object, ByVal AULIA As System.EventArgs) Handles B236108001.Click
If T136108001.Text.Length = 0 Then
MsgBox("Nomor transaksi belum terisi")
Exit Sub
End If
If T236108001.Text.Length = 0 Then
MsgBox("Jenis transaksi belum terisi")
Exit Sub
End If
If LOVE.Rows.Count = 0 Then
MsgBox("Data tidak terisi")
Exit Sub
End If
AYI.AturPencarianDataBase("mastertransaksi", "NOTRANS", T136108001.Text, 1, INCE)
If AYI.JumlanBaris > 0 Then
MsgBox("Nomor transaksi tersebut sudah ada")
Exit Sub
End If
Dim ANHYE As New OleDb.OleDbCommand
Dim VENUS As String
VENUS = "INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & T136108001.Text & "', #" & DTP36108001.Value.Date & "#, '" & T236108001.Text & "');"
ANHYE = New OleDb.OleDbCommand(VENUS, INCE)
INCE.Open()
ANHYE.ExecuteNonQuery()
INCE.Close()
For Each ARHY As DataRow In LOVE.Rows
Dim EGIET As String
EGIET = "INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & T136108001.Text & "', '" & ARHY("KODEBARANG") & "', '" & ARHY("UNIT") & "', '" & ARHY("HARGA") & "');"
ANHYE = New OleDb.OleDbCommand(EGIET, INCE)
INCE.Open()
ANHYE.ExecuteNonQuery()
INCE.Close()
Next
ANHYE.Dispose()
T136108001.Text = ""
T236108001.Text = ""
T736108001.Text = ""
T836108001.Text = ""
AI()
TOTAL()
End Sub
End Class
Public Class Latihan_037_36109056
BalasHapusDim B As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=2422")
Dim DT As New DataTable
Dim DR As DataRow
Private Sub Latihan37017_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= '" & nt_36109056.Text & "'", B)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DataGridView1.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
Tot_36109056.Text = TOT
End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb_36109056.Leave
If kb_36109056.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb_36109056.Text, 1, B)
If Pencari.JumlanBaris > 0 Then
kb_36109056.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb_36109056.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 kb_36109056.TextChanged
nb_36109056.Text = ""
un_36109056.Text = ""
hr_36109056.Text = ""
End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un_36109056.TextChanged, hr_36109056.TextChanged
jm_36109056.Text = Val(un_36109056.Text) * Val(hr_36109056.Text)
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'a'
If kb_36109056.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb_36109056.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un_36109056.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr_36109056.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
DR = DT.Rows.Find(kb_36109056.Text)
If DR Is Nothing Then
DR = DT.NewRow
DR("KODEBARANG") = kb_36109056.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
DR = DT.NewRow
DR("KODEBARANG") = kb_36109056.Text
DR("NAMABARANG") = nb_36109056.Text
DR("UNIT") = un_36109056.Text
DR("HARGA") = hr_36109056.Text
DR("JUMLAH") = jm_36109056.Text
DT.Rows.Add(DR)
'd'
kb_36109056.Text = ""
nb_36109056.Text = ""
un_36109056.Text = ""
hr_36109056.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
BalasHapus'a'
If nt_36109056.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt_36109056.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If DT.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_36109056.Text, 1, B)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_36109056.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt_36109056.Text & "')", B)
B.Open()
CM.ExecuteNonQuery()
B.Close()
'e'
For Each X As DataRow In DT.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_36109056.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", B)
B.Open()
CM.ExecuteNonQuery()
B.Close()
CM.Dispose()
Next
'f'
nt_36109056.Text = ""
jt_36109056.Text = ""
jm_36109056.Text = ""
'g'
DT.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
Public Class LATIHAN03736109033
BalasHapusDim CONECT As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=tahir")
Dim data As New DataTable
Dim tiwi As DataRow
Private Sub LATIHAN03736109033_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim pratiwi As New OleDb.OleDbDataAdapter
pratiwi = 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= '" & nt36109033.Text & "'", CONECT)
pratiwi.Fill(data)
pratiwi.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = data.Columns("KODEBARANG")
data.PrimaryKey = dataPrimary
DataGridView1.DataSource = data
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each t As DataRow In data.Rows
TOT = TOT + t("JUMLAH")
Next
Tot36109033.Text = TOT
End Sub
Private Sub KB36109033_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb36109033.Leave
If kb36109033.Text.Length = 0 Then
Exit Sub
End If
Dim browse As New ByIskandar.CariKeDataBaseByIskandar
browse.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109033.Text, 1, CONECT)
If browse.JumlanBaris > 0 Then
kb36109033.Text = browse.DataTablenya.Rows(0).Item("KODEBARANG")
nb36109033.Text = browse.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub kb36109033_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109033.TextChanged
nb36109033.Text = ""
un36109033.Text = ""
hr36109033.Text = ""
End Sub
Private Sub un36109033_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109033.TextChanged
jm36109033.Text = Val(un36109033.Text) * Val(hr36109033.Text)
End Sub
Private Sub Button136109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109033.Click
'a'
If kb36109033.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb36109033.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un36109033.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr36109033.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
tiwi = data.Rows.Find(kb36109033.Text)
If tiwi Is Nothing Then
tiwi = data.NewRow
tiwi("KODEBARANG") = kb36109033.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
tiwi = data.NewRow
tiwi("KODEBARANG") = kb36109033.Text
tiwi("NAMABARANG") = nb36109033.Text
tiwi("UNIT") = un36109033.Text
tiwi("HARGA") = hr36109033.Text
tiwi("JUMLAH") = jm36109033.Text
data.Rows.Add(tiwi)
'd'
kb36109033.Text = ""
nb36109033.Text = ""
un36109033.Text = ""
hr36109033.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub Button336109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109033.Click
BalasHapus'a'
If nt36109033.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt36109033.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If data.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim browse As New ByIskandar.CariKeDataBaseByIskandar
browse.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt36109033.Text, 1, CONECT)
If browse.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim Coba As New OleDb.OleDbCommand
Coba = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt36109033.Text & "', #" & DateTimePicker136109033.Value.Month & "/" & DateTimePicker136109033.Value.Day & "/" & DateTimePicker136109033.Value.Year & "#, '" & jt36109033.Text & "')", CONECT)
CONECT.Open()
Coba.ExecuteNonQuery()
CONECT.Close()
'e'
For Each t As DataRow In data.Rows
Coba = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt36109033.Text & "','" & t("KODEBARANG") & "'," & t("UNIT") & ", " & t("HARGA") & ")", CONECT)
CONECT.Open()
Coba.ExecuteNonQuery()
CONECT.Close()
Coba.Dispose()
Next
'f'
nt36109033.Text = ""
jt36109033.Text = ""
jm36109033.Text = ""
'g'
data.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
Public Class LATIHAN037_36109037
BalasHapusDim n As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=2901911691")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub Latihan37_36109037_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Juni As New OleDb.OleDbDataAdapter
Juni = 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= '" & nt36109037.Text & "'", n)
Juni.Fill(dt)
Juni.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DataGridView1.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
Tot36109037.Text = TOT
End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb36109037.Leave
If kb36109037.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109037.Text, 1, n)
If Pencari.JumlanBaris > 0 Then
kb36109037.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb36109037.Text = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub KB36109037_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109037.TextChanged
nb36109037.Text = ""
un36109037.Text = ""
hr36109037.Text = ""
End Sub
Public Class Latih37_36109034
BalasHapusDim n As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=miss")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub Latih37_36109034_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= '" & nt_36109034.Text & "'", n)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DataGridView1.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
Tot_36109034.Text = TOT
End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb_36109034.Leave
If kb_36109034.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb_36109034.Text, 1, n)
If Pencari.JumlanBaris > 0 Then
kb_36109034.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb_36109034.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 kb_36109034.TextChanged
nb_36109034.Text = ""
un_36109034.Text = ""
hr_36109034.Text = ""
End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un_36109034.TextChanged, hr_36109034.TextChanged
jm_36109034.Text = Val(un_36109034.Text) * Val(hr_36109034.Text)
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH.Click
'a'
If kb_36109034.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb_36109034.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un_36109034.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr_36109034.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
dr = dt.Rows.Find(kb_36109034.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = kb_36109034.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
dr = dt.NewRow
dr("KODEBARANG") = kb_36109034.Text
dr("NAMABARANG") = nb_36109034.Text
dr("UNIT") = un_36109034.Text
dr("HARGA") = hr_36109034.Text
dr("JUMLAH") = jm_36109034.Text
dt.Rows.Add(dr)
'd'
kb_36109034.Text = ""
nb_36109034.Text = ""
un_36109034.Text = ""
hr_36109034.Text = ""
'e'
TOTALJUMLAH()
End Sub
'lanjutan
BalasHapusPrivate Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN.Click
'a'
If nt_36109034.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt_36109034.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_36109034.Text, 1, n)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_36109034.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt_36109034.Text & "')", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
'e'
For Each X As DataRow In dt.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_36109034.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", n)
n.Open()
CM.ExecuteNonQuery()
n.Close()
CM.Dispose()
Next
'f'
nt_36109034.Text = ""
jt_36109034.Text = ""
jm_36109034.Text = ""
'g'
dt.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
Public Class Latihan_037_36109045
BalasHapus'DEKLARASI CONECTION
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;jet OLEDB:database password=florista")
'deklarasi data tabel
Dim DT As New DataTable
Dim kolom(3) As DataColumn
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109045.Click
kolom(0) = DT.Columns("kodebarang")
DT.PrimaryKey = kolom
Dim sary As DataRow
sary = DT.Rows.Find(kb36109045.Text)
If sary Is Nothing Then
sary = DT.NewRow ' menambah baris
sary("KODEBARANG") = kb36109045.Text
sary("NAMABARANG") = nb36109045.Text
sary("UNIT") = un36109045.Text
sary("HARGA") = hr36109045.Text
sary("JUMLAH") = jm36109045.Text
DT.Rows.Add(sary)
Else
MsgBox("baris sudah ada")
kb36109045.Text = ""
End If
If kb36109045.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("kode barang belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If Val(un36109045.Text) = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("UNIT belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If Val(hr36109045.Text) = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("HARGA belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
kb36109045.Text = ""
un36109045.Text = ""
hr36109045.Text = ""
nb36109045.Text = ""
jm36109045.Text = ""
lara()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap
If nt36109045.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("no.transaksi belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If jt36109045.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("jenis transaksi belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada
cari.AturPencarianDataBase("mastertransaksi", "notrans", nt36109045.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
BalasHapusMsgBox("NO.TRANS sudah ada")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
'untuk memasukkan data dari visual basc ke dlm acces
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt36109045.Text & "',#" & DateTimePicker136109045.Value.Date & "#,'" & jt36109045.Text & "')", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In DT.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & nt36109045.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
DT.Rows.Clear()
nt36109045.Text = ""
jt36109045.Text = ""
lara()
End Sub
Private Sub LATIHAN036012_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim chaca As New OleDb.OleDbDataAdapter
chaca = New OleDb.OleDbDataAdapter("select detailtransaksi.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, (detailtransaksi.unit * detailtransaksi.harga) as jumlah from detailtransaksi inner join barang on detailtransaksi.kodebarang=barang.kodebarang WHERE detailtransaksi.NOTRANS='" & kb36109045.Text & "'", CONECT) 'memunculkan semua data dari tabel barang dlm acces
DT.Rows.Clear() 'membersihkan data table
chaca.Fill(DT) 'mengisi database ke dlm data table
DataGridView1.DataSource = DT 'memunculkan dlm datagridview
chaca.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
End Sub
Private Sub NB_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nb36109045.Click
cari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109045.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
nb36109045.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang baru")
nb36109045.ReadOnly = False
Exit Sub
End If
End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109045.TextChanged, hr36109045.TextChanged
jm36109045.Text = Val(un36109045.Text) * Val(hr36109045.Text)
End Sub
Public Sub lara()
Dim total As Double
For Each x As DataRow In DT.Rows
total = total + x("jumlah")
Next
Tot36109045.Text = total
End Sub
End Class
Public Class Form3736109040
BalasHapusDim Mt As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=150991")
Dim DT As New DataTable
Dim DR As DataRow
Private Sub Latihan37017_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= '" & nt_36109040.Text & "'", B)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DataGridView1.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
Tot_36109040.Text = TOT
End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb_36109056.Leave
If kb_36109040.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb_36109056.Text, 1, B)
If Pencari.JumlanBaris > 0 Then
kb_36109040.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb_36109040.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 kb_36109040.TextChanged
nb_36109040.Text = ""
un_36109040.Text = ""
hr_36109040.Text = ""
End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un_36109040.TextChanged, hr_36109040.TextChanged
jm_36109040.Text = Val(un_36109040.Text) * Val(hr_36109040.Text)
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'a'
If kb_36109040.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb_36109040.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un_36109040.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr_36109040.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
DR = DT.Rows.Find(kb_36109040.Text)
If DR Is Nothing Then
DR = DT.NewRow
DR("KODEBARANG") = kb_36109040.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
DR = DT.NewRow
DR("KODEBARANG") = kb_36109040.Text
DR("NAMABARANG") = nb_36109040.Text
DR("UNIT") = un_36109040.Text
DR("HARGA") = hr_36109040.Text
DR("JUMLAH") = jm_36109040.Text
DT.Rows.Add(DR)
'd'
kb_36109040.Text = ""
nb_36109040.Text = ""
un_36109040.Text = ""
hr_36109040.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
BalasHapus'a'
If nt_36109040.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt_36109040.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If DT.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_36109040.Text, 1, Mt)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_36109040.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt_36109040.Text & "')", Mt)
Mt.Open()
CM.ExecuteNonQuery()
Mt.Close()
'e'
For Each X As DataRow In DT.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_36109056.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", Mt)
Mt.Open()
CM.ExecuteNonQuery()
Mt.Close()
CM.Dispose()
Next
'f'
nt_36109040.Text = ""
jt_36109040.Text = ""
jm_36109040.Text = ""
'g'
DT.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
Public Class LATIHAN037035
BalasHapusDim Jalan As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Application.StartupPath & "\Datamajemuk.ACCDB")
Dim gitik As New DataTable
Private Sub botto()
Dim ttotal As Integer
For Each hasil As DataRow In gitik.Rows
ttotal += hasil("Jumlah")
Next
Tot035.Text = ttotal
End Sub
Private Sub Latihan037035_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'mendeklarasikan kendaraan
Dim bojel As New OleDb.OleDbDataAdapter
'Mengatur data yang akan di angkut
bojel = New OleDb.OleDbDataAdapter("SELECT detailtransaksi.kodebarang,barang.namabarang,detailtransaksi.unit,detailtransaksi.harga, detailtransaksi.unit * detailtransaksi.harga as jumlah FROM DETAILTRANSAKSI inner join barang on detailtransaksi.kodebarang=barang.kodebarang where detailtransaksi.notrans='" & nt035.Text & "'", Jalan)
'bersihkan data
gitik.Rows.Clear()
'untuk memasukkan data yg telah di angkut ke dalam datatable
bojel.Fill(gitik)
'untuk menampilkan isi datatable ke data grid view
bojel.Dispose()
DataGridView1035.DataSource = gitik
'perintah primarykey
Dim kabotcibay(2) As DataColumn
kabotcibay(0) = gitik.Columns("Kodebarang")
gitik.PrimaryKey = kabotcibay
End Sub
Private Sub kb035_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb035.Leave
If kb035.Text.Length = 0 Then
Exit Sub
End If
'mencari data yang ada di tabel
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("barang", "kodebarang", kb035.Text, 1, Jalan)
If Pencari.JumlanBaris > 0 Then
nb035.Text = Pencari.DataTablenya.Rows(0).Item(1)
Else
MsgBox("the data is not exist")
kb035.Text = ""
nb035.Text = ""
Exit Sub
End If
End Sub
Private Sub Button1035_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1035.Click
'Memeriksa isi textbox
If kb035.Text.Length = 0 Then
MsgBox("Please, insert the code of goods")
Exit Sub
End If
If un035.Text.Length = 0 Then
MsgBox("Please, insert the unit of goods")
Exit Sub
End If
If hr035.Text.Length = 0 Then
MsgBox("Please, insert the cost of goods")
Exit Sub
End If
'perintah pencarian data
Dim dr As DataRow
dr = gitik.Rows.Find(kb035.Text)
If Not dr Is Nothing Then
MsgBox("Sorry, the data has been exist!!! Please insert new data")
Exit Sub
End If
'penyimpanan data ke datatable
gitik.Rows.Add(kb035.Text, nb035.Text, Val(un035.Text), Val(hr035.Text), jm035.Text)
botto()
'mengosongkan textbox
kb035.Text = ""
nb035.Text = ""
un035.Text = ""
hr035.Text = ""
jm035.Text = ""
End Sub
Private Sub un035_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un035.TextChanged, hr035.TextChanged
BalasHapusjm035.Text = Val(un035.Text) * Val(hr035.Text)
End Sub
Private Sub Button3035_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3035.Click
'Memeriksa isi textbox
If nt035.Text.Length = 0 Then
MsgBox("Please, insert the Number of the transaction")
Exit Sub
End If
If jt035.Text.Length = 0 Then
MsgBox("Please, insert the type of the transaction")
Exit Sub
End If
If gitik.Rows.Count = 0 Then
MsgBox("the data is none")
Exit Sub
End If
'Memeriksa nomor transaksi pd master transaksi
Dim search As New ByIskandar.CariKeDataBaseByIskandar
search.AturPencarianDataBase("mastertransaksi", "notrans", nt035.Text, 1, Jalan)
If search.JumlanBaris > 0 Then
MsgBox("the code has been exist")
Exit Sub
End If
'Proses Penyimpanan ke tabel master transaksi
Dim kacci As New OleDb.OleDbCommand
kacci = New OleDb.OleDbCommand("insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values ('" & nt035.Text & "',#" & DateTimePicker1035.Value.Month & "/" & DateTimePicker1035.Value.Day & "/" & DateTimePicker1035.Value.Year & "#,'" & jt035.Text & "')", Jalan)
Jalan.Open()
kacci.ExecuteNonQuery()
Jalan.Close()
'penyimpanan isi datatable ke detail transaksi
For Each nhana As DataRow In gitik.Rows
kacci = New OleDb.OleDbCommand("insert into detailtransaksi (notrans,kodebarang,unit,harga) values ('" & nt035.Text & "','" & nhana("kodebarang") & "'," & nhana("unit") & "," & nhana("harga") & ")", Jalan)
Jalan.Open()
kacci.ExecuteNonQuery()
Jalan.Close()
Next
kacci.Dispose()
'Mengosongkan isi text box
nt035.Text = ""
jt035.Text = ""
'Mengosongkan baris datatable
gitik.Rows.Clear()
'menutup form
Me.Close()
End Sub
End Class
Public Class Latihan037_36109049
BalasHapusDim conect As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=wirda")
Dim dt As New DataTable
Dim dr As DataRow
Private Sub Latihan037_36109049_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wirda As New OleDb.OleDbDataAdapter
wirda = 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= '" & TextBox1_36109049.Text & "'", conect)
wirda.Fill(dt)
wirda.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DGV1_36109049.DataSource = dt
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double
For Each x As DataRow In dt.Rows
TOT = TOT + x("JUMLAH")
Next
Tot1.Text = TOT
End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB_36109049.Leave
If KB_36109049.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KB_36109049.Text, 1, conect)
If Pencari.JumlanBaris > 0 Then
KB_36109049.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
NB_36109049.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 KB_36109049.TextChanged
NB_36109049.Text = ""
UN_36109049.Text = ""
HR_36109049.Text = ""
End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UN_36109049.TextChanged, HR_36109049.TextChanged
JM_36109049.Text = Val(UN_36109049.Text) * Val(HR_36109049.Text)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'a'
If TextBox1_36109049.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If TextBox2_36109049.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If dt.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox1_36109049.Text, 1, conect)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Lanjutan 37
BalasHapus'd'
Dim wirdapaulus As New OleDb.OleDbCommand
wirdapaulus = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & TextBox1_36109049.Text & "', #" & DTP1_36109049.Value.Month & "/" & DTP1_36109049.Value.Day & "/" & DTP1_36109049.Value.Year & "#, '" & TextBox2_36109049.Text & "')", conect)
conect.Open()
wirdapaulus.ExecuteNonQuery()
conect.Close()
'e'
For Each X As DataRow In dt.Rows
wirdapaulus = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox1_36109049.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", conect)
conect.Open()
wirdapaulus.ExecuteNonQuery()
conect.Close()
wirdapaulus.Dispose()
Next
'f'
TextBox1_36109049.Text = ""
TextBox2_36109049.Text = ""
JM_36109049.Text = ""
'g'
dt.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'a'
If KB_36109049.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If NB_36109049.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(UN_36109049.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(HR_36109049.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
dr = dt.Rows.Find(KB_36109049.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = KB_36109049.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
dr = dt.NewRow
dr("KODEBARANG") = KB_36109049.Text
dr("NAMABARANG") = NB_36109049.Text
dr("UNIT") = UN_36109049.Text
dr("HARGA") = HR_36109049.Text
dr("JUMLAH") = JM_36109049.Text
dt.Rows.Add(dr)
TOTALJUMLAH()
'd'
KB_36109049.Text = ""
NB_36109049.Text = ""
UN_36109049.Text = ""
HR_36109049.Text = ""
'e'
End Sub
End Class
Public Class LATIHAN03736109038
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=icha")
Dim DT As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub LATIHAN03736109038_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Azizah As New OleDb.OleDbDataAdapter
Azizah = New OleDb.OleDbDataAdapter("select detailtransaksi.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= '" & KB36109038.Text & "'", CONECT)
DT.Rows.Clear()
Azizah.Fill(DT)
Azizah.Dispose()
Dim dcp(1) As DataColumn
dcp(0) = DT.Columns("kodebarang")
DT.PrimaryKey = dcp
DataGridView136109038.DataSource = DT
End Sub
Private Sub hitung()
Dim cantik As Integer
For Each r As DataRow In DT.Rows
cantik = cantik + r("JUMLAH")
Next
Tot36109038.Text = cantik
End Sub
Private Sub UN36109038_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles UN36109038.TextChanged, HR36109038.TextChanged
JM36109038.Text = Val(UN36109038.Text) * Val(HR36109038.Text)
End Sub
Private Sub KB36109038_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB36109038.Leave
If KB36109038.Text.Length = 0 Then
Exit Sub
End If
cari.AturPencarianDataBase("barang", "kodebarang", KB36109038.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
KB36109038.Text = cari.DataTablenya.Rows(0).Item("KodeBarang")
NB36109038.Text = cari.DataTablenya.Rows(0).Item("namabarang")
Else
MsgBox("Kode barang tersebut tidak ada")
KB36109038.Text = ""
Exit Sub
End If
End Sub
Private Sub KB36109038_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB36109038.TextChanged
NB36109038.Text = ""
UN36109038.Text = ""
HR36109038.Text = ""
End Sub
Private Sub Button136109038_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button136109038.Click
If KB36109038.Text.Length = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If
If Val(UN36109038.Text) = 0 Then
MsgBox("UNIT belum terisi")
Exit Sub
End If
If Val(HR36109038.Text) = 0 Then
MsgBox("HARGA belum terisi")
Exit Sub
End If
Dim Reza As DataRow
Reza = DT.Rows.Find(KB36109038.Text)
If Reza Is Nothing Then
Reza = DT.NewRow
Reza("kodebarang") = KB36109038.Text
Reza("namabarang") = NB36109038.Text
Reza("unit") = UN36109038.Text
Reza("harga") = HR36109038.Text
Reza("jumlah") = JM36109038.Text
DT.Rows.Add(Reza)
Else
MsgBox("nomor sudah ada")
End If
KB36109038.Text = ""
UN36109038.Text = ""
HR36109038.Text = ""
hitung()
End Sub
Private Sub Button336109038_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button336109038.Click
BalasHapusIf NT36109038.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If JT36109038.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", NT36109038.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("NO.TRANS sudah ada")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT36109038.Text & "',#" & DateTimePicker136109038.Value.Date & "#," & Val(JT36109038.Text) & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In DT.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & NT36109038.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
NT36109038.Text = ""
JT36109038.Text = ""
JM36109038.Text = ""
Tot36109038.Text = ""
DT.Rows.Clear()
hitung()
End Sub
End Class
Public Class LATIHAN03736109032
BalasHapusDim sambung As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=jayapura")
Dim toshiba As New DataTable
Dim nokia As DataRow
Private Sub LATIHAN03736109032_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim laptop As New OleDb.OleDbDataAdapter
laptop = 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.Text & "'", sambung)
laptop.Fill(toshiba)
laptop.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = toshiba.Columns("KODEBARANG")
toshiba.PrimaryKey = dataPrimary
DataGridView1.DataSource = toshiba
End Sub
Private Sub TOTALJUMLAH()
Dim TOTJUM As Double
For Each x As DataRow In toshiba.Rows
TOTJUM = TOTJUM + x("JUMLAH")
Next
TOT.Text = TOTJUM
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
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", KB.Text, 1, sambung)
If Pencari.JumlanBaris > 0 Then
KB.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
NB.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 KB.TextChanged
NB.Text = ""
UN.Text = ""
HR.Text = ""
End Sub
Private Sub UN_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UN.TextChanged, HR.TextChanged
JM.Text = Val(UN.Text) * Val(HR.Text)
End Sub
lanjutan..
BalasHapusPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'a'
If KB.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If NB.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(UN.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(HR.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
nokia = toshiba.Rows.Find(KB.Text)
If nokia Is Nothing Then
nokia = toshiba.NewRow
nokia("KODEBARANG") = KB.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
nokia = toshiba.NewRow
nokia("KODEBARANG") = KB.Text
nokia("NAMABARANG") = NB.Text
nokia("UNIT") = UN.Text
nokia("HARGA") = HR.Text
nokia("JUMLAH") = JM.Text
toshiba.Rows.Add(nokia)
'd'
KB.Text = ""
NB.Text = ""
UN.Text = ""
HR.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'a'
If NT.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If JT.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If toshiba.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim angka As New ByIskandar.CariKeDataBaseByIskandar
angka.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT.Text, 1, sambung)
If angka.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim huruf As New OleDb.OleDbCommand
huruf = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & JT.Text & "')", sambung)
sambung.Open()
huruf.ExecuteNonQuery()
sambung.Close()
'e'
For Each X As DataRow In toshiba.Rows
huruf = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", sambung)
sambung.Open()
huruf.ExecuteNonQuery()
sambung.Close()
huruf.Dispose()
Next
'f'
NT.Text = ""
JT.Text = ""
JM.Text = ""
'g'
toshiba.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
Public Class LATIHAN037041
BalasHapus'DEKLARASI CONECTION
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb; Jet OLEDB:Database Password=12")
'deklarasi data tabel
Dim DT As New DataTable
Dim kolom(3) As DataColumn
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109041.Click
kolom(0) = DT.Columns("kodebarang")
DT.PrimaryKey = kolom
Dim drzany As DataRow
drzany = DT.Rows.Find(kb36109041.Text)
If drzany Is Nothing Then
drzany = DT.NewRow ' menambah baris
drzany("KODEBARANG") = kb36109041.Text
drzany("NAMABARANG") = nb36109041.Text
drzany("UNIT") = un36109041.Text
drzany("HARGA") = hr36109041.Text
drzany("JUMLAH") = jm36109041.Text
DT.Rows.Add(drzany)
Else
MsgBox("baris sudah ada")
kb36109041.Text = ""
End If
If kb36109041.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("kode barang belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If Val(un36109041.Text) = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("UNIT belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If Val(hr36109041.Text) = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("HARGA belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
kb36109041.Text = ""
un36109041.Text = ""
hr36109041.Text = ""
nb36109041.Text = ""
jm36109041.Text = ""
farid()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109041.Click
'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap
If nt36109041.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("no.transaksi belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If jt36109041.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("jenis transaksi belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada
cari.AturPencarianDataBase("mastertransaksi", "notrans", nt36109041.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("NO.TRANS sudah ada")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
'untuk memasukkan data dari visual basc ke dlm acces
BalasHapusDim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt36109041.Text & "',#" & DTP136109041.Value.Date & "#,'" & jt36109041.Text & "')", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In DT.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & nt36109041.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
DT.Rows.Clear()
nt36109041.Text = ""
jt36109041.Text = ""
farid()
End Sub
Private Sub LATIHAN036012_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 detailtransaksi.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, (detailtransaksi.unit * detailtransaksi.harga) as jumlah from detailtransaksi inner join barang on detailtransaksi.kodebarang=barang.kodebarang WHERE detailtransaksi.NOTRANS='" & kb36109041.Text & "'", CONECT) 'memunculkan semua data dari tabel barang dlm acces
DT.Rows.Clear() 'membersihkan data table
nisa.Fill(DT) 'mengisi database ke dlm data table
DataGridView1.DataSource = DT 'memunculkan dlm datagridview
nisa.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
End Sub
Private Sub NB_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nb36109041.Click
cari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109041.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
nb36109041.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang baru")
nb36109041.ReadOnly = False
Exit Sub
End If
End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109041.TextChanged, hr36109041.TextChanged
jm36109041.Text = Val(un36109041.Text) * Val(hr36109041.Text)
End Sub
Public Sub farid()
Dim total As Double
For Each x As DataRow In DT.Rows
total = total + x("jumlah")
Next
Tot36109041.Text = total
End Sub
End Class
Private Sub Button336109048_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button336109048.Click
BalasHapusIf NT36109048.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If JT36109048.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", NT36109048.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("NO.TRANS sudah ada")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT36109048.Text & "',#" & DateTimePicker136109048.Value.Date & "#," & Val(JT36109048.Text) & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In DT.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & NT36109048.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
NT36109048.Text = ""
JT36109048.Text = ""
JM36109048.Text = ""
Tot36109048.Text = ""
DT.Rows.Clear()
hitung()
End Sub
End Class
Public Class Latihan_3736109055
BalasHapusDim F As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=2312")
Dim DT As New DataTable
Dim DR As DataRow
Private Sub Latihan_3736109055_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= '" & nt36109055.Text & "'", F)
X.Fill(dt)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = dt.Columns("KODEBARANG")
dt.PrimaryKey = dataPrimary
DataGridView136109055.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
Tot36109055.Text = TOT
End Sub
Private Sub KB_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb36109055.Leave
If kb36109055.Text.Length = 0 Then
Exit Sub
End If
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109055.Text, 1, F)
If Pencari.JumlanBaris > 0 Then
kb36109055.Text = Pencari.DataTablenya.Rows(0).Item("KODEBARANG")
nb36109055.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 kb36109055.TextChanged
nb36109055.Text = ""
un36109055.Text = ""
hr36109055.Text = ""
End Sub
Private Sub UNIT_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109055.TextChanged, hr36109055.TextChanged
jm36109055.Text = Val(un36109055.Text) * Val(hr36109055.Text)
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'a'
If kb36109055.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb36109055.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un36109055.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr36109055.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
DR = DT.Rows.Find(kb36109055.Text)
If DR Is Nothing Then
DR = DT.NewRow
DR("KODEBARANG") = kb36109055.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
DR = DT.NewRow
DR("KODEBARANG") = kb36109055.Text
DR("NAMABARANG") = nb36109055.Text
DR("UNIT") = un36109055.Text
DR("HARGA") = hr36109055.Text
DR("JUMLAH") = jm36109055.Text
DT.Rows.Add(DR)
'd'
kb36109055.Text = ""
nb36109055.Text = ""
un36109055.Text = ""
hr36109055.Text = ""
'e'
TOTALJUMLAH()
End Sub
lanjutan
BalasHapusPrivate Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'a'
If nt36109055.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt36109055.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If DT.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt36109055.Text, 1, F)
If pencari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt36109055.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109055.Text & "')", F)
F.Open()
CM.ExecuteNonQuery()
F.Close()
'e'
For Each X As DataRow In DT.Rows
CM = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt36109055.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", F)
F.Open()
CM.ExecuteNonQuery()
F.Close()
CM.Dispose()
Next
'f'
nt36109055.Text = ""
jt36109055.Text = ""
jm36109055.Text = ""
'g'
DT.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
Part 1
BalasHapusPublic Class LATIHAN03736109054
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= D:\berbagi\LATIHAN 35-40 DATA MAJEMUK\DataMajemuk.accdb;Jet OLEDB:Database Password=salam")
Dim DT As New DataTable
Dim kolom(3) As DataColumn
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Button136109054_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109054.Click
kolom(0) = DT.Columns("kodebarang")
DT.PrimaryKey = kolom
Dim drzany As DataRow
drzany = DT.Rows.Find(kb36109054.Text)
If drzany Is Nothing Then
drzany = DT.NewRow
drzany("KODEBARANG") = kb36109054.Text
drzany("NAMABARANG") = nb36109054.Text
drzany("UNIT") = un36109054.Text
drzany("HARGA") = hr36109054.Text
drzany("JUMLAH") = jm36109054.Text
DT.Rows.Add(drzany)
Else
MsgBox("baris sudah ada")
kb36109054.Text = ""
End If
If kb36109054.Text.Length = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If
If Val(un36109054.Text) = 0 Then
MsgBox("UNIT belum terisi")
Exit Sub
End If
If Val(hr36109054.Text) = 0 Then
MsgBox("HARGA belum terisi")
Exit Sub
End If
kb36109054.Text = ""
un36109054.Text = ""
hr36109054.Text = ""
nb36109054.Text = ""
jm36109054.Text = ""
wawan()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109054.Click
If nt36109054.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If jt36109054.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", nt36109054.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("NO.TRANS sudah ada")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt36109054.Text & "',#" & DTP136109054.Value.Date & "#,'" & jt36109054.Text & "')", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In DT.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & nt36109054.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
Part 2
BalasHapusCONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
DT.Rows.Clear()
nt36109054.Text = ""
jt36109054.Text = ""
wawan()
End Sub
Private Sub LATIHAN036012_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 detailtransaksi.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, (detailtransaksi.unit * detailtransaksi.harga) as jumlah from detailtransaksi inner join barang on detailtransaksi.kodebarang=barang.kodebarang WHERE detailtransaksi.NOTRANS='" & kb36109054.Text & "'", CONECT) 'memunculkan semua data dari tabel barang dlm acces
DT.Rows.Clear()
nisa.Fill(DT) '
DGV136109054.DataSource = DT
nisa.Dispose()
End Sub
Private Sub label4_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
cari.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109054.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
nb36109054.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang baru")
nb36109054.ReadOnly = False
Exit Sub
End If
End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109054.TextChanged, hr36109054.TextChanged
jm36109054.Text = Val(un36109054.Text) * Val(hr36109054.Text)
End Sub
Public Sub wawan()
Dim total As Double
For Each x As DataRow In DT.Rows
total = total + x("jumlah")
Next
Tot36109054.Text = total
End Sub
End Class
Public Class Form3736109050
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=nideria")
Dim data As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Form3736109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim adapt As New OleDb.OleDbDataAdapter
adapt = New OleDb.OleDbDataAdapter("select detailtransaksi.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= '" & kb.Text & "'", CONECT) 'memunculkan semua data dari tabel barang dlm acces
data.Rows.Clear()
adapt.Fill(data)
adapt.Dispose()
Dim dcp(1) As DataColumn
dcp(0) = data.Columns("kodebarang")
data.PrimaryKey = dcp
DataGridView1.DataSource = data
End Sub
Private Sub hitung()
Dim intr As Integer
For Each r As DataRow In data.Rows
intr = intr + r("JUMLAH")
Next
Tot.Text = intr
End Sub
Private Sub un_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un.TextChanged, hr.TextChanged
jm.Text = Val(un.Text) * Val(hr.Text)
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 kb_Leave(ByVal sender As System.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, CONECT)
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 tersebut tidak ada")
kb.Text = ""
Exit Sub
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
BalasHapusIf 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 simpan As DataRow
simpan = data.Rows.Find(kb.Text)
If simpan Is Nothing Then
simpan = data.NewRow
simpan("kodebarang") = kb.Text
simpan("namabarang") = nb.Text
simpan("unit") = un.Text
simpan("harga") = hr.Text
simpan("jumlah") = jm.Text
data.Rows.Add(simpan)
Else
MsgBox("nomor sudah ada")
End If
kb.Text = ""
un.Text = ""
hr.Text = ""
hitung()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If nt.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If jt.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
If data.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", nt.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("NO.TRANS sudah ada")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt.Text & "',#" & DateTimePicker1.Value.Date & "#," & Val(jt.Text) & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In data.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & nt.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
nt.Text = ""
jt.Text = ""
jm.Text = ""
Tot.Text = ""
data.Rows.Clear()
hitung()
End Sub
End Class
Public Class LATIHAN03736109029
BalasHapus'DEKLARASI CONECTION
Dim CONNECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;jet oledb:database password = hapsari")
'deklarasi data tabel
Dim DT As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub LATIHAN03736109029_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'deklarasi adapter
Dim CUTE As New OleDb.OleDbDataAdapter
CUTE = New OleDb.OleDbDataAdapter("select detailtransaksi.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= '" & kb36109029.Text & "'", CONNECT) 'memunculkan semua data dari tabel barang dlm acces
DT.Rows.Clear() 'membersihkan data table
CUTE.Fill(DT) 'mengisi database ke dlm data table
CUTE.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
'rumus dibwh ini untuk membuat primary key dimana dcp adalah nama sembarangji
Dim dcp(1) As DataColumn
dcp(0) = DT.Columns("kodebarang")
DT.PrimaryKey = dcp
DataGridView1.DataSource = DT 'memunculkan dlm datagridview
End Sub
Private Sub hitung()
Dim INDAH As Integer
For Each r As DataRow In DT.Rows
INDAH = INDAH + r("JUMLAH")
Next
Tot36109029.Text = INDAH
End Sub
Private Sub un36109029_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109029.TextChanged, hr36109029.TextChanged
jm36109029.Text = Val(un36109029.Text) * Val(hr36109029.Text)
End Sub
Private Sub kb36109029_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109029.TextChanged
nb36109029.Text = ""
un36109029.Text = ""
hr36109029.Text = ""
End Sub
'moment mencari saat kursor meninggalkan texbox
Private Sub kb36109029_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109029.Leave
If kb36109029.Text.Length = 0 Then 'jika kodebarang tidak diisi jgn lanjutkan perintah selanjutnya
Exit Sub
End If
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada
cari.AturPencarianDataBase("barang", "kodebarang", kb36109029.Text, 1, CONNECT) '1 untuk huruf
If cari.JumlanBaris > 0 Then 'jika barang yg kita cari ada dlm table
kb36109029.Text = cari.DataTablenya.Rows(0).Item("KodeBarang")
nb36109029.Text = cari.DataTablenya.Rows(0).Item("namabarang")
Else
MsgBox("Kode barang tersebut tidak ada")
kb36109029.Text = ""
Exit Sub
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109029.Click
'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap
If kb36109029.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("kode barang belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If Val(un36109029.Text) = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("UNIT belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If Val(hr36109029.Text) = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("HARGA belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
'UNTUK MENYMPAN DATA YG DIMASUKKAN KE DALAM DATAGRIDVIEW
BalasHapusDim INDAH As DataRow
INDAH = DT.Rows.Find(kb36109029.Text) 'untuk mencari apakah ada no.pembelian sdh ada agar tdak double
If INDAH Is Nothing Then 'jika tidak ad ji maka lanjutkan penyimpanan
INDAH = DT.NewRow ' menambah baris
INDAH("kodebarang") = kb36109029.Text
INDAH("namabarang") = nb36109029.Text
INDAH("unit") = un36109029.Text
INDAH("harga") = hr36109029.Text
INDAH("jumlah") = jm36109029.Text
DT.Rows.Add(INDAH)
Else
MsgBox("nomor sudah ada")
End If
kb36109029.Text = ""
un36109029.Text = ""
hr36109029.Text = ""
hitung()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap
If nt36109029.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("no.transaksi belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If jt36109029.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("jenis transaksi belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada
cari.AturPencarianDataBase("mastertransaksi", "notrans", nt36109029.Text, 1, CONNECT)
If cari.JumlanBaris > 0 Then
MsgBox("NO.TRANS sudah ada")
Exit Sub
End If
'untuk memasukkan data dari visual basc ke dlm acces
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt36109029.Text & "',#" & DateTimePicker1.Value.Date & "#," & Val(jt36109029.Text) & ")", CONNECT)
CONNECT.Open()
com.ExecuteNonQuery()
CONNECT.Close()
For Each r As DataRow In DT.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & nt36109029.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONNECT)
CONNECT.Open()
com.ExecuteNonQuery()
CONNECT.Close()
com.Dispose()
Next
nt36109029.Text = ""
jt36109029.Text = ""
jm36109029.Text = ""
Tot36109029.Text = ""
DT.Rows.Clear()
hitung()
End Sub
End Class
ublic Class LATIHAN03736109036
BalasHapusDim CONECT As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=100191")
Dim data As New DataTable
Dim iben As DataRow
Private Sub LATIHAN03736109036_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ibnu As New OleDb.OleDbDataAdapter
ibnu = 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= '" & nt36109036.Text & "'", CONECT)
ibnu.Fill(data)
ibnu.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = data.Columns("KODEBARANG")
data.PrimaryKey = dataPrimary
DataGridView1.DataSource = data
End Sub
Private Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each t As DataRow In data.Rows
TOT = TOT + t("JUMLAH")
Next
Tot36109036.Text = TOT
End Sub
Private Sub KB36109036_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles kb36109036.Leave
If kb36109036.Text.Length = 0 Then
Exit Sub
End If
Dim browse As New ByIskandar.CariKeDataBaseByIskandar
browse.AturPencarianDataBase("BARANG", "KODEBARANG", kb36109036.Text, 1, CONECT)
If browse.JumlanBaris > 0 Then
kb36109036.Text = browse.DataTablenya.Rows(0).Item("KODEBARANG")
nb36109036.Text = browse.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub kb36109036_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb36109036.TextChanged
nb36109036.Text = ""
un36109036.Text = ""
hr36109036.Text = ""
End Sub
Private Sub un36109036_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles un36109036.TextChanged, hr36109036.TextChanged
jm36109036.Text = Val(un36109036.Text) * Val(hr36109036.Text)
End Sub
Private Sub Button136109036_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109036.Click
'a'
If kb36109036.Text.Length Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If nb36109036.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(un36109036.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(hr36109036.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
'b'
iben = data.Rows.Find(kb36109036.Text)
If iben Is Nothing Then
iben = data.NewRow
iben("KODEBARANG") = kb36109036.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
'c'
iben = data.NewRow
iben("KODEBARANG") = kb36109036.Text
iben("NAMABARANG") = nb36109036.Text
iben("UNIT") = un36109036.Text
iben("HARGA") = hr36109036.Text
iben("JUMLAH") = jm36109036.Text
data.Rows.Add(iben)
'd'
kb36109036.Text = ""
nb36109036.Text = ""
un36109036.Text = ""
hr36109036.Text = ""
'e'
TOTALJUMLAH()
End Sub
Private Sub Button366109036_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button366109036.Click
BalasHapus'a'
If nt36109036.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If jt36109036.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
'b'
If data.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
'c'
Dim browse As New ByIskandar.CariKeDataBaseByIskandar
browse.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt36109036.Text, 1, CONECT)
If browse.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
'd'
Dim Coba As New OleDb.OleDbCommand
Coba = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt36109036.Text & "', #" & DateTimePicker136109036.Value.Month & "/" & DateTimePicker136109036.Value.Day & "/" & DateTimePicker136109036.Value.Year & "#, '" & jt36109036.Text & "')", CONECT)
CONECT.Open()
Coba.ExecuteNonQuery()
CONECT.Close()
'e'
For Each t As DataRow In data.Rows
Coba = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt36109036.Text & "','" & t("KODEBARANG") & "'," & t("UNIT") & ", " & t("HARGA") & ")", CONECT)
CONECT.Open()
Coba.ExecuteNonQuery()
CONECT.Close()
Coba.Dispose()
Next
'f'
nt36109036.Text = ""
jt36109036.Text = ""
jm36109036.Text = ""
'g'
data.Rows.Clear()
'h'
TOTALJUMLAH()
End Sub
End Class
pembaharuan..
BalasHapusPublic Class Form3736108001
Dim INCE As New OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb;Jet OLEDB:Database Password=36108001")
Dim LOVE As New DataTable
Dim AYI As New ByIskandar.CariKeDataBaseByIskandar
Public Sub AI()
Dim YNK As New OleDb.OleDbDataAdapter
YNK = New OleDb.OleDbDataAdapter("Select BARANG.KodeBarang, BARANG.NamaBarang, DETAILTRANSAKSI.unit, DETAILTRANSAKSI.Harga, DETAILTRANSAKSI.Unit * DETAILTRANSAKSI.harga AS Jumlah FROM BARANG INNER JOIN detailtransaksi ON BARANG.KODEBARANG=DETAILTRANSAKSI.KODEBARANG Where notrans='" & T136108001.Text & "' ", INCE)
LOVE.Rows.Clear()
YNK.Fill(LOVE)
YNK.Dispose()
DGV36108001.DataSource = LOVE
End Sub
Private Sub Form3736108001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AI()
Dim PK(1) As DataColumn
PK(0) = LOVE.Columns("KODEBARANG")
LOVE.PrimaryKey = PK
End Sub
Private Sub TOTAL()
Dim LO As Integer
For Each VE As DataRow In LOVE.Rows
LO = LO + VE("Jumlah")
Next
T836108001.Text = LO
End Sub
Private Sub T536108001_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T536108001.TextChanged, T636108001.TextChanged
T736108001.Text = Val(T536108001.Text) * Val(T636108001.Text)
End Sub
Private Sub T336108001_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T336108001.TextChanged
T436108001.Text = ""
T536108001.Text = ""
T636108001.Text = ""
End Sub
Private Sub T336108001_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T336108001.Leave
If T336108001.Text.Length = 0 Then
Exit Sub
End If
Dim IA As New ByIskandar.CariKeDataBaseByIskandar
IA.AturPencarianDataBase("barang", "kodebarang", T336108001.Text, 1, INCE)
If IA.JumlanBaris > 0 Then
T336108001.Text = IA.DataTablenya.Rows(0).Item("KodeBarang")
T436108001.Text = IA.DataTablenya.Rows(0).Item("NamaBarang")
T636108001.Text = IA.DataTablenya.Rows(0).Item("HargaJual")
Else
MsgBox("Kode barang tersbut tidak ada")
Exit Sub
End If
End Sub
lanjutan pembaharuan..
BalasHapusPrivate Sub B136108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B136108001.Click
If T336108001.Text.Length = 0 Then
MsgBox("Kode Barang belum terisi")
Exit Sub
End If
If Val(T536108001.Text) = 0 Then
MsgBox("Unit belum terisi")
Exit Sub
End If
If Val(T636108001.Text) = 0 Then
MsgBox("Harga belum terisi")
Exit Sub
End If
If LOVE.Rows.Find(T336108001.Text) Is Nothing Then
LOVE.Rows.Add(T336108001.Text, T436108001.Text, Val(T536108001.Text), Val(T636108001.Text), Val(T736108001.Text))
Else
MsgBox("Kode barang sudah ada")
End If
T336108001.Text = ""
T536108001.Text = ""
T636108001.Text = ""
TOTAL()
End Sub
Private Sub B236108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B236108001.Click
If T136108001.Text.Length = 0 Then
MsgBox("Nomor transaksi belum terisi")
Exit Sub
End If
If T236108001.Text.Length = 0 Then
MsgBox("Jenis transaksi belum terisi")
Exit Sub
End If
If LOVE.Rows.Count = 0 Then
MsgBox("Data tidak terisi")
Exit Sub
End If
AYI.AturPencarianDataBase("mastertransaksi", "NOTRANS", T136108001.Text, 1, INCE)
If AYI.JumlanBaris > 0 Then
MsgBox("Nomor transaksi tersebut sudah ada")
Exit Sub
End If
Dim ANHYE As New OleDb.OleDbCommand
Dim VENUS As String
VENUS = "INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & T136108001.Text & "', #" & DTP36108001.Value.Date & "#, '" & T236108001.Text & "');"
ANHYE = New OleDb.OleDbCommand(VENUS, INCE)
INCE.Open()
ANHYE.ExecuteNonQuery()
INCE.Close()
For Each ARHY As DataRow In LOVE.Rows
Dim EGIET As String
EGIET = "INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & T136108001.Text & "', '" & ARHY("KODEBARANG") & "', '" & ARHY("UNIT") & "', '" & ARHY("HARGA") & "');"
ANHYE = New OleDb.OleDbCommand(EGIET, INCE)
INCE.Open()
ANHYE.ExecuteNonQuery()
INCE.Close()
Next
ANHYE.Dispose()
T136108001.Text = ""
T236108001.Text = ""
T736108001.Text = ""
T836108001.Text = ""
AI()
TOTAL()
End Sub
End Class
lanjutan
BalasHapusIf Val(HR36109044.Text) = 0 Then
MsgBox("HARGA belum terisi")
Exit Sub
End If
Dim noval As DataRow
noval = DT.Rows.Find(KB36109044.Text)
If noval Is Nothing Then
noval = DT.NewRow
noval("kodebarang") = KB36109044.Text
noval("namabarang") = NB36109044.Text
noval("unit") = UN36109044.Text
noval("harga") = HR36109044.Text
noval("jumlah") = JM36109044.Text
DT.Rows.Add(noval)
Else
MsgBox("nomor sudah ada")
End If
KB36109044.Text = ""
UN36109044.Text = ""
HR36109044.Text = ""
hitung()
End Sub
Private Sub Button336109044_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109044.Click
If NT36109044.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If JT36109044.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", NT36109044.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("NO.TRANS sudah ada")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT36109044.Text & "',#" & DateTimePicker136109044.Value.Date & "#," & Val(JT36109044.Text) & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In DT.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & NT36109044.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
NT36109044.Text = ""
JT36109044.Text = ""
JM36109044.Text = ""
Tot36109044.Text = ""
DT.Rows.Clear()
hitung()
End Sub
End Class
http://hilariusmariotonapa.blogspot.com/2012/10/prosedur-penyelesaian-latihan3736110048.html
BalasHapushttp://hilariusmariotonapa.blogspot.com/2012/10/deskripsi-latihan3736110048.html
http://tiya-sri.blogspot.com/2012/10/latihan3736110044-aplikasi-komputer-4.html
BalasHapushttp://eminaomi.blogspot.com/2012/10/latihan3736110049.html
BalasHapushttp://nurrahmahrasyid2.blogspot.com/2012/10/latihan3736110042.html
BalasHapus03melisa.blogspot.com/2012/10/latihan-37-36110051-apkom-4-d3b.html
BalasHapushttp://reskypurwono.blogspot.com/2012/10/prosedur-penyelesaian-latihan3736110037.html
BalasHapushttp://benhilll.blogspot.com/2012/10/deskripsi-dan-prosedur-latihan3736110039.html
BalasHapushttp://rosyanausman.blogspot.com/2012/10/latihan3736110036.html
BalasHapushttp://hasfiahzain.blogspot.com/2012/10/latihan3736110052.html
BalasHapushttp://ilhaazzahra.blogspot.com/2012/10/latihan3736110033.html
BalasHapushttp://ias-anakbola.blogspot.com/2012/10/latihan3736110056.html
BalasHapushttp://sriayu-36110030.blogspot.com/2012/10/diskripsi-prosedur-latihan-37_28.html
BalasHapushttp://rainaagrippinaa.blogspot.com/2012/10/latihan3736110032.html
BalasHapushttp://rahmisuryatama05.blogspot.com/2012/10/latihan3736110040.html
BalasHapushttp://dewiwahyuni91.blogspot.com/2012/10/latihan3736110038.html
BalasHapushttp://sukadriady.blogspot.com/2012/10/latihan3736110043.html
BalasHapushttp://andiniwarakusuma.blogspot.com/2012/10/latihan3736110034.html
BalasHapushttp://zulkiflitryputra.blogspot.com/2012/10/latihan3736110046.html
BalasHapushttp://audryasharii.blogspot.com/2012/10/latihan3736110031.html
BalasHapushttp://ruslancullank1.blogspot.com/2012/10/deskripsilatihan3736110054.html
BalasHapushttp://burhankhang58.blogspot.com/2012/10/latihan3736110047_28.html
BalasHapushttp://rizka-azisah.blogspot.com/2012/11/deskripsi-penyelesaian-latihan3736110041.html
BalasHapus