DGV36108001.DataSource = LOVE End Sub 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
If T136108001.Text <> T936108001.Text Then Dim AYI As New ByIskandar.CariKeDataBaseByIskandar AYI.AturPencarianDataBase("mastertransaksi", "NOTRANS", T136108001.Text, 1, INCE) If AYI.JumlanBaris > 0 Then MsgBox("Nomor transaksi tersebut sudah ada") Else AA() End If Exit Sub End If AA() End Sub End Class
lanjutan Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If LATIHAN40B.Visible = False Then LATIHAN40B.Show() Else LATIHAN40B.Activate() End If LATIHAN40B.TextBox1.Text = DataGridView1.CurrentRow.Cells("notrans").Value LATIHAN40B.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("tanggaltransaksi").Value LATIHAN40B.ToolStripStatusLabel2.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value LATIHAN40B.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("notrans").Value End Sub
lanjutan Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim heril As String = "delete * from detailtransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(heril, konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() angkut.Dispose()
lanjutan Dim Ilyas As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(Ilyas, konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() angkut.Dispose() MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If LATIHAN40B.Visible = False Then LATIHAN40B.Show() Else LATIHAN40B.Activate() End If End Sub End Class
Public Class LATIHAN040A012 Dim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=280765") Dim khaeril As New DataTable Dim khaerilanak As New DataTable Dim datset As New DataSet Dim bin As New BindingSource
Dim bin2 As New BindingSource Dim angkut As New OleDb.OleDbCommand Private Sub latihan213619043_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cobaji As New OleDb.OleDbDataAdapter Dim cobaji2 As New OleDb.OleDbDataAdapter cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", konek) cobaji.Fill(khaeril) cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", konek) cobaji2.Fill(khaerilanak)
LANJUTAN If khaeril.Rows.Count = 0 Then MsgBox("Isi datatable k..") Exit Sub End If cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each r As DataRow In khaeril.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
Public Class LATIHAN40B Dim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=280765") Dim khaeril As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar
lanjutan If khaeril.Rows.Count = 0 Then MsgBox("cek data tabelta") Exit Sub End If cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If
For Each r As DataRow In khaeril.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
Public Sub edit() If TextBox1.Text.Length = 0 Then MsgBox("belum terisi notrans") Exit Sub End If
If jt.Text.Length = 0 Then MsgBox("belum terisi jenitransaksi") Exit Sub End If LANJUTAN If khaeril.Rows.Count = 0 Then MsgBox("cek data tabelta") Exit Sub End If If TextBox1.Text <> ToolStripStatusLabel1.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If
lanjutan For Each r As DataRow In khaeril.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() Next angkut.Dispose() TextBox1.Text = "" jt.Text = "" Tot.Text = "" ToolStripStatusLabel1.Text = "-" khaeril.Rows.Clear() End Sub Private Sub LATIHAN40b_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load hubung = 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 = '" & TextBox1.Text & "'", konek) khaeril.Rows.Clear() hubung.Fill(khaeril) Dim dc(1) As DataColumn dc(0) = khaeril.Columns("kodebarang") khaeril.PrimaryKey = dc
LANJUTAN khaeril.Columns("unit").DefaultValue = 0 khaeril.Columns("harga").DefaultValue = 0 khaeril.Columns("jumlah").DefaultValue = 0 DataGridView1.DataSource = khaeril End Sub Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView1.CurrentRow.Cells("UNIT").Value=0 DataGridView1.CurrentRow.Cells("HARGA").Value=0 DataGridView1.CurrentRow.Cells("JUMLAH").Value=0 cari.AturPencarianDataBase("barang","kodebarang",DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, konek) If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value =cari.DataTablenya.Rows(0).Item("NAMABARANG")
LANJUTAN Else DataGridView1.CurrentRow.Cells("NAMABARANG").Value ="" If LATIHAN3839.ShowDialog =Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("NAMABARANG").Value End If End If ElseIf DataGridView1.Columns(e.ColumnIndex).Name="UNIT"OrDataGridView1.Columns(e.ColumnIndex).Name="HARGA" Then DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value Dim manis As Integer For Each r As DataGridViewRow In DataGridView1. Rows manis = manis + r.Cells("JUMLAH").Value Next Tot.Text = manis End If End Sub Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then tambah() Else edit() End If End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub End Class
Public Class Form40A36109040 Dim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=150991") Dim mytha1 As New DataTable Dim mytha2 As New DataTable Dim datset As New DataSet Dim bin As New BindingSource Dim bin2 As New BindingSource Dim angkut As New OleDb.OleDbCommand Private Sub form30A36109040_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cobaji As New OleDb.OleDbDataAdapter Dim cobaji2 As New OleDb.OleDbDataAdapter cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", konek) cobaji.Fill(mytha1) cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", konek) cobaji2.Fill(mytha2) mytha1.TableName = "induknya" mytha2.TableName = "anaknya" datset.Tables.Add(mytha1) datset.Tables.Add(mytha2) datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS"))) bin.DataSource = datset bin.DataMember = "induknya" bin2.DataSource = bin bin2.DataMember = "cobaji" DataGridView1.DataSource = bin DataGridView2.DataSource = bin2 End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If Form40B36109040.Visible = False Then Form40B36109040.Show() Else Form40B36109040.Activate() End If Form40B36109040.TextBox1.Text = DataGridView1.CurrentRow.Cells("notrans").Value Form40B36109040.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("tanggaltransaksi").Value Form40B36109040.ToolStripStatusLabel2.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value Form40B36109040.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("notrans").Value End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim temmyta As String = "delete * from detailtransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(temmyta, konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() angkut.Dispose()
Dim tamy As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(tamy, konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() angkut.Dispose() MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Form40B36109040.Visible = False Then Form40B36109040.Show() Else Form40B36109040.Activate() End If End Sub End Class
Public Class Form40B36109040 Dim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=150991") Dim mytha1 As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim angkut As New OleDb.OleDbCommand Dim hubung As New OleDb.OleDbDataAdapter Private Sub tambah() If TextBox1.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If mytha1.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If
For Each r As DataRow In mytha1.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
konek.Open() angkut.ExecuteNonQuery() konek.Close() Next angkut.Dispose()
Public Sub edit() If TextBox1.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If mytha1.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If If TextBox1.Text <> ToolStripStatusLabel1.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close()
For Each r As DataRow In khaeril.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() Next angkut.Dispose()
Private Sub Form40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load hubung = 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 = '" & TextBox1.Text & "'", konek) mytha1.Rows.Clear() hubung.Fill(mytha1) Dim dc(1) As DataColumn dc(0) = mytha1.Columns("kodebarang") mytha1.PrimaryKey = dc
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView1.CurrentRow.Cells("UNIT").Value = 0 DataGridView1.CurrentRow.Cells("HARGA").Value = 0 DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0 cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, konek) If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" If LATIHAN3839.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value Dim donggg As Integer For Each r As DataGridViewRow In DataGridView1.Rows donggg = donggg + r.Cells("JUMLAH").Value Next Tot.Text = donggg End If End Sub Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then tambah() Else edit() End If End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError MsgBox("ada yang salah") End Sub End Class
Public Class Latih40A_36109034 Dim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=miss") Dim nurhidayah As New DataTable Dim nhunoe As New DataTable Dim datset As New DataSet Dim bin As New BindingSource Dim bin2 As New BindingSource Dim angkut As New OleDb.OleDbCommand Private Sub Lati21_36109034_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cobaji As New OleDb.OleDbDataAdapter Dim cobaji2 As New OleDb.OleDbDataAdapter cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", conect) cobaji.Fill(nurhidayah) cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", conect) cobaji2.Fill(nhunoe) nurhidayah.TableName = "induknya" nhunoe.TableName = "anaknya" datset.Tables.Add(nurhidayah) datset.Tables.Add(nhunoe) datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS"))) bin.DataSource = datset bin.DataMember = "induknya" bin2.DataSource = bin bin2.DataMember = "cobaji" DataGridView1.DataSource = bin DataGridView2.DataSource = bin2 End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If Latih40B_36109034.Visible = False Then Latih40B_36109034.Show() Else Latih40B_36109034.Activate() End If Latih40B_36109034.TextBox1_36109034.Text = DataGridView1.CurrentRow.Cells("notrans").Value Latih40B_36109034.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("tanggaltransaksi").Value Latih40B_36109034.TS.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value Latih40B_36109034.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("notrans").Value End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim noe As String = "delete * from detailtransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(noe, conect) conect.Open() angkut.ExecuteNonQuery() conect.Close() angkut.Dispose()
Dim Ibrahim As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(Ibrahim, conect) conect.Open() angkut.ExecuteNonQuery() conect.Close() angkut.Dispose() MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Latih40B_36109034.Visible = False Then Latih40B_36109034.Show() Else Latih40B_36109034.Activate() End If End Sub End Class
For Each r As DataRow In Juni.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox136109037.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", Conect) Conect.Open() angkut.ExecuteNonQuery() Conect.Close() Next angkut.Dispose() TextBox136109037.Text = "" jt36109037.Text = "" Tot36109037.Text = "" ToolStripStatusLabel1.Text = "Sudah tersimpan" Juni.Rows.Clear() End Sub Public Sub edit() If TextBox136109037.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If If jt36109037.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If If Juni.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If If TextBox136109037.Text <> ToolStripStatusLabel1.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109037.Text, 1, Conect) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", Conect) Conect.Open() angkut.ExecuteNonQuery() Conect.Close() angkut = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox136109037.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109037.Text & "')", Conect) Conect.Open() angkut.ExecuteNonQuery() Conect.Close() angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", Conect) Conect.Open() angkut.ExecuteNonQuery() Conect.Close()
Public Class Latihan40a_36109049 Dim wirda 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 dt1 As New DataTable Dim dset As New DataSet 'Deklarasi dataset' Dim Bsource1 As New BindingSource 'Deklarasi bindingsource' Dim Bsource2 As New BindingSource Public Sub wirdapaulus() 'Membersihkan detailtransaksi lalu mastertransaksi' dt1.Rows.Clear() dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", wirda) B1.Fill(dt)
B1 = New OleDb.OleDbDataAdapter("Select DETAILTRANSAKSI.NOTRANS, DETAILTRANSAKSI.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG", wirda) B1.Fill(dt1)
B1.Dispose() End Sub
Private Sub Latihan_40a_36109058_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load wirdapaulus()
'Memasukkan datatabel dalam dataset' dset.Tables.Add(dt) dset.Tables.Add(dt1)
'Mengganti nama datatabel dalam dataset' dt.TableName = "T01" dt1.TableName = "T02"
'Menambahkan relasi dalam dataset' dset.Relations.Add(New DataRelation("X", dset.Tables("T01").Columns("NOTRANS"), dset.Tables("T02").Columns("NOTRANS")))
'Datasource dan membersource' Bsource1.DataSource = dset Bsource1.DataMember = "T01" Bsource2.DataSource = Bsource1 Bsource2.DataMember = "X"
'Memasukkan datatabel dari bindingsource ke dalam DVG' DataGridView1.DataSource = Bsource1 DataGridView2.DataSource = Bsource2 End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim z As New OleDb.OleDbCommand z = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", wirda) wirda.Open() z.ExecuteNonQuery() wirda.Close()
z = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", wirda) wirda.Open() z.ExecuteNonQuery() wirda.Close()
z.Dispose()
wirdapaulus()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If Latihan40B_36109049.Visible = False Then Latihan40B_36109049.Show() Else Latihan40B_36109049.Activate() End If
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Latihan40B_36109049.Visible = False Then Latihan40B_36109049.Show() Else Latihan40B_36109049.Activate() End If
Public Class Latihan40B_36109049 Dim wirda As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;jet OLEDB:database password=wirda") Dim DATA As New DataTable Public Sub dandy() 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= '" & TextBox1_36109049.Text & "'", wirda) DATA.Rows.Clear() X.Fill(DATA) End Sub
Private Sub Latihan40B_36109049_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dataPrimary(1) As DataColumn dataPrimary(0) = DATA.Columns("NOTRANS") DATA.PrimaryKey = dataPrimary
DataGridView1.DataSource = DATA
TOTALJUMLAH() End Sub Public Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In DATA.Rows TOT = TOT + x("JUMLAH") Next TextBox3_36109049.Text = TOT End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then 'Cari nama barang' DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView1.CurrentRow.Cells("UNIT").Value = 0 DataGridView1.CurrentRow.Cells("HARGA").Value = 0 DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, wirda) 'Menampilkan nama barang jika isi kolom kodebarang ditemukan oleh proses diatas' If Pencari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView1.CurrentRow.Cells("KODEBARANG").Value = "" If LATIHAN3839_36109049.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839_36109049.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839_36109049.DataGridView1.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then 'Hitung kolom jumlah' DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value End If End Sub
Private Sub simpan_tambah() If TextBox1_36109049.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If TextBox2_36109049.Text.Length = 0 Then MsgBox("Maaf, Jenis transaksi harus diisi dulu") Exit Sub End If
If DATA.Rows.Count() = 0 Then MsgBox("Maaf, Proses tidak dapat dilanjutkan") Exit Sub End If
If StatusStrip1.Text <> TextBox1_36109049.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox1_36109049.Text, 1, wirda) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim z As New OleDb.OleDbCommand z = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & TextBox1_36109049.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & TextBox1_36109049.Text & "')", wirda) 'Membuka koneksi' wirda.Open() 'Eksekusi prose penyimpanan' z.ExecuteNonQuery() 'Menutup koneksi' wirda.Close()
'Memeriksa isi jumlah baris dalam object tabel' For Each X As DataRow In DATA.Rows 'Mengatur perintah simpan' z = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox1_36109049.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", wirda) wirda.Open() z.ExecuteNonQuery() wirda.Close() z.Dispose() Next
Private Sub simpan_edit() If TextBox1_36109049.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If TextBox2_36109049.Text.Length = 0 Then MsgBox("Maaf, Jenis transaksi harus diisi dulu") Exit Sub End If
If DATA.Rows.Count() = 0 Then MsgBox("Maaf, Proses tidak dapat dilanjutkan") Exit Sub End If
If StatusStrip1.Text <> TextBox1_36109049.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox1_36109049.Text, 1, wirda) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim z As New OleDb.OleDbCommand z = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & TextBox1_36109049.Text & "'", wirda) wirda.Open() z.ExecuteNonQuery() wirda.Close()
z = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & TextBox1_36109049.Text & "'", wirda) wirda.Open() z.ExecuteNonQuery() wirda.Close()
'Memeriksa isi jumlah baris dalam object tabel' For Each XX As DataRow In DATA.Rows 'Mengatur perintah simpan' z = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox1_36109049.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", wirda) wirda.Open() z.ExecuteNonQuery() wirda.Close() z.Dispose() Next
TOTALJUMLAH() Latihan40a_36109049.wirdapaulus() End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If StatusStrip1.Text = "-" Then simpan_tambah() Else simpan_edit() End If End Sub End Class
Public Class Latih40B_36109034 Dim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=miss") Dim nurhidayah As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim angkut As New OleDb.OleDbCommand Dim hubung As New OleDb.OleDbDataAdapter Private Sub tambah() If TextBox1_36109034.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt_36109034.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If nurhidayah.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1_36109034.Text, 1, conect) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If
For Each r As DataRow In nurhidayah.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1_36109034.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", conect)
conect.Open() angkut.ExecuteNonQuery() conect.Close() Next angkut.Dispose()
'LANJUTAN Public Sub edit() If TextBox1_36109034.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt_36109034.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If nurhidayah.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If If TextBox1_36109034.Text <> ToolStripStatusLabel1.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1_36109034.Text, 1, conect) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect) conect.Open() angkut.ExecuteNonQuery() conect.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect) conect.Open() angkut.ExecuteNonQuery() conect.Close()
For Each r As DataRow In nurhidayah.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1_36109034.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", conect) conect.Open() angkut.ExecuteNonQuery() conect.Close() Next angkut.Dispose()
Private Sub LATIHAN40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load hubung = 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 = '" & TextBox1_36109034.Text & "'", conect) nurhidayah.Rows.Clear() hubung.Fill(nurhidayah) Dim dc(1) As DataColumn dc(0) = nurhidayah.Columns("kodebarang") nurhidayah.PrimaryKey = dc
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView1.CurrentRow.Cells("UNIT").Value = 0 DataGridView1.CurrentRow.Cells("HARGA").Value = 0 DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0 cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, conect) If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" If Latih3839_36109034.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = Latih3839_36109034.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = Latih3839_36109034.DataGridView1.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value Dim manis As Integer For Each r As DataGridViewRow In DataGridView1.Rows manis = manis + r.Cells("JUMLAH").Value Next Tot_36109034.Text = manis End If End Sub Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then tambah() Else edit() End If End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError MsgBox("ada yang salah") End Sub End Class
Dim sambung As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=jayapura") Dim papua As New DataTable Dim jayapura As New DataTable Dim datset As New DataSet Dim bin As New BindingSource Dim bin2 As New BindingSource Dim esthi As New OleDb.OleDbCommand
Private Sub LATIHAN040A36109032_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim tes As New OleDb.OleDbDataAdapter Dim testes As New OleDb.OleDbDataAdapter tes = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", sambung) tes.Fill(papua) testes = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", sambung) testes.Fill(jayapura) papua.TableName = "induknya" jayapura.TableName = "anaknya" datset.Tables.Add(papua) datset.Tables.Add(jayapura) datset.Relations.Add(New DataRelation("tes", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS"))) bin.DataSource = datset bin.DataMember = "induknya" bin2.DataSource = bin bin2.DataMember = "tes" DataGridView1.DataSource = bin DataGridView2.DataSource = bin2 End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If LATIHAN040B36109032.Visible = False Then LATIHAN040B36109032.Show() Else LATIHAN040B36109032.Activate() End If LATIHAN040B36109032.TextBox1.Text = DataGridView1.CurrentRow.Cells("notrans").Value LATIHAN040B36109032.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("tanggaltransaksi").Value LATIHAN040B36109032.TS.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value LATIHAN040B36109032.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("notrans").Value End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim mirasthi As String = "delete * from detailtransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" esthi = New OleDb.OleDbCommand(mirasthi, sambung) sambung.Open() esthi.ExecuteNonQuery() sambung.Close() esthi.Dispose()
Dim batotampak As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" esthi = New OleDb.OleDbCommand(batotampak, sambung) sambung.Open() esthi.ExecuteNonQuery() sambung.Close() esthi.Dispose() MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ") End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If LATIHAN040B36109032.Visible = False Then LATIHAN040B36109032.Show() Else LATIHAN040B36109032.Activate() End If End Sub End Class
Dim sambung As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=jayapura") Dim esthi As New DataTable Dim nokia As New ByIskandar.CariKeDataBaseByIskandar Dim toshiba As New OleDb.OleDbCommand Dim key As New OleDb.OleDbDataAdapter
Private Sub akuntansi() If TextBox1.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If JT.Text.Length = 0 Then MsgBox("Jenis Transaksi belum terisi") Exit Sub End If
If esthi.Rows.Count = 0 Then MsgBox("coba periksa tabel anda") Exit Sub End If nokia.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, sambung) If nokia.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If
For Each r As DataRow In esthi.Rows toshiba = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", sambung)
sambung.Open() toshiba.ExecuteNonQuery() sambung.Close() Next toshiba.Dispose()
Public Sub flash() If TextBox1.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If JT.Text.Length = 0 Then MsgBox("Jenis Transaksi Belum Terisi") Exit Sub End If
If esthi.Rows.Count = 0 Then MsgBox("coba periksa tabel anda") Exit Sub End If If TextBox1.Text <> ToolStripStatusLabel1.Text Then nokia.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, sambung) If nokia.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If
toshiba = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", sambung) sambung.Open() toshiba.ExecuteNonQuery() sambung.Close()
toshiba = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", sambung) sambung.Open() toshiba.ExecuteNonQuery() sambung.Close()
For Each r As DataRow In esthi.Rows toshiba = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", sambung) sambung.Open() toshiba.ExecuteNonQuery() sambung.Close() Next toshiba.Dispose()
Private Sub LATIHAN040A36109032_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load key = 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 = '" & TextBox1.Text & "'", sambung) esthi.Rows.Clear() key.Fill(esthi) Dim dc(1) As DataColumn dc(0) = esthi.Columns("kodebarang") esthi.PrimaryKey = dc
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView1.CurrentRow.Cells("UNIT").Value = 0 DataGridView1.CurrentRow.Cells("HARGA").Value = 0 DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0 nokia.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, sambung) If nokia.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = nokia.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" If LATIHAN038039.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN038039.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN038039.DataGridView1.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value Dim makan As Integer For Each r As DataGridViewRow In DataGridView1.Rows makan = makan + r.Cells("JUMLAH").Value Next TOT.Text = makan End If End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then akuntansi() Else flash() End If End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError MsgBox("ada yang salah")
Public Class LATIHAN040A041 Dim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=12") Dim khaeril As New DataTable Dim khaerilanak As New DataTable Dim datset As New DataSet Dim bin As New BindingSource Dim bin2 As New BindingSource Dim angkut As New OleDb.OleDbCommand Private Sub latihan213619043_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cobaji As New OleDb.OleDbDataAdapter Dim cobaji2 As New OleDb.OleDbDataAdapter cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", konek) cobaji.Fill(khaeril) cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", konek) cobaji2.Fill(khaerilanak) khaeril.TableName = "induknya" khaerilanak.TableName = "anaknya" datset.Tables.Add(khaeril) datset.Tables.Add(khaerilanak) datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS"))) bin.DataSource = datset bin.DataMember = "induknya" bin2.DataSource = bin bin2.DataMember = "cobaji" DataGridView136109041.DataSource = bin DataGridView236109041.DataSource = bin2 End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109041.Click If LATIHAN040B041.Visible = False Then LATIHAN040B041.Show() Else LATIHAN040B041.Activate() End If LATIHAN040B041.TextBox136109041.Text = DataGridView136109041.CurrentRow.Cells("notrans").Value LATIHAN040B041.DateTimePicker136109041.Value = DataGridView136109041.CurrentRow.Cells("tanggaltransaksi").Value LATIHAN040B041.ToolStripStatusLabel236109041.Text = DataGridView136109041.CurrentRow.Cells("jenistransaksi").Value LATIHAN040B041.ToolStripStatusLabel136109041.Text = DataGridView136109041.CurrentRow.Cells("notrans").Value End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109041.Click Dim heril As String = "delete * from detailtransaksi where notrans = '" & DataGridView136109041.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(heril, konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() angkut.Dispose()
Dim Ilyas As String = "delete * from mastertransaksi where notrans = '" & DataGridView136109041.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(Ilyas, konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() angkut.Dispose() MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109041.Click If LATIHAN040B041.Visible = False Then LATIHAN040B041.Show() Else LATIHAN040B041.Activate() End If End Sub End Class
Public Class LATIHAN040B041 Dim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=12") Dim khaeril As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim angkut As New OleDb.OleDbCommand Dim hubung As New OleDb.OleDbDataAdapter Private Sub tambah() If TextBox136109041.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt36109041.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If khaeril.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109041.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If
For Each r As DataRow In khaeril.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox136109041.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
konek.Open() angkut.ExecuteNonQuery() konek.Close() Next angkut.Dispose()
lanjutan Public Sub edit() If TextBox136109041.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt36109041.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If khaeril.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If If TextBox136109041.Text <> ToolStripStatusLabel136109041.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109041.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel136109041.Text & "'", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel136109041.Text & "'", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close()
For Each r As DataRow In khaeril.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox136109041.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() Next angkut.Dispose()
lanjutan Private Sub LATIHAN40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load hubung = 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 = '" & TextBox136109041.Text & "'", konek) khaeril.Rows.Clear() hubung.Fill(khaeril) Dim dc(1) As DataColumn dc(0) = khaeril.Columns("kodebarang") khaeril.PrimaryKey = dc
DataGridView136109041.DataSource = khaeril End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView136109041.CellEndEdit If DataGridView136109041.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView136109041.CurrentRow.Cells("UNIT").Value = 0 DataGridView136109041.CurrentRow.Cells("HARGA").Value = 0 DataGridView136109041.CurrentRow.Cells("JUMLAH").Value = 0 cari.AturPencarianDataBase("barang", "kodebarang", DataGridView136109041.CurrentRow.Cells("KODEBARANG").Value, 1, konek) If cari.JumlanBaris > 0 Then DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value = "" If LATIHAN3839.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView136109041.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839.DataGridView136109041.CurrentRow.Cells("KODEBARANG").Value DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839.DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DataGridView136109041.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView136109041.Columns(e.ColumnIndex).Name = "HARGA" Then DataGridView136109041.CurrentRow.Cells("JUMLAH").Value = DataGridView136109041.CurrentRow.Cells("UNIT").Value * DataGridView136109041.CurrentRow.Cells("HARGA").Value Dim manis As Integer For Each r As DataGridViewRow In DataGridView136109041.Rows manis = manis + r.Cells("JUMLAH").Value Next Tot36109041.Text = manis End If End Sub Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109041.Click If ToolStripStatusLabel136109041.Text = "NO.TRANSAKSI" Then tambah() Else edit() End If End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView136109041.DataError MsgBox("ada yang salah") End Sub End Class
Public Class LATIHAN040A36109033 Dim pratiwi 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 data1 As New DataTable Dim dset As New DataSet 'Deklarasi dataset' Dim Bsource As New BindingSource 'Deklarasi bindingsource' Dim Bsource1 As New BindingSource Public Sub tiwi() 'Membersihkan detailtransaksi lalu mastertransaksi' data1.Rows.Clear() data.Rows.Clear()
Dim tahir As New OleDb.OleDbDataAdapter tahir = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", pratiwi) tahir.Fill(data)
tahir = New OleDb.OleDbDataAdapter("Select DETAILTRANSAKSI.NOTRANS, DETAILTRANSAKSI.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG", pratiwi) tahir.Fill(data1)
tahir.Dispose() End Sub Private Sub LATIHAN040A36109033_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load tiwi()
'Memasukkan datatabel dalam dataset' dset.Tables.Add(data) dset.Tables.Add(data1)
'Mengganti nama datatabel dalam dataset' data.TableName = "T01" data1.TableName = "T02"
'Menambahkan relasi dalam dataset' dset.Relations.Add(New DataRelation("X", dset.Tables("T01").Columns("NOTRANS"), dset.Tables("T02").Columns("NOTRANS")))
'Datasource dan membersource' Bsource.DataSource = dset Bsource.DataMember = "T01" Bsource1.DataSource = Bsource Bsource1.DataMember = "X"
'Memasukkan datatabel dari bindingsource ke dalam DVG' DataGridView1.DataSource = Bsource DataGridView2.DataSource = Bsource1 End Sub
Private Sub Button136109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109033.Click Dim t As New OleDb.OleDbCommand t = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", pratiwi) pratiwi.Open() t.ExecuteNonQuery() pratiwi.Close()
t = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", pratiwi) pratiwi.Open() t.ExecuteNonQuery() pratiwi.Close()
t.Dispose()
tiwi() End Sub Private Sub Button336109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109033.Click
If LATIHAN_040B_36109033.Visible = False Then LATIHAN_040B_36109033.Show() Else LATIHAN_040B_36109033.Activate() End If
End Sub Private Sub Button236109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109033.Click If LATIHAN_040B_36109033.Visible = False Then LATIHAN_040B_36109033.Show() Else LATIHAN_040B_36109033.Activate() End If
Public Class LATIHAN_040B_36109033 Dim pratiwi 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 Public Sub poltek() 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= '" & TextBox136109033.Text & "'", pratiwi) data.Rows.Clear() X.Fill(data) End Sub Private Sub LATIHAN_040B_36109033_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dataPrimary(1) As DataColumn dataPrimary(0) = data.Columns("NOTRANS") data.PrimaryKey = dataPrimary
DataGridView1.DataSource = data
TOTALJUMLAH() End Sub Public Sub TOTALJUMLAH() Dim TOT As Double = 0 For Each x As DataRow In data.Rows TOT = TOT + x("JUMLAH") Next Tot36109033.Text = TOT
End Sub Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then 'Cari nama barang' DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView1.CurrentRow.Cells("UNIT").Value = 0 DataGridView1.CurrentRow.Cells("HARGA").Value = 0 DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0 Dim browse As New ByIskandar.CariKeDataBaseByIskandar browse.AturPencarianDataBase("BARANG", "KODEBARANG", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, pratiwi) 'Menampilkan nama barang jika isi kolom kodebarang ditemukan oleh proses diatas' If browse.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = browse.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView1.CurrentRow.Cells("KODEBARANG").Value = "" If LATIHAN3839_36109033.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839_36109033.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839_36109033.DataGridView1.CurrentRow.Cells("NAMABARANG").Value End If End If ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then 'Hitung kolom jumlah' DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value End If End Sub
Private Sub simpan_tambah() If TextBox136109033.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If If TextBox136109033.Text.Length = 0 Then MsgBox("Maaf, Jenis transaksi harus diisi dulu") Exit Sub End If
If data.Rows.Count() = 0 Then MsgBox("Maaf, Proses tidak dapat dilanjutkan") Exit Sub End If If StatusStrip1.Text <> TextBox136109033.Text Then Dim browse As New ByIskandar.CariKeDataBaseByIskandar browse.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox136109033.Text, 1, pratiwi) If browse.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If Dim t As New OleDb.OleDbCommand t = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & TextBox136109033.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109033.Text & "')", pratiwi) 'Membuka koneksi' pratiwi.Open() 'Eksekusi prose penyimpanan' t.ExecuteNonQuery() 'Menutup koneksi' pratiwi.Close() 'Memeriksa isi jumlah baris dalam object tabel' For Each X As DataRow In data.Rows 'Mengatur perintah simpan' t = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox136109033.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", pratiwi) pratiwi.Open() t.ExecuteNonQuery() pratiwi.Close() t.Dispose() Next
Private Sub simpan_edit() If TextBox136109033.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If jt36109033.Text.Length = 0 Then MsgBox("Maaf, Jenis transaksi harus diisi dulu") Exit Sub End If
If DATA.Rows.Count() = 0 Then MsgBox("Maaf, Proses tidak dapat dilanjutkan") Exit Sub End If
If StatusStrip1.Text <> TextBox136109033.Text Then Dim browse As New ByIskandar.CariKeDataBaseByIskandar browse.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox136109033.Text, 1, pratiwi) If browse.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If Dim z As New OleDb.OleDbCommand z = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & TextBox136109033.Text & "'", pratiwi) pratiwi.Open() z.ExecuteNonQuery() pratiwi.Close()
z = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & TextBox136109033.Text & "'", pratiwi) pratiwi.Open() z.ExecuteNonQuery() pratiwi.Close()
'Memeriksa isi jumlah baris dalam object tabel' For Each XX As DataRow In data.Rows 'Mengatur perintah simpan' z = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox136109033.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", pratiwi) pratiwi.Open() z.ExecuteNonQuery() pratiwi.Close() z.Dispose() Next
TOTALJUMLAH() LATIHAN040A36109033.tiwi() End Sub Private Sub Button236109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109033.Click If StatusStrip1.Text = "-" Then simpan_tambah() Else simpan_edit() End If End Sub End Class
Public Class LATIHAN40B_36109051 Dim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=molnan") Dim novi As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim greenholic As New OleDb.OleDbCommand Dim hubung As New OleDb.OleDbDataAdapter Private Sub tambah() If TextBox1.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If khaeril.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, novi) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If
For Each r As DataRow In novi.Rows greenholic = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", conect)
conect.Open() greenholic.ExecuteNonQuery() conect.Close() Next greenholic.Dispose()
novi.Rows.Clear() End Sub Public Sub edit() If TextBox1.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If novi.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If If TextBox1.Text <> ToolStripStatusLabel1.Text Then cari.AturPencarianDataBase
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, conect) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If
greenholic = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect) conect.Open() greenholic.ExecuteNonQuery() conect.Close()
greenholic = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect) conect.Open() greenholic.ExecuteNonQuery() conect.Close()
For Each r As DataRow In novi.Rows greenholic = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", conect) conect.Open() greenholic.ExecuteNonQuery() conect.Close() Next greenholic.Dispose()
Private Sub LATIHAN40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load hubung = 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 = '" & TextBox1.Text & "'", conect) novi.Rows.Clear() hubung.Fill(novi) Dim dc(1) As DataColumn dc(0) = novi.Columns("kodebarang") novi.PrimaryKey = dc
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView1.CurrentRow.Cells("UNIT").Value = 0 DataGridView1.CurrentRow.Cells("HARGA").Value = 0 DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0 cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, conect) If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" If LATIHAN3839.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value Dim greenpeace As Integer For Each r As DataGridViewRow In DataGridView1.Rows greenpeace = greenpeace + r.Cells("JUMLAH").Value Next Tot.Text = greenpeace End If End Sub Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then tambah() Else edit() End If End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError MsgBox("ada yang salah") End Sub End Class
Public Class LATIHAN_40B36109055 Dim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=2312") Dim falah As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim antar As New OleDb.OleDbCommand Dim hubung As New OleDb.OleDbDataAdapter Private Sub tambah() If TextBox136109055.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt36109055.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If falah.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109055.Text, 1, conect) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If
For Each r As DataRow In falah.Rows antar = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox136109055.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", conect)
conect.Open() antar.ExecuteNonQuery() conect.Close() Next antar.Dispose()
Public Sub edit() If TextBox136109055.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt36109055.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If falah.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If If TextBox136109055.Text <> ToolStripStatusLabel1.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109055.Text, 1, conect) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If
antar = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect) conect.Open() antar.ExecuteNonQuery() conect.Close()
antar = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect) conect.Open() antar.ExecuteNonQuery() conect.Close()
For Each r As DataRow In hasbiya.Rows antar = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox136109055.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", conect) conect.Open() antar.ExecuteNonQuery() conect.Close() Next antar.Dispose()
Private Sub LATIHAN_40B3610955_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load hubung = 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 = '" & TextBox136109055.Text & "'", conect) falah.Rows.Clear() hubung.Fill(falah) Dim dc(1) As DataColumn dc(0) = falah.Columns("kodebarang") falah.PrimaryKey = dc
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView136109055.CellEndEdit If DataGridView136109055.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView136109055.CurrentRow.Cells("UNIT").Value = 0 DataGridView136109055.CurrentRow.Cells("HARGA").Value = 0 DataGridView136109055.CurrentRow.Cells("JUMLAH").Value = 0 cari.AturPencarianDataBase("barang", "kodebarang", DataGridView136109055.CurrentRow.Cells("KODEBARANG").Value, 1, conect) If cari.JumlanBaris > 0 Then DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value = "" If LATIHAN3839_36109055.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView136109055.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839_36109055.DataGridView136109055.CurrentRow.Cells("KODEBARANG").Value DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839_36109055.DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DataGridView136109055.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then DataGridView136109055.CurrentRow.Cells("JUMLAH").Value = DataGridView136109055.CurrentRow.Cells("UNIT").Value * DataGridView136109055.CurrentRow.Cells("HARGA").Value Dim tes As Integer For Each r As DataGridViewRow In DataGridView1.Rows tes = tes + r.Cells("JUMLAH").Value Next Tot.Text = tes End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then tambah() Else edit() End If End Sub Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError MsgBox("ada yang salah") End Sub End Class
Public Class Form40A36109050 'DEKLARASI CONECTION Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=nideria") Dim DT1 As New DataTable Dim dt2 As New DataTable Dim dset As New DataSet Dim bs1 As New BindingSource Dim angkut As New OleDb.OleDbCommand Dim bs2 As New BindingSource Public Sub AP() Dim adapt As New OleDb.OleDbDataAdapter adapt = New OleDb.OleDbDataAdapter("select * FROM MASTERTRANSAKSI", CONECT) DT1.Rows.Clear() adapt.Fill(DT1) adapt = New OleDb.OleDbDataAdapter("select * FROM DETAILTRANSAKSI", CONECT) dt2.Rows.Clear() adapt.Fill(dt2) adapt.Dispose() End Sub Private Sub Form40A36109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim tes As New OleDb.OleDbDataAdapter Dim testes As New OleDb.OleDbDataAdapter tes = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", CONECT) tes.Fill(DT1) testes = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", CONECT) testes.Fill(dt2) DT1.TableName = "induknya" dt2.TableName = "anaknya" dset.Tables.Add(DT1) dset.Tables.Add(dt2) dset.Relations.Add(New DataRelation("tes", dset.Tables("induknya").Columns("NOTRANS"), dset.Tables("anaknya").Columns("NOTRANS"))) bs1.DataSource = dset bs1.DataMember = "induknya" bs2.DataSource = bs1 bs2.DataMember = "tes" DataGridView1.DataSource = bs1 DataGridView2.DataSource = bs2 End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim pp As New OleDb.OleDbCommand pp = New OleDb.OleDbCommand(" delete * from mastertransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONECT) CONECT.Open() pp.ExecuteNonQuery() CONECT.Close() pp = New OleDb.OleDbCommand(" delete * from detailtransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONECT) CONECT.Open() pp.ExecuteNonQuery() CONECT.Close() pp.Dispose() AP() Dim st As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(st, CONECT) CONECT.Open() angkut.ExecuteNonQuery() CONECT.Close() angkut.Dispose() MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Form40B36109050.Visible = False Then Form40B36109050.Show() Else Form40B36109050.Activate() End If Form40B36109050.TextBox1.Text = "" Form40B36109050.TS.Text = "-" Form40B36109050.jt.Text = "" Form40B36109050.NN() Form40B36109050.Pp() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If Form40B36109050.Visible = False Then Form40B36109050.Show() Else Form40B36109050.Activate() End If Form40B36109050.TextBox1.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value Form40B36109050.TS.Text = DataGridView1.CurrentRow.Cells("notrans").Value Form40B36109050.jt.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value Form40B36109050.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("TANGGALTRANSAKSI").Value Form40B36109050.NN() Form40B36109050.Pp() End Sub End Class
Public Class Form40B36109050 Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=nideria") Dim DT As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim angkut As New OleDb.OleDbCommand Dim hubung As New OleDb.OleDbDataAdapter Public Sub Pp() Dim db As Double For Each r As DataGridViewRow In DataGridView1.Rows db = db + r.Cells("JUMLAH").Value Next Tot.Text = db End Sub
Public Sub NN() Dim adapt As New OleDb.OleDbDataAdapter adapt = 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='" & TextBox1.Text & "'", CONECT) DT.Rows.Clear() adapt.Fill(DT) End Sub
Public Sub comm() Dim p As New OleDb.OleDbCommand p = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans='" & TS.Text & "'", CONECT) CONECT.Open() p.ExecuteNonQuery() CONECT.Close() Dim md As String md = "insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values('" & TextBox1.Text & "',#" & DateTimePicker1.Value & "#.'" & jt.Text & "');" p = New OleDb.OleDbCommand(md, CONECT) CONECT.Open() p.ExecuteNonQuery() CONECT.Close() p = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans='" & TS.Text & "'", CONECT) CONECT.Open() p.ExecuteNonQuery() CONECT.Close() For Each y As DataRow In DT.Rows p = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS,KODEBARANG,UNIT,HARGA VALUES('" & TextBox1.Text & "','" & y("kodebarang") & "','" & y("unit") & "','" & y("harga") & "')", CONECT) CONECT.Open() p.ExecuteNonQuery() CONECT.Close() Next p.Dispose() TextBox1.Text = "" jt.Text = "" TS.Text = "-" Tot.Text = "" DT.Rows.Clear() Pp() Form40A36109050.AP() End Sub
Private Sub Form40B36109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load NN() DT.Columns("unit").DefaultValue = 0 DT.Columns("harga").DefaultValue = 0 DT.Columns("jumlah").DefaultValue = 0 DataGridView1.DataSource = DT End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If e.ColumnIndex = 0 Then cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("kodebarang").Value, 1, CONECT) If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("kodebarang").Value = cari.DataTablenya.Rows(0).Item("kodebarang") DataGridView1.CurrentRow.Cells("namabarang").Value = cari.DataTablenya.Rows(0).Item("namabarang") DataGridView1.CurrentRow.Cells("harga").Value = cari.DataTablenya.Rows(0).Item("hargajual") Else MsgBox("kodebarang tersebut tdk ada") If Form38394036109050.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("kodebarang").Value = Form38394036109050.DataGridView1.CurrentRow.Cells("kodebarang").Value DataGridView1.CurrentRow.Cells("namabarang").Value = Form38394036109050.DataGridView1.CurrentRow.Cells("namabarang").Value DataGridView1.CurrentRow.Cells("harga").Value = Form38394036109050.DataGridView1.CurrentRow.Cells("hargajual").Value Else DataGridView1.CurrentRow.Cells("kodebarang").Value = "" DataGridView1.CurrentRow.Cells("namabarang").Value = "" DataGridView1.CurrentRow.Cells("harga").Value = "" End If End If ElseIf e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then DataGridView1.CurrentRow.Cells("jumlah").Value = DataGridView1.CurrentRow.Cells("unit").Value * DataGridView1.CurrentRow.Cells("harga").Value Pp() End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If TextBox1.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 DT.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If If TextBox1.Text <> TS.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, CONECT) If cari.JumlanBaris > 0 Then MsgBox("no.trans sudah ada") Else comm() End If Exit Sub End If comm() 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) Dim DT1 As New DataTable Dim dt2 As New DataTable Dim dset As New DataSet Dim bs1 As New BindingSource Dim bs2 As New BindingSource
Public Sub AP() 'deklarasi(adapter) Dim indah As New OleDb.OleDbDataAdapter indah = New OleDb.OleDbDataAdapter("select * FROM MASTERTRANSAKSI", CONNECT) 'memunculkan semua data dari dlm acces DT1.Rows.Clear() 'membersihkan data table indah.Fill(DT1) 'mengisi database ke dlm data table
indah = New OleDb.OleDbDataAdapter("select * FROM DETAILTRANSAKSI", CONNECT) 'memunculkan semua data dari dlm acces dt2.Rows.Clear() 'membersihkan data table indah.Fill(dt2) 'mengisi database ke dlm data table
indah.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
End Sub
Private Sub LATIHAN040A36109029_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dcp(1) As DataColumn dcp(0) = DT1.Columns("NOTRANS") DT1.PrimaryKey = dcp
AP()
dset.Tables.Add(DT1) dset.Tables.Add(dt2)
'mengganti nama dlm dataset DT1.TableName = "PP" dt2.TableName = "qq"
Private Sub Button136109029_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109029.Click Dim pp As New OleDb.OleDbCommand pp = New OleDb.OleDbCommand(" delete * from mastertransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONNECT) CONNECT.Open() pp.ExecuteNonQuery() CONNECT.Close()
pp = New OleDb.OleDbCommand(" delete * from detailtransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONNECT) CONNECT.Open() pp.ExecuteNonQuery() CONNECT.Close()
pp.Dispose()
AP()
End Sub
Private Sub Button236109029_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109029.Click If LATIHAN040B36109029.Visible = False Then LATIHAN040B36109029.Show() Else LATIHAN040B36109029.Activate() 'jika sdh muncul tp dibelakang End If
LATIHAN040B36109029.NN() LATIHAN040B36109029.Pp() End Sub
Private Sub Button336109029_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109029.Click If LATIHAN040B36109029.Visible = False Then LATIHAN040B36109029.Show() Else LATIHAN040B36109029.Activate() 'jika sdh muncul tp dibelakang End If
'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
Public Sub Pp()
Dim indah As Double For Each r As DataGridViewRow In DataGridView1.Rows indah = indah + r.Cells("JUMLAH").Value Next Tot36109029.Text = indah
End Sub
Public Sub NN() 'deklarasi adapter Dim nisa As New OleDb.OleDbDataAdapter nisa = New OleDb.OleDbDataAdapter("SELECT BARANG.KODEBARANG,BARANG.NAMABARANG,DETAILTRANSAKSI.UNIT,DETAILTRANSAKSI.HARGA,DETAILTRANSAKSI.UNIT * DETAILTRANSAKSI.HARGA AS JUMLAH FROM BARANG INNER JOIN DETAILTRANSAKSI ON BARANG.KODEBARANG=DETAILTRANSAKSI.KODEBARANG WHERE NOTRANS='" & TextBox136109029.Text & "'", CONNECT) DT.Rows.Clear() nisa.Fill(DT) End Sub
Public Sub princessqu() Dim p As New OleDb.OleDbCommand p = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans='" & TS.Text & "'", CONNECT) CONNECT.Open() p.ExecuteNonQuery() CONNECT.Close()
Dim md As String md = "insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values('" & TextBox136109029.Text & "',#" & DateTimePicker1.Value & "#.'" & jt36109029.Text & "');" p = New OleDb.OleDbCommand(md, CONNECT) CONNECT.Open() p.ExecuteNonQuery() CONNECT.Close()
p = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans='" & TS.Text & "'", CONNECT) CONNECT.Open() p.ExecuteNonQuery() CONNECT.Close()
For Each y As DataRow In DT.Rows p = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS,KODEBARANG,UNIT,HARGA VALUES('" & TextBox136109029.Text & "','" & y("kodebarang") & "','" & y("unit") & "','" & y("harga") & "')", CONNECT) CONNECT.Open() p.ExecuteNonQuery() CONNECT.Close() Next p.Dispose() TextBox136109029.Text = "" jt36109029.Text = "" TS.Text = "-" Tot36109029.Text = ""
DataGridView1.DataSource = DT 'memunculkan dlm datagridview End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If e.ColumnIndex = 0 Then cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("kodebarang").Value, 1, CONNECT)
If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("kodebarang").Value = cari.DataTablenya.Rows(0).Item("kodebarang") DataGridView1.CurrentRow.Cells("namabarang").Value = cari.DataTablenya.Rows(0).Item("namabarang") DataGridView1.CurrentRow.Cells("harga").Value = cari.DataTablenya.Rows(0).Item("hargajual") Else MsgBox("kodebarang tersebut tdk ada") If Latihan38029.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("kodebarang").Value = Latihan38029.DataGridView1.CurrentRow.Cells("kodebarang").Value DataGridView1.CurrentRow.Cells("namabarang").Value = Latihan38029.DataGridView1.CurrentRow.Cells("namabarang").Value DataGridView1.CurrentRow.Cells("harga").Value = Latihan38029.DataGridView1.CurrentRow.Cells("hargajual").Value Else DataGridView1.CurrentRow.Cells("kodebarang").Value = "" DataGridView1.CurrentRow.Cells("namabarang").Value = "" DataGridView1.CurrentRow.Cells("harga").Value = ""
End If End If
ElseIf e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then DataGridView1.CurrentRow.Cells("jumlah").Value = DataGridView1.CurrentRow.Cells("unit").Value * DataGridView1.CurrentRow.Cells("harga").Value Pp()
End If End Sub
Private Sub Button236109029_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109029.Click 'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap If TextBox136109029.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
If TextBox136109029.Text <> TS.Text Then 'untuk mencari jgn sampai data yg akan dimasukkan sudah ada cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109029.Text, 1, CONNECT)
If cari.JumlanBaris > 0 Then MsgBox("no.trans sudah ada") Else princessqu()
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
Public Sub Pp()
Dim cantik As Double For Each r As DataGridViewRow In DataGridView136109038.Rows cantik = cantik + r.Cells("JUMLAH").Value Next Tot36109038.Text = cantik
End Sub
Public Sub NN() Dim Icha As New OleDb.OleDbDataAdapter Icha = 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='" & TextBox136109038.Text & "'", CONECT) DT.Rows.Clear() Icha.Fill(DT) End Sub
Public Sub princessqu() Dim p As New OleDb.OleDbCommand p = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans='" & TS.Text & "'", CONECT) CONECT.Open() p.ExecuteNonQuery() CONECT.Close()
Dim md As String md = "insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values('" & TextBox136109038.Text & "',#" & DateTimePicker136109038.Value & "#.'" & jt36109038.Text & "');" p = New OleDb.OleDbCommand(md, CONECT) CONECT.Open() p.ExecuteNonQuery() CONECT.Close()
p = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans='" & TS.Text & "'", CONECT) CONECT.Open() p.ExecuteNonQuery() CONECT.Close()
For Each y As DataRow In DT.Rows p = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS,KODEBARANG,UNIT,HARGA VALUES('" & TextBox136109038.Text & "','" & y("kodebarang") & "','" & y("unit") & "','" & y("harga") & "')", CONECT) CONECT.Open() p.ExecuteNonQuery() CONECT.Close() Next p.Dispose() TextBox136109038.Text = "" jt36109038.Text = "" TS.Text = "-" Tot36109038.Text = ""
DT.Rows.Clear() Pp() LATIHAN040A36109038.AP()
End Sub
Private Sub LATIHAN040B36109038Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Private Sub DataGridView136109038_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView136109038.CellEndEdit If e.ColumnIndex = 0 Then cari.AturPencarianDataBase("barang", "kodebarang", DataGridView136109038.CurrentRow.Cells("kodebarang").Value, 1, CONECT)
Public Class LATIHAN040A36109054 Dim konek 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 wawan As New DataTable Dim wcuank As New DataTable Dim datset As New DataSet Dim bin As New BindingSource Dim bin2 As New BindingSource Dim angkut As New OleDb.OleDbCommand Private Sub latihan213619043_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim cobaji As New OleDb.OleDbDataAdapter Dim cobaji2 As New OleDb.OleDbDataAdapter cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", konek) cobaji.Fill(wawan) cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", konek) cobaji2.Fill(wcuank) wawan.TableName = "induknya" wcuank.TableName = "anaknya" datset.Tables.Add(wawan) datset.Tables.Add(wcuank) datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS"))) bin.DataSource = datset bin.DataMember = "induknya" bin2.DataSource = bin bin2.DataMember = "cobaji" DGV136109054.DataSource = bin DGV236109054.DataSource = bin2 End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109054.Click If LATIHAN40B36109054.Visible = False Then LATIHAN40B36109054.Show() Else LATIHAN40B36109054.Activate() End If LATIHAN40B36109054.TextBox136109054.Text = DGV136109054.CurrentRow.Cells("notrans").Value LATIHAN40B36109054.DTP136109054.Value = DGV136109054.CurrentRow.Cells("tanggaltransaksi").Value LATIHAN40B36109054.ToolStripStatusLabel2.Text = DGV136109054.CurrentRow.Cells("jenistransaksi").Value LATIHAN40B36109054.ToolStripStatusLabel1.Text = DGV136109054.CurrentRow.Cells("notrans").Value End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109054.Click Dim y As String y = MsgBox("apakah anda ingin hapusnya?", vbYesNo) If y = 6 Then
Dim sukma As String = "delete * from detailtransaksi where notrans = '" & DGV136109054.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(sukma, konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() angkut.Dispose()
Dim wan As String = "delete * from mastertransaksi where notrans = '" & DGV136109054.CurrentRow.Cells("notrans").Value & "'" angkut = New OleDb.OleDbCommand(wan, konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() angkut.Dispose() MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109054.Click If LATIHAN40B36109054.Visible = False Then LATIHAN40B36109054.Show() Else LATIHAN40B36109054.Activate() End If End Sub End Class
part 2 Public Sub edit() If TextBox136109054.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt36109054.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If wawan.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If If TextBox136109054.Text <> ToolStripStatusLabel1.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109054.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close()
For Each r As DataRow In wawan.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox136109054.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", konek) konek.Open() angkut.ExecuteNonQuery() konek.Close() Next angkut.Dispose()
Private Sub LATIHAN40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load hubung = 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 = '" & TextBox136109054.Text & "'", konek) wawan.Rows.Clear() hubung.Fill(wawan) Dim dc(1) As DataColumn dc(0) = wawan.Columns("kodebarang") wawan.PrimaryKey = dc
part 1 Public Class LATIHAN40B36109054 Dim konek 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 wawan As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim angkut As New OleDb.OleDbCommand Dim hubung As New OleDb.OleDbDataAdapter Private Sub tambah() If TextBox136109054.Text.Length = 0 Then MsgBox("notrans belum terisi") Exit Sub End If
If jt36109054.Text.Length = 0 Then MsgBox("Jenis Transaksinyabelum terisi") Exit Sub End If
If wawan.Rows.Count = 0 Then MsgBox("coba periksa tabelta") Exit Sub End If cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109054.Text, 1, konek) If cari.JumlanBaris > 0 Then MsgBox("notrans sudah ada") Exit Sub End If
For Each r As DataRow In wawan.Rows angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox136109054.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
konek.Open() angkut.ExecuteNonQuery() konek.Close() Next angkut.Dispose()
part 3 Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV136109054.CellEndEdit If DGV136109054.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DGV136109054.CurrentRow.Cells("NAMABARANG").Value = "" DGV136109054.CurrentRow.Cells("UNIT").Value = 0 DGV136109054.CurrentRow.Cells("HARGA").Value = 0 DGV136109054.CurrentRow.Cells("JUMLAH").Value = 0 cari.AturPencarianDataBase("barang", "kodebarang", DGV136109054.CurrentRow.Cells("KODEBARANG").Value, 1, konek) If cari.JumlanBaris > 0 Then DGV136109054.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else DGV136109054.CurrentRow.Cells("NAMABARANG").Value = "" If Latihan383940012.ShowDialog = Windows.Forms.DialogResult.OK Then DGV136109054.CurrentRow.Cells("KODEBARANG").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DGV136109054.CurrentRow.Cells("NAMABARANG").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DGV136109054.Columns(e.ColumnIndex).Name = "UNIT" Or DGV136109054.Columns(e.ColumnIndex).Name = "HARGA" Then DGV136109054.CurrentRow.Cells("JUMLAH").Value = DGV136109054.CurrentRow.Cells("UNIT").Value * DGV136109054.CurrentRow.Cells("HARGA").Value Dim manis As Integer For Each r As DataGridViewRow In DGV136109054.Rows manis = manis + r.Cells("JUMLAH").Value Next Tot36109054.Text = manis End If End Sub Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109054.Click If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then tambah() Else edit() End If End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DGV136109054.DataError MsgBox("ada yang salah") End Sub
Public Class LATIHAN040A012 'DEKLARASI CONECTION Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb") Dim DT1 As New DataTable Dim dt2 As New DataTable Dim dset As New DataSet Dim bs1 As New BindingSource Dim bs2 As New BindingSource
Public Sub AP() 'deklarasi(adapter) Dim jal As New OleDb.OleDbDataAdapter jal = New OleDb.OleDbDataAdapter("select * FROM MASTERTRANSAKSI", CONECT) 'memunculkan semua data dari dlm acces DT1.Rows.Clear() 'membersihkan data table jal.Fill(DT1) 'mengisi database ke dlm data table
jal = New OleDb.OleDbDataAdapter("select * FROM DETAILTRANSAKSI", CONECT) 'memunculkan semua data dari dlm acces dt2.Rows.Clear() 'membersihkan data table jal.Fill(dt2) 'mengisi database ke dlm data table
jal.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
End Sub
Private Sub LATIHAN040A012_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dcp(1) As DataColumn dcp(0) = DT1.Columns("NOTRANS") DT1.PrimaryKey = dcp
AP()
dset.Tables.Add(DT1) dset.Tables.Add(dt2)
'mengganti nama dlm dataset DT1.TableName = "PP" dt2.TableName = "qq"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim pp As New OleDb.OleDbCommand pp = New OleDb.OleDbCommand(" delete * from mastertransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONECT) CONECT.Open() pp.ExecuteNonQuery() CONECT.Close()
pp = New OleDb.OleDbCommand(" delete * from detailtransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONECT) CONECT.Open() pp.ExecuteNonQuery() CONECT.Close()
pp.Dispose()
AP()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If LATIHAN_040B_012.Visible = False Then LATIHAN_040B_012.Show() Else LATIHAN_040B_012.Activate() 'jika sdh muncul tp dibelakang End If
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If LATIHAN_040B_012.Visible = False Then LATIHAN_040B_012.Show() Else LATIHAN_040B_012.Activate() 'jika sdh muncul tp dibelakang End If
DataGridView1.DataSource = IJAL 'memunculkan dlm datagridview End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If e.ColumnIndex = 0 Then cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("kodebarang").Value, 1, CONECT)
If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("kodebarang").Value = cari.DataTablenya.Rows(0).Item("kodebarang") DataGridView1.CurrentRow.Cells("namabarang").Value = cari.DataTablenya.Rows(0).Item("namabarang") DataGridView1.CurrentRow.Cells("harga").Value = cari.DataTablenya.Rows(0).Item("hargajual") Else MsgBox("kodebarang tersebut tdk ada") If Latihan383940012.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("kodebarang").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("kodebarang").Value DataGridView1.CurrentRow.Cells("namabarang").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("namabarang").Value DataGridView1.CurrentRow.Cells("harga").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("hargajual").Value Else DataGridView1.CurrentRow.Cells("kodebarang").Value = "" DataGridView1.CurrentRow.Cells("namabarang").Value = "" DataGridView1.CurrentRow.Cells("harga").Value = ""
End If End If
elseif e.ColumnIndex=2 or e.ColumnIndex=3 then DataGridView1.CurrentRow.Cells("jumlah").Value = DataGridView1.CurrentRow.Cells("unit").Value * DataGridView1.CurrentRow.Cells("harga").Value Pp()
End If End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap If TextBox1.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("no transaksi belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If jt.Text.Length = 0 Then 'untuk pencarian yang bersifat angka MsgBox("jenis transaksi belum terisi") Exit Sub 'jgn lanjut ke proses berikutnya End If
If IJAL.Rows.Count = 0 Then MsgBox("data tidak tersedia") End If
If TextBox1.Text <> TS.Text Then 'untuk mencari jgn sampai data yg akan dimasukkan sudah ada cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then MsgBox("no.trans sudah ada") Else Rez()
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, CINTA As New DataTable Dim KASIH As New DataSet Dim KANGEN, RINDU As New BindingSource Public Sub UDANI() Dim YNK As New OleDb.OleDbDataAdapter CINTA.Rows.Clear() LOVE.Rows.Clear() YNK = New OleDb.OleDbDataAdapter("Select * from mastertransaksi", INCE) YNK.Fill(LOVE) YNK = New OleDb.OleDbDataAdapter("Select * from detailtransaksi", INCE) YNK.Fill(CINTA) End Sub Private Sub Form40b36108001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load UDANI()
Private Sub B136108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B136108001.Click Dim VE As New OleDb.OleDbCommand Dim PU As String PU = "delete * from mastertransaksi where notrans='" & DGV136108001.CurrentRow.Cells("notrans").Value & "'" VE = New OleDb.OleDbCommand(PU, INCE) INCE.Open() VE.ExecuteNonQuery() INCE.Close() Dim RA As String RA = "delete * from detailtransaksi where notrans='" & DGV136108001.CurrentRow.Cells("notrans").Value & "'" VE = New OleDb.OleDbCommand(RA, INCE) INCE.Open() VE.ExecuteNonQuery() INCE.Close() VE.Dispose() UDANI() End Sub Private Sub B236108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B236108001.Click If Form40b36108001.Visible = False Then Form40b36108001.Show() Else Form40b36108001.Activate() End If
Form40b36108001.TOT() End Sub Private Sub B336108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B336108001.Click If Form40b36108001.Visible = False Then Form40b36108001.Show() Else Form40b36108001.Activate() End If
Public Class Form40b36108001 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 Public Sub TOT() Dim LO As Integer For Each VE As DataRow In LOVE.Rows LO = LO + VE("Jumlah") Next T836108001.Text = LO End Sub Public Sub SAYANG() 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) End Sub Public Sub AA() Dim AKBAR As New OleDb.OleDbCommand Dim AAA As String AAA = "delete * from mastertransaksi where notrans='" & T936108001.Text & "'" AKBAR = New OleDb.OleDbCommand(AAA, INCE) INCE.Open() AKBAR.ExecuteNonQuery() INCE.Close()
Dim ANHYE As String ANHYE = "INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & T136108001.Text & "',#" & DTP36108001.Value.Date & "#,'" & T236108001.Text & "');" AKBAR = New OleDb.OleDbCommand(ANHYE, INCE) INCE.Open() AKBAR.ExecuteNonQuery() INCE.Close()
Dim TF As String TF = "delete * from detailtransaksi where notrans='" & T936108001.Text & "'" AKBAR = New OleDb.OleDbCommand(TF, INCE) INCE.Open() AKBAR.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") & "');" AKBAR = New OleDb.OleDbCommand(EGIET, INCE) INCE.Open() AKBAR.ExecuteNonQuery() INCE.Close() Next AKBAR.Dispose()
Private Sub DGV36108001_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV36108001.CellEndEdit If e.ColumnIndex = 0 Then Dim IA As New ByIskandar.CariKeDataBaseByIskandar IA.AturPencarianDataBase("barang", "kodebarang", DGV36108001.CurrentRow.Cells("KodeBarang").Value, 1, INCE) If IA.JumlanBaris > 0 Then DGV36108001.CurrentRow.Cells("KodeBarang").Value = IA.DataTablenya.Rows(0).Item("KodeBarang") DGV36108001.CurrentRow.Cells("NamaBarang").Value = IA.DataTablenya.Rows(0).Item("NamaBarang") DGV36108001.CurrentRow.Cells("Harga").Value = IA.DataTablenya.Rows(0).Item("HargaJual") Else MsgBox("Kode barang tersbut tidak ada") If Form38394036108001.ShowDialog = Windows.Forms.DialogResult.OK Then DGV36108001.CurrentRow.Cells("KodeBarang").Value = Form38394036108001.DGV36108001.CurrentRow.Cells("KodeBarang").Value DGV36108001.CurrentRow.Cells("NamaBarang").Value = Form38394036108001.DGV36108001.CurrentRow.Cells("NamaBarang").Value DGV36108001.CurrentRow.Cells("Harga").Value = Form38394036108001.DGV36108001.CurrentRow.Cells("HargaJual").Value Else DGV36108001.CurrentRow.Cells("KodeBarang").Value = "" DGV36108001.CurrentRow.Cells("NamaBarang").Value = "" DGV36108001.CurrentRow.Cells("Harga").Value = "" End If End If ElseIf e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then DGV36108001.CurrentRow.Cells("Jumlah").Value = DGV36108001.CurrentRow.Cells("Unit").Value * DGV36108001.CurrentRow.Cells("Harga").Value TOT() End If End Sub Private Sub Form40b36108001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SAYANG()
DGV36108001.DataSource = LOVE 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
If T136108001.Text <> T936108001.Text Then Dim AYI As New ByIskandar.CariKeDataBaseByIskandar AYI.AturPencarianDataBase("mastertransaksi", "NOTRANS", T136108001.Text, 1, INCE) If AYI.JumlanBaris > 0 Then MsgBox("Nomor transaksi tersebut sudah ada") Else AA() End If Exit Sub End If AA() End Sub End Class
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb") Dim fira As New DataTable Dim mula As New DataTable Dim uwais As New DataSet Dim ical As New BindingSource Dim arul As New BindingSource Public Sub AP() Dim kyu As New OleDb.OleDbDataAdapter kyu = New OleDb.OleDbDataAdapter("select * FROM MASTERTRANSAKSI", CONECT) fira.Rows.Clear() kyu.Fill(fira)
kyu = New OleDb.OleDbDataAdapter("select * FROM DETAILTRANSAKSI", CONECT) mula.Rows.Clear() kyu.Fill(mula)
kyu.Dispose()
End Sub
Private Sub LATIHAN40A36109044_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dcp(1) As DataColumn dcp(0) = fira.Columns("NOTRANS") fira.PrimaryKey = dcp
AP()
uwais.Tables.Add(fira) uwais.Tables.Add(mula)
'mengganti nama dlm dataset fira.TableName = "PP" mula.TableName = "qq"
'membuat binding data source (mengatur datasource dan data membernya) ical.DataSource = uwais ical.DataMember = "pp"
'datasource binding2 adalah nama binding pertama dan ata membernya adalah nama relasinya arul.DataSource = ical arul.DataMember = "NI"
DataGridView136109044.DataSource = ical DataGridView236109044.DataSource = arul End Sub
Private Sub Button136109044_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button136109044.Click Dim yoon As New OleDb.OleDbCommand yoon = New OleDb.OleDbCommand(" delete * from mastertransaksi where notrans='" & DataGridView136109044.CurrentRow.Cells("notrans").Value & "'", CONECT) CONECT.Open() yoon.ExecuteNonQuery() CONECT.Close()
yoon = New OleDb.OleDbCommand(" delete * from detailtransaksi where notrans='" & DataGridView136109044.CurrentRow.Cells("notrans").Value & "'", CONECT) CONECT.Open() yoon.ExecuteNonQuery() CONECT.Close()
yoon.Dispose()
AP() End Sub
Private Sub Button236109044_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button236109044.Click If LATIHAN40B36109044.Visible = False Then LATIHAN40B36109044.Show() Else LATIHAN40B36109044.Activate() End If
lanjutan lg..
BalasHapusPrivate Sub Form40b36108001_Load(ByVal sender As System.Object, ByVal AULIA As System.EventArgs) Handles MyBase.Load
SAYANG()
LOVE.Columns("Unit").DefaultValue = 0
LOVE.Columns("Harga").DefaultValue = 0
LOVE.Columns("Jumlah").DefaultValue = 0
DGV36108001.DataSource = LOVE
End Sub
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
If T136108001.Text <> T936108001.Text Then
Dim AYI As New ByIskandar.CariKeDataBaseByIskandar
AYI.AturPencarianDataBase("mastertransaksi", "NOTRANS", T136108001.Text, 1, INCE)
If AYI.JumlanBaris > 0 Then
MsgBox("Nomor transaksi tersebut sudah ada")
Else
AA()
End If
Exit Sub
End If
AA()
End Sub
End Class
lanjutan
BalasHapuskhaeril.TableName = "induknya"
khaerilanak.TableName = "anaknya"
datset.Tables.Add(khaeril)
datset.Tables.Add(khaerilanak)
datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS")))
bin.DataSource = datset
bin.DataMember = "induknya"
bin2.DataSource = bin
bin2.DataMember = "cobaji"
DataGridView1.DataSource = bin
DataGridView2.DataSource = bin2
End Sub
lanjutan
BalasHapusPrivate Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If LATIHAN40B.Visible = False Then
LATIHAN40B.Show()
Else
LATIHAN40B.Activate()
End If
LATIHAN40B.TextBox1.Text = DataGridView1.CurrentRow.Cells("notrans").Value
LATIHAN40B.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("tanggaltransaksi").Value
LATIHAN40B.ToolStripStatusLabel2.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value
LATIHAN40B.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("notrans").Value
End Sub
lanjutan
BalasHapusPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim heril As String = "delete * from detailtransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(heril, konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut.Dispose()
lanjutan
BalasHapusDim Ilyas As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(Ilyas, konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut.Dispose()
MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If LATIHAN40B.Visible = False Then
LATIHAN40B.Show()
Else
LATIHAN40B.Activate()
End If
End Sub
End Class
Public Class LATIHAN040A012
BalasHapusDim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=280765")
Dim khaeril As New DataTable
Dim khaerilanak As New DataTable
Dim datset As New DataSet
Dim bin As New BindingSource
Dim bin2 As New BindingSource
BalasHapusDim angkut As New OleDb.OleDbCommand
Private Sub latihan213619043_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cobaji As New OleDb.OleDbDataAdapter
Dim cobaji2 As New OleDb.OleDbDataAdapter
cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", konek)
cobaji.Fill(khaeril)
cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", konek)
cobaji2.Fill(khaerilanak)
LANJUTAN
BalasHapusIf khaeril.Rows.Count = 0 Then
MsgBox("Isi datatable k..")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
angkut = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
For Each r As DataRow In khaeril.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
lanjutan
BalasHapusPrivate Sub tambah()
If TextBox1.Text.Length = 0 Then
MsgBox("belum terisi notrans")
Exit Sub
End If
If jt.Text.Length = 0 Then
MsgBox("belum terisi jenitransaksi")
Exit Sub
End If
Public Class LATIHAN40B
BalasHapusDim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=280765")
Dim khaeril As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
lanjutan
BalasHapusDim angkut As New OleDb.OleDbCommand
Dim hubung As New OleDb.OleDbDataAdapter
lanjutan
BalasHapusIf khaeril.Rows.Count = 0 Then
MsgBox("cek data tabelta")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
lanjutan
BalasHapusangkut = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
For Each r As DataRow In khaeril.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
LANJUTAN
BalasHapuskonek.Open()
angkut.ExecuteNonQuery()
konek.Close()
Next
angkut.Dispose()
TextBox1.Text = ""
jt.Text = ""
Tot.Text = ""
ToolStripStatusLabel1.Text = "sudahmi tersimpan"
khaeril.Rows.Clear()
End Sub
Komentar ini telah dihapus oleh pengarang.
BalasHapusPublic Sub edit()
BalasHapusIf TextBox1.Text.Length = 0 Then
MsgBox("belum terisi notrans")
Exit Sub
End If
If jt.Text.Length = 0 Then
MsgBox("belum terisi jenitransaksi")
Exit Sub
End If
LANJUTAN
If khaeril.Rows.Count = 0 Then
MsgBox("cek data tabelta")
Exit Sub
End If
If TextBox1.Text <> ToolStripStatusLabel1.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
lanjutan
BalasHapusangkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
LANJUTAN
angkut = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
lanjutan
BalasHapusFor Each r As DataRow In khaeril.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
Next
angkut.Dispose()
TextBox1.Text = ""
jt.Text = ""
Tot.Text = ""
ToolStripStatusLabel1.Text = "-"
khaeril.Rows.Clear()
End Sub
Private Sub LATIHAN40b_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hubung = 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 = '" & TextBox1.Text & "'", konek)
khaeril.Rows.Clear()
hubung.Fill(khaeril)
Dim dc(1) As DataColumn
dc(0) = khaeril.Columns("kodebarang")
khaeril.PrimaryKey = dc
LANJUTAN
BalasHapuskhaeril.Columns("unit").DefaultValue = 0 khaeril.Columns("harga").DefaultValue = 0
khaeril.Columns("jumlah").DefaultValue = 0
DataGridView1.DataSource = khaeril
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" DataGridView1.CurrentRow.Cells("UNIT").Value=0 DataGridView1.CurrentRow.Cells("HARGA").Value=0
DataGridView1.CurrentRow.Cells("JUMLAH").Value=0
cari.AturPencarianDataBase("barang","kodebarang",DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, konek)
If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value =cari.DataTablenya.Rows(0).Item("NAMABARANG")
LANJUTAN
BalasHapusElse DataGridView1.CurrentRow.Cells("NAMABARANG").Value =""
If LATIHAN3839.ShowDialog =Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name="UNIT"OrDataGridView1.Columns(e.ColumnIndex).Name="HARGA" Then DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
Dim manis As Integer
For Each r As DataGridViewRow In DataGridView1. Rows
manis = manis + r.Cells("JUMLAH").Value
Next
Tot.Text = manis
End If
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then
tambah()
Else
edit()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class
Public Class Form40A36109040
BalasHapusDim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=150991")
Dim mytha1 As New DataTable
Dim mytha2 As New DataTable
Dim datset As New DataSet
Dim bin As New BindingSource
Dim bin2 As New BindingSource
Dim angkut As New OleDb.OleDbCommand
Private Sub form30A36109040_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cobaji As New OleDb.OleDbDataAdapter
Dim cobaji2 As New OleDb.OleDbDataAdapter
cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", konek)
cobaji.Fill(mytha1)
cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", konek)
cobaji2.Fill(mytha2)
mytha1.TableName = "induknya"
mytha2.TableName = "anaknya"
datset.Tables.Add(mytha1)
datset.Tables.Add(mytha2)
datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS")))
bin.DataSource = datset
bin.DataMember = "induknya"
bin2.DataSource = bin
bin2.DataMember = "cobaji"
DataGridView1.DataSource = bin
DataGridView2.DataSource = bin2
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Form40B36109040.Visible = False Then
Form40B36109040.Show()
Else
Form40B36109040.Activate()
End If
Form40B36109040.TextBox1.Text = DataGridView1.CurrentRow.Cells("notrans").Value
Form40B36109040.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("tanggaltransaksi").Value
Form40B36109040.ToolStripStatusLabel2.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value
Form40B36109040.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("notrans").Value
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim temmyta As String = "delete * from detailtransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(temmyta, konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut.Dispose()
Dim tamy As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(tamy, konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut.Dispose()
MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Form40B36109040.Visible = False Then
Form40B36109040.Show()
Else
Form40B36109040.Activate()
End If
End Sub
End Class
Public Class Form40B36109040
BalasHapusDim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=150991")
Dim mytha1 As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim angkut As New OleDb.OleDbCommand
Dim hubung As New OleDb.OleDbDataAdapter
Private Sub tambah()
If TextBox1.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If mytha1.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
angkut = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
For Each r As DataRow In mytha1.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
Next
angkut.Dispose()
TextBox1.Text = ""
jt.Text = ""
Tot.Text = ""
ToolStripStatusLabel1.Text = "sudahmi tersimpan"
mytha1.Rows.Clear()
End Sub
Public Sub edit()
BalasHapusIf TextBox1.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If mytha1.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
If TextBox1.Text <> ToolStripStatusLabel1.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
For Each r As DataRow In khaeril.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
Next
angkut.Dispose()
TextBox1.Text = ""
jt.Text = ""
Tot.Text = ""
ToolStripStatusLabel1.Text = "-"
mytha1.Rows.Clear()
End Sub
Private Sub Form40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BalasHapushubung = 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 = '" & TextBox1.Text & "'", konek)
mytha1.Rows.Clear()
hubung.Fill(mytha1)
Dim dc(1) As DataColumn
dc(0) = mytha1.Columns("kodebarang")
mytha1.PrimaryKey = dc
mytha1.Columns("unit").DefaultValue = 0
mytha1.Columns("harga").DefaultValue = 0
mytha1.Columns("jumlah").DefaultValue = 0
DataGridView1.DataSource = mytha1
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, konek)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
If LATIHAN3839.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
Dim donggg As Integer
For Each r As DataGridViewRow In DataGridView1.Rows
donggg = donggg + r.Cells("JUMLAH").Value
Next
Tot.Text = donggg
End If
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then
tambah()
Else
edit()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
MsgBox("ada yang salah")
End Sub
End Class
Public Class Latih40A_36109034
BalasHapusDim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=miss")
Dim nurhidayah As New DataTable
Dim nhunoe As New DataTable
Dim datset As New DataSet
Dim bin As New BindingSource
Dim bin2 As New BindingSource
Dim angkut As New OleDb.OleDbCommand
Private Sub Lati21_36109034_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cobaji As New OleDb.OleDbDataAdapter
Dim cobaji2 As New OleDb.OleDbDataAdapter
cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", conect)
cobaji.Fill(nurhidayah)
cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", conect)
cobaji2.Fill(nhunoe)
nurhidayah.TableName = "induknya"
nhunoe.TableName = "anaknya"
datset.Tables.Add(nurhidayah)
datset.Tables.Add(nhunoe)
datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS")))
bin.DataSource = datset
bin.DataMember = "induknya"
bin2.DataSource = bin
bin2.DataMember = "cobaji"
DataGridView1.DataSource = bin
DataGridView2.DataSource = bin2
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Latih40B_36109034.Visible = False Then
Latih40B_36109034.Show()
Else
Latih40B_36109034.Activate()
End If
Latih40B_36109034.TextBox1_36109034.Text = DataGridView1.CurrentRow.Cells("notrans").Value
Latih40B_36109034.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("tanggaltransaksi").Value
Latih40B_36109034.TS.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value
Latih40B_36109034.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("notrans").Value
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim noe As String = "delete * from detailtransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(noe, conect)
conect.Open()
angkut.ExecuteNonQuery()
conect.Close()
angkut.Dispose()
Dim Ibrahim As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(Ibrahim, conect)
conect.Open()
angkut.ExecuteNonQuery()
conect.Close()
angkut.Dispose()
MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Latih40B_36109034.Visible = False Then
Latih40B_36109034.Show()
Else
Latih40B_36109034.Activate()
End If
End Sub
End Class
Lanjutan
BalasHapusFor Each r As DataRow In Juni.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox136109037.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", Conect)
Conect.Open()
angkut.ExecuteNonQuery()
Conect.Close()
Next
angkut.Dispose()
TextBox136109037.Text = ""
jt36109037.Text = ""
Tot36109037.Text = ""
ToolStripStatusLabel1.Text = "Sudah tersimpan"
Juni.Rows.Clear()
End Sub
Public Sub edit()
If TextBox136109037.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt36109037.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If Juni.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
If TextBox136109037.Text <> ToolStripStatusLabel1.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109037.Text, 1, Conect)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", Conect)
Conect.Open()
angkut.ExecuteNonQuery()
Conect.Close()
angkut = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox136109037.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109037.Text & "')", Conect)
Conect.Open()
angkut.ExecuteNonQuery()
Conect.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", Conect)
Conect.Open()
angkut.ExecuteNonQuery()
Conect.Close()
Public Class Latihan40a_36109049
BalasHapusDim wirda 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 dt1 As New DataTable
Dim dset As New DataSet 'Deklarasi dataset'
Dim Bsource1 As New BindingSource 'Deklarasi bindingsource'
Dim Bsource2 As New BindingSource
Public Sub wirdapaulus()
'Membersihkan detailtransaksi lalu mastertransaksi'
dt1.Rows.Clear()
dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter
B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", wirda)
B1.Fill(dt)
B1 = New OleDb.OleDbDataAdapter("Select DETAILTRANSAKSI.NOTRANS, DETAILTRANSAKSI.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG", wirda)
B1.Fill(dt1)
B1.Dispose()
End Sub
Private Sub Latihan_40a_36109058_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
wirdapaulus()
'Memasukkan datatabel dalam dataset'
dset.Tables.Add(dt)
dset.Tables.Add(dt1)
'Mengganti nama datatabel dalam dataset'
dt.TableName = "T01"
dt1.TableName = "T02"
'Menambahkan relasi dalam dataset'
dset.Relations.Add(New DataRelation("X", dset.Tables("T01").Columns("NOTRANS"), dset.Tables("T02").Columns("NOTRANS")))
'Datasource dan membersource'
Bsource1.DataSource = dset
Bsource1.DataMember = "T01"
Bsource2.DataSource = Bsource1
Bsource2.DataMember = "X"
'Memasukkan datatabel dari bindingsource ke dalam DVG'
DataGridView1.DataSource = Bsource1
DataGridView2.DataSource = Bsource2
End Sub
Lanjutan 40a
BalasHapusPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim z As New OleDb.OleDbCommand
z = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", wirda)
wirda.Open()
z.ExecuteNonQuery()
wirda.Close()
z = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", wirda)
wirda.Open()
z.ExecuteNonQuery()
wirda.Close()
z.Dispose()
wirdapaulus()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Latihan40B_36109049.Visible = False Then
Latihan40B_36109049.Show()
Else
Latihan40B_36109049.Activate()
End If
Latihan40B_36109049.StatusStrip1.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
Latihan40b_36109049.TextBox1_36109049.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
Latihan40b_36109049.TextBox2_36109049.Text = DataGridView1.CurrentRow.Cells("JENISTRANSAKSI").Value
Latihan40B_36109049.dandy()
Latihan40B_36109049.TOTALJUMLAH()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Latihan40B_36109049.Visible = False Then
Latihan40B_36109049.Show()
Else
Latihan40B_36109049.Activate()
End If
Latihan40B_36109049.StatusStrip1.Text = "-"
Latihan40B_36109049.TextBox1_36109049.Text = ""
Latihan40B_36109049.TextBox2_36109049.Text = ""
Latihan40B_36109049.dandy()
Latihan40B_36109049.TOTALJUMLAH()
End Sub
End Class
Public Class Latihan40B_36109049
BalasHapusDim wirda As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb;jet OLEDB:database password=wirda")
Dim DATA As New DataTable
Public Sub dandy()
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= '" & TextBox1_36109049.Text & "'", wirda)
DATA.Rows.Clear()
X.Fill(DATA)
End Sub
Private Sub Latihan40B_36109049_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = DATA.Columns("NOTRANS")
DATA.PrimaryKey = dataPrimary
DataGridView1.DataSource = DATA
TOTALJUMLAH()
End Sub
Public Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In DATA.Rows
TOT = TOT + x("JUMLAH")
Next
TextBox3_36109049.Text = TOT
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
'Cari nama barang'
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, wirda)
'Menampilkan nama barang jika isi kolom kodebarang ditemukan oleh proses diatas'
If Pencari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = ""
If LATIHAN3839_36109049.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839_36109049.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839_36109049.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
Lanjutan 40B
BalasHapusElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
'Hitung kolom jumlah'
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
End If
End Sub
Private Sub simpan_tambah()
If TextBox1_36109049.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If TextBox2_36109049.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
Exit Sub
End If
If DATA.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
Exit Sub
End If
If StatusStrip1.Text <> TextBox1_36109049.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox1_36109049.Text, 1, wirda)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim z As New OleDb.OleDbCommand
z = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & TextBox1_36109049.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & TextBox1_36109049.Text & "')", wirda)
'Membuka koneksi'
wirda.Open()
'Eksekusi prose penyimpanan'
z.ExecuteNonQuery()
'Menutup koneksi'
wirda.Close()
'Memeriksa isi jumlah baris dalam object tabel'
For Each X As DataRow In DATA.Rows
'Mengatur perintah simpan'
z = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox1_36109049.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", wirda)
wirda.Open()
z.ExecuteNonQuery()
wirda.Close()
z.Dispose()
Next
StatusStrip1.Text = "-"
TextBox1_36109049.Text = ""
TextBox2_36109049.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
'Prosedur mengambil data dari Latihan40A017'
Latihan40a_36109049.wirdapaulus()
End Sub
Lanjutan 40B(lagi)
BalasHapusPrivate Sub simpan_edit()
If TextBox1_36109049.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If TextBox2_36109049.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
Exit Sub
End If
If DATA.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
Exit Sub
End If
If StatusStrip1.Text <> TextBox1_36109049.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox1_36109049.Text, 1, wirda)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim z As New OleDb.OleDbCommand
z = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & TextBox1_36109049.Text & "'", wirda)
wirda.Open()
z.ExecuteNonQuery()
wirda.Close()
z = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & TextBox1_36109049.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & TextBox2_36109049.Text & "')", wirda)
wirda.Open()
z.ExecuteNonQuery()
wirda.Close()
z = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & TextBox1_36109049.Text & "'", wirda)
wirda.Open()
z.ExecuteNonQuery()
wirda.Close()
'Memeriksa isi jumlah baris dalam object tabel'
For Each XX As DataRow In DATA.Rows
'Mengatur perintah simpan'
z = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox1_36109049.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", wirda)
wirda.Open()
z.ExecuteNonQuery()
wirda.Close()
z.Dispose()
Next
StatusStrip1.Text = "-"
TextBox1_36109049.Text = ""
TextBox2_36109049.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40a_36109049.wirdapaulus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If StatusStrip1.Text = "-" Then
simpan_tambah()
Else
simpan_edit()
End If
End Sub
End Class
Komentar ini telah dihapus oleh pengarang.
BalasHapusKomentar ini telah dihapus oleh pengarang.
BalasHapusPublic Class Latih40B_36109034
BalasHapusDim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=miss")
Dim nurhidayah As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim angkut As New OleDb.OleDbCommand
Dim hubung As New OleDb.OleDbDataAdapter
Private Sub tambah()
If TextBox1_36109034.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt_36109034.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If nurhidayah.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1_36109034.Text, 1, conect)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
angkut = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1_36109034.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt_36109034.Text & "')", conect)
conect.Open()
angkut.ExecuteNonQuery()
conect.Close()
For Each r As DataRow In nurhidayah.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1_36109034.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", conect)
conect.Open()
angkut.ExecuteNonQuery()
conect.Close()
Next
angkut.Dispose()
TextBox1_36109034.Text = ""
jt_36109034.Text = ""
Tot_36109034.Text = ""
ToolStripStatusLabel1.Text = "sudahmi tersimpan"
nurhidayah.Rows.Clear()
End Sub
'LANJUTAN
BalasHapusPublic Sub edit()
If TextBox1_36109034.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt_36109034.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If nurhidayah.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
If TextBox1_36109034.Text <> ToolStripStatusLabel1.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1_36109034.Text, 1, conect)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect)
conect.Open()
angkut.ExecuteNonQuery()
conect.Close()
angkut = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1_36109034.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt_36109034.Text & "')", conect)
conect.Open()
angkut.ExecuteNonQuery()
conect.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect)
conect.Open()
angkut.ExecuteNonQuery()
conect.Close()
For Each r As DataRow In nurhidayah.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1_36109034.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", conect)
conect.Open()
angkut.ExecuteNonQuery()
conect.Close()
Next
angkut.Dispose()
TextBox1_36109034.Text = ""
jt_36109034.Text = ""
Tot_36109034.Text = ""
ToolStripStatusLabel1.Text = "-"
nurhidayah.Rows.Clear()
End Sub
Private Sub LATIHAN40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hubung = 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 = '" & TextBox1_36109034.Text & "'", conect)
nurhidayah.Rows.Clear()
hubung.Fill(nurhidayah)
Dim dc(1) As DataColumn
dc(0) = nurhidayah.Columns("kodebarang")
nurhidayah.PrimaryKey = dc
nurhidayah.Columns("unit").DefaultValue = 0
nurhidayah.Columns("harga").DefaultValue = 0
nurhidayah.Columns("jumlah").DefaultValue = 0
DataGridView1.DataSource = nurhidayah
End Sub
'LANJUTAN
BalasHapusPrivate Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, conect)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
If Latih3839_36109034.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = Latih3839_36109034.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = Latih3839_36109034.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
Dim manis As Integer
For Each r As DataGridViewRow In DataGridView1.Rows
manis = manis + r.Cells("JUMLAH").Value
Next
Tot_36109034.Text = manis
End If
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then
tambah()
Else
edit()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
MsgBox("ada yang salah")
End Sub
End Class
Public Class LATIHAN040A36109032
BalasHapusDim sambung As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=jayapura")
Dim papua As New DataTable
Dim jayapura As New DataTable
Dim datset As New DataSet
Dim bin As New BindingSource
Dim bin2 As New BindingSource
Dim esthi As New OleDb.OleDbCommand
Private Sub LATIHAN040A36109032_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tes As New OleDb.OleDbDataAdapter
Dim testes As New OleDb.OleDbDataAdapter
tes = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", sambung)
tes.Fill(papua)
testes = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", sambung)
testes.Fill(jayapura)
papua.TableName = "induknya"
jayapura.TableName = "anaknya"
datset.Tables.Add(papua)
datset.Tables.Add(jayapura)
datset.Relations.Add(New DataRelation("tes", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS")))
bin.DataSource = datset
bin.DataMember = "induknya"
bin2.DataSource = bin
bin2.DataMember = "tes"
DataGridView1.DataSource = bin
DataGridView2.DataSource = bin2
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If LATIHAN040B36109032.Visible = False Then
LATIHAN040B36109032.Show()
Else
LATIHAN040B36109032.Activate()
End If
LATIHAN040B36109032.TextBox1.Text = DataGridView1.CurrentRow.Cells("notrans").Value
LATIHAN040B36109032.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("tanggaltransaksi").Value
LATIHAN040B36109032.TS.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value
LATIHAN040B36109032.ToolStripStatusLabel1.Text = DataGridView1.CurrentRow.Cells("notrans").Value
End Sub
lanjutan..
BalasHapusPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mirasthi As String = "delete * from detailtransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
esthi = New OleDb.OleDbCommand(mirasthi, sambung)
sambung.Open()
esthi.ExecuteNonQuery()
sambung.Close()
esthi.Dispose()
Dim batotampak As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
esthi = New OleDb.OleDbCommand(batotampak, sambung)
sambung.Open()
esthi.ExecuteNonQuery()
sambung.Close()
esthi.Dispose()
MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If LATIHAN040B36109032.Visible = False Then
LATIHAN040B36109032.Show()
Else
LATIHAN040B36109032.Activate()
End If
End Sub
End Class
Public Class LATIHAN040B36109032
BalasHapusDim sambung As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=jayapura")
Dim esthi As New DataTable
Dim nokia As New ByIskandar.CariKeDataBaseByIskandar
Dim toshiba As New OleDb.OleDbCommand
Dim key As New OleDb.OleDbDataAdapter
Private Sub akuntansi()
If TextBox1.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If JT.Text.Length = 0 Then
MsgBox("Jenis Transaksi belum terisi")
Exit Sub
End If
If esthi.Rows.Count = 0 Then
MsgBox("coba periksa tabel anda")
Exit Sub
End If
nokia.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, sambung)
If nokia.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
toshiba = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & JT.Text & "')", sambung)
sambung.Open()
toshiba.ExecuteNonQuery()
sambung.Close()
For Each r As DataRow In esthi.Rows
toshiba = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", sambung)
sambung.Open()
toshiba.ExecuteNonQuery()
sambung.Close()
Next
toshiba.Dispose()
TextBox1.Text = ""
JT.Text = ""
TOT.Text = ""
ToolStripStatusLabel1.Text = "sudah tersimpan"
esthi.Rows.Clear()
End Sub
lanjutan..
BalasHapusPublic Sub flash()
If TextBox1.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If JT.Text.Length = 0 Then
MsgBox("Jenis Transaksi Belum Terisi")
Exit Sub
End If
If esthi.Rows.Count = 0 Then
MsgBox("coba periksa tabel anda")
Exit Sub
End If
If TextBox1.Text <> ToolStripStatusLabel1.Text Then
nokia.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, sambung)
If nokia.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
toshiba = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", sambung)
sambung.Open()
toshiba.ExecuteNonQuery()
sambung.Close()
toshiba = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & JT.Text & "')", sambung)
sambung.Open()
toshiba.ExecuteNonQuery()
sambung.Close()
toshiba = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", sambung)
sambung.Open()
toshiba.ExecuteNonQuery()
sambung.Close()
For Each r As DataRow In esthi.Rows
toshiba = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", sambung)
sambung.Open()
toshiba.ExecuteNonQuery()
sambung.Close()
Next
toshiba.Dispose()
TextBox1.Text = ""
JT.Text = ""
TOT.Text = ""
ToolStripStatusLabel1.Text = "-"
esthi.Rows.Clear()
End Sub
lanjutan..
BalasHapusPrivate Sub LATIHAN040A36109032_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
key = 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 = '" & TextBox1.Text & "'", sambung)
esthi.Rows.Clear()
key.Fill(esthi)
Dim dc(1) As DataColumn
dc(0) = esthi.Columns("kodebarang")
esthi.PrimaryKey = dc
esthi.Columns("unit").DefaultValue = 0
esthi.Columns("harga").DefaultValue = 0
esthi.Columns("jumlah").DefaultValue = 0
DataGridView1.DataSource = esthi
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
nokia.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, sambung)
If nokia.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = nokia.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
If LATIHAN038039.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN038039.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN038039.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
Dim makan As Integer
For Each r As DataGridViewRow In DataGridView1.Rows
makan = makan + r.Cells("JUMLAH").Value
Next
TOT.Text = makan
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then
akuntansi()
Else
flash()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
MsgBox("ada yang salah")
End Sub
End Class
Public Class LATIHAN040A041
BalasHapusDim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;jet OLEDB:database password=12")
Dim khaeril As New DataTable
Dim khaerilanak As New DataTable
Dim datset As New DataSet
Dim bin As New BindingSource
Dim bin2 As New BindingSource
Dim angkut As New OleDb.OleDbCommand
Private Sub latihan213619043_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cobaji As New OleDb.OleDbDataAdapter
Dim cobaji2 As New OleDb.OleDbDataAdapter
cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", konek)
cobaji.Fill(khaeril)
cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", konek)
cobaji2.Fill(khaerilanak)
khaeril.TableName = "induknya"
khaerilanak.TableName = "anaknya"
datset.Tables.Add(khaeril)
datset.Tables.Add(khaerilanak)
datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS")))
bin.DataSource = datset
bin.DataMember = "induknya"
bin2.DataSource = bin
bin2.DataMember = "cobaji"
DataGridView136109041.DataSource = bin
DataGridView236109041.DataSource = bin2
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109041.Click
If LATIHAN040B041.Visible = False Then
LATIHAN040B041.Show()
Else
LATIHAN040B041.Activate()
End If
LATIHAN040B041.TextBox136109041.Text = DataGridView136109041.CurrentRow.Cells("notrans").Value
LATIHAN040B041.DateTimePicker136109041.Value = DataGridView136109041.CurrentRow.Cells("tanggaltransaksi").Value
LATIHAN040B041.ToolStripStatusLabel236109041.Text = DataGridView136109041.CurrentRow.Cells("jenistransaksi").Value
LATIHAN040B041.ToolStripStatusLabel136109041.Text = DataGridView136109041.CurrentRow.Cells("notrans").Value
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109041.Click
Dim heril As String = "delete * from detailtransaksi where notrans = '" & DataGridView136109041.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(heril, konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut.Dispose()
Dim Ilyas As String = "delete * from mastertransaksi where notrans = '" & DataGridView136109041.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(Ilyas, konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut.Dispose()
MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109041.Click
If LATIHAN040B041.Visible = False Then
LATIHAN040B041.Show()
Else
LATIHAN040B041.Activate()
End If
End Sub
End Class
Public Class LATIHAN040B041
BalasHapusDim konek As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=12")
Dim khaeril As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim angkut As New OleDb.OleDbCommand
Dim hubung As New OleDb.OleDbDataAdapter
Private Sub tambah()
If TextBox136109041.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt36109041.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If khaeril.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109041.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
angkut = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox136109041.Text & "',#" & DateTimePicker136109041.Value.Month & "/" & DateTimePicker136109041.Value.Day & "/" & DateTimePicker136109041.Value.Year & "#, '" & jt36109041.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
For Each r As DataRow In khaeril.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox136109041.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
Next
angkut.Dispose()
TextBox136109041.Text = ""
jt36109041.Text = ""
Tot36109041.Text = ""
ToolStripStatusLabel136109041.Text = "sudahmi tersimpan"
khaeril.Rows.Clear()
End Sub
lanjutan
BalasHapusPublic Sub edit()
If TextBox136109041.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt36109041.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If khaeril.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
If TextBox136109041.Text <> ToolStripStatusLabel136109041.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109041.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel136109041.Text & "'", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox136109041.Text & "',#" & DateTimePicker136109041.Value.Month & "/" & DateTimePicker136109041.Value.Day & "/" & DateTimePicker136109041.Value.Year & "#, '" & jt36109041.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel136109041.Text & "'", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
For Each r As DataRow In khaeril.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox136109041.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
Next
angkut.Dispose()
TextBox136109041.Text = ""
jt36109041.Text = ""
Tot36109041.Text = ""
ToolStripStatusLabel136109041.Text = "-"
khaeril.Rows.Clear()
End Sub
lanjutan
BalasHapusPrivate Sub LATIHAN40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hubung = 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 = '" & TextBox136109041.Text & "'", konek)
khaeril.Rows.Clear()
hubung.Fill(khaeril)
Dim dc(1) As DataColumn
dc(0) = khaeril.Columns("kodebarang")
khaeril.PrimaryKey = dc
khaeril.Columns("unit").DefaultValue = 0
khaeril.Columns("harga").DefaultValue = 0
khaeril.Columns("jumlah").DefaultValue = 0
DataGridView136109041.DataSource = khaeril
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView136109041.CellEndEdit
If DataGridView136109041.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView136109041.CurrentRow.Cells("UNIT").Value = 0
DataGridView136109041.CurrentRow.Cells("HARGA").Value = 0
DataGridView136109041.CurrentRow.Cells("JUMLAH").Value = 0
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView136109041.CurrentRow.Cells("KODEBARANG").Value, 1, konek)
If cari.JumlanBaris > 0 Then
DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value = ""
If LATIHAN3839.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView136109041.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839.DataGridView136109041.CurrentRow.Cells("KODEBARANG").Value
DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839.DataGridView136109041.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView136109041.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView136109041.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView136109041.CurrentRow.Cells("JUMLAH").Value = DataGridView136109041.CurrentRow.Cells("UNIT").Value * DataGridView136109041.CurrentRow.Cells("HARGA").Value
Dim manis As Integer
For Each r As DataGridViewRow In DataGridView136109041.Rows
manis = manis + r.Cells("JUMLAH").Value
Next
Tot36109041.Text = manis
End If
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109041.Click
If ToolStripStatusLabel136109041.Text = "NO.TRANSAKSI" Then
tambah()
Else
edit()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView136109041.DataError
MsgBox("ada yang salah")
End Sub
End Class
Public Class LATIHAN040A36109033
BalasHapusDim pratiwi 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 data1 As New DataTable
Dim dset As New DataSet 'Deklarasi dataset'
Dim Bsource As New BindingSource 'Deklarasi bindingsource'
Dim Bsource1 As New BindingSource
Public Sub tiwi()
'Membersihkan detailtransaksi lalu mastertransaksi'
data1.Rows.Clear()
data.Rows.Clear()
Dim tahir As New OleDb.OleDbDataAdapter
tahir = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", pratiwi)
tahir.Fill(data)
tahir = New OleDb.OleDbDataAdapter("Select DETAILTRANSAKSI.NOTRANS, DETAILTRANSAKSI.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG", pratiwi)
tahir.Fill(data1)
tahir.Dispose()
End Sub
Private Sub LATIHAN040A36109033_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tiwi()
'Memasukkan datatabel dalam dataset'
dset.Tables.Add(data)
dset.Tables.Add(data1)
'Mengganti nama datatabel dalam dataset'
data.TableName = "T01"
data1.TableName = "T02"
'Menambahkan relasi dalam dataset'
dset.Relations.Add(New DataRelation("X", dset.Tables("T01").Columns("NOTRANS"), dset.Tables("T02").Columns("NOTRANS")))
'Datasource dan membersource'
Bsource.DataSource = dset
Bsource.DataMember = "T01"
Bsource1.DataSource = Bsource
Bsource1.DataMember = "X"
'Memasukkan datatabel dari bindingsource ke dalam DVG'
DataGridView1.DataSource = Bsource
DataGridView2.DataSource = Bsource1
End Sub
Private Sub Button136109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109033.Click
BalasHapusDim t As New OleDb.OleDbCommand
t = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", pratiwi)
pratiwi.Open()
t.ExecuteNonQuery()
pratiwi.Close()
t = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", pratiwi)
pratiwi.Open()
t.ExecuteNonQuery()
pratiwi.Close()
t.Dispose()
tiwi()
End Sub
Private Sub Button336109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109033.Click
If LATIHAN_040B_36109033.Visible = False Then
LATIHAN_040B_36109033.Show()
Else
LATIHAN_040B_36109033.Activate()
End If
LATIHAN_040B_36109033.StatusStrip1.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
LATIHAN_040B_36109033.TextBox136109033.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
LATIHAN_040B_36109033.jt36109033.Text = DataGridView1.CurrentRow.Cells("JENISTRANSAKSI").Value
LATIHAN_040B_36109033.poltek()
LATIHAN_040B_36109033.TOTALJUMLAH()
End Sub
Private Sub Button236109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109033.Click
If LATIHAN_040B_36109033.Visible = False Then
LATIHAN_040B_36109033.Show()
Else
LATIHAN_040B_36109033.Activate()
End If
LATIHAN_040B_36109033.StatusStrip1.Text = "-"
LATIHAN_040B_36109033.TextBox136109033.Text = ""
LATIHAN_040B_36109033.jt36109033.Text = ""
LATIHAN_040B_36109033.poltek()
LATIHAN_040B_36109033.TOTALJUMLAH()
End Sub
End Class
Public Class LATIHAN_040B_36109033
BalasHapusDim pratiwi 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
Public Sub poltek()
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= '" & TextBox136109033.Text & "'", pratiwi)
data.Rows.Clear()
X.Fill(data)
End Sub
Private Sub LATIHAN_040B_36109033_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = data.Columns("NOTRANS")
data.PrimaryKey = dataPrimary
DataGridView1.DataSource = data
TOTALJUMLAH()
End Sub
Public Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In data.Rows
TOT = TOT + x("JUMLAH")
Next
Tot36109033.Text = TOT
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
'Cari nama barang'
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
Dim browse As New ByIskandar.CariKeDataBaseByIskandar
browse.AturPencarianDataBase("BARANG", "KODEBARANG", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, pratiwi)
'Menampilkan nama barang jika isi kolom kodebarang ditemukan oleh proses diatas'
If browse.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = browse.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = ""
If LATIHAN3839_36109033.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839_36109033.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839_36109033.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
'Hitung kolom jumlah'
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
End If
End Sub
Private Sub simpan_tambah()
BalasHapusIf TextBox136109033.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If TextBox136109033.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
Exit Sub
End If
If data.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
Exit Sub
End If
If StatusStrip1.Text <> TextBox136109033.Text Then
Dim browse As New ByIskandar.CariKeDataBaseByIskandar
browse.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox136109033.Text, 1, pratiwi)
If browse.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim t As New OleDb.OleDbCommand
t = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & TextBox136109033.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109033.Text & "')", pratiwi)
'Membuka koneksi'
pratiwi.Open()
'Eksekusi prose penyimpanan'
t.ExecuteNonQuery()
'Menutup koneksi'
pratiwi.Close()
'Memeriksa isi jumlah baris dalam object tabel'
For Each X As DataRow In data.Rows
'Mengatur perintah simpan'
t = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox136109033.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", pratiwi)
pratiwi.Open()
t.ExecuteNonQuery()
pratiwi.Close()
t.Dispose()
Next
StatusStrip1.Text = "-"
TextBox136109033.Text = ""
jt36109033.Text = ""
data.Rows.Clear()
TOTALJUMLAH()
'Prosedur mengambil data dari Latihan40A017'
LATIHAN040A36109033.tiwi()
End Sub
Private Sub simpan_edit()
BalasHapusIf TextBox136109033.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt36109033.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
Exit Sub
End If
If DATA.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
Exit Sub
End If
If StatusStrip1.Text <> TextBox136109033.Text Then
Dim browse As New ByIskandar.CariKeDataBaseByIskandar
browse.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", TextBox136109033.Text, 1, pratiwi)
If browse.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim z As New OleDb.OleDbCommand
z = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & TextBox136109033.Text & "'", pratiwi)
pratiwi.Open()
z.ExecuteNonQuery()
pratiwi.Close()
z = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & TextBox136109033.Text & "', #" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109033.Text & "')", pratiwi)
pratiwi.Open()
z.ExecuteNonQuery()
pratiwi.Close()
z = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & TextBox136109033.Text & "'", pratiwi)
pratiwi.Open()
z.ExecuteNonQuery()
pratiwi.Close()
'Memeriksa isi jumlah baris dalam object tabel'
For Each XX As DataRow In data.Rows
'Mengatur perintah simpan'
z = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & TextBox136109033.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", pratiwi)
pratiwi.Open()
z.ExecuteNonQuery()
pratiwi.Close()
z.Dispose()
Next
StatusStrip1.Text = "-"
TextBox136109033.Text = ""
jt36109033.Text = ""
data.Rows.Clear()
TOTALJUMLAH()
LATIHAN040A36109033.tiwi()
End Sub
Private Sub Button236109033_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109033.Click
If StatusStrip1.Text = "-" Then
simpan_tambah()
Else
simpan_edit()
End If
End Sub
End Class
Public Class LATIHAN40B_36109051
BalasHapusDim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=molnan")
Dim novi As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim greenholic As New OleDb.OleDbCommand
Dim hubung As New OleDb.OleDbDataAdapter
Private Sub tambah()
If TextBox1.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If khaeril.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, novi)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
greenholic = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt.Text & "')", conect)
conect.Open()
greenholic.ExecuteNonQuery()
conect.Close()
For Each r As DataRow In novi.Rows
greenholic = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", conect)
conect.Open()
greenholic.ExecuteNonQuery()
conect.Close()
Next
greenholic.Dispose()
TextBox1.Text = ""
jt.Text = ""
Tot.Text = ""
ToolStripStatusLabel1.Text = "sudahmi tersimpan"
novi.Rows.Clear()
End Sub
Public Sub edit()
If TextBox1.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If novi.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
If TextBox1.Text <> ToolStripStatusLabel1.Text Then
cari.AturPencarianDataBase
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, conect)
BalasHapusIf cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
greenholic = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect)
conect.Open()
greenholic.ExecuteNonQuery()
conect.Close()
greenholic = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox1.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt.Text & "')", conect)
conect.Open()
greenholic.ExecuteNonQuery()
conect.Close()
greenholic = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect)
conect.Open()
greenholic.ExecuteNonQuery()
conect.Close()
For Each r As DataRow In novi.Rows
greenholic = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox1.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", conect)
conect.Open()
greenholic.ExecuteNonQuery()
conect.Close()
Next
greenholic.Dispose()
TextBox1.Text = ""
jt.Text = ""
Tot.Text = ""
ToolStripStatusLabel1.Text = "-"
novi.Rows.Clear()
End Sub
Private Sub LATIHAN40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hubung = 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 = '" & TextBox1.Text & "'", conect)
novi.Rows.Clear()
hubung.Fill(novi)
Dim dc(1) As DataColumn
dc(0) = novi.Columns("kodebarang")
novi.PrimaryKey = dc
novi.Columns("unit").DefaultValue = 0
novi.Columns("harga").DefaultValue = 0
novi.Columns("jumlah").DefaultValue = 0
DataGridView1.DataSource = novi
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
BalasHapusIf DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, conect)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
If LATIHAN3839.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
Dim greenpeace As Integer
For Each r As DataGridViewRow In DataGridView1.Rows
greenpeace = greenpeace + r.Cells("JUMLAH").Value
Next
Tot.Text = greenpeace
End If
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then
tambah()
Else
edit()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
MsgBox("ada yang salah")
End Sub
End Class
Public Class LATIHAN_40B36109055
BalasHapusDim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=2312")
Dim falah As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim antar As New OleDb.OleDbCommand
Dim hubung As New OleDb.OleDbDataAdapter
Private Sub tambah()
If TextBox136109055.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt36109055.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If falah.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109055.Text, 1, conect)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
antar = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox136109055.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109055.Text & "')", conect)
conect.Open()
antar.ExecuteNonQuery()
conect.Close()
For Each r As DataRow In falah.Rows
antar = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox136109055.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", conect)
conect.Open()
antar.ExecuteNonQuery()
conect.Close()
Next
antar.Dispose()
TextBox136109055.Text = ""
jt36109055.Text = ""
Tot.Text = ""
ToolStripStatusLabel1.Text = "sudahmi tersimpan"
falah.Rows.Clear()
End Sub
lanjutan
BalasHapusPublic Sub edit()
If TextBox136109055.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt36109055.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If falah.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
If TextBox136109055.Text <> ToolStripStatusLabel1.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109055.Text, 1, conect)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
antar = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect)
conect.Open()
antar.ExecuteNonQuery()
conect.Close()
antar = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox136109055.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt36109055.Text & "')", conect)
conect.Open()
antar.ExecuteNonQuery()
conect.Close()
antar = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", conect)
conect.Open()
antar.ExecuteNonQuery()
conect.Close()
For Each r As DataRow In hasbiya.Rows
antar = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox136109055.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", conect)
conect.Open()
antar.ExecuteNonQuery()
conect.Close()
Next
antar.Dispose()
TextBox136109055.Text = ""
jt36109055.Text = ""
Tot36109055.Text = ""
ToolStripStatusLabel1.Text = "-"
falah.Rows.Clear()
End Sub
Private Sub LATIHAN_40B3610955_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hubung = 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 = '" & TextBox136109055.Text & "'", conect)
falah.Rows.Clear()
hubung.Fill(falah)
Dim dc(1) As DataColumn
dc(0) = falah.Columns("kodebarang")
falah.PrimaryKey = dc
falah.Columns("unit").DefaultValue = 0
falah.Columns("harga").DefaultValue = 0
falah.Columns("jumlah").DefaultValue = 0
DataGridView136109055.DataSource = falah
End Sub
lanjutan
BalasHapusPrivate Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView136109055.CellEndEdit
If DataGridView136109055.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView136109055.CurrentRow.Cells("UNIT").Value = 0
DataGridView136109055.CurrentRow.Cells("HARGA").Value = 0
DataGridView136109055.CurrentRow.Cells("JUMLAH").Value = 0
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView136109055.CurrentRow.Cells("KODEBARANG").Value, 1, conect)
If cari.JumlanBaris > 0 Then
DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value = ""
If LATIHAN3839_36109055.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView136109055.CurrentRow.Cells("KODEBARANG").Value = LATIHAN3839_36109055.DataGridView136109055.CurrentRow.Cells("KODEBARANG").Value
DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value = LATIHAN3839_36109055.DataGridView136109055.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView136109055.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView136109055.CurrentRow.Cells("JUMLAH").Value = DataGridView136109055.CurrentRow.Cells("UNIT").Value * DataGridView136109055.CurrentRow.Cells("HARGA").Value
Dim tes As Integer
For Each r As DataGridViewRow In DataGridView1.Rows
tes = tes + r.Cells("JUMLAH").Value
Next
Tot.Text = tes
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then
tambah()
Else
edit()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
MsgBox("ada yang salah")
End Sub
End Class
Public Class Form40A36109050
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=nideria")
Dim DT1 As New DataTable
Dim dt2 As New DataTable
Dim dset As New DataSet
Dim bs1 As New BindingSource
Dim angkut As New OleDb.OleDbCommand
Dim bs2 As New BindingSource
Public Sub AP()
Dim adapt As New OleDb.OleDbDataAdapter
adapt = New OleDb.OleDbDataAdapter("select * FROM MASTERTRANSAKSI", CONECT)
DT1.Rows.Clear()
adapt.Fill(DT1)
adapt = New OleDb.OleDbDataAdapter("select * FROM DETAILTRANSAKSI", CONECT)
dt2.Rows.Clear()
adapt.Fill(dt2)
adapt.Dispose()
End Sub
Private Sub Form40A36109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim tes As New OleDb.OleDbDataAdapter
Dim testes As New OleDb.OleDbDataAdapter
tes = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", CONECT)
tes.Fill(DT1)
testes = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", CONECT)
testes.Fill(dt2)
DT1.TableName = "induknya"
dt2.TableName = "anaknya"
dset.Tables.Add(DT1)
dset.Tables.Add(dt2)
dset.Relations.Add(New DataRelation("tes", dset.Tables("induknya").Columns("NOTRANS"), dset.Tables("anaknya").Columns("NOTRANS")))
bs1.DataSource = dset
bs1.DataMember = "induknya"
bs2.DataSource = bs1
bs2.DataMember = "tes"
DataGridView1.DataSource = bs1
DataGridView2.DataSource = bs2
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
BalasHapusDim pp As New OleDb.OleDbCommand
pp = New OleDb.OleDbCommand(" delete * from mastertransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONECT)
CONECT.Open()
pp.ExecuteNonQuery()
CONECT.Close()
pp = New OleDb.OleDbCommand(" delete * from detailtransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONECT)
CONECT.Open()
pp.ExecuteNonQuery()
CONECT.Close()
pp.Dispose()
AP()
Dim st As String = "delete * from mastertransaksi where notrans = '" & DataGridView1.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(st, CONECT)
CONECT.Open()
angkut.ExecuteNonQuery()
CONECT.Close()
angkut.Dispose()
MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Form40B36109050.Visible = False Then
Form40B36109050.Show()
Else
Form40B36109050.Activate()
End If
Form40B36109050.TextBox1.Text = ""
Form40B36109050.TS.Text = "-"
Form40B36109050.jt.Text = ""
Form40B36109050.NN()
Form40B36109050.Pp()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Form40B36109050.Visible = False Then
Form40B36109050.Show()
Else
Form40B36109050.Activate()
End If
Form40B36109050.TextBox1.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
Form40B36109050.TS.Text = DataGridView1.CurrentRow.Cells("notrans").Value
Form40B36109050.jt.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value
Form40B36109050.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("TANGGALTRANSAKSI").Value
Form40B36109050.NN()
Form40B36109050.Pp()
End Sub
End Class
Public Class Form40B36109050
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=nideria")
Dim DT As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim angkut As New OleDb.OleDbCommand
Dim hubung As New OleDb.OleDbDataAdapter
Public Sub Pp()
Dim db As Double
For Each r As DataGridViewRow In DataGridView1.Rows
db = db + r.Cells("JUMLAH").Value
Next
Tot.Text = db
End Sub
Public Sub NN()
Dim adapt As New OleDb.OleDbDataAdapter
adapt = 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='" & TextBox1.Text & "'", CONECT)
DT.Rows.Clear()
adapt.Fill(DT)
End Sub
Public Sub comm()
Dim p As New OleDb.OleDbCommand
p = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans='" & TS.Text & "'", CONECT)
CONECT.Open()
p.ExecuteNonQuery()
CONECT.Close()
Dim md As String
md = "insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values('" & TextBox1.Text & "',#" & DateTimePicker1.Value & "#.'" & jt.Text & "');"
p = New OleDb.OleDbCommand(md, CONECT)
CONECT.Open()
p.ExecuteNonQuery()
CONECT.Close()
p = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans='" & TS.Text & "'", CONECT)
CONECT.Open()
p.ExecuteNonQuery()
CONECT.Close()
For Each y As DataRow In DT.Rows
p = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS,KODEBARANG,UNIT,HARGA VALUES('" & TextBox1.Text & "','" & y("kodebarang") & "','" & y("unit") & "','" & y("harga") & "')", CONECT)
CONECT.Open()
p.ExecuteNonQuery()
CONECT.Close()
Next
p.Dispose()
TextBox1.Text = ""
jt.Text = ""
TS.Text = "-"
Tot.Text = ""
DT.Rows.Clear()
Pp()
Form40A36109050.AP()
End Sub
Private Sub Form40B36109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NN()
DT.Columns("unit").DefaultValue = 0
DT.Columns("harga").DefaultValue = 0
DT.Columns("jumlah").DefaultValue = 0
DataGridView1.DataSource = DT
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
BalasHapusIf e.ColumnIndex = 0 Then
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("kodebarang").Value, 1, CONECT)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("kodebarang").Value = cari.DataTablenya.Rows(0).Item("kodebarang")
DataGridView1.CurrentRow.Cells("namabarang").Value = cari.DataTablenya.Rows(0).Item("namabarang")
DataGridView1.CurrentRow.Cells("harga").Value = cari.DataTablenya.Rows(0).Item("hargajual")
Else
MsgBox("kodebarang tersebut tdk ada")
If Form38394036109050.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("kodebarang").Value = Form38394036109050.DataGridView1.CurrentRow.Cells("kodebarang").Value
DataGridView1.CurrentRow.Cells("namabarang").Value = Form38394036109050.DataGridView1.CurrentRow.Cells("namabarang").Value
DataGridView1.CurrentRow.Cells("harga").Value = Form38394036109050.DataGridView1.CurrentRow.Cells("hargajual").Value
Else
DataGridView1.CurrentRow.Cells("kodebarang").Value = ""
DataGridView1.CurrentRow.Cells("namabarang").Value = ""
DataGridView1.CurrentRow.Cells("harga").Value = ""
End If
End If
ElseIf e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then
DataGridView1.CurrentRow.Cells("jumlah").Value = DataGridView1.CurrentRow.Cells("unit").Value * DataGridView1.CurrentRow.Cells("harga").Value
Pp()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.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 DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
If TextBox1.Text <> TS.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("no.trans sudah ada")
Else
comm()
End If
Exit Sub
End If
comm()
End Sub
End Class
Public Class LATIHAN040A36109029
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)
Dim DT1 As New DataTable
Dim dt2 As New DataTable
Dim dset As New DataSet
Dim bs1 As New BindingSource
Dim bs2 As New BindingSource
Public Sub AP()
'deklarasi(adapter)
Dim indah As New OleDb.OleDbDataAdapter
indah = New OleDb.OleDbDataAdapter("select * FROM MASTERTRANSAKSI", CONNECT) 'memunculkan semua data dari dlm acces
DT1.Rows.Clear() 'membersihkan data table
indah.Fill(DT1) 'mengisi database ke dlm data table
indah = New OleDb.OleDbDataAdapter("select * FROM DETAILTRANSAKSI", CONNECT) 'memunculkan semua data dari dlm acces
dt2.Rows.Clear() 'membersihkan data table
indah.Fill(dt2) 'mengisi database ke dlm data table
indah.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
End Sub
Private Sub LATIHAN040A36109029_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dcp(1) As DataColumn
dcp(0) = DT1.Columns("NOTRANS")
DT1.PrimaryKey = dcp
AP()
dset.Tables.Add(DT1)
dset.Tables.Add(dt2)
'mengganti nama dlm dataset
DT1.TableName = "PP"
dt2.TableName = "qq"
dset.Relations.Add(New DataRelation("NI", dset.Tables("pp").Columns("NOTRANS"), dset.Tables("qq").Columns("NOTRANS")))
'membuat binding data source (mengatur datasource dan data membernya)
bs1.DataSource = dset
bs1.DataMember = "pp"
'datasource binding2 adalah nama binding pertama dan ata membernya adalah nama relasinya
bs2.DataSource = bs1
bs2.DataMember = "NI"
DataGridView1.DataSource = bs1
DataGridView2.DataSource = bs2
End Sub
lanjutan 40A
BalasHapusPrivate Sub Button136109029_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109029.Click
Dim pp As New OleDb.OleDbCommand
pp = New OleDb.OleDbCommand(" delete * from mastertransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONNECT)
CONNECT.Open()
pp.ExecuteNonQuery()
CONNECT.Close()
pp = New OleDb.OleDbCommand(" delete * from detailtransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONNECT)
CONNECT.Open()
pp.ExecuteNonQuery()
CONNECT.Close()
pp.Dispose()
AP()
End Sub
Private Sub Button236109029_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109029.Click
If LATIHAN040B36109029.Visible = False Then
LATIHAN040B36109029.Show()
Else
LATIHAN040B36109029.Activate() 'jika sdh muncul tp dibelakang
End If
LATIHAN040B36109029.TextBox136109029.Text = ""
LATIHAN040B36109029.TS.Text = "-"
LATIHAN040B36109029.jt36109029.Text = ""
LATIHAN040B36109029.NN()
LATIHAN040B36109029.Pp()
End Sub
Private Sub Button336109029_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109029.Click
If LATIHAN040B36109029.Visible = False Then
LATIHAN040B36109029.Show()
Else
LATIHAN040B36109029.Activate() 'jika sdh muncul tp dibelakang
End If
LATIHAN040B36109029.TextBox136109029.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
LATIHAN040B36109029.TS.Text = DataGridView1.CurrentRow.Cells("notrans").Value
LATIHAN040B36109029.jt36109029.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value
LATIHAN040B36109029.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("TANGGALTRANSAKSI").Value
LATIHAN040B36109029.NN()
LATIHAN040B36109029.Pp()
End Sub
End Class
Public Class LATIHAN040B36109029
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
Public Sub Pp()
Dim indah As Double
For Each r As DataGridViewRow In DataGridView1.Rows
indah = indah + r.Cells("JUMLAH").Value
Next
Tot36109029.Text = indah
End Sub
Public Sub NN()
'deklarasi adapter
Dim nisa As New OleDb.OleDbDataAdapter
nisa = New OleDb.OleDbDataAdapter("SELECT BARANG.KODEBARANG,BARANG.NAMABARANG,DETAILTRANSAKSI.UNIT,DETAILTRANSAKSI.HARGA,DETAILTRANSAKSI.UNIT * DETAILTRANSAKSI.HARGA AS JUMLAH FROM BARANG INNER JOIN DETAILTRANSAKSI ON BARANG.KODEBARANG=DETAILTRANSAKSI.KODEBARANG WHERE NOTRANS='" & TextBox136109029.Text & "'", CONNECT)
DT.Rows.Clear()
nisa.Fill(DT)
End Sub
Public Sub princessqu()
Dim p As New OleDb.OleDbCommand
p = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans='" & TS.Text & "'", CONNECT)
CONNECT.Open()
p.ExecuteNonQuery()
CONNECT.Close()
Dim md As String
md = "insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values('" & TextBox136109029.Text & "',#" & DateTimePicker1.Value & "#.'" & jt36109029.Text & "');"
p = New OleDb.OleDbCommand(md, CONNECT)
CONNECT.Open()
p.ExecuteNonQuery()
CONNECT.Close()
p = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans='" & TS.Text & "'", CONNECT)
CONNECT.Open()
p.ExecuteNonQuery()
CONNECT.Close()
For Each y As DataRow In DT.Rows
p = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS,KODEBARANG,UNIT,HARGA VALUES('" & TextBox136109029.Text & "','" & y("kodebarang") & "','" & y("unit") & "','" & y("harga") & "')", CONNECT)
CONNECT.Open()
p.ExecuteNonQuery()
CONNECT.Close()
Next
p.Dispose()
TextBox136109029.Text = ""
jt36109029.Text = ""
TS.Text = "-"
Tot36109029.Text = ""
DT.Rows.Clear()
Pp()
LATIHAN040A36109029.AP()
End Sub
Private Sub LATIHAN040B36109029_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BalasHapusNN()
DT.Columns("unit").DefaultValue = 0
DT.Columns("harga").DefaultValue = 0
DT.Columns("jumlah").DefaultValue = 0
DataGridView1.DataSource = DT 'memunculkan dlm datagridview
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If e.ColumnIndex = 0 Then
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("kodebarang").Value, 1, CONNECT)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("kodebarang").Value = cari.DataTablenya.Rows(0).Item("kodebarang")
DataGridView1.CurrentRow.Cells("namabarang").Value = cari.DataTablenya.Rows(0).Item("namabarang")
DataGridView1.CurrentRow.Cells("harga").Value = cari.DataTablenya.Rows(0).Item("hargajual")
Else
MsgBox("kodebarang tersebut tdk ada")
If Latihan38029.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("kodebarang").Value = Latihan38029.DataGridView1.CurrentRow.Cells("kodebarang").Value
DataGridView1.CurrentRow.Cells("namabarang").Value = Latihan38029.DataGridView1.CurrentRow.Cells("namabarang").Value
DataGridView1.CurrentRow.Cells("harga").Value = Latihan38029.DataGridView1.CurrentRow.Cells("hargajual").Value
Else
DataGridView1.CurrentRow.Cells("kodebarang").Value = ""
DataGridView1.CurrentRow.Cells("namabarang").Value = ""
DataGridView1.CurrentRow.Cells("harga").Value = ""
End If
End If
ElseIf e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then
DataGridView1.CurrentRow.Cells("jumlah").Value = DataGridView1.CurrentRow.Cells("unit").Value * DataGridView1.CurrentRow.Cells("harga").Value
Pp()
End If
End Sub
Private Sub Button236109029_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109029.Click
'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap
If TextBox136109029.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
If TextBox136109029.Text <> TS.Text Then
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109029.Text, 1, CONNECT)
If cari.JumlanBaris > 0 Then
MsgBox("no.trans sudah ada")
Else
princessqu()
End If
Exit Sub
End If
princessqu()
End Sub
End Class
Public Class LATIHAN040B36109038
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
Public Sub Pp()
Dim cantik As Double
For Each r As DataGridViewRow In DataGridView136109038.Rows
cantik = cantik + r.Cells("JUMLAH").Value
Next
Tot36109038.Text = cantik
End Sub
Public Sub NN()
Dim Icha As New OleDb.OleDbDataAdapter
Icha = 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='" & TextBox136109038.Text & "'", CONECT)
DT.Rows.Clear()
Icha.Fill(DT)
End Sub
Public Sub princessqu()
Dim p As New OleDb.OleDbCommand
p = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans='" & TS.Text & "'", CONECT)
CONECT.Open()
p.ExecuteNonQuery()
CONECT.Close()
Dim md As String
md = "insert into mastertransaksi (notrans,tanggaltransaksi,jenistransaksi) values('" & TextBox136109038.Text & "',#" & DateTimePicker136109038.Value & "#.'" & jt36109038.Text & "');"
p = New OleDb.OleDbCommand(md, CONECT)
CONECT.Open()
p.ExecuteNonQuery()
CONECT.Close()
p = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans='" & TS.Text & "'", CONECT)
CONECT.Open()
p.ExecuteNonQuery()
CONECT.Close()
For Each y As DataRow In DT.Rows
p = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS,KODEBARANG,UNIT,HARGA VALUES('" & TextBox136109038.Text & "','" & y("kodebarang") & "','" & y("unit") & "','" & y("harga") & "')", CONECT)
CONECT.Open()
p.ExecuteNonQuery()
CONECT.Close()
Next
p.Dispose()
TextBox136109038.Text = ""
jt36109038.Text = ""
TS.Text = "-"
Tot36109038.Text = ""
DT.Rows.Clear()
Pp()
LATIHAN040A36109038.AP()
End Sub
Private Sub LATIHAN040B36109038Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
NN()
DT.Columns("unit").DefaultValue = 0
DT.Columns("harga").DefaultValue = 0
DT.Columns("jumlah").DefaultValue = 0
DataGridView136109038.DataSource = DT
End Sub
Private Sub DataGridView136109038_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView136109038.CellEndEdit
If e.ColumnIndex = 0 Then
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView136109038.CurrentRow.Cells("kodebarang").Value, 1, CONECT)
If cari.JumlanBaris > 0 Then
BalasHapusDataGridView136109038.CurrentRow.Cells("kodebarang").Value = cari.DataTablenya.Rows(0).Item("kodebarang")
DataGridView136109038.CurrentRow.Cells("namabarang").Value = cari.DataTablenya.Rows(0).Item("namabarang")
DataGridView136109038.CurrentRow.Cells("harga").Value = cari.DataTablenya.Rows(0).Item("hargajual")
Else
MsgBox("kodebarang tersebut tdk ada")
If Latihan03803904036109038.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView136109038.CurrentRow.Cells("kodebarang").Value = Latihan03803904036109038.DataGridView136109038.CurrentRow.Cells("kodebarang").Value
DataGridView136109038.CurrentRow.Cells("namabarang").Value = Latihan03803904036109038.DataGridView136109038.CurrentRow.Cells("namabarang").Value
DataGridView136109038.CurrentRow.Cells("harga").Value = Latihan03803904036109038.DataGridView136109038.CurrentRow.Cells("hargajual").Value
Else
DataGridView136109038.CurrentRow.Cells("kodebarang").Value = ""
DataGridView136109038.CurrentRow.Cells("namabarang").Value = ""
DataGridView136109038.CurrentRow.Cells("harga").Value = ""
End If
End If
ElseIf e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then
DataGridView136109038.CurrentRow.Cells("jumlah").Value = DataGridView136109038.CurrentRow.Cells("unit").Value * DataGridView136109038.CurrentRow.Cells("harga").Value
Pp()
End If
End Sub
Private Sub Button236109038_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109038.Click
If TextBox136109038.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 TextBox136109038.Text <> TS.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109038.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("no.trans sudah ada")
Else
princessqu()
End If
Exit Sub
End If
princessqu()
End Sub
End Class
Public Class LATIHAN040A36109054
BalasHapusDim konek 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 wawan As New DataTable
Dim wcuank As New DataTable
Dim datset As New DataSet
Dim bin As New BindingSource
Dim bin2 As New BindingSource
Dim angkut As New OleDb.OleDbCommand
Private Sub latihan213619043_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cobaji As New OleDb.OleDbDataAdapter
Dim cobaji2 As New OleDb.OleDbDataAdapter
cobaji = New OleDb.OleDbDataAdapter("select * from MASTERTRANSAKSI ", konek)
cobaji.Fill(wawan)
cobaji2 = New OleDb.OleDbDataAdapter("select * from DETAILTRANSAKSI ", konek)
cobaji2.Fill(wcuank)
wawan.TableName = "induknya"
wcuank.TableName = "anaknya"
datset.Tables.Add(wawan)
datset.Tables.Add(wcuank)
datset.Relations.Add(New DataRelation("cobaji", datset.Tables("induknya").Columns("NOTRANS"), datset.Tables("anaknya").Columns("NOTRANS")))
bin.DataSource = datset
bin.DataMember = "induknya"
bin2.DataSource = bin
bin2.DataMember = "cobaji"
DGV136109054.DataSource = bin
DGV236109054.DataSource = bin2
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button336109054.Click
If LATIHAN40B36109054.Visible = False Then
LATIHAN40B36109054.Show()
Else
LATIHAN40B36109054.Activate()
End If
LATIHAN40B36109054.TextBox136109054.Text = DGV136109054.CurrentRow.Cells("notrans").Value
LATIHAN40B36109054.DTP136109054.Value = DGV136109054.CurrentRow.Cells("tanggaltransaksi").Value
LATIHAN40B36109054.ToolStripStatusLabel2.Text = DGV136109054.CurrentRow.Cells("jenistransaksi").Value
LATIHAN40B36109054.ToolStripStatusLabel1.Text = DGV136109054.CurrentRow.Cells("notrans").Value
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button136109054.Click
Dim y As String
y = MsgBox("apakah anda ingin hapusnya?", vbYesNo)
If y = 6 Then
Dim sukma As String = "delete * from detailtransaksi where notrans = '" & DGV136109054.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(sukma, konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut.Dispose()
Dim wan As String = "delete * from mastertransaksi where notrans = '" & DGV136109054.CurrentRow.Cells("notrans").Value & "'"
angkut = New OleDb.OleDbCommand(wan, konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut.Dispose()
MsgBox("data anda sudah terhapus.Untuk memastikan cek pada data acces datamajemuk ")
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109054.Click
If LATIHAN40B36109054.Visible = False Then
LATIHAN40B36109054.Show()
Else
LATIHAN40B36109054.Activate()
End If
End Sub
End Class
Komentar ini telah dihapus oleh pengarang.
BalasHapuspart 2
BalasHapusPublic Sub edit()
If TextBox136109054.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt36109054.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If wawan.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
If TextBox136109054.Text <> ToolStripStatusLabel1.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109054.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
End If
angkut = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox136109054.Text & "',#" & DTP136109054.Value.Month & "/" & DTP136109054.Value.Day & "/" & DTP136109054.Value.Year & "#, '" & jt36109054.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
angkut = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ToolStripStatusLabel1.Text & "'", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
For Each r As DataRow In wawan.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & TextBox136109054.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
Next
angkut.Dispose()
TextBox136109054.Text = ""
jt36109054.Text = ""
Tot36109054.Text = ""
ToolStripStatusLabel1.Text = "-"
wawan.Rows.Clear()
End Sub
Private Sub LATIHAN40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hubung = 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 = '" & TextBox136109054.Text & "'", konek)
wawan.Rows.Clear()
hubung.Fill(wawan)
Dim dc(1) As DataColumn
dc(0) = wawan.Columns("kodebarang")
wawan.PrimaryKey = dc
wawan.Columns("unit").DefaultValue = 0
wawan.Columns("harga").DefaultValue = 0
wawan.Columns("jumlah").DefaultValue = 0
DGV136109054.DataSource = wawan
End Sub
part 1
BalasHapusPublic Class LATIHAN40B36109054
Dim konek 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 wawan As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim angkut As New OleDb.OleDbCommand
Dim hubung As New OleDb.OleDbDataAdapter
Private Sub tambah()
If TextBox136109054.Text.Length = 0 Then
MsgBox("notrans belum terisi")
Exit Sub
End If
If jt36109054.Text.Length = 0 Then
MsgBox("Jenis Transaksinyabelum terisi")
Exit Sub
End If
If wawan.Rows.Count = 0 Then
MsgBox("coba periksa tabelta")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox136109054.Text, 1, konek)
If cari.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
angkut = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & TextBox136109054.Text & "',#" & DTP136109054.Value.Month & "/" & DTP136109054.Value.Day & "/" & DTP136109054.Value.Year & "#, '" & jt36109054.Text & "')", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
For Each r As DataRow In wawan.Rows
angkut = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & TextBox136109054.Text & "', '" & r("kodebarang") & "', '" & r("unit") & "', '" & r("harga") & "') ", konek)
konek.Open()
angkut.ExecuteNonQuery()
konek.Close()
Next
angkut.Dispose()
TextBox136109054.Text = ""
jt36109054.Text = ""
Tot36109054.Text = ""
ToolStripStatusLabel1.Text = "sudahmi tersimpan"
wawan.Rows.Clear()
End Sub
part 3
BalasHapusPrivate Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV136109054.CellEndEdit
If DGV136109054.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DGV136109054.CurrentRow.Cells("NAMABARANG").Value = ""
DGV136109054.CurrentRow.Cells("UNIT").Value = 0
DGV136109054.CurrentRow.Cells("HARGA").Value = 0
DGV136109054.CurrentRow.Cells("JUMLAH").Value = 0
cari.AturPencarianDataBase("barang", "kodebarang", DGV136109054.CurrentRow.Cells("KODEBARANG").Value, 1, konek)
If cari.JumlanBaris > 0 Then
DGV136109054.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV136109054.CurrentRow.Cells("NAMABARANG").Value = ""
If Latihan383940012.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV136109054.CurrentRow.Cells("KODEBARANG").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DGV136109054.CurrentRow.Cells("NAMABARANG").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DGV136109054.Columns(e.ColumnIndex).Name = "UNIT" Or DGV136109054.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV136109054.CurrentRow.Cells("JUMLAH").Value = DGV136109054.CurrentRow.Cells("UNIT").Value * DGV136109054.CurrentRow.Cells("HARGA").Value
Dim manis As Integer
For Each r As DataGridViewRow In DGV136109054.Rows
manis = manis + r.Cells("JUMLAH").Value
Next
Tot36109054.Text = manis
End If
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button236109054.Click
If ToolStripStatusLabel1.Text = "NO.TRANSAKSI" Then
tambah()
Else
edit()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DGV136109054.DataError
MsgBox("ada yang salah")
End Sub
End Class
Public Class LATIHAN040A012
BalasHapus'DEKLARASI CONECTION
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim DT1 As New DataTable
Dim dt2 As New DataTable
Dim dset As New DataSet
Dim bs1 As New BindingSource
Dim bs2 As New BindingSource
Public Sub AP()
'deklarasi(adapter)
Dim jal As New OleDb.OleDbDataAdapter
jal = New OleDb.OleDbDataAdapter("select * FROM MASTERTRANSAKSI", CONECT) 'memunculkan semua data dari dlm acces
DT1.Rows.Clear() 'membersihkan data table
jal.Fill(DT1) 'mengisi database ke dlm data table
jal = New OleDb.OleDbDataAdapter("select * FROM DETAILTRANSAKSI", CONECT) 'memunculkan semua data dari dlm acces
dt2.Rows.Clear() 'membersihkan data table
jal.Fill(dt2) 'mengisi database ke dlm data table
jal.Dispose() 'menghancurkan kendaraan (adapter) yg sdh dipake
End Sub
Private Sub LATIHAN040A012_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dcp(1) As DataColumn
dcp(0) = DT1.Columns("NOTRANS")
DT1.PrimaryKey = dcp
AP()
dset.Tables.Add(DT1)
dset.Tables.Add(dt2)
'mengganti nama dlm dataset
DT1.TableName = "PP"
dt2.TableName = "qq"
dset.Relations.Add(New DataRelation("NI", dset.Tables("pp").Columns("NOTRANS"), dset.Tables("qq").Columns("NOTRANS")))
'membuat binding data source (mengatur datasource dan data membernya)
bs1.DataSource = dset
bs1.DataMember = "pp"
'datasource binding2 adalah nama binding pertama dan ata membernya adalah nama relasinya
bs2.DataSource = bs1
bs2.DataMember = "NI"
DataGridView1.DataSource = bs1
DataGridView2.DataSource = bs2
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim pp As New OleDb.OleDbCommand
pp = New OleDb.OleDbCommand(" delete * from mastertransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONECT)
CONECT.Open()
pp.ExecuteNonQuery()
CONECT.Close()
pp = New OleDb.OleDbCommand(" delete * from detailtransaksi where notrans='" & DataGridView1.CurrentRow.Cells("notrans").Value & "'", CONECT)
CONECT.Open()
pp.ExecuteNonQuery()
CONECT.Close()
pp.Dispose()
AP()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If LATIHAN_040B_012.Visible = False Then
LATIHAN_040B_012.Show()
Else
LATIHAN_040B_012.Activate() 'jika sdh muncul tp dibelakang
End If
LATIHAN_040B_012.TextBox1.Text = ""
LATIHAN_040B_012.TS.Text = "-"
LATIHAN_040B_012.jt.Text = ""
LATIHAN_040B_012.NN()
LATIHAN_040B_012.Pp()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
BalasHapusIf LATIHAN_040B_012.Visible = False Then
LATIHAN_040B_012.Show()
Else
LATIHAN_040B_012.Activate() 'jika sdh muncul tp dibelakang
End If
LATIHAN_040B_012.TextBox1.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
LATIHAN_040B_012.TS.Text = DataGridView1.CurrentRow.Cells("notrans").Value
LATIHAN_040B_012.jt.Text = DataGridView1.CurrentRow.Cells("jenistransaksi").Value
LATIHAN_040B_012.DateTimePicker1.Value = DataGridView1.CurrentRow.Cells("TANGGALTRANSAKSI").Value
LATIHAN_040B_012.NN()
LATIHAN_040B_012.Pp()
End Sub
End Class
Komentar ini telah dihapus oleh pengarang.
BalasHapusPrivate Sub LATIHAN_040B_012_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BalasHapusNN()
IJAL.Columns("unit").DefaultValue = 0
IJAL.Columns("harga").DefaultValue = 0
IJAL.Columns("jumlah").DefaultValue = 0
DataGridView1.DataSource = IJAL 'memunculkan dlm datagridview
End Sub
Private Sub DataGridView1_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
If e.ColumnIndex = 0 Then
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("kodebarang").Value, 1, CONECT)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("kodebarang").Value = cari.DataTablenya.Rows(0).Item("kodebarang")
DataGridView1.CurrentRow.Cells("namabarang").Value = cari.DataTablenya.Rows(0).Item("namabarang")
DataGridView1.CurrentRow.Cells("harga").Value = cari.DataTablenya.Rows(0).Item("hargajual")
Else
MsgBox("kodebarang tersebut tdk ada")
If Latihan383940012.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("kodebarang").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("kodebarang").Value
DataGridView1.CurrentRow.Cells("namabarang").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("namabarang").Value
DataGridView1.CurrentRow.Cells("harga").Value = Latihan383940012.DataGridView1.CurrentRow.Cells("hargajual").Value
Else
DataGridView1.CurrentRow.Cells("kodebarang").Value = ""
DataGridView1.CurrentRow.Cells("namabarang").Value = ""
DataGridView1.CurrentRow.Cells("harga").Value = ""
End If
End If
elseif e.ColumnIndex=2 or e.ColumnIndex=3 then
DataGridView1.CurrentRow.Cells("jumlah").Value = DataGridView1.CurrentRow.Cells("unit").Value * DataGridView1.CurrentRow.Cells("harga").Value
Pp()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'untuk mencari jgn sampai data yg akan dimasukkan tidak lengkap
If TextBox1.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("no transaksi belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If jt.Text.Length = 0 Then 'untuk pencarian yang bersifat angka
MsgBox("jenis transaksi belum terisi")
Exit Sub 'jgn lanjut ke proses berikutnya
End If
If IJAL.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
If TextBox1.Text <> TS.Text Then
'untuk mencari jgn sampai data yg akan dimasukkan sudah ada
cari.AturPencarianDataBase("mastertransaksi", "notrans", TextBox1.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("no.trans sudah ada")
Else
Rez()
End If
Exit Sub
End If
Rez()
End Sub
End Class
pembaharuan
BalasHapusDim INCE As New OleDb.OleDbConnection("provider=Microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DataMajemuk.accdb;Jet OLEDB:Database Password=36108001")
Dim LOVE, CINTA As New DataTable
Dim KASIH As New DataSet
Dim KANGEN, RINDU As New BindingSource
Public Sub UDANI()
Dim YNK As New OleDb.OleDbDataAdapter
CINTA.Rows.Clear()
LOVE.Rows.Clear()
YNK = New OleDb.OleDbDataAdapter("Select * from mastertransaksi", INCE)
YNK.Fill(LOVE)
YNK = New OleDb.OleDbDataAdapter("Select * from detailtransaksi", INCE)
YNK.Fill(CINTA)
End Sub
Private Sub Form40b36108001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
UDANI()
KASIH.Tables.Add(LOVE)
KASIH.Tables.Add(CINTA)
LOVE.TableName = "dst"
CINTA.TableName = "dst2"
KASIH.Relations.Add(New DataRelation("r", KASIH.Tables("dst").Columns("Notrans"), KASIH.Tables("dst2").Columns("Notrans")))
KANGEN.DataSource = KASIH
KANGEN.DataMember = "dst"
RINDU.DataSource = KANGEN
RINDU.DataMember = "r"
Dim PK(1) As DataColumn
PK(0) = LOVE.Columns("Notrans")
LOVE.PrimaryKey = PK
DGV136108001.DataSource = KANGEN
DGV236108001.DataSource = RINDU
End Sub
lanjutan pembaharuan
BalasHapusPrivate Sub B136108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B136108001.Click
Dim VE As New OleDb.OleDbCommand
Dim PU As String
PU = "delete * from mastertransaksi where notrans='" & DGV136108001.CurrentRow.Cells("notrans").Value & "'"
VE = New OleDb.OleDbCommand(PU, INCE)
INCE.Open()
VE.ExecuteNonQuery()
INCE.Close()
Dim RA As String
RA = "delete * from detailtransaksi where notrans='" & DGV136108001.CurrentRow.Cells("notrans").Value & "'"
VE = New OleDb.OleDbCommand(RA, INCE)
INCE.Open()
VE.ExecuteNonQuery()
INCE.Close()
VE.Dispose()
UDANI()
End Sub
Private Sub B236108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B236108001.Click
If Form40b36108001.Visible = False Then
Form40b36108001.Show()
Else
Form40b36108001.Activate()
End If
Form40b36108001.T136108001.Text = ""
Form40b36108001.T936108001.Text = "-"
Form40b36108001.T236108001.Text = ""
Form40b36108001.SAYANG()
Form40b36108001.TOT()
End Sub
Private Sub B336108001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B336108001.Click
If Form40b36108001.Visible = False Then
Form40b36108001.Show()
Else
Form40b36108001.Activate()
End If
Form40b36108001.T136108001.Text = DGV136108001.CurrentRow.Cells("notrans").Value
Form40b36108001.T936108001.Text = DGV136108001.CurrentRow.Cells("notrans").Value
Form40b36108001.T236108001.Text = DGV136108001.CurrentRow.Cells("jenistransaksi").Value
Form40b36108001.DTP36108001.Value = DGV136108001.CurrentRow.Cells("tanggaltransaksi").Value
Form40b36108001.SAYANG()
Form40b36108001.TOT()
End Sub
End Class
pembaharuan lg
BalasHapusPublic Class Form40b36108001
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
Public Sub TOT()
Dim LO As Integer
For Each VE As DataRow In LOVE.Rows
LO = LO + VE("Jumlah")
Next
T836108001.Text = LO
End Sub
Public Sub SAYANG()
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)
End Sub
Public Sub AA()
Dim AKBAR As New OleDb.OleDbCommand
Dim AAA As String
AAA = "delete * from mastertransaksi where notrans='" & T936108001.Text & "'"
AKBAR = New OleDb.OleDbCommand(AAA, INCE)
INCE.Open()
AKBAR.ExecuteNonQuery()
INCE.Close()
Dim ANHYE As String
ANHYE = "INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & T136108001.Text & "',#" & DTP36108001.Value.Date & "#,'" & T236108001.Text & "');"
AKBAR = New OleDb.OleDbCommand(ANHYE, INCE)
INCE.Open()
AKBAR.ExecuteNonQuery()
INCE.Close()
Dim TF As String
TF = "delete * from detailtransaksi where notrans='" & T936108001.Text & "'"
AKBAR = New OleDb.OleDbCommand(TF, INCE)
INCE.Open()
AKBAR.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") & "');"
AKBAR = New OleDb.OleDbCommand(EGIET, INCE)
INCE.Open()
AKBAR.ExecuteNonQuery()
INCE.Close()
Next
AKBAR.Dispose()
T136108001.Text = ""
T236108001.Text = ""
T936108001.Text = "-"
T836108001.Text = ""
LOVE.Rows.Clear()
TOT()
Form40a36108001.UDANI()
End Sub
lanjutan pembaharuan lg..
BalasHapusPrivate Sub DGV36108001_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV36108001.CellEndEdit
If e.ColumnIndex = 0 Then
Dim IA As New ByIskandar.CariKeDataBaseByIskandar
IA.AturPencarianDataBase("barang", "kodebarang", DGV36108001.CurrentRow.Cells("KodeBarang").Value, 1, INCE)
If IA.JumlanBaris > 0 Then
DGV36108001.CurrentRow.Cells("KodeBarang").Value = IA.DataTablenya.Rows(0).Item("KodeBarang")
DGV36108001.CurrentRow.Cells("NamaBarang").Value = IA.DataTablenya.Rows(0).Item("NamaBarang")
DGV36108001.CurrentRow.Cells("Harga").Value = IA.DataTablenya.Rows(0).Item("HargaJual")
Else
MsgBox("Kode barang tersbut tidak ada")
If Form38394036108001.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV36108001.CurrentRow.Cells("KodeBarang").Value = Form38394036108001.DGV36108001.CurrentRow.Cells("KodeBarang").Value
DGV36108001.CurrentRow.Cells("NamaBarang").Value = Form38394036108001.DGV36108001.CurrentRow.Cells("NamaBarang").Value
DGV36108001.CurrentRow.Cells("Harga").Value = Form38394036108001.DGV36108001.CurrentRow.Cells("HargaJual").Value
Else
DGV36108001.CurrentRow.Cells("KodeBarang").Value = ""
DGV36108001.CurrentRow.Cells("NamaBarang").Value = ""
DGV36108001.CurrentRow.Cells("Harga").Value = ""
End If
End If
ElseIf e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then
DGV36108001.CurrentRow.Cells("Jumlah").Value = DGV36108001.CurrentRow.Cells("Unit").Value * DGV36108001.CurrentRow.Cells("Harga").Value
TOT()
End If
End Sub
Private Sub Form40b36108001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SAYANG()
LOVE.Columns("Unit").DefaultValue = 0
LOVE.Columns("Harga").DefaultValue = 0
LOVE.Columns("Jumlah").DefaultValue = 0
DGV36108001.DataSource = LOVE
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
If T136108001.Text <> T936108001.Text Then
Dim AYI As New ByIskandar.CariKeDataBaseByIskandar
AYI.AturPencarianDataBase("mastertransaksi", "NOTRANS", T136108001.Text, 1, INCE)
If AYI.JumlanBaris > 0 Then
MsgBox("Nomor transaksi tersebut sudah ada")
Else
AA()
End If
Exit Sub
End If
AA()
End Sub
End Class
Public Class LATIHAN40A36109044
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim fira As New DataTable
Dim mula As New DataTable
Dim uwais As New DataSet
Dim ical As New BindingSource
Dim arul As New BindingSource
Public Sub AP()
Dim kyu As New OleDb.OleDbDataAdapter
kyu = New OleDb.OleDbDataAdapter("select * FROM MASTERTRANSAKSI", CONECT)
fira.Rows.Clear()
kyu.Fill(fira)
kyu = New OleDb.OleDbDataAdapter("select * FROM DETAILTRANSAKSI", CONECT)
mula.Rows.Clear()
kyu.Fill(mula)
kyu.Dispose()
End Sub
Private Sub LATIHAN40A36109044_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dcp(1) As DataColumn
dcp(0) = fira.Columns("NOTRANS")
fira.PrimaryKey = dcp
AP()
uwais.Tables.Add(fira)
uwais.Tables.Add(mula)
'mengganti nama dlm dataset
fira.TableName = "PP"
mula.TableName = "qq"
uwais.Relations.Add(New DataRelation("NI", uwais.Tables("pp").Columns("NOTRANS"), uwais.Tables("qq").Columns("NOTRANS")))
'membuat binding data source (mengatur datasource dan data membernya)
ical.DataSource = uwais
ical.DataMember = "pp"
'datasource binding2 adalah nama binding pertama dan ata membernya adalah nama relasinya
arul.DataSource = ical
arul.DataMember = "NI"
DataGridView136109044.DataSource = ical
DataGridView236109044.DataSource = arul
End Sub
Private Sub Button136109044_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button136109044.Click
Dim yoon As New OleDb.OleDbCommand
yoon = New OleDb.OleDbCommand(" delete * from mastertransaksi where notrans='" & DataGridView136109044.CurrentRow.Cells("notrans").Value & "'", CONECT)
CONECT.Open()
yoon.ExecuteNonQuery()
CONECT.Close()
yoon = New OleDb.OleDbCommand(" delete * from detailtransaksi where notrans='" & DataGridView136109044.CurrentRow.Cells("notrans").Value & "'", CONECT)
CONECT.Open()
yoon.ExecuteNonQuery()
CONECT.Close()
yoon.Dispose()
AP()
End Sub
Private Sub Button236109044_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button236109044.Click
If LATIHAN40B36109044.Visible = False Then
LATIHAN40B36109044.Show()
Else
LATIHAN40B36109044.Activate()
End If
LATIHAN40B36109044.TextBox136109044.Text = ""
LATIHAN40B36109044.TS.Text = "-"
LATIHAN40B36109044.JT36109044.Text = ""
LATIHAN40B36109044.NN()
LATIHAN40B36109044.Pp()
End Sub
End Class
http://hilariusmariotonapa.blogspot.com/2012/10/deskripsi-latihan40a36110048.html
BalasHapushttp://hilariusmariotonapa.blogspot.com/2012/10/prosedur-penyelesaian-latihan40a36110048.html
http://hilariusmariotonapa.blogspot.com/2012/10/prosedur-penyelesaian-latihan40b36110048.html
http://hilariusmariotonapa.blogspot.com/2012/10/deskripsi-latihan40b36110048.html
http://tiya-sri.blogspot.com/2012/10/latihan40a36110044-aplikasi-komputer-4.html
BalasHapushttp://tiya-sri.blogspot.com/2012/10/latihan40b36110044-aplikasi-komputer-4.html
http://eminaomi.blogspot.com/2012/10/latihan40a36110049_27.html
BalasHapushttp://eminaomi.blogspot.com/2012/10/latihan40b36110049.html
http://nurrahmahrasyid2.blogspot.com/2012/10/latihan40a36110042.html
BalasHapushttp://nurrahmahrasyid2.blogspot.com/2012/10/latihan40b36110042.html
http://03melisa.blogspot.com/2012/10/latihan-40a-36110051-apkom-4-d3b.html
BalasHapushttp://03melisa.blogspot.com/2012/10/latihan-40b-36110051-apkom-4-d3b.html
http://reskypurwono.blogspot.com/2012/10/prosedur-penyelesaian-latihan40a36110037.html
BalasHapushttp://reskypurwono.blogspot.com/2012/10/prosedur-penyelesaian-latihan40b36110037.html
http://benhilll.blogspot.com/2012/10/deskripsi-dan-prosedur_9053.html
BalasHapushttp://benhilll.blogspot.com/2012/10/deskripsi-dan-prosedur_3127.html
http://rosyanausman.blogspot.com/2012/10/latihan40a36110036.html
BalasHapushttp://rosyanausman.blogspot.com/2012/10/latihan40b36110036.html
Komentar ini telah dihapus oleh pengarang.
BalasHapushttp://hasfiahzain.blogspot.com/2012/10/latihan4036110052.html
BalasHapushttp://hasfiahzain.blogspot.com/2012/10/latihan40b36110052.html
http://ilhaazzahra.blogspot.com/2012/10/latihan4036110033.html
BalasHapushttp://ilhaazzahra.blogspot.com/2012/10/latihan40b36110033.html
http://ias-anakbola.blogspot.com/2012/10/latihan40a36110056.html
BalasHapushttp://ias-anakbola.blogspot.com/2012/10/latihan4036110056.html
http://rainaagrippinaa.blogspot.com/2012/10/latihan40a36110032.html
BalasHapushttp://rainaagrippinaa.blogspot.com/2012/10/latihan40b36110032.html
http://rahmisuryatama05.blogspot.com/2012/10/latihan40a36110040.html
BalasHapushttp://rahmisuryatama05.blogspot.com/2012/10/latihan40b36110040.html
http://sriayu-36110030.blogspot.com/2012/10/diskripsi-prosedur-latihan-40-a.html
BalasHapushttp://sriayu-36110030.blogspot.com/2012/10/diskripsi-prosedur-latihan-40b.html
http://dewiwahyuni91.blogspot.com/2012/10/latihan40a36110038.html
BalasHapushttp://dewiwahyuni91.blogspot.com/2012/10/latihan40b36110038.html
http://andiniwarakusuma.blogspot.com/2012/10/latihan40a36110034.html
BalasHapushttp://andiniwarakusuma.blogspot.com/2012/10/latihan40b36110034.html
http://zulkiflitryputra.blogspot.com/2012/10/latihan40a36110046.html
BalasHapushttp://zulkiflitryputra.blogspot.com/2012/10/latihan40b36110046.html
http://zulkiflitryputra.blogspot.com/2012/10/latihan38394036110046.html
http://audryasharii.blogspot.com/2012/10/latihan40a36110031.html
BalasHapushttp://audryasharii.blogspot.com/2012/10/latihan40b36110031.html
http://sukadriady.blogspot.com/2012/10/latihan40a36110043.html
BalasHapushttp://sukadriady.blogspot.com/2012/10/latihan40b36110043.html
http://ruslancullank1.blogspot.com/2012/11/deskripsilatihan40a36110054.html
BalasHapushttp://ruslancullank1.blogspot.com/2012/11/deskripsilatihan40b36110054.html
http://burhankhang58.blogspot.com/2012/10/latihan40a36110047.html
BalasHapushttp://burhankhang58.blogspot.com/2012/10/latihan40b36110047.html
http://rizka-azisah.blogspot.com/2012/11/deskripsi-penyelesaian-latihan40a3611004.html
BalasHapushttp://rizka-azisah.blogspot.com/2012/11/deskripsi-penyelesaian_10.html