Public Class Form37
Dim cimi As New DataTable
Dim ismi As New OleDb.OleDbCommand
Dim sri As New ByIskandar.CariKeDataBaseByIskandar
Dim conect As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\datamajemuk.accdb;Jet OLEDB:Database Password=cimi")
Private Sub Form37_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ismisriwahyuni As New OleDb.OleDbDataAdapter
ismisriwahyuni = 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 ='" & NT46109023.Text & "'", conect)
cimi.Rows.Clear()
ismisriwahyuni.Fill(cimi)
ismisriwahyuni.Dispose()
Dim dpc(1) As DataColumn
dpc(0) = cimi.Columns("kodebarang")
cimi.PrimaryKey = dpc
DATA46109023.DataSource = cimi
End Sub
Private Sub cim()
Dim cimi1 As Integer = 0
For Each cimi2 As DataRow In cimi.Rows
cimi1 += cimi2("JUMLAH")
Next
TOT46109023.Text = cimi1
End Sub
Private Sub UN46109023_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UN46109023.TextChanged, HR46109023.TextChanged
JM46109023.Text = Val(UN46109023.Text) * Val(HR46109023.Text)
End Sub
Private Sub KB46109023_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles KB46109023.Leave
If KB46109023.Text.Length = 0 Then
Exit Sub
End If
sri.AturPencarianDataBase("barang", "kodebarang", KB46109023.Text, 1, conect)
If sri.JumlanBaris > 0 Then
KB46109023.Text = sri.DataTablenya.Rows(0).Item("KODEBARANG")
NB46109023.Text = sri.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang itu tidak ada..")
Exit Sub
End If
End Sub
Private Sub KB46109001_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KB46109023.TextChanged
NB46109023.Text = ""
UN46109023.Text = ""
HR46109023.Text = ""
End Sub
Private Sub TM46109001_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TM46109023.Click
If KB46109023.Text.Length = 0 Then
MsgBox("Isi Kode Barang")
Exit Sub
End If
If Val(UN46109023.Text) = 0 Then
MsgBox("Isi Unit Barang")
Exit Sub
End If
If Val(HR46109023.Text) = 0 Then
MsgBox("Isi Harga Barang")
Exit Sub
End If
Dim cimcim As DataRow
cimcim = cimi.Rows.Find(KB46109023.Text)
If cimcim Is Nothing Then
cimcim = cimi.NewRow
cimcim("KODEBARANG") = KB46109023.Text
cimcim("NAMABARANG") = NB46109023.Text
cimcim("UNIT") = Val(UN46109023.Text)
cimcim("HARGA") = Val(HR46109023.Text)
cimcim("JUMLAH") = Val(JM46109023.Text)
cimi.Rows.Add(cimcim)
KB46109023.Text = ""
UN46109023.Text = ""
HR46109023.Text = ""
Else
MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain...")
End If
cim()
End Sub
Private Sub S46109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S46109023.Click
If NT46109023.Text.Length = 0 Then
MsgBox("Isi No Transaksi")
Exit Sub
End If
If JT46109023.Text.Length = 0 Then
MsgBox("isi Jenis Transaksi")
Exit Sub
End If
If cimi.Rows.Count = 0 Then
MsgBox("Isi datatable")
Exit Sub
End If
sri.AturPencarianDataBase("mastertransaksi", "notrans", NT46109023.Text, 1, conect)
If sri.JumlanBaris > 0 Then
MsgBox("No Trans sudah ada")
Exit Sub
End If
ismi = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT46109023.Text & "',#" & T46109023.Value.Month & "/" & T46109023.Value.Day & "/" & T46109023.Value.Year & "#,'" & JT46109023.Text & "')", conect)
conect.Open()
ismi.ExecuteNonQuery()
conect.Close()
For Each x As DataRow In cimi.Rows
ismi = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & NT46109023.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", conect)
conect.Open()
ismi.ExecuteNonQuery()
conect.Close()
Next
ismi.Dispose()
NT46109023.Text = ""
JT46109023.Text = ""
cimi.Rows.Clear()
cim()
End Sub
End Class
Tidak ada komentar:
Posting Komentar