Public Class form40a_36109003 Dim anto As New DataSet Dim arman1 As New DataTable Dim arman2 As New DataTable Dim soe1 As New BindingSource Dim soe2 As New BindingSource Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DataMajemuk.accdb'") Public Sub anra1() Dim a As New OleDb.OleDbDataAdapter arman2.Rows.Clear() arman1.Rows.Clear() a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", ndut) a.Fill(arman1) a = New OleDb.OleDbDataAdapter("select detailtransaksi.notrans, barang.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, detailtransaksi.unit*harga as jumlah from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang", ndut) a.Fill(arman2) End Sub Private Sub form40a_36109003_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load anra1()
Dim dc(1) As DataColumn dc(0) = arman1.Columns("notrans") arman1.PrimaryKey = dc
dgv1_36109003.DataSource = soe1 dgv2_36109003.DataSource = soe2 End Sub
Private Sub hapus_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_36109003.Click Dim cm As New OleDb.OleDbCommand cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv1_36109003.CurrentRow.Cells("notrans").Value & "'", ndut) ndut.Open() cm.ExecuteNonQuery() ndut.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv1_36109003.CurrentRow.Cells("notrans").Value & "'", ndut) ndut.Open() cm.ExecuteNonQuery() ndut.Close() cm.Dispose() anra1() End Sub
Private Sub tambah_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109003.Click If Form40b_36109003.Visible = False Then Form40b_36109003.Show() Else Form40b_36109003.Activate() End If
Form40b_36109003.anra2() Form40b_36109003.anra3() End Sub
Private Sub edit_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109003.Click If Form40b_36109003.Visible = False Then Form40b_36109003.Show() Else Form40b_36109003.Activate() End If
Public Class Form40b_36109003 Dim arman As New ByIskandar.CariKeDataBaseByIskandar Dim anto As New DataTable Dim soe As New OleDb.OleDbCommand Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DataMajemuk.accdb'") Public Sub anra2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & nt_36109003.Text & "'", ndut) anto.Rows.Clear() a.Fill(anto) End Sub Public Sub anra3() Dim anra31 As Integer = 0 For Each anra32 As DataRow In anto.Rows anra31 += anra32("JUMLAH") Next total_36109003.Text = anra31 End Sub
Private Sub anra4() If nt_36109003.Text.Length = 0 Then MsgBox("no transaksi harus terisi") Exit Sub End If
If jt_36109003.Text.Length = 0 Then MsgBox("jenis transaksi harus terisi") Exit Sub End If
If anto.Rows.Count = 0 Then MsgBox("Isi datatable") Exit Sub End If End Sub
Private Sub tambah() anra4() arman.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109003.Text, 1, ndut) If arman.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each x As DataRow In anto.Rows soe = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt_36109003.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", ndut) ndut.Open() soe.ExecuteNonQuery() ndut.Close() Next soe.Dispose()
anto.Rows.Clear() form40a_36109003.anra1() End Sub
Public Sub edit() anra4() If nt_36109003.Text <> kode_36109003.Text Then arman.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109003.Text, 1, ndut) If arman.JumlanBaris > 0 Then MsgBox("no transaksi telah ada") Exit Sub End If End If
soe = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & kode_36109003.Text & "'", ndut) ndut.Open() soe.ExecuteNonQuery() ndut.Close()
soe = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & kode_36109003.Text & "'", ndut) ndut.Open() soe.ExecuteNonQuery() ndut.Close()
For Each x As DataRow In anto.Rows soe = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt_36109003.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", ndut) ndut.Open() soe.ExecuteNonQuery() ndut.Close() Next soe.Dispose()
Private Sub dgv_36109003_Cellendedit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv_36109003.CellEndEdit If dgv_36109003.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
arman.AturPencarianDataBase("barang", "kodebarang", dgv_36109003.CurrentRow.Cells("KODEBARANG").Value, 1, ndut) If arman.JumlanBaris > 0 Then dgv_36109003.CurrentRow.Cells("NAMABARANG").Value = arman.DataTablenya.Rows(0).Item("NAMABARANG") Else dgv_36109003.CurrentRow.Cells("NAMABARANG").Value = "" If form38_39_40_36109003.ShowDialog = Windows.Forms.DialogResult.OK Then dgv_36109003.CurrentRow.Cells("KODEBARANG").Value = form38_39_40_36109003.dgv_36109003.CurrentRow.Cells("KODEBARANG").Value dgv_36109003.CurrentRow.Cells("NAMABARANG").Value = form38_39_40_36109003.dgv_36109003.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf dgv_36109003.Columns(e.ColumnIndex).Name = "UNIT" Or dgv_36109003.Columns(e.ColumnIndex).Name = "HARGA" Then dgv_36109003.CurrentRow.Cells("JUMLAH").Value = dgv_36109003.CurrentRow.Cells("UNIT").Value * dgv_36109003.CurrentRow.Cells("HARGA").Value anra3() End If End Sub
Private Sub simpan_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109003.Click If kode_36109003.Text = "-" Then tambah() Else edit() End If End Sub End Class
Public Class Form40A_36109001 Dim imps 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 ds As New DataSet Dim bs1 As New BindingSource Dim bs2 As New BindingSource
Public Sub apreal1() Dim a As New OleDb.OleDbDataAdapter dt2.Rows.Clear() dt1.Rows.Clear() a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", imps) a.Fill(dt1) a = New OleDb.OleDbDataAdapter("select detailtransaksi.notrans, barang.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, detailtransaksi.unit*harga as jumlah from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang", imps) a.Fill(dt2) End Sub
Private Sub Form40A_36109001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load apreal1()
Dim dc(1) As DataColumn dc(0) = dt1.Columns("notrans") dt1.PrimaryKey = dc
dgv1_36109001.DataSource = bs1 dgv2_36109001.DataSource = bs2 End Sub
Private Sub btn1_36109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1_36109001.Click Dim cm As New OleDb.OleDbCommand cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv1_36109001.CurrentRow.Cells("notrans").Value & "'", imps) imps.Open() cm.ExecuteNonQuery() imps.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv1_36109001.CurrentRow.Cells("notrans").Value & "'", imps) imps.Open() cm.ExecuteNonQuery() imps.Close() cm.Dispose() apreal1() End Sub
Private Sub btn2_36109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2_36109001.Click If Form40B_36109001.Visible = False Then Form40B_36109001.Show() Else Form40B_36109001.Activate() End If
Form40B_36109001.apreal2() Form40B_36109001.apreal3() End Sub
Private Sub btn3_36109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3_36109001.Click If Form40B_36109001.Visible = False Then Form40B_36109001.Show() Else Form40B_36109001.Activate() End If
Public Class Form40B_36109001 Dim imps As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/dataMajemuk.accdb") Dim dt As New DataTable Dim apreal As New ByIskandar.CariKeDataBaseByIskandar Dim rr As New OleDb.OleDbCommand
Public Sub apreal2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & not_36109001.Text & "'", imps) dt.Rows.Clear() a.Fill(dt) End Sub
Public Sub apreal3() Dim total As Integer = 0 For Each x As DataRow In dt.Rows total += x("Jumlah") Next tot_36109001.Text = total End Sub
Private Sub apreal4() If not_36109001.Text.Length = 0 Then MsgBox("Isi itu Notransnya..") Exit Sub End If
If jt_36109001.Text.Length = 0 Then MsgBox("Isi itu Jenis Transaksinya..") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Isi itu datatable k..") Exit Sub End If End Sub
Private Sub tambah() apreal4() apreal.AturPencarianDataBase("mastertransaksi", "notrans", not_36109001.Text, 1, imps) If apreal.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each x As DataRow In dt.Rows rr = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & not_36109001.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", imps) imps.Open() rr.ExecuteNonQuery() imps.Close() Next rr.Dispose()
Public Sub edit() apreal4() If not_36109001.Text <> ts_36109001.Text Then apreal.AturPencarianDataBase("mastertransaksi", "notrans", not_36109001.Text, 1, imps) If apreal.JumlanBaris > 0 Then MsgBox("Adami Notrans seperti itu,,mohon ganti..") Exit Sub End If End If
rr = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ts_36109001.Text & "'", imps) imps.Open() rr.ExecuteNonQuery() imps.Close()
rr = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ts_36109001.Text & "'", imps) imps.Open() rr.ExecuteNonQuery() imps.Close()
For Each x As DataRow In dt.Rows rr = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & not_36109001.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", imps) imps.Open() rr.ExecuteNonQuery() imps.Close() Next rr.Dispose()
Private Sub dgv_36109001_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv_36109001.CellEndEdit If dgv_36109001.Columns(e.ColumnIndex).Name = "KODEBARANG" Then 'If dgv_36109001.CurrentRow.Cells(0) = "KODEBARANG" Then (rumus lain)
'untuk mencari nama barang dgv_36109001.CurrentRow.Cells("NAMABARANG").Value = "" dgv_36109001.CurrentRow.Cells("UNIT").Value = 0 dgv_36109001.CurrentRow.Cells("HARGA").Value = 0 dgv_36109001.CurrentRow.Cells("JUMLAH").Value = 0
apreal.AturPencarianDataBase("barang", "kodebarang", dgv_36109001.CurrentRow.Cells("KODEBARANG").Value, 1, imps) If apreal.JumlanBaris > 0 Then '(menampilkan nama barang jika kolom kode barang ditemukan oleh proses di atas dgv_36109001.CurrentRow.Cells("NAMABARANG").Value = apreal.DataTablenya.Rows(0).Item("NAMABARANG") Else dgv_36109001.CurrentRow.Cells("NAMABARANG").Value = "" If Form38_39_40_36109001.ShowDialog = Windows.Forms.DialogResult.OK Then dgv_36109001.CurrentRow.Cells("KODEBARANG").Value = Form38_39_40_36109001.dgv_36109001.CurrentRow.Cells("KODEBARANG").Value dgv_36109001.CurrentRow.Cells("NAMABARANG").Value = Form38_39_40_36109001.dgv_36109001.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf dgv_36109001.Columns(e.ColumnIndex).Name = "UNIT" Or dgv_36109001.Columns(e.ColumnIndex).Name = "HARGA" Then dgv_36109001.CurrentRow.Cells("JUMLAH").Value = dgv_36109001.CurrentRow.Cells("UNIT").Value * dgv_36109001.CurrentRow.Cells("HARGA").Value apreal3() End If End Sub
Private Sub btn_36109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_36109001.Click If ts_36109001.Text = "-" Then tambah() Else edit() End If End Sub
Private Sub dgv_36109001_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgv_36109001.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub End Class
Public Class form40a_36109003
BalasHapusDim anto As New DataSet
Dim arman1 As New DataTable
Dim arman2 As New DataTable
Dim soe1 As New BindingSource
Dim soe2 As New BindingSource
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DataMajemuk.accdb'")
Public Sub anra1()
Dim a As New OleDb.OleDbDataAdapter
arman2.Rows.Clear()
arman1.Rows.Clear()
a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", ndut)
a.Fill(arman1)
a = New OleDb.OleDbDataAdapter("select detailtransaksi.notrans, barang.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, detailtransaksi.unit*harga as jumlah from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang", ndut)
a.Fill(arman2)
End Sub
Private Sub form40a_36109003_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
anra1()
anto.Tables.Add(arman1)
anto.Tables.Add(arman2)
arman1.TableName = "r1"
arman2.TableName = "r2"
anto.Relations.Add(New DataRelation("an", anto.Tables("r1").Columns("notrans"), anto.Tables("r2").Columns("notrans")))
soe1.DataSource = anto
soe1.DataMember = "r1"
soe2.DataSource = soe1
soe2.DataMember = "an"
Dim dc(1) As DataColumn
dc(0) = arman1.Columns("notrans")
arman1.PrimaryKey = dc
dgv1_36109003.DataSource = soe1
dgv2_36109003.DataSource = soe2
End Sub
Private Sub hapus_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_36109003.Click
Dim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv1_36109003.CurrentRow.Cells("notrans").Value & "'", ndut)
ndut.Open()
cm.ExecuteNonQuery()
ndut.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv1_36109003.CurrentRow.Cells("notrans").Value & "'", ndut)
ndut.Open()
cm.ExecuteNonQuery()
ndut.Close()
cm.Dispose()
anra1()
End Sub
Private Sub tambah_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah_36109003.Click
If Form40b_36109003.Visible = False Then
Form40b_36109003.Show()
Else
Form40b_36109003.Activate()
End If
Form40b_36109003.nt_36109003.Text = ""
Form40b_36109003.jt_36109003.Text = ""
Form40b_36109003.kode_36109003.Text = "-"
Form40b_36109003.anra2()
Form40b_36109003.anra3()
End Sub
Private Sub edit_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit_36109003.Click
If Form40b_36109003.Visible = False Then
Form40b_36109003.Show()
Else
Form40b_36109003.Activate()
End If
Form40b_36109003.nt_36109003.Text = dgv1_36109003.CurrentRow.Cells("notrans").Value
Form40b_36109003.tgl_36109003.Value = dgv1_36109003.CurrentRow.Cells("tanggaltransaksi").Value
Form40b_36109003.jt_36109003.Text = dgv1_36109003.CurrentRow.Cells("jenistransaksi").Value
Form40b_36109003.kode_36109003.Text = dgv1_36109003.CurrentRow.Cells("notrans").Value
Form40b_36109003.anra2()
Form40b_36109003.anra3()
End Sub
End Class
Public Class Form40b_36109003
BalasHapusDim arman As New ByIskandar.CariKeDataBaseByIskandar
Dim anto As New DataTable
Dim soe As New OleDb.OleDbCommand
Dim ndut As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & Application.StartupPath & "\DataMajemuk.accdb'")
Public Sub anra2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & nt_36109003.Text & "'", ndut)
anto.Rows.Clear()
a.Fill(anto)
End Sub
Public Sub anra3()
Dim anra31 As Integer = 0
For Each anra32 As DataRow In anto.Rows
anra31 += anra32("JUMLAH")
Next
total_36109003.Text = anra31
End Sub
Private Sub anra4()
If nt_36109003.Text.Length = 0 Then
MsgBox("no transaksi harus terisi")
Exit Sub
End If
If jt_36109003.Text.Length = 0 Then
MsgBox("jenis transaksi harus terisi")
Exit Sub
End If
If anto.Rows.Count = 0 Then
MsgBox("Isi datatable")
Exit Sub
End If
End Sub
Private Sub tambah()
BalasHapusanra4()
arman.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109003.Text, 1, ndut)
If arman.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
soe = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt_36109003.Text & "',#" & tgl_36109003.Value.Month & "/" & tgl_36109003.Value.Day & "/" & tgl_36109003.Value.Year & "#, '" & tgl_36109003.Text & "')", ndut)
ndut.Open()
soe.ExecuteNonQuery()
ndut.Close()
For Each x As DataRow In anto.Rows
soe = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt_36109003.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", ndut)
ndut.Open()
soe.ExecuteNonQuery()
ndut.Close()
Next
soe.Dispose()
nt_36109003.Text = ""
jt_36109003.Text = ""
total_36109003.Text = ""
kode_36109003.Text = "-"
anto.Rows.Clear()
form40a_36109003.anra1()
End Sub
Public Sub edit()
anra4()
If nt_36109003.Text <> kode_36109003.Text Then
arman.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109003.Text, 1, ndut)
If arman.JumlanBaris > 0 Then
MsgBox("no transaksi telah ada")
Exit Sub
End If
End If
soe = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & kode_36109003.Text & "'", ndut)
ndut.Open()
soe.ExecuteNonQuery()
ndut.Close()
soe = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt_36109003.Text & "',#" & tgl_36109003.Value.Month & "/" & tgl_36109003.Value.Day & "/" & tgl_36109003.Value.Year & "#, '" & jt_36109003.Text & "')", ndut)
ndut.Open()
soe.ExecuteNonQuery()
ndut.Close()
soe = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & kode_36109003.Text & "'", ndut)
ndut.Open()
soe.ExecuteNonQuery()
ndut.Close()
For Each x As DataRow In anto.Rows
soe = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt_36109003.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", ndut)
ndut.Open()
soe.ExecuteNonQuery()
ndut.Close()
Next
soe.Dispose()
nt_36109003.Text = ""
jt_36109003.Text = ""
total_36109003.Text = ""
kode_36109003.Text = "-"
anto.Rows.Clear()
form40a_36109003.anra1()
End Sub
Private Sub Form40b_36109003_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BalasHapusanra2()
Dim dc(1) As DataColumn
dc(0) = anto.Columns("kodebarang")
anto.PrimaryKey = dc
anto.Columns("unit").DefaultValue = 0
anto.Columns("harga").DefaultValue = 0
anto.Columns("jumlah").DefaultValue = 0
dgv_36109003.DataSource = anto
End Sub
Private Sub dgv_36109003_Cellendedit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv_36109003.CellEndEdit
If dgv_36109003.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
dgv_36109003.CurrentRow.Cells("NAMABARANG").Value = ""
dgv_36109003.CurrentRow.Cells("UNIT").Value = 0
dgv_36109003.CurrentRow.Cells("HARGA").Value = 0
dgv_36109003.CurrentRow.Cells("JUMLAH").Value = 0
arman.AturPencarianDataBase("barang", "kodebarang", dgv_36109003.CurrentRow.Cells("KODEBARANG").Value, 1, ndut)
If arman.JumlanBaris > 0 Then
dgv_36109003.CurrentRow.Cells("NAMABARANG").Value = arman.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dgv_36109003.CurrentRow.Cells("NAMABARANG").Value = ""
If form38_39_40_36109003.ShowDialog = Windows.Forms.DialogResult.OK Then
dgv_36109003.CurrentRow.Cells("KODEBARANG").Value = form38_39_40_36109003.dgv_36109003.CurrentRow.Cells("KODEBARANG").Value
dgv_36109003.CurrentRow.Cells("NAMABARANG").Value = form38_39_40_36109003.dgv_36109003.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf dgv_36109003.Columns(e.ColumnIndex).Name = "UNIT" Or dgv_36109003.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv_36109003.CurrentRow.Cells("JUMLAH").Value = dgv_36109003.CurrentRow.Cells("UNIT").Value * dgv_36109003.CurrentRow.Cells("HARGA").Value
anra3()
End If
End Sub
Private Sub simpan_36109003_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_36109003.Click
If kode_36109003.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
End Class
ridhayanti saleh
BalasHapus36109015
http://ridhacayoo-ridhaahmad.blogspot.com/2011/12/tugas-40.html
Ismi Febriani A
BalasHapus3a D3
361 09 005
http://ismifebriani.blogspot.com/2011/12/apkom-4-latihan-40a-dan-40b.html
Amelia Indahsari
BalasHapus361 09 023
http://heiamee.blogspot.com/2011/12/form-40.html
Public Class Form40A_36109001
BalasHapusDim imps 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 ds As New DataSet
Dim bs1 As New BindingSource
Dim bs2 As New BindingSource
Public Sub apreal1()
Dim a As New OleDb.OleDbDataAdapter
dt2.Rows.Clear()
dt1.Rows.Clear()
a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", imps)
a.Fill(dt1)
a = New OleDb.OleDbDataAdapter("select detailtransaksi.notrans, barang.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, detailtransaksi.unit*harga as jumlah from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang", imps)
a.Fill(dt2)
End Sub
Private Sub Form40A_36109001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
apreal1()
ds.Tables.Add(dt1)
ds.Tables.Add(dt2)
dt1.TableName = "aprl"
dt2.TableName = "aprl2"
ds.Relations.Add(New DataRelation("a", ds.Tables("aprl").Columns("notrans"), ds.Tables("aprl2").Columns("notrans")))
bs1.DataSource = ds
bs1.DataMember = "aprl"
bs2.DataSource = bs1
bs2.DataMember = "a"
Dim dc(1) As DataColumn
dc(0) = dt1.Columns("notrans")
dt1.PrimaryKey = dc
dgv1_36109001.DataSource = bs1
dgv2_36109001.DataSource = bs2
End Sub
Private Sub btn1_36109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1_36109001.Click
Dim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv1_36109001.CurrentRow.Cells("notrans").Value & "'", imps)
imps.Open()
cm.ExecuteNonQuery()
imps.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv1_36109001.CurrentRow.Cells("notrans").Value & "'", imps)
imps.Open()
cm.ExecuteNonQuery()
imps.Close()
cm.Dispose()
apreal1()
End Sub
Private Sub btn2_36109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2_36109001.Click
If Form40B_36109001.Visible = False Then
Form40B_36109001.Show()
Else
Form40B_36109001.Activate()
End If
Form40B_36109001.not_36109001.Text = ""
Form40B_36109001.jt_36109001.Text = ""
Form40B_36109001.btn_36109001.Text = ""
Form40B_36109001.apreal2()
Form40B_36109001.apreal3()
End Sub
Private Sub btn3_36109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3_36109001.Click
If Form40B_36109001.Visible = False Then
Form40B_36109001.Show()
Else
Form40B_36109001.Activate()
End If
Form40B_36109001.not_36109001 = dgv1_36109001.CurrentRow.Cells("notrans").Value
Form40B_36109001.tgl_36109001 = dgv1_36109001.CurrentRow.Cells("tanggaltransaksi").Value
Form40B_36109001.jt_36109001 = dgv1_36109001.CurrentRow.Cells("jenistransaksi").Value
Form40B_36109001.btn_36109001 = dgv1_36109001.CurrentRow.Cells("notrans").Value
Form40B_36109001.apreal2()
Form40B_36109001.apreal3()
End Sub
End Class
iwan
BalasHapus361 09 026
3A-D3
Latihan 40
http://iwandinejad.blogspot.com/2012/01/latihan-383940-apkom4.html
Muhammad Harun hamid
BalasHapus361 09 006
http://h4r0en.blogspot.com/2012/01/script-visual-basic-apkomp-4-pnup_11.html
NURFAHNY
BalasHapus361 09 013
http://fanykecil.blogspot.com/2012/01/latihan-40.html
Public Class Form40B_36109001
BalasHapusDim imps As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/dataMajemuk.accdb")
Dim dt As New DataTable
Dim apreal As New ByIskandar.CariKeDataBaseByIskandar
Dim rr As New OleDb.OleDbCommand
Public Sub apreal2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & not_36109001.Text & "'", imps)
dt.Rows.Clear()
a.Fill(dt)
End Sub
Public Sub apreal3()
Dim total As Integer = 0
For Each x As DataRow In dt.Rows
total += x("Jumlah")
Next
tot_36109001.Text = total
End Sub
Private Sub apreal4()
If not_36109001.Text.Length = 0 Then
MsgBox("Isi itu Notransnya..")
Exit Sub
End If
If jt_36109001.Text.Length = 0 Then
MsgBox("Isi itu Jenis Transaksinya..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Isi itu datatable k..")
Exit Sub
End If
End Sub
Private Sub tambah()
apreal4()
apreal.AturPencarianDataBase("mastertransaksi", "notrans", not_36109001.Text, 1, imps)
If apreal.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
rr = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & not_36109001.Text & "',#" & tgl_36109001.Value.Month & "/" & tgl_36109001.Value.Day & "/" & tgl_36109001.Value.Year & "#, '" & jt_36109001.Text & "')", imps)
imps.Open()
rr.ExecuteNonQuery()
imps.Close()
For Each x As DataRow In dt.Rows
rr = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & not_36109001.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", imps)
imps.Open()
rr.ExecuteNonQuery()
imps.Close()
Next
rr.Dispose()
not_36109001.Text = ""
jt_36109001.Text = ""
tot_36109001.Text = ""
ts_36109001.Text = "-"
dt.Rows.Clear()
Form40A_36109001.apreal1()
End Sub
Public Sub edit()
BalasHapusapreal4()
If not_36109001.Text <> ts_36109001.Text Then
apreal.AturPencarianDataBase("mastertransaksi", "notrans", not_36109001.Text, 1, imps)
If apreal.JumlanBaris > 0 Then
MsgBox("Adami Notrans seperti itu,,mohon ganti..")
Exit Sub
End If
End If
rr = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ts_36109001.Text & "'", imps)
imps.Open()
rr.ExecuteNonQuery()
imps.Close()
rr = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & not_36109001.Text & "',#" & tgl_36109001.Value.Month & "/" & tgl_36109001.Value.Day & "/" & tgl_36109001.Value.Year & "#, '" & jt_36109001.Text & "')", imps)
imps.Open()
rr.ExecuteNonQuery()
imps.Close()
rr = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ts_36109001.Text & "'", imps)
imps.Open()
rr.ExecuteNonQuery()
imps.Close()
For Each x As DataRow In dt.Rows
rr = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & not_36109001.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", imps)
imps.Open()
rr.ExecuteNonQuery()
imps.Close()
Next
rr.Dispose()
not_36109001.Text = ""
jt_36109001.Text = ""
tot_36109001.Text = ""
ts_36109001.Text = "-"
dt.Rows.Clear()
Form40A_36109001.apreal1()
End Sub
Private Sub Form40B_36109001_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
apreal2()
Dim dc(1) As DataColumn
dc(0) = dt.Columns("kodebarang")
dt.PrimaryKey = dc
dt.Columns("unit").DefaultValue = 0
dt.Columns("harga").DefaultValue = 0
dt.Columns("jumlah").DefaultValue = 0
dgv_36109001.DataSource = dt
End Sub
Private Sub dgv_36109001_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv_36109001.CellEndEdit
BalasHapusIf dgv_36109001.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
'If dgv_36109001.CurrentRow.Cells(0) = "KODEBARANG" Then (rumus lain)
'untuk mencari nama barang
dgv_36109001.CurrentRow.Cells("NAMABARANG").Value = ""
dgv_36109001.CurrentRow.Cells("UNIT").Value = 0
dgv_36109001.CurrentRow.Cells("HARGA").Value = 0
dgv_36109001.CurrentRow.Cells("JUMLAH").Value = 0
apreal.AturPencarianDataBase("barang", "kodebarang", dgv_36109001.CurrentRow.Cells("KODEBARANG").Value, 1, imps)
If apreal.JumlanBaris > 0 Then '(menampilkan nama barang jika kolom kode barang ditemukan oleh proses di atas
dgv_36109001.CurrentRow.Cells("NAMABARANG").Value = apreal.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dgv_36109001.CurrentRow.Cells("NAMABARANG").Value = ""
If Form38_39_40_36109001.ShowDialog = Windows.Forms.DialogResult.OK Then
dgv_36109001.CurrentRow.Cells("KODEBARANG").Value = Form38_39_40_36109001.dgv_36109001.CurrentRow.Cells("KODEBARANG").Value
dgv_36109001.CurrentRow.Cells("NAMABARANG").Value = Form38_39_40_36109001.dgv_36109001.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf dgv_36109001.Columns(e.ColumnIndex).Name = "UNIT" Or dgv_36109001.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv_36109001.CurrentRow.Cells("JUMLAH").Value = dgv_36109001.CurrentRow.Cells("UNIT").Value * dgv_36109001.CurrentRow.Cells("HARGA").Value
apreal3()
End If
End Sub
Private Sub btn_36109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_36109001.Click
If ts_36109001.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub dgv_36109001_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgv_36109001.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class