Public Class Form38_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 Form38_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)
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 sj()
Dim sj1 As Integer = 0
For Each sj2 As DataRow In dt.Rows
sj1 += sj2("JUMLAH")
Next
jj36109023.Text = sj1
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 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
Private Sub dd_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 seperti itu tidak ada..")
If Form38_39_40_36109023.ShowDialog = Windows.Forms.DialogResult.OK Then
dd36109023.Text = Form38_39_40_36109023.dgv36109023.CurrentRow.Cells("kodebarang").Value
ee36109023.Text = Form38_39_40_36109023.dgv36109023.CurrentRow.Cells("namabarang").Value
Else
dd36109023.Text = ""
End If
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") = ff36109023.Text
dr("HARGA") = gg36109023.Text
dr("JUMLAH") = 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
sj()
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 itu No Transaksi na..")
Exit Sub
End If
If cc36109023.Text.Length = 0 Then
MsgBox("Isi rong itu Jenis Transaksi na..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("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 Transaksi 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()
sj()
End Sub
End Class
Minggu, 04 Desember 2011
Form 38
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar