Public Class Form39
Dim ismi As New DataTable
Dim sri As New OleDb.OleDbCommand
Dim cimi 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 Form39_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)
ismisriwahyuni.Fill(ismi)
ismisriwahyuni.Dispose()
Dim dpc(1) As DataColumn
dpc(0) = ismi.Columns("kodebarang")
ismi.PrimaryKey = dpc
DATA46109023.DataSource = ismi
End Sub
Private Sub DATA46109023_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DATA46109023.CellEndEdit
If DATA46109023.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DATA46109023.CurrentRow.Cells("NAMABARANG").Value = ""
DATA46109023.CurrentRow.Cells("UNIT").Value = 0
DATA46109023.CurrentRow.Cells("HARGA").Value = 0
DATA46109023.CurrentRow.Cells("JUMLAH").Value = 0
cimi.AturPencarianDataBase("barang", "kodebarang", DATA46109023.CurrentRow.Cells("KODEBARANG").Value, 1, conect)
If cimi.JumlanBaris > 0 Then
DATA46109023.CurrentRow.Cells("NAMABARANG").Value = cimi.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DATA46109023.CurrentRow.Cells("NAMABARANG").Value = ""
If Form383940_46109023.ShowDialog = Windows.Forms.DialogResult.OK Then
DATA46109023.CurrentRow.Cells("KODEBARANG").Value = Form383940_46109023.DATA46109023.CurrentRow.Cells("KODEBARANG").Value
DATA46109023.CurrentRow.Cells("NAMABARANG").Value = Form383940_46109023.DATA46109023.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DATA46109023.Columns(e.ColumnIndex).Name = "UNIT" Or DATA46109023.Columns(e.ColumnIndex).Name = "HARGA" Then
DATA46109023.CurrentRow.Cells("JUMLAH").Value = DATA46109023.CurrentRow.Cells("UNIT").Value * DATA46109023.CurrentRow.Cells("HARGA").Value
cim()
End If
End Sub
Private Sub cim()
Dim cim1 As Integer = 0
For Each cim2 As DataRow In ismi.Rows
cim1 += cim2("JUMLAH")
Next
TOT46109023.Text = cim1
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 Transaksinya")
Exit Sub
End If
If JT46109023.Text.Length = 0 Then
MsgBox("Isi Jenis Transaksinya")
Exit Sub
End If
If ismi.Rows.Count = 0 Then
MsgBox("Isi datatable")
Exit Sub
End If
cimi.AturPencarianDataBase("mastertransaksi", "notrans", NT46109023.Text, 1, conect)
If cimi.JumlanBaris > 0 Then
MsgBox("notrans sudah ada")
Exit Sub
End If
sri = 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()
sri.ExecuteNonQuery()
conect.Close()
For Each x As DataRow In ismi.Rows
sri = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & NT46109023.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", conect)
conect.Open()
sri.ExecuteNonQuery()
conect.Close()
Next
sri.Dispose()
NT46109023.Text = ""
JT46109023.Text = ""
TOT46109023.Text = ""
ismi.Rows.Clear()
cim()
End Sub
End Class
Tidak ada komentar:
Posting Komentar