Public Class Form36_36109023
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=25")
Dim DT As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim com As New OleDb.OleDbCommand
Private Sub tambah36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah36109023.Click
If kode36109023.Text.Length = 0 Then
MsgBox("kode barang belum terisi")
Exit Sub
End If
If Val(unit36109023.Text) = 0 Then
MsgBox("UNIT belum terisi")
Exit Sub
End If
If Val(harga36109023.Text) = 0 Then
MsgBox("HARGA belum terisi")
Exit Sub
End If
Dim drzany As DataRow
drzany = DT.NewRow
drzany("KODEBARANG") = kode36109023.Text
drzany("UNIT") = unit36109023.Text
drzany("HARGA") = harga36109023.Text
DT.Rows.Add(drzany)
kode36109023.Text = ""
unit36109023.Text = ""
harga36109023.Text = ""
End Sub
Private Sub Form36_36109023_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ame As New OleDb.OleDbDataAdapter
ame = New OleDb.OleDbDataAdapter("select KODEBARANG, UNIT, HARGA FROM DETAILTRANSAKSI WHERE NOTRANS= '" & kode36109023.Text & "'", CONECT)
DT.Rows.Clear()
ame.Fill(DT)
dgv36109023.DataSource = DT
ame.Dispose()
Dim pororo(1) As DataColumn
pororo(0) = DT.Columns("kodebarang")
DT.PrimaryKey = pororo
End Sub
Private Sub simpan361099023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan361099023.Click
If no36109023.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If jenis36109023.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", no36109023.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("NO.TRANS sudah ada")
Exit Sub
End If
If DT.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & no36109023.Text & "',#" & tgl36109023.Value.Month & "/" & tgl36109023.Value.Day & "/" & tgl36109023.Value.Year & "#, '" & jenis36109023.Text & "')", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In DT.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & no36109023.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
DT.Rows.Clear()
no36109023.Text = ""
jenis36109023.Text = ""
End Sub
End Class
Minggu, 04 Desember 2011
Form 36
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar