Public Class Form37_36109023
Dim dt As New DataTable
Dim cm As New OleDb.OleDbCommand
Dim amelia As New ByIskandar.CariKeDataBaseByIskandar
Dim ame As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/Datamajemuk.ACCDB")
Private Sub Form37_36109023_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim a As New OleDb.OleDbDataAdapter
a = 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 ='" & aa36109023.Text & "'", ame)
dt.Rows.Clear()
a.Fill(dt)
a.Dispose()
Dim dc(1) As DataColumn
dc(0) = dt.Columns("kodebarang")
dt.PrimaryKey = dc
dgv36109023.DataSource = dt
End Sub
Private Sub pororo()
Dim pororo As Integer = 0
For Each pororo2 As DataRow In dt.Rows
pororo += pororo2("JUMLAH")
Next
jj36109023.Text = pororo
End Sub
Private Sub ff36109023_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ff36109023.TextChanged
hh36109023.Text = Val(ff36109023.Text) * Val(gg36109023.Text)
End Sub
Private Sub dd36109023_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles dd36109023.Leave
If dd36109023.Text.Length = 0 Then
Exit Sub
End If
amelia.AturPencarianDataBase("barang", "kodebarang", dd36109023.Text, 1, ame)
If amelia.JumlanBaris > 0 Then
dd36109023.Text = amelia.DataTablenya.Rows(0).Item("KODEBARANG")
ee36109023.Text = amelia.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang itu tidak ada..")
Exit Sub
End If
End Sub
Private Sub dd36109023_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dd36109023.TextChanged
ee36109023.Text = ""
ff36109023.Text = ""
gg36109023.Text = ""
End Sub
Private Sub ii36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ii36109023.Click
If dd36109023.Text.Length = 0 Then
MsgBox("Isi rong itu Kode Barang na..")
Exit Sub
End If
If Val(ff36109023.Text) = 0 Then
MsgBox("Isi rong itu Unit na..")
Exit Sub
End If
If Val(gg36109023.Text) = 0 Then
MsgBox("Isi rong itu Harga na..")
Exit Sub
End If
Dim dr As DataRow
dr = dt.Rows.Find(dd36109023.Text)
If dr Is Nothing Then
dr = dt.NewRow
dr("KODEBARANG") = dd36109023.Text
dr("NAMABARANG") = ee36109023.Text
dr("UNIT") = Val(ff36109023.Text)
dr("HARGA") = Val(gg36109023.Text)
dr("JUMLAH") = Val(hh36109023.Text)
dt.Rows.Add(dr)
dd36109023.Text = ""
ff36109023.Text = ""
gg36109023.Text = ""
Else
MsgBox("Kode barang itu sudah ada, mohon ganti dengan kode barang yang lain...")
End If
pororo()
End Sub
Private Sub kk36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kk36109023.Click
If aa36109023.Text.Length = 0 Then
MsgBox("Isi rong No Transaksi na..")
Exit Sub
End If
If cc36109023.Text.Length = 0 Then
MsgBox("isi rong Jenis Transaksi na..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Maaf..Isi rong itu datatable na..")
Exit Sub
End If
amelia.AturPencarianDataBase("mastertransaksi", "notrans", aa36109023.Text, 1, ame)
If amelia.JumlanBaris > 0 Then
MsgBox("Adami no trans seperti itu...")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & aa36109023.Text & "',#" & bb36109023.Value.Month & "/" & bb36109023.Value.Day & "/" & bb36109023.Value.Year & "#,'" & cc36109023.Text & "')", ame)
ame.Open()
cm.ExecuteNonQuery()
ame.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & aa36109023.Text & "','" & x("kodebarang") & "','" & x("unit") & "','" & x("harga") & "')", ame)
ame.Open()
cm.ExecuteNonQuery()
ame.Close()
Next
cm.Dispose()
aa36109023.Text = ""
cc36109023.Text = ""
dt.Rows.Clear()
pororo()
End Sub
Private Sub gg36109023_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gg36109023.TextChanged
hh36109023.Text = Val(ff36109023.Text) * Val(gg36109023.Text)
End Sub
Private Sub hh36109023_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hh36109023.TextChanged
hh36109023.Text = Val(ff36109023.Text) * Val(gg36109023.Text)
End Sub
End Class
Minggu, 04 Desember 2011
Form 37
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar