Public Class Form39_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'")
Private Sub Form39_36109003_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim r As New OleDb.OleDbDataAdapter r = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, detailtransaksi.UNIT, detailtransaksi.HARGA, detailtransaksi.unit*harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans ='" & nt_36109003.Text & "'", ndut) anto.Rows.Clear() r.Fill(anto) r.Dispose()
dgv_36109003.DataSource = anto
Dim sudar(1) As DataColumn sudar(0) = anto.Columns("kodebarang") anto.PrimaryKey = sudar 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
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 anra() End If End Sub
Private Sub anra() Dim anra1 As Integer = 0 For Each anra2 As DataRow In anto.Rows anra1 += anra2("JUMLAH") Next total_36109003.Text = anra1 End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click If nt_36109003.Text.Length = 0 Then MsgBox("nomor transaksi harus terisi") ElseIf jt_36109003.Text.Length = 0 Then MsgBox("Isi rong Jenis Transaksi na..") ElseIf anto.Rows.Count = 0 Then MsgBox("data table tidak boleh kosong") Exit Sub End If
arman.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109003.Text, 1, ndut) If arman.JumlanBaris > 0 Then MsgBox("nomor transaksi telah ada") 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()
Amelia Indahsari
BalasHapus361 09 023
http://heiamee.blogspot.com/2011/12/form-39.html
RUSNANINGSI R
BalasHapus36109010
http://rusnaningsi.blogspot.com/2011/12/latihan-39-apkom-4.html
Ismi Febriani A
BalasHapus3a D3
361 09 005
http://ismifebriani.blogspot.com/2011/12/apkom-4-latihan-39.html
ridhayanti saleh
BalasHapus36109015
http://ridhacayoo-ridhaahmad.blogspot.com/2011/12/tugas-39.html
Public Class Form39_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'")
Private Sub Form39_36109003_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim r As New OleDb.OleDbDataAdapter
r = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, detailtransaksi.UNIT, detailtransaksi.HARGA, detailtransaksi.unit*harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans ='" & nt_36109003.Text & "'", ndut)
anto.Rows.Clear()
r.Fill(anto)
r.Dispose()
dgv_36109003.DataSource = anto
Dim sudar(1) As DataColumn
sudar(0) = anto.Columns("kodebarang")
anto.PrimaryKey = sudar
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
anra()
End If
End Sub
Private Sub anra()
BalasHapusDim anra1 As Integer = 0
For Each anra2 As DataRow In anto.Rows
anra1 += anra2("JUMLAH")
Next
total_36109003.Text = anra1
End Sub
Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
If nt_36109003.Text.Length = 0 Then
MsgBox("nomor transaksi harus terisi")
ElseIf jt_36109003.Text.Length = 0 Then
MsgBox("Isi rong Jenis Transaksi na..")
ElseIf anto.Rows.Count = 0 Then
MsgBox("data table tidak boleh kosong")
Exit Sub
End If
arman.AturPencarianDataBase("mastertransaksi", "notrans", nt_36109003.Text, 1, ndut)
If arman.JumlanBaris > 0 Then
MsgBox("nomor transaksi telah ada")
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 & "#,'" & jt_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 = ""
anto.Rows.Clear()
anra()
End Sub
End Class
iwan
BalasHapus361 09 026
3A-D3
latihan 39 apkom4
http://iwandinejad.blogspot.com/#!/2012/01/latihan-39-apkom-4.html
Muhammad Harun Hamid
BalasHapus361 09 006
http://h4r0en.blogspot.com/2012/01/script-visual-basic-apkomp-4-pnup_2604.html
http://aminurul.blogspot.com/2012/01/apkom4-form-35-40b.html
BalasHapusNURFAHNY
BalasHapus361 09 013
http://fanykecil.blogspot.com/2012/01/latihan39.html