Public Class Form40B
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim DATA As New DataTable
Public Sub catherine()
Dim X As New OleDb.OleDbDataAdapter
X = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & a.Text & "'", I)
DATA.Rows.Clear()
X.Fill(DATA)
End Sub
Private Sub Form40B_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = DATA.Columns("NOTRANS")
DATA.PrimaryKey = dataPrimary
DataGridView1.DataSource = DATA
TOTALJUMLAH()
End Sub
Public Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In DATA.Rows
TOT = TOT + x("JUMLAH")
Next
d.Text = TOT
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("BARANG", "KODEBARANG", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, I)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = ""
If Form383940.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = Form383940.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = Form383940.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
End If
TOTALJUMLAH()
End Sub
Private Sub SIMPAN_TAMBAH()
If a.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
Exit Sub
End If
If DATA.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
Exit Sub
End If
If NO1.Text <> a.Text Then
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
For Each X As DataRow In DATA.Rows
CC = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
Next
NO1.Text = "-"
a.Text = ""
c.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Form40a.cate()
End Sub
Private Sub Simpan_Edit()
If a.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If b.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
Exit Sub
End If
If DATA.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
Exit Sub
End If
If NO1.Text <> a.Text Then
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & a.Text & "'", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & a.Text & "'", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
For Each XX As DataRow In DATA.Rows
CC = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
Next
NO1.Text = "-"
a.Text = ""
c.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Form40a.cate()
End Sub
Private Sub ee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
If NO1.Text = "-" Then
SIMPAN_TAMBAH()
Else
Simpan_Edit()
End If
End Sub
End Class
putri duyung
Selasa, 06 Desember 2011
Latihan 40a
Public Class Form40a
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Dim CI1 As New DataTable
Dim dset As New DataSet
Dim Bsource1 As New BindingSource
Dim Bsource2 As New BindingSource
Public Sub cate()
CI1.Rows.Clear()
CI1.Rows.Clear()
Dim Kate As New OleDb.OleDbDataAdapter
Kate = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", I)
Kate.Fill(CI)
Kate = New OleDb.OleDbDataAdapter("Select DETAILTRANSAKSI.NOTRANS, DETAILTRANSAKSI.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG", I)
Kate.Fill(CI1)
Kate.Dispose()
End Sub
Private Sub Form40a_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cate()
dset.Tables.Add(CI)
dset.Tables.Add(CI1)
CI.TableName = "T01"
CI1.TableName = "T02"
dset.Relations.Add(New DataRelation("X", dset.Tables("T01").Columns("NOTRANS"), dset.Tables("T02").Columns("NOTRANS")))
Bsource1.DataSource = dset
Bsource1.DataMember = "T01"
Bsource2.DataSource = Bsource1
Bsource2.DataMember = "X"
DataGridView1.DataSource = Bsource1
DataGridView2.DataSource = Bsource2
End Sub
Private Sub Hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus.Click
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
cate()
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tambah.Click
If Form40B.Visible = False Then
Form40B.Show()
Else
Form40B.Activate()
End If
Form40B.NO1.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
Form40B.a.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
Form40B.c.Text = DataGridView1.CurrentRow.Cells("JENISTRANSAKSI").Value
Form40B.catherine()
Form40B.TOTALJUMLAH()
End Sub
Private Sub Edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Edit.Click
If Form40B.Visible = False Then
Form40B.Show()
Else
Form40B.Activate()
End If
Form40B.NO1.Text = "-"
Form40B.a.Text = ""
Form40B.c.Text = ""
Form40B.catherine()
Form40B.TOTALJUMLAH()
End Sub
End Class
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Dim CI1 As New DataTable
Dim dset As New DataSet
Dim Bsource1 As New BindingSource
Dim Bsource2 As New BindingSource
Public Sub cate()
CI1.Rows.Clear()
CI1.Rows.Clear()
Dim Kate As New OleDb.OleDbDataAdapter
Kate = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", I)
Kate.Fill(CI)
Kate = New OleDb.OleDbDataAdapter("Select DETAILTRANSAKSI.NOTRANS, DETAILTRANSAKSI.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH FROM DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG", I)
Kate.Fill(CI1)
Kate.Dispose()
End Sub
Private Sub Form40a_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cate()
dset.Tables.Add(CI)
dset.Tables.Add(CI1)
CI.TableName = "T01"
CI1.TableName = "T02"
dset.Relations.Add(New DataRelation("X", dset.Tables("T01").Columns("NOTRANS"), dset.Tables("T02").Columns("NOTRANS")))
Bsource1.DataSource = dset
Bsource1.DataMember = "T01"
Bsource2.DataSource = Bsource1
Bsource2.DataMember = "X"
DataGridView1.DataSource = Bsource1
DataGridView2.DataSource = Bsource2
End Sub
Private Sub Hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus.Click
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DataGridView1.CurrentRow.Cells("NOTRANS").Value & "'", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
cate()
End Sub
Private Sub Tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tambah.Click
If Form40B.Visible = False Then
Form40B.Show()
Else
Form40B.Activate()
End If
Form40B.NO1.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
Form40B.a.Text = DataGridView1.CurrentRow.Cells("NOTRANS").Value
Form40B.c.Text = DataGridView1.CurrentRow.Cells("JENISTRANSAKSI").Value
Form40B.catherine()
Form40B.TOTALJUMLAH()
End Sub
Private Sub Edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Edit.Click
If Form40B.Visible = False Then
Form40B.Show()
Else
Form40B.Activate()
End If
Form40B.NO1.Text = "-"
Form40B.a.Text = ""
Form40B.c.Text = ""
Form40B.catherine()
Form40B.TOTALJUMLAH()
End Sub
End Class
Minggu, 04 Desember 2011
Latihan 39
Public Class Form39
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Private Sub Form39_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & a.Text & "'", I)
Z.Fill(CI)
Z.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CI.Columns("KODEBARANG")
CI.PrimaryKey = dataPrimary
DataGridView1.DataSource = CI
End Sub
Public Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In CI.Rows
TOT = TOT + x("JUMLAH")
Next
d.Text = TOT
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("BARANG", "KODEBARANG", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, I)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = ""
If Form383940.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = Form383940.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = Form383940.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
TOTALJUMLAH()
End If
End Sub
Private Sub ee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ee.Click
If a.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If CI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
For Each X As DataRow In CI.Rows
CC = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
Next
a.Text = ""
b.Text = ""
CI.Rows.Clear()
End Sub
End Class
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Private Sub Form39_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & a.Text & "'", I)
Z.Fill(CI)
Z.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CI.Columns("KODEBARANG")
CI.PrimaryKey = dataPrimary
DataGridView1.DataSource = CI
End Sub
Public Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In CI.Rows
TOT = TOT + x("JUMLAH")
Next
d.Text = TOT
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
DataGridView1.CurrentRow.Cells("UNIT").Value = 0
DataGridView1.CurrentRow.Cells("HARGA").Value = 0
DataGridView1.CurrentRow.Cells("JUMLAH").Value = 0
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("BARANG", "KODEBARANG", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, I)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = ""
If Form383940.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = Form383940.DataGridView1.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = Form383940.DataGridView1.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DataGridView1.Columns(e.ColumnIndex).Name = "UNIT" Or DataGridView1.Columns(e.ColumnIndex).Name = "HARGA" Then
DataGridView1.CurrentRow.Cells("JUMLAH").Value = DataGridView1.CurrentRow.Cells("UNIT").Value * DataGridView1.CurrentRow.Cells("HARGA").Value
TOTALJUMLAH()
End If
End Sub
Private Sub ee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ee.Click
If a.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If CI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
For Each X As DataRow In CI.Rows
CC = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
Next
a.Text = ""
b.Text = ""
CI.Rows.Clear()
End Sub
End Class
Latihan 383940
Public Class Form383940
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Public Sub catherine()
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select * From BARANG", I)
CI.Rows.Clear()
Z.Fill(CI)
Z.Dispose()
End Sub
Private Sub Form383940_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
catherine()
DataGridView1.DataSource = CI
End Sub
End Class
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Public Sub catherine()
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select * From BARANG", I)
CI.Rows.Clear()
Z.Fill(CI)
Z.Dispose()
End Sub
Private Sub Form383940_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
catherine()
DataGridView1.DataSource = CI
End Sub
End Class
Latihan 38
Public Class Form38
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Dim CT As DataRow
Private Sub Form38_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim X As New OleDb.OleDbDataAdapter
X = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & a.Text & "'", I)
X.Fill(CI)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CI.Columns("KODEBARANG")
CI.PrimaryKey = dataPrimary
DataGridView1.DataSource = CI
End Sub
Public Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In CI.Rows
TOT = TOT + x("JUMLAH")
Next
L.Text = TOT
End Sub
Private Sub d_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles d.Leave
If d.Text.Length = 0 Then
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("BARANG", "KODEBARANG", d.Text, 1, I)
If cari.JumlanBaris > 0 Then
d.Text = cari.DataTablenya.Rows(0).Item("KODEBARANG")
J.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
If form383940.ShowDialog = Windows.Forms.DialogResult.OK Then
d.Text = Form383940.DataGridView1.CurrentRow.Cells("KodeBarang").Value
J.Text = Form383940.DataGridView1.CurrentRow.Cells("NamaBarang").Value
Else
d.Text = ""
End If
End If
End Sub
Private Sub d_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles d.TextChanged
J.Text = ""
ee.Text = ""
f.Text = ""
End Sub
Private Sub ee_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ee.TextChanged
K.Text = Val(ee.Text) * Val(f.Text)
End Sub
Private Sub g_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click
If d.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If J.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(ee.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(f.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
CT = CI.Rows.Find(d.Text)
If CT Is Nothing Then
CT = CI.NewRow
CT("KODEBARANG") = d.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
CT = CI.NewRow
CT("KODEBARANG") = d.Text
CT("NAMABARANG") = J.Text
CT("UNIT") = ee.Text
CT("HARGA") = f.Text
CT("JUMLAH") = K.Text
CI.Rows.Add(CT)
d.Text = ""
J.Text = ""
ee.Text = ""
f.Text = ""
TOTALJUMLAH()
End Sub
Private Sub h_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles h.Click
If a.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If CI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
For Each X As DataRow In CI.Rows
CC = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
Next
a.Text = ""
c.Text = ""
K.Text = ""
CI.Rows.Clear()
TOTALJUMLAH()
End Sub
End Class
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Dim CT As DataRow
Private Sub Form38_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim X As New OleDb.OleDbDataAdapter
X = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & a.Text & "'", I)
X.Fill(CI)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CI.Columns("KODEBARANG")
CI.PrimaryKey = dataPrimary
DataGridView1.DataSource = CI
End Sub
Public Sub TOTALJUMLAH()
Dim TOT As Double = 0
For Each x As DataRow In CI.Rows
TOT = TOT + x("JUMLAH")
Next
L.Text = TOT
End Sub
Private Sub d_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles d.Leave
If d.Text.Length = 0 Then
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("BARANG", "KODEBARANG", d.Text, 1, I)
If cari.JumlanBaris > 0 Then
d.Text = cari.DataTablenya.Rows(0).Item("KODEBARANG")
J.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
If form383940.ShowDialog = Windows.Forms.DialogResult.OK Then
d.Text = Form383940.DataGridView1.CurrentRow.Cells("KodeBarang").Value
J.Text = Form383940.DataGridView1.CurrentRow.Cells("NamaBarang").Value
Else
d.Text = ""
End If
End If
End Sub
Private Sub d_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles d.TextChanged
J.Text = ""
ee.Text = ""
f.Text = ""
End Sub
Private Sub ee_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ee.TextChanged
K.Text = Val(ee.Text) * Val(f.Text)
End Sub
Private Sub g_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click
If d.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If J.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(ee.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(f.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
CT = CI.Rows.Find(d.Text)
If CT Is Nothing Then
CT = CI.NewRow
CT("KODEBARANG") = d.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
CT = CI.NewRow
CT("KODEBARANG") = d.Text
CT("NAMABARANG") = J.Text
CT("UNIT") = ee.Text
CT("HARGA") = f.Text
CT("JUMLAH") = K.Text
CI.Rows.Add(CT)
d.Text = ""
J.Text = ""
ee.Text = ""
f.Text = ""
TOTALJUMLAH()
End Sub
Private Sub h_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles h.Click
If a.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If CI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
For Each X As DataRow In CI.Rows
CC = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
Next
a.Text = ""
c.Text = ""
K.Text = ""
CI.Rows.Clear()
TOTALJUMLAH()
End Sub
End Class
Kamis, 01 Desember 2011
latihan 37
Public Class Form37
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Dim CT As DataRow
Private Sub Form37_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim X As New OleDb.OleDbDataAdapter
X = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & a.Text & "'", I)
X.Fill(CI)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CI.Columns("KODEBARANG")
CI.PrimaryKey = dataPrimary
DataGridView1.DataSource = CI
End Sub
Private Sub TOTALJumlah()
Dim TOT As Double = 0
For Each x As DataRow In CI.Rows
TOT = TOT + x("JUMLAH")
Next
L.Text = TOT
End Sub
Private Sub d_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles d.Leave
If d.Text.Length = 0 Then
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("BARANG", "KODEBARANG", d.Text, 1, I)
If cari.JumlanBaris > 0 Then
d.Text = cari.DataTablenya.Rows(0).Item("KODEBARANG")
J.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub d_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles d.TextChanged
J.Text = ""
ee.Text = ""
f.Text = ""
End Sub
Private Sub ee_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ee.TextChanged
K.Text = Val(ee.Text) * Val(f.Text)
End Sub
Private Sub g_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click
If d.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If J.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(ee.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(f.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
CT = CI.Rows.Find(d.Text)
If CT Is Nothing Then
CT = CI.NewRow
CT("KODEBARANG") = d.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
CT = CI.NewRow
CT("KODEBARANG") = d.Text
CT("NAMABARANG") = J.Text
CT("UNIT") = ee.Text
CT("HARGA") = f.Text
CT("JUMLAH") = K.Text
CI.Rows.Add(CT)
d.Text = ""
J.Text = ""
ee.Text = ""
f.Text = ""
TOTALJumlah()
End Sub
Private Sub h_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles h.Click
If a.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If CI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
For Each X As DataRow In CI.Rows
CC = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
Next
a.Text = ""
c.Text = ""
K.Text = ""
CI.Rows.Clear()
TOTALJumlah()
End Sub
End Class
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Dim CT As DataRow
Private Sub Form37_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim X As New OleDb.OleDbDataAdapter
X = New OleDb.OleDbDataAdapter("Select BARANG.KODEBARANG, BARANG.NAMABARANG, DETAILTRANSAKSI.UNIT, DETAILTRANSAKSI.HARGA, DETAILTRANSAKSI.UNIT*DETAILTRANSAKSI.HARGA AS JUMLAH from DETAILTRANSAKSI INNER JOIN BARANG ON DETAILTRANSAKSI.KODEBARANG=BARANG.KODEBARANG WHERE NOTRANS= '" & a.Text & "'", I)
X.Fill(CI)
X.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CI.Columns("KODEBARANG")
CI.PrimaryKey = dataPrimary
DataGridView1.DataSource = CI
End Sub
Private Sub TOTALJumlah()
Dim TOT As Double = 0
For Each x As DataRow In CI.Rows
TOT = TOT + x("JUMLAH")
Next
L.Text = TOT
End Sub
Private Sub d_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles d.Leave
If d.Text.Length = 0 Then
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("BARANG", "KODEBARANG", d.Text, 1, I)
If cari.JumlanBaris > 0 Then
d.Text = cari.DataTablenya.Rows(0).Item("KODEBARANG")
J.Text = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
MsgBox("Kode barang tersebut tidak ada")
Exit Sub
End If
End Sub
Private Sub d_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles d.TextChanged
J.Text = ""
ee.Text = ""
f.Text = ""
End Sub
Private Sub ee_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ee.TextChanged
K.Text = Val(ee.Text) * Val(f.Text)
End Sub
Private Sub g_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click
If d.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If J.Text.Length = 0 Then
MsgBox("Nama barang sudah ada")
End If
If Val(ee.Text) = 0 Then
MsgBox("Masukkan unit barang")
Exit Sub
End If
If Val(f.Text) = 0 Then
MsgBox("Masukkan harga barang barang")
Exit Sub
End If
CT = CI.Rows.Find(d.Text)
If CT Is Nothing Then
CT = CI.NewRow
CT("KODEBARANG") = d.Text
Else
MsgBox("Maaf kodebarang sudah ada")
Exit Sub
End If
CT = CI.NewRow
CT("KODEBARANG") = d.Text
CT("NAMABARANG") = J.Text
CT("UNIT") = ee.Text
CT("HARGA") = f.Text
CT("JUMLAH") = K.Text
CI.Rows.Add(CT)
d.Text = ""
J.Text = ""
ee.Text = ""
f.Text = ""
TOTALJumlah()
End Sub
Private Sub h_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles h.Click
If a.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If CI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim CC As New OleDb.OleDbCommand
CC = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
For Each X As DataRow In CI.Rows
CC = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "','" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
CC.ExecuteNonQuery()
I.Close()
CC.Dispose()
Next
a.Text = ""
c.Text = ""
K.Text = ""
CI.Rows.Clear()
TOTALJumlah()
End Sub
End Class
latihan 36
Public Class Form36
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Dim CT As DataRow
Private Sub Form36_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select KODEBARANG, UNIT, HARGA from DETAILTRANSAKSI WHERE NOTRANS= '" & a.Text & "'", I)
Z.Fill(CI)
Z.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CI.Columns("KODEBARANG")
CI.PrimaryKey = dataPrimary
DataGridView1.DataSource = CI
End Sub
Private Sub g_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click
If d.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If Val(ee.Text) = 0 Then
MsgBox("Masukkan Harga barang")
Exit Sub
End If
If Val(f.Text) = 0 Then
MsgBox("Masukkan jumlah barang")
Exit Sub
End If
CT = CI.Rows.Find(d.Text)
If CT Is Nothing Then
CT = CI.NewRow
CT("KODEBARANG") = d.Text
Else
MsgBox("Maaf kode barang sudah ada")
Exit Sub
End If
CT = CI.NewRow
CT("KODEBARANG") = d.Text
CT("UNIT") = ee.Text
CT("HARGA") = f.Text
CI.Rows.Add(CT)
d.Text = ""
ee.Text = ""
f.Text = ""
End Sub
Private Sub h_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles h.Click
If a.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If CI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim jj As New OleDb.OleDbCommand
jj = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
jj.ExecuteNonQuery()
I.Close()
For Each X As DataRow In CI.Rows
jj = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "','" & X("KODEBARANG") & "', " & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
jj.ExecuteNonQuery()
I.Close()
jj.Dispose()
Next
a.Text = ""
c.Text = ""
CI.Rows.Clear()
End Sub
End Class
Dim I As New OleDb.OleDbConnection("Provider=microsoft.ACE.OLEDB.12.0;data source=" & Application.StartupPath & "\DATAMAJEMUK.accdb")
Dim CI As New DataTable
Dim CT As DataRow
Private Sub Form36_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Z As New OleDb.OleDbDataAdapter
Z = New OleDb.OleDbDataAdapter("Select KODEBARANG, UNIT, HARGA from DETAILTRANSAKSI WHERE NOTRANS= '" & a.Text & "'", I)
Z.Fill(CI)
Z.Dispose()
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = CI.Columns("KODEBARANG")
CI.PrimaryKey = dataPrimary
DataGridView1.DataSource = CI
End Sub
Private Sub g_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles g.Click
If d.Text.Length = 0 Then
MsgBox("Kode barang sudah ada")
Exit Sub
End If
If Val(ee.Text) = 0 Then
MsgBox("Masukkan Harga barang")
Exit Sub
End If
If Val(f.Text) = 0 Then
MsgBox("Masukkan jumlah barang")
Exit Sub
End If
CT = CI.Rows.Find(d.Text)
If CT Is Nothing Then
CT = CI.NewRow
CT("KODEBARANG") = d.Text
Else
MsgBox("Maaf kode barang sudah ada")
Exit Sub
End If
CT = CI.NewRow
CT("KODEBARANG") = d.Text
CT("UNIT") = ee.Text
CT("HARGA") = f.Text
CI.Rows.Add(CT)
d.Text = ""
ee.Text = ""
f.Text = ""
End Sub
Private Sub h_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles h.Click
If a.Text.Length = 0 Then
MsgBox("No. transaksi sudah ada")
Exit Sub
End If
If c.Text.Length = 0 Then
MsgBox("Jenis transaksi sudah ada")
Exit Sub
End If
If CI.Rows.Count = 0 Then
MsgBox("Jumlah baris tidak terisi")
Exit Sub
End If
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
cari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", a.Text, 1, I)
If cari.JumlanBaris > 0 Then
MsgBox("data tersebut sudah ada")
Exit Sub
End If
Dim jj As New OleDb.OleDbCommand
jj = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & a.Text & "', #" & b.Value.Month & "/" & b.Value.Day & "/" & b.Value.Year & "#, '" & c.Text & "')", I)
I.Open()
jj.ExecuteNonQuery()
I.Close()
For Each X As DataRow In CI.Rows
jj = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & a.Text & "','" & X("KODEBARANG") & "', " & X("UNIT") & ", " & X("HARGA") & ")", I)
I.Open()
jj.ExecuteNonQuery()
I.Close()
jj.Dispose()
Next
a.Text = ""
c.Text = ""
CI.Rows.Clear()
End Sub
End Class
Langganan:
Postingan (Atom)