Public Class Form39_36109023
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim ame As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Private Sub Form39_36109023_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ame.Columns.Add(New DataColumn("KODEBARANG", GetType(String)))
ame.Columns.Add(New DataColumn("NAMABARANG", GetType(String)))
ame.Columns.Add(New DataColumn("UNIT", GetType(Double)))
ame.Columns.Add(New DataColumn("HARGA", GetType(Integer)))
ame.Columns.Add(New DataColumn("JUMLAH", GetType(Double)))
dgv36109023.DataSource = ame
Dim dcp(1) As DataColumn
dcp(0) = ame.Columns("KODEBARANG")
ame.PrimaryKey = dcp
ame.Columns("UNIT").DefaultValue = 0
ame.Columns("HARGA").DefaultValue = 0
ame.Columns("JUMLAH").DefaultValue = 0
End Sub
Private Sub hitung()
Dim pororo As Integer
For Each r As DataGridViewRow In dgv36109023.Rows
pororo = pororo + r.Cells("JUMLAH").Value
Next
dd36109023.Text = pororo
End Sub
Private Sub dgv36109023_CellEndEdit(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv36109023.CellEndEdit
If e.ColumnIndex = 0 Then
cari.AturPencarianDataBase("BARANG", "kodebarang", dgv36109023.CurrentRow.Cells("kodebarang").Value, 1, CONECT)
If cari.JumlanBaris > 0 Then
dgv36109023.CurrentRow.Cells("KODEBARANG").Value = cari.DataTablenya.Rows(0).Item("KODEBARANG")
dgv36109023.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NamaBarang")
Else
MsgBox("kode barang tidak tersedia")
If Form38_39_40_36109023.ShowDialog = Windows.Forms.DialogResult.OK Then
dgv36109023.CurrentRow.Cells("KODEBARANG").Value = Form38_39_40_36109023.dgv36109023.CurrentRow.Cells("KodeBarang").Value
dgv36109023.CurrentRow.Cells("NAMABARANG").Value = Form38_39_40_36109023.dgv36109023.CurrentRow.Cells("namabarang").Value
dgv36109023.CurrentRow.Cells("HARGA").Value = Form38_39_40_36109023.dgv36109023.CurrentRow.Cells("HARGAJUAL").Value
Else
dgv36109023.CurrentRow.Cells("KODEBARANG").Value = ""
dgv36109023.CurrentRow.Cells("NAMABARANG").Value = ""
End If
End If
End If
If e.ColumnIndex = 2 Or e.ColumnIndex = 3 Then
dgv36109023.CurrentRow.Cells("JUMLAH").Value = dgv36109023.CurrentRow.Cells("UNIT").Value * dgv36109023.CurrentRow.Cells("HARGA").Value
End If
hitung()
End Sub
Private Sub d36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles d36109023.Click
If aa36109023.Text.Length = 0 Then
MsgBox("no transaksi belum terisi")
Exit Sub
End If
If cc36109023.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
If ame.Rows.Count = 0 Then
MsgBox("data tidak tersedia")
End If
cari.AturPencarianDataBase("mastertransaksi", "notrans", aa36109023.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("kode sudah ada")
Exit Sub
End If
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & aa36109023.Text & "',#" & bb36109023.Value.Date & "#," & Val(cc36109023.Text) & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
For Each r As DataRow In ame.Rows
com = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga ) values ('" & aa36109023.Text & "','" & r("kodebarang") & "'," & r("unit") & "," & r("harga") & ")", CONECT)
CONECT.Open()
com.ExecuteNonQuery()
CONECT.Close()
com.Dispose()
Next
aa36109023.Text = ""
cc36109023.Text = ""
dd36109023.Text = ""
ame.Rows.Clear()
hitung()
End Sub
End Class
Sabtu, 10 Desember 2011
Form 39
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar