Form 40A
Public Class Form40A_36109023
Dim ame As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/DataMajemuk.accdb")
Dim dt1 As New DataTable
Dim dt2 As New DataTable
Dim pororo As New DataSet
Dim bs1 As New BindingSource
Dim bs2 As New BindingSource
Public Sub amelia1()
Dim sj As New OleDb.OleDbDataAdapter
dt2.Rows.Clear()
dt1.Rows.Clear()
sj = New OleDb.OleDbDataAdapter("select * from mastertransaksi", ame)
sj.Fill(dt1)
sj = New OleDb.OleDbDataAdapter("select detailtransaksi.notrans, barang.kodebarang, barang.namabarang, detailtransaksi.unit, detailtransaksi.harga, detailtransaksi.unit*harga as jumlah from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang", ame)
sj.Fill(dt2)
End Sub
Private Sub Form40A_36109023_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
amelia1()
pororo.Tables.Add(dt1)
pororo.Tables.Add(dt2)
dt1.TableName = "evil"
dt2.TableName = "evil2"
pororo.Relations.Add(New DataRelation("sj", pororo.Tables("evil").Columns("notrans"), pororo.Tables("evil2").Columns("notrans")))
bs1.DataSource = pororo
bs1.DataMember = "evil"
bs2.DataSource = bs1
bs2.DataMember = "sj"
Dim dc(1) As DataColumn
dc(0) = dt1.Columns("notrans")
dt1.PrimaryKey = dc
dgv1_36109023.DataSource = bs1
dgv2_36109023.DataSource = bs2
End Sub
Private Sub aa36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles aa36109023.Click
Dim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv1_36109023.CurrentRow.Cells("notrans").Value & "'", ame)
ame.Open()
cm.ExecuteNonQuery()
ame.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv1_36109023.CurrentRow.Cells("notrans").Value & "'", ame)
ame.Open()
cm.ExecuteNonQuery()
ame.Close()
cm.Dispose()
amelia1()
End Sub
Private Sub bb36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bb36109023.Click
If Form40B_36109023.Visible = False Then
Form40B_36109023.Show()
Else
Form40B_36109023.Activate()
End If
Form40B_36109023.aa36109023.Text = ""
Form40B_36109023.cc36109023.Text = ""
Form40B_36109023.ff36109023.Text = "-"
Form40B_36109023.amelia2()
Form40B_36109023.amelia3()
End Sub
Private Sub cc36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cc36109023.Click
If Form40B_36109023.Visible = False Then
Form40B_36109023.Show()
Else
Form40B_36109023.Activate()
End If
Form40B_36109023.aa36109023.Text = dgv1_36109023.CurrentRow.Cells("notrans").Value
Form40B_36109023.bb36109023.Value = dgv1_36109023.CurrentRow.Cells("tanggaltransaksi").Value
Form40B_36109023.cc36109023.Text = dgv1_36109023.CurrentRow.Cells("jenistransaksi").Value
Form40B_36109023.ff36109023.Text = dgv1_36109023.CurrentRow.Cells("notrans").Value
Form40B_36109023.amelia2()
Form40B_36109023.amelia3()
End Sub
End Class
Form 40 B
Public Class Form40B_36109023
Dim ame As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/dataMajemuk.accdb")
Dim dt As New DataTable
Dim amelia As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Public Sub amelia2()
Dim pororo As New OleDb.OleDbDataAdapter
pororo = New OleDb.OleDbDataAdapter("select barang.KODEBARANG, barang.NAMABARANG, detailtransaksi.UNIT, detailtransaksi.HARGA, detailtransaksi.unit * detailtransaksi.harga as JUMLAH from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang where notrans = '" & aa36109023.Text & "'", ame)
dt.Rows.Clear()
pororo.Fill(dt)
End Sub
Public Sub amelia3()
Dim total1 As Integer
For Each total2 As DataGridViewRow In dgv36109023.Rows
total1 = total1 + total2.Cells("JUMLAH").Value
Next
dd36109023.Text = total1
End Sub
Private Sub amelia4()
If aa36109023.Text.Length = 0 Then
MsgBox("Isi rong itu Notransnya..")
Exit Sub
End If
If cc36109023.Text.Length = 0 Then
MsgBox("Isi rong itu Jenis Transaksinya..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Isi rong itu datatable k..")
Exit Sub
End If
End Sub
Private Sub tambah()
amelia4()
amelia.AturPencarianDataBase("mastertransaksi", "notrans", aa36109023.Text, 1, ame)
If amelia.JumlanBaris > 0 Then
MsgBox("Adami notrans 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 = ""
dd36109023.Text = ""
ff36109023.Text = "-"
dt.Rows.Clear()
Form40A_36109023.amelia1()
End Sub
Public Sub edit()
amelia4()
If aa36109023.Text <> ff36109023.Text Then
amelia.AturPencarianDataBase("mastertransaksi", "notrans", aa36109023.Text, 1, ame)
If amelia.JumlanBaris > 0 Then
MsgBox("Adami Notrans seperti itu,,mohon ganti..")
Exit Sub
End If
End If
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & ff36109023.Text & "'", ame)
ame.Open()
cm.ExecuteNonQuery()
ame.Close()
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()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ff36109023.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 = ""
dd36109023.Text = ""
ff36109023.Text = "-"
dt.Rows.Clear()
Form40A_36109023.amelia1()
End Sub
Private Sub Form40B_36109023_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
amelia2()
Dim bumbum(1) As DataColumn
bumbum(0) = dt.Columns("kodebarang")
dt.PrimaryKey = bumbum
dt.Columns("unit").DefaultValue = 0
dt.Columns("harga").DefaultValue = 0
dt.Columns("jumlah").DefaultValue = 0
dgv36109023.DataSource = dt
End Sub
Private Sub dgv36109023_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv36109023.CellEndEdit
If dgv36109023.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
dgv36109023.CurrentRow.Cells("NAMABARANG").Value = ""
dgv36109023.CurrentRow.Cells("UNIT").Value = 0
dgv36109023.CurrentRow.Cells("HARGA").Value = 0
dgv36109023.CurrentRow.Cells("JUMLAH").Value = 0
amelia.AturPencarianDataBase("barang", "kodebarang", dgv36109023.CurrentRow.Cells("KODEBARANG").Value, 1, ame)
If amelia.JumlanBaris > 0 Then
dgv36109023.CurrentRow.Cells("NAMABARANG").Value = amelia.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dgv36109023.CurrentRow.Cells("NAMABARANG").Value = ""
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
End If
End If
ElseIf dgv36109023.Columns(e.ColumnIndex).Name = "UNIT" Or dgv36109023.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv36109023.CurrentRow.Cells("JUMLAH").Value = dgv36109023.CurrentRow.Cells("UNIT").Value * dgv36109023.CurrentRow.Cells("HARGA").Value
amelia3()
End If
End Sub
Private Sub ee36109023_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ee36109023.Click
If ff36109023.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub dgv36109023_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgv36109023.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class
Rabu, 21 Desember 2011
Form 40
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar