Public Class Form40a068
Dim A As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
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 winny()
'Membersihkan detailtransaksi lalu mastertransaksi'
dt1.Rows.Clear()
dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter
B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", A)
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", A)
B1.Fill(dt1)
B1.Dispose()
End Sub
Private Sub Form40a068_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
winny()
'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'
DGV40A1.DataSource = Bsource1
DGV40A2.DataSource = Bsource2
End Sub
Private Sub Hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus.Click
Dim CM As New OleDb.OleDbCommand
CM = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DGV40A1.CurrentRow.Cells("NOTRANS").Value & "'", A)
A.Open()
CM.ExecuteNonQuery()
A.Close()
CM = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DGV40A1.CurrentRow.Cells("NOTRANS").Value & "'", A)
A.Open()
CM.ExecuteNonQuery()
A.Close()
CM.Dispose()
winny()
End Sub
Private Sub Edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Edit.Click
If Form40b068.Visible = False Then
Form40b068.Show()
Else
Form40b068.Activate()
End If
Form40b068.NO1.Text = DGV40A1.CurrentRow.Cells("NOTRANS").Value
Form40b068.nt068.Text = DGV40A1.CurrentRow.Cells("NOTRANS").Value
Form40b068.jt068.Text = DGV40A1.CurrentRow.Cells("JENISTRANSAKSI").Value
Form40b068.asni()
Form40b068.TOTALJUMLAH()
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tambah.Click
If Form40b068.Visible = False Then
Form40b068.Show()
Else
Form40b068.Activate()
End If
Form40b068.NO1.Text = "-"
Form40b068.nt068.Text = ""
Form40b068.jt068.Text = ""
Form40b068.asni()
Form40b068.TOTALJUMLAH()
End Sub
End Class
Tidak ada komentar:
Posting Komentar