Sambungan latihan40b_46109035 TOTALJUMLAH() End Sub Private Sub bt1_46109035_bt2_46109035() If nt_46109035.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If jt_46109035.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 StatusStrip1.Text <> nt_46109035.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_46109035.Text, 1, Asrini) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_46109035.Text & "', #" & dtp_46109035.Value.Month & "/" & dtp_46109035.Value.Day & "/" & dtp_46109035.Value.Year & "#, '" & jt_46109035.Text & "')", Asrini)
Asrini.Open()
T.ExecuteNonQuery()
Asrini.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_46109035.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", Asrini) Asrini.Open() T.ExecuteNonQuery() Asrini.Close() T.Dispose() Next
If jt_46109035.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 StatusStrip1.Text <> nt_46109035.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_46109035.Text, 1, Asrini) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & nt_46109035.Text & "'", Asrini) Asrini.Open() T.ExecuteNonQuery() Asrini.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & nt_46109035.Text & "'", Asrini) Asrini.Open() T.ExecuteNonQuery() Asrini.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_46109035.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", Asrini) Asrini.Open() T.ExecuteNonQuery() Asrini.Close() T.Dispose() Next
Private Sub bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt1_46109035.Click If StatusStrip1.Text = "-" Then bt1_46109035_bt2_46109035() Else Button1_edit() End If End Sub End Class
LATIHAN 40 A Public Class LATIHAN040A_46109010 Dim faradillah As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46") Dim fara1 As New DataTable Dim fara2 As New DataTable Dim dset As New DataSet Dim bs1 As New BindingSource Dim bs2 As New BindingSource
Public Sub faradillahrivai() Dim a As New OleDb.OleDbDataAdapter fara2.Rows.Clear() fara1.Rows.Clear() a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", faradillah) a.Fill(fara1) a = 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", faradillah) a.Fill(fara2) End Sub
Private Sub latihan040A_46109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load faradillahrivai()
Private Sub hapus46109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus46109010.Click
Dim cm As New OleDb.OleDbCommand cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv146109010.CurrentRow.Cells("notrans").Value & "'", faradillah) faradillah.Open() cm.ExecuteNonQuery() faradillah.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv146109010.CurrentRow.Cells("notrans").Value & "'", faradillah) faradillah.Open() cm.ExecuteNonQuery() faradillah.Close() cm.Dispose() faradillahrivai()
Private Sub tambah46109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah46109010.Click If LATIHAN040B_46109010.Visible = False Then
LATIHAN040B_46109010.Show() Else LATIHAN040B_46109010.Activate() End If
Private Sub edit46109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit46109010.Click If LATIHAN040B_46109010.Visible = False Then LATIHAN040B_46109010.Show() Else LATIHAN040B_46109010.Activate() End If
Dim faradillah As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46") Dim fara As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim cm As New OleDb.OleDbCommand
Public Sub faradillahrivai2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & nt46109010.Text & "'", faradillah) fara.Rows.Clear() a.Fill(fara) End Sub
Public Sub faradillahrivai3() Dim total As Integer = 0 For Each x As DataRow In fara.Rows total += x("Jumlah") Next Tot46109010.Text = total End Sub
Private Sub faradillahrivai4() If nt46109010.Text.Length = 0 Then MsgBox("Isi Notransnya..") Exit Sub End If
If jt46109010.Text.Length = 0 Then MsgBox("Isi Jenis Transaksinya..") Exit Sub End If
If fara.Rows.Count = 0 Then MsgBox("Isi datatable k..") Exit Sub End If End Sub
Private Sub faradillahrivai4() If nt46109010.Text.Length = 0 Then MsgBox("Isi Notransnya..") Exit Sub End If
If jt46109010.Text.Length = 0 Then MsgBox("Isi Jenis Transaksinya..") Exit Sub End If
If fara.Rows.Count = 0 Then MsgBox("Isi datatable k..") Exit Sub End If End Sub
Private Sub tambah() faradillahrivai4() cari.AturPencarianDataBase("mastertransaksi", "notrans", nt46109010.Text, 1, faradillah) If cari.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each x As DataRow In fara.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109010.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", faradillah)
faradillah.Open() cm.ExecuteNonQuery() faradillah.Close() Next cm.Dispose()
LANJUTAN LATIHAN 40 B BY FARADILLAH AMALIA RIVAI Public Sub edit() faradillahrivai4() If nt46109010.Text <> Statusstrip46109010.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", nt46109010.Text, 1, faradillah) If cari.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 = '" & Statusstrip46109010.Text & "'", faradillah) faradillah.Open() cm.ExecuteNonQuery() faradillah.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & Statusstrip46109010.Text & "'", faradillah) faradillah.Open() cm.ExecuteNonQuery() faradillah.Close()
For Each x As DataRow In fara.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt46109010.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", faradillah) faradillah.Open() cm.ExecuteNonQuery() faradillah.Close() Next cm.Dispose()
cari.AturPencarianDataBase("barang", "kodebarang", dtg46109010.CurrentRow.Cells("KODEBARANG").Value, 1, faradillah) If cari.JumlanBaris > 0 Then dtg46109010.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else dtg46109010.CurrentRow.Cells("NAMABARANG").Value = "" If Latihan383940_46109010.ShowDialog = Windows.Forms.DialogResult.OK Then dtg46109010.CurrentRow.Cells("KODEBARANG").Value = Latihan383940_46109010.DGV46109010.CurrentRow.Cells("KODEBARANG").Value dtg46109010.CurrentRow.Cells("NAMABARANG").Value = Latihan383940_46109010.DGV46109010.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf dtg46109010.Columns(e.ColumnIndex).Name = "UNIT" Or dtg46109010.Columns(e.ColumnIndex).Name = "HARGA" Then dtg46109010.CurrentRow.Cells("JUMLAH").Value = dtg46109010.CurrentRow.Cells("UNIT").Value * dtg46109010.CurrentRow.Cells("HARGA").Value faradillahrivai3() End If End Sub
Private Sub simpan46109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan46109010.Click If Statusstrip46109010.Text = "-" Then tambah() Else edit() End If End Sub
Private Sub dtg46109010_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dtg46109010.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub End Class
Public Class TUGAS40A Dim SRY As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;Jet OLEDB:Database Password=11") Dim REJEKI1 As New DataTable Dim REJEKI2 As New DataTable Dim CARI As New ByIskandar.CariKeDataBaseByIskandar
Public Sub KIKIE1() Dim r As New OleDb.OleDbDataAdapter REJEKI1.Rows.Clear() REJEKI1.Rows.Clear() r = New OleDb.OleDbDataAdapter("select * from mastertransaksi", SRY) r.Fill(REJEKI1) r = 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", SRY) r.Fill(REJEKI2) End Sub
Private Sub TUGAS40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim DS As New DataSet Dim BS1 As New BindingSource Dim BS2 As New BindingSource KIKIE1()
Dim dc(1) As DataColumn dc(0) = REJEKI1.Columns("notrans") REJEKI1.PrimaryKey = dc
DGV146109006.DataSource = BS1 DGV246109006.DataSource = BS2 End Sub
Private Sub TOMBOL1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL1.Click If TUGAS40B.Visible = False Then TUGAS40B.Show() Else TUGAS40B.Activate() End If
Private Sub TOMBOL2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL2.Click If TUGAS40B.Visible = False Then TUGAS40B.Show() Else TUGAS40B.Activate() End If
Private Sub TOMBOL3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL3.Click Dim KI2 As New OleDb.OleDbCommand KI2 = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & DGV146109006.CurrentRow.Cells("notrans").Value & "'", SRY) SRY.Open() KI2.ExecuteNonQuery() SRY.Close()
KI2 = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & DGV146109006.CurrentRow.Cells("notrans").Value & "'", SRY) SRY.Open() KI2.ExecuteNonQuery() SRY.Close() KI2.Dispose() KIKIE1() End Sub End Class
Public Class TUGAS40B Dim SRY As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.aT246109006db;Jet OLEDB:Database Password=11") Dim REJEKI As New DataTable Dim CARI As New ByIskandar.CariKeDataBaseByIskandar Dim QQ As New OleDb.OleDbCommand
Public Sub KIKIE2() Dim Q As New OleDb.OleDbDataAdapter Q = 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 = '" & T146109006.Text & "'", SRY) REJEKI.Rows.Clear() Q.Fill(REJEKI) End Sub
Public Sub KIKIE3() Dim total As Integer = 0 For Each x As DataRow In REJEKI.Rows total += x("Jumlah") Next TOT46109006.Text = total End Sub
Private Sub KIKIE4() If T146109006.Text.Length = 0 Then MsgBox("no.transaksi belum terisi") Exit Sub End If
If T246109006.Text.Length = 0 Then MsgBox("jenis transaksi belum terisi") Exit Sub End If
If REJEKI.Rows.Count = 0 Then MsgBox("Data tidak tersedia") Exit Sub End If End Sub
Private Sub tambah() KIKIE4() CARI.AturPencarianDataBase("mastertransaksi", "notrans", T146109006.Text, 1, SRY) If CARI.JumlanBaris > 0 Then MsgBox("NO.TRANSAKSI sudah ada") Exit Sub End If
For Each x As DataRow In REJEKI.Rows QQ = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & T146109006.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", SRY) SRY.Open() QQ.ExecuteNonQuery() SRY.Close() Next QQ.Dispose()
Public Sub edit() KIKIE4() If T146109006.Text <> TS46109006.Text Then CARI.AturPencarianDataBase("mastertransaksi", "notrans", T146109006.Text, 1, SRY) If CARI.JumlanBaris > 0 Then MsgBox("Adami Notrans seperti itu,,mohon ganti..") Exit Sub End If End If
QQ = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & TS46109006.Text & "'", SRY) SRY.Open() QQ.ExecuteNonQuery() SRY.Close()
QQ = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & TS46109006.Text & "'", SRY) SRY.Open() QQ.ExecuteNonQuery() SRY.Close()
For Each x As DataRow In REJEKI.Rows QQ = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & T146109006.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", SRY) SRY.Open() QQ.ExecuteNonQuery() SRY.Close() Next QQ.Dispose()
REJEKI.Rows.Clear() TUGAS40A.KIKIE1() End Sub Private Sub TUGAS40B_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load KIKIE2()
Dim dc(1) As DataColumn dc(0) = REJEKI.Columns("kodebarang") REJEKI.PrimaryKey = dc
Private Sub DGV46109006_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV46109006.CellEndEdit If DGV46109006.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
If CARI.JumlanBaris > 0 Then DGV46109006.CurrentRow.Cells("NAMABARANG").Value = CARI.DataTablenya.Rows(0).Item("NAMABARANG") Else DGV46109006.CurrentRow.Cells("NAMABARANG").Value = "" If TUGAS383940.ShowDialog = Windows.Forms.DialogResult.OK Then DGV46109006.CurrentRow.Cells("KODEBARANG").Value = TUGAS383940.DGV46109006.CurrentRow.Cells("KODEBARANG").Value DGV46109006.CurrentRow.Cells("NAMABARANG").Value = TUGAS383940.DGV46109006.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DGV46109006.Columns(e.ColumnIndex).Name = "UNIT" Or DGV46109006.Columns(e.ColumnIndex).Name = "HARGA" Then DGV46109006.CurrentRow.Cells("JUMLAH").Value = DGV46109006.CurrentRow.Cells("UNIT").Value * DGV46109006.CurrentRow.Cells("HARGA").Value KIKIE3() End If End Sub Private Sub TOMBOL1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL1.Click If TS46109006.Text = "-" Then tambah() Else edit() End If End Sub Private Sub DGV46109006_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DGV46109006.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub End Class
Dim Muhitha As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=12345") Dim dt As New DataTable Dim dt1 As New DataTable Dim dset As New DataSet Dim Bsource1 As New BindingSource Dim Bsource2 As New BindingSource Public Sub itha()
dt1.Rows.Clear() dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", Muhitha) B1.Fill(dt)
B1 = 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", Muhitha) B1.Fill(dt1)
B1.Dispose() End Sub
Private Sub Latihan40A46109047_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load itha()
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & dgv146109047.CurrentRow.Cells("NOTRANS").Value & "'", Muhitha) Muhitha.Open() T.ExecuteNonQuery() Muhitha.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & dgv146109047.CurrentRow.Cells("NOTRANS").Value & "'", Muhitha) Muhitha.Open() T.ExecuteNonQuery() Muhitha.Close()
Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If Latihan40B46109047.Visible = False Then Latihan40B46109047.Show() Else Latihan40B46109047.Activate() End If
Latihan40B46109047.faster() Latihan40B46109047.TOTALJUMLAH() End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Latihan40B46109047.Visible = False Then Latihan40B46109047.Show() Else Latihan40B46109047.Activate() End If
Dim Muhitha As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=12345") Dim DATA As New DataTable
Public Sub faster() 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= '" & nt46109047.Text & "'", Muhitha) DATA.Rows.Clear() X.Fill(DATA) End Sub
Private Sub Latihan40B46109047_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
dgv46109047.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 Tot46109047.Text = TOT End Sub Private Sub dgv46109047_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv46109047.CellContentClick If dgv46109047.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", dgv46109047.CurrentRow.Cells("KODEBARANG").Value, 1, Muhitha)
If Pencari.JumlanBaris > 0 Then dgv46109047.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else dgv46109047.CurrentRow.Cells("KODEBARANG").Value = "" If Latihan3839400047.ShowDialog = Windows.Forms.DialogResult.OK Then dgv46109047.CurrentRow.Cells("KODEBARANG").Value = Latihan3839400047.DGV46109047.CurrentRow.Cells("KODEBARANG").Value dgv46109047.CurrentRow.Cells("NAMABARANG").Value = Latihan3839400047.DGV46109047.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf dgv46109047.Columns(e.ColumnIndex).Name = "UNIT" Or dgv46109047.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv46109047.CurrentRow.Cells("JUMLAH").Value = dgv46109047.CurrentRow.Cells("UNIT").Value * dgv46109047.CurrentRow.Cells("HARGA").Value End If
Private Sub Button1_Button2() If nt46109047.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If jt46109047.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 StatusStrip1.Text <> nt46109047.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109047.Text, 1, Muhitha) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt46109047.Text & "', #" & dtp46109047.Value.Month & "/" & dtp46109047.Value.Day & "/" & dtp46109047.Value.Year & "#, '" & jt46109047.Text & "')", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109047.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", Muhitha) Muhitha.Open() T.ExecuteNonQuery() Muhitha.Close() T.Dispose() Next
Private Sub Button1_edit() If nt46109047.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If jt46109047.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 StatusStrip1.Text <> nt46109047.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109047.Text, 1, Muhitha) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & nt46109047.Text & "'", Muhitha) Muhitha.Open() T.ExecuteNonQuery() Muhitha.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & nt46109047.Text & "'", Muhitha) Muhitha.Open() T.ExecuteNonQuery() Muhitha.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109047.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", Muhitha) Muhitha.Open() T.ExecuteNonQuery() Muhitha.Close() T.Dispose() Next
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If StatusStrip1.Text = "-" Then Button1_Button2() Else Button1_edit() End If End Sub End Class
Public Class LATIHAN040B_46109002 Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=1234") Dim wawan As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim cm As New OleDb.OleDbCommand Public Sub riswan2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & nomor46109002.Text & "'", CONECT) wawan.Rows.Clear() a.Fill(wawan) End Sub Public Sub riswan3() Dim total As Integer = 0 For Each x As DataRow In wawan.Rows total += x("Jumlah") Next total46109002.Text = total End Sub Private Sub riswan4() If nomor46109002.Text.Length = 0 Then MsgBox("Isi Notransnya..") Exit Sub End If
If jenis46109002.Text.Length = 0 Then MsgBox("Isi Jenis Transaksinya..") Exit Sub End If
If wawan.Rows.Count = 0 Then MsgBox("Isi datatable k..") Exit Sub End If End Sub Private Sub tambah() riswan4() cari.AturPencarianDataBase("mastertransaksi", "notrans", nomor46109002.Text, 1, CONECT) If cari.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each x As DataRow In wawan.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nomor46109002.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", CONECT)
CONECT.Open() cm.ExecuteNonQuery() CONECT.Close() Next cm.Dispose()
Public Sub edit() riswan4() If nomor46109002.Text <> StatusStrip46109002.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", nomor46109002.Text, 1, CONECT) If cari.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 = '" & StatusStrip46109002.Text & "'", CONECT) CONECT.Open() cm.ExecuteNonQuery() CONECT.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip46109002.Text & "'", CONECT) CONECT.Open() cm.ExecuteNonQuery() CONECT.Close()
For Each x As DataRow In wawan.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nomor46109002.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", CONECT) CONECT.Open() cm.ExecuteNonQuery() CONECT.Close() Next cm.Dispose()
wawan.Rows.Clear() LATIHAN040A_46109002.riswan() End Sub Private Sub LATIHAN040B_46109002_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load riswan2()
Dim dc(1) As DataColumn dc(0) = wawan.Columns("kodebarang") wawan.PrimaryKey = dc
Public Sub edit() riswan4() If nomor46109002.Text <> StatusStrip46109002.Text Then cari.AturPencarianDataBase("mastertransaksi", "notrans", nomor46109002.Text, 1, CONECT) If cari.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 = '" & StatusStrip46109002.Text & "'", CONECT) CONECT.Open() cm.ExecuteNonQuery() CONECT.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip46109002.Text & "'", CONECT) CONECT.Open() cm.ExecuteNonQuery() CONECT.Close()
For Each x As DataRow In wawan.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nomor46109002.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", CONECT) CONECT.Open() cm.ExecuteNonQuery() CONECT.Close() Next cm.Dispose()
wawan.Rows.Clear() LATIHAN040A_46109002.riswan() End Sub Private Sub LATIHAN040B_46109002_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load riswan2()
Dim dc(1) As DataColumn dc(0) = wawan.Columns("kodebarang") wawan.PrimaryKey = dc
Dim CONECT AsNew OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= "& Application.StartupPath &"\DATAMAJEMUK.accdb;jet oledb:database Password=KYKY") Dim DATA AsNew DataTable PublicSub faster() Dim X AsNew 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= '"& NT_46109050.Text &"'", CONECT) DATA.Rows.Clear() X.Fill(DATA) EndSub
PrivateSub Latihan40B_46109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load Dim dataPrimary(1) As DataColumn dataPrimary(0) = DATA.Columns("NOTRANS") DATA.PrimaryKey = dataPrimary
DGV_46109050.DataSource = DATA
TOTALJUMLAH() EndSub PublicSub TOTALJUMLAH() Dim TOT AsDouble = 0 ForEach x As DataRow In DATA.Rows TOT = TOT + x("JUMLAH") Next TOT_46109050.Text = TOT EndSub PrivateSub DGV_46109050_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_46109050.CellContentClick If DGV_46109050.Columns(e.ColumnIndex).Name = "KODEBARANG"Then
TOTALJUMLAH() EndSub PrivateSub Button1_Button2() If NT_46109050.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") ExitSub EndIf
If JT_46109050.Text.Length = 0 Then MsgBox("Maaf, Jenis transaksi harus diisi dulu") ExitSub EndIf
If DATA.Rows.Count() = 0 Then MsgBox("Maaf, Proses tidak dapat dilanjutkan") ExitSub EndIf
If StatusStrip1.Text <> NT_46109050.Text Then Dim pencari AsNew ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT_46109050.Text, 1, CONECT) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") ExitSub EndIf EndIf
EndSub PrivateSub Button1_edit() If NT_46109050.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") ExitSub EndIf
If JT_46109050.Text.Length = 0 Then MsgBox("Maaf, Jenis transaksi harus diisi dulu") ExitSub EndIf
If DATA.Rows.Count() = 0 Then MsgBox("Maaf, Proses tidak dapat dilanjutkan") ExitSub EndIf
If StatusStrip1.Text <> NT_46109050.Text Then Dim pencari AsNew ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT_46109050.Text, 1, CONECT) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") ExitSub EndIf EndIf
Dim T AsNew OleDb.OleDbCommand T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '"& NT_46109050.Text &"'", CONECT) CONECT.Open() T.ExecuteNonQuery() CONECT.Close()
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('"& NT_46109050.Text &"', #"& TGL_46109050.Value.Month &"/"& TGL_46109050.Value.Day &"/"& TGL_46109050.Value.Year &"#, '"& JT_46109050.Text &"')", CONECT) CONECT.Open() T.ExecuteNonQuery() CONECT.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '"& NT_46109050.Text &"'", CONECT) CONECT.Open() T.ExecuteNonQuery() CONECT.Close()
ForEach XX As DataRow In DATA.Rows T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('"& NT_46109050.Text &"', '"& XX("KODEBARANG") &"', "& XX("UNIT") &", "& XX("HARGA") &")", CONECT) CONECT.Open() T.ExecuteNonQuery() CONECT.Close() T.Dispose() Next
Dim yayu As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=Parandangi") Dim DATA As New DataTable Public Sub faster() 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= '" & nt46109004.Text & "'", yayu) DATA.Rows.Clear() X.Fill(DATA) End Sub
Private Sub Latihan40b_46109004_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
dgv46109004.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 Tot46109004.Text = TOT End Sub Private Sub dgv46109004_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv46109004.CellContentClick If dgv46109004.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", dgv46109004.CurrentRow.Cells("KODEBARANG").Value, 1, yayu)
If Pencari.JumlanBaris > 0 Then dgv46109004.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else dgv46109004.CurrentRow.Cells("KODEBARANG").Value = "" If Latihan383940004.ShowDialog = Windows.Forms.DialogResult.OK Then dgv46109004.CurrentRow.Cells("KODEBARANG").Value = Latihan3839400004.DGV46109004.CurrentRow.Cells("KODEBARANG").Value dgv46109004.CurrentRow.Cells("NAMABARANG").Value = Latihan3839400004.DGV46109004.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf dgv46109004.Columns(e.ColumnIndex).Name = "UNIT" Or dgv46109004.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv46109004.CurrentRow.Cells("JUMLAH").Value = dgv46109004.CurrentRow.Cells("UNIT").Value * dgv46109004.CurrentRow.Cells("HARGA").Value End If
TOTALJUMLAH() End Sub Private Sub Button1_Button2() If nt46109004.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If jt46109004.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 StatusStrip1.Text <> nt46109004.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109004.Text, 1, yayu) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt46109004.Text & "', #" & dtp46109004.Value.Month & "/" & dtp46109004.Value.Day & "/" & dtp46109004.Value.Year & "#, '" & jt46109004.Text & "')", yayu)
yayu.Open()
T.ExecuteNonQuery()
yayu.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109004.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", yayu) yayu.Open() T.ExecuteNonQuery() yayu.Close() T.Dispose() Next
End Sub Private Sub Button1_edit() If nt46109004.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If jt46109004.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 StatusStrip1.Text <> nt46109004.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109004.Text, 1, yayu) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & nt46109004.Text & "'", yayu) yayu.Open() T.ExecuteNonQuery() yayu.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & nt46109004.Text & "'", yayu) yayu.Open() T.ExecuteNonQuery() yayu.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109004.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", yayu) yayu.Open() T.ExecuteNonQuery() yayu.Close() T.Dispose() Next
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If StatusStrip1.Text = "-" Then Button1_Button2() Else Button1_edit() End If End Sub End Class
Dim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=yusri") Dim DATA As New DataTable Public Sub uchy() 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= '" & NoTrans_46109038.Text & "'", conect) DATA.Rows.Clear() X.Fill(DATA) End Sub
Private Sub Latihan40B_46109038_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
DGV_46109038.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 Total_46109038.Text = TOT End Sub Private Sub DGV_46109038_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_46109038.CellContentClick If DGV_46109038.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DGV_46109038.CurrentRow.Cells("KODEBARANG").Value, 1, conect)
If Pencari.JumlanBaris > 0 Then DGV_46109038.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else DGV_46109038.CurrentRow.Cells("KODEBARANG").Value = "" If Latihan38_39_40_46109038.ShowDialog = Windows.Forms.DialogResult.OK Then DGV_46109038.CurrentRow.Cells("KODEBARANG").Value = Latihan38_39_40_46109038.DGV46109047.CurrentRow.Cells("KODEBARANG").Value DGV_46109038.CurrentRow.Cells("NAMABARANG").Value = Latihan38_39_40_46109038.DGV46109047.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DGV_46109038.Columns(e.ColumnIndex).Name = "UNIT" Or DGV_46109038.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV_46109038.CurrentRow.Cells("JUMLAH").Value = DGV_46109038.CurrentRow.Cells("UNIT").Value * DGV_46109038.CurrentRow.Cells("HARGA").Value End If
Private Sub Button1_Button2() If NoTrans_46109038.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If JenTrans_46109038.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 StatusStrip1.Text <> NoTrans_46109038.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NoTrans_46109038.Text, 1, conect) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NoTrans_46109038.Text & "', #" & Tgl_46109038.Value.Month & "/" & Tgl_46109038.Value.Day & "/" & Tgl_46109038.Value.Year & "#, '" & JenTrans_46109038.Text & "')", conect)
conect.Open()
T.ExecuteNonQuery()
conect.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NoTrans_46109038.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", conect) conect.Open() T.ExecuteNonQuery() conect.Close() T.Dispose() Next
Private Sub Button1_edit() If NoTrans_46109038.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If JenTrans_46109038.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 StatusStrip1.Text <> NoTrans_46109038.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NoTrans_46109038.Text, 1, conect) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & NoTrans_46109038.Text & "'", conect) conect.Open() T.ExecuteNonQuery() conect.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & NoTrans_46109038.Text & "'", conect) conect.Open() T.ExecuteNonQuery() conect.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NoTrans_46109038.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", conect) conect.Open() T.ExecuteNonQuery() conect.Close() T.Dispose() Next
Private Sub Simpan_46109038_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_46109038.Click If StatusStrip1.Text = "-" Then Button1_Button2() Else Button1_edit() End If End Sub End Class
Dim Vero As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=allah swt") Dim dt As New DataTable Dim dt1 As New DataTable Dim dset As New DataSet Dim Bsource1 As New BindingSource Dim Bsource2 As New BindingSource Public Sub nika()
dt1.Rows.Clear() dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", Vero) B1.Fill(dt)
B1 = 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", Vero) B1.Fill(dt1)
B1.Dispose() End Sub
Private Sub Latihan40A46109052_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load nika()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & dgv146109052.CurrentRow.Cells("NOTRANS").Value & "'", Vero) Vero.Open() T.ExecuteNonQuery() Vero.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & dgv146109052.CurrentRow.Cells("NOTRANS").Value & "'", Vero) Vero.Open() T.ExecuteNonQuery() Vero.Close()
T.Dispose()
nika() End Sub Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If Latihan40B46109052.Visible = False Then Latihan40B46109052.Show() Else Latihan40B46109052.Activate() End If
Latihan40B46109052.faster() Latihan40B46109052.TOTALJUMLAH() End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Latihan40B46109052.Visible = False Then Latihan40B46109052.Show() Else Latihan40B46109052.Activate() End If
Public Class LATIHAN040A_46109020 Dim HUBUNG As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46") Dim TARI1 As New DataTable Dim TARI2 As New DataTable Dim DS As New DataSet Dim BS1 As New BindingSource Dim BS2 As New BindingSource Public Sub hardiyanti()
TARI1.Rows.Clear() TARI2.Rows.Clear()
Dim adapter As New OleDb.OleDbDataAdapter adapter = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", HUBUNG) adapter.Fill(TARI1)
adapter = 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", HUBUNG) adapter.Fill(TARI2)
adapter.Dispose() End Sub Private Sub LATIHAN040A_46109020_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load hardiyanti()
Private Sub HAPUS46109020_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HAPUS46109020.Click Dim com As New OleDb.OleDbCommand com = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DGV46109020.CurrentRow.Cells("NOTRANS").Value & "'", HUBUNG) HUBUNG.Open() com.ExecuteNonQuery() HUBUNG.Close()
com = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DGV46109020.CurrentRow.Cells("NOTRANS").Value & "'", HUBUNG) HUBUNG.Open() com.ExecuteNonQuery() HUBUNG.Close()
com.Dispose()
hardiyanti() End Sub
Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EDIT46109020.Click If LATIHAN040B_46109020.Visible = False Then LATIHAN040B_46109020.Show() Else LATIHAN040B_46109020.Activate() End If
LATIHAN040B_46109020.somsek() LATIHAN040B_46109020.TOTALJUMLAH() End Sub
Private Sub tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH46109020.Click If LATIHAN040B_46109020.Visible = False Then LATIHAN040B_46109020.Show() Else LATIHAN040B_46109020.Activate() End If
Public Class LATIHAN040B_46109020 Dim HUBUNG As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46") Dim DATA As New DataTable Public Sub somsek() Dim adapter As New OleDb.OleDbDataAdapter adapter = 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= '" & NT46109020.Text & "'", HUBUNG) DATA.Rows.Clear() adapter.Fill(DATA) End Sub Private Sub LATIHAN040B_46109020_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
DGV46109020.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 TOT46109020.Text = TOT End Sub Private Sub DGV46109020_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV46109020.CellContentClick If DGV46109020.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DGV46109020.CurrentRow.Cells("KODEBARANG").Value, 1, HUBUNG)
If Pencari.JumlanBaris > 0 Then DGV46109020.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG") Else DGV46109020.CurrentRow.Cells("KODEBARANG").Value = "" If Latihan383940_46109020.ShowDialog = Windows.Forms.DialogResult.OK Then DGV46109020.CurrentRow.Cells("KODEBARANG").Value = Latihan383940_46109020.DGV46109020.CurrentRow.Cells("KODEBARANG").Value DGV46109020.CurrentRow.Cells("NAMABARANG").Value = Latihan383940_46109020.DGV46109020.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DGV46109020.Columns(e.ColumnIndex).Name = "UNIT" Or DGV46109020.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV46109020.CurrentRow.Cells("JUMLAH").Value = DGV46109020.CurrentRow.Cells("UNIT").Value * DGV46109020.CurrentRow.Cells("HARGA").Value End If
Private Sub Button1_Button2() If NT46109020.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If JT46109020.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 StatusStrip1.Text <> NT46109020.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT46109020.Text, 1, HUBUNG) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT46109020.Text & "', #" & DT46109020.Value.Month & "/" & DT46109020.Value.Day & "/" & DT46109020.Value.Year & "#, '" & JT46109020.Text & "')", HUBUNG)
HUBUNG.Open()
T.ExecuteNonQuery()
HUBUNG.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT46109020.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", HUBUNG) HUBUNG.Open() T.ExecuteNonQuery() HUBUNG.Close() T.Dispose() Next
Private Sub Button1_edit() If NT46109020.Text.Length = 0 Then MsgBox("Maaf, Nomor transaksi harus diisi dulu") Exit Sub End If
If JT46109020.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 StatusStrip1.Text <> NT46109020.Text Then Dim pencari As New ByIskandar.CariKeDataBaseByIskandar pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT46109020.Text, 1, HUBUNG) If pencari.JumlanBaris > 0 Then MsgBox("Nomor transaksi sudah ada") Exit Sub End If End If
Dim T As New OleDb.OleDbCommand T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & NT46109020.Text & "'", HUBUNG) HUBUNG.Open() T.ExecuteNonQuery() HUBUNG.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & NT46109020.Text & "'", HUBUNG) HUBUNG.Open() T.ExecuteNonQuery() HUBUNG.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT46109020.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", HUBUNG) HUBUNG.Open() T.ExecuteNonQuery() HUBUNG.Close() T.Dispose() Next
TOTALJUMLAH() LATIHAN040A_46109020.hardiyanti() End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN46109020.Click If StatusStrip1.Text = "-" Then Button1_Button2() Else Button1_edit() End If End Sub End Class
Public Class Form40_A_46109042 Dim batari As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=8")
Dim dt1 As New DataTable Dim dt2 As New DataTable Dim ds As New DataSet Dim bs1 As New BindingSource Dim bs2 As New BindingSource
Public Sub novi1() Dim a As New OleDb.OleDbDataAdapter dt2.Rows.Clear() dt1.Rows.Clear() a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", batari) a.Fill(dt1) a = 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", batari) a.Fill(dt2) End Sub
Private Sub Form40_A_46109042_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load novi1()
Dim dc(1) As DataColumn dc(0) = dt1.Columns("notrans") dt1.PrimaryKey = dc
dgv146109042.DataSource = bs1 dgv246109042.DataSource = bs2 End Sub
Private Sub Button146109042_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109042.Click Dim cm As New OleDb.OleDbCommand cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv146109042.CurrentRow.Cells("notrans").Value & "'", batari) batari.Open() cm.ExecuteNonQuery() batari.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv146109042.CurrentRow.Cells("notrans").Value & "'", batari) batari.Open() cm.ExecuteNonQuery() batari.Close() cm.Dispose() novi1() End Sub
Private Sub Button246109042_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button246109042.Click If Form40_B_46109042.Visible = False Then Form40_B_46109042.Show() Else Form40_B_46109042.Activate() End If
Form40_B_46109042.novi2() Form40_B_46109042.novi3() End Sub
Private Sub Button346109042_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button346109042.Click If Form40_B_46109042.Visible = False Then Form40_B_46109042.Show() Else Form40_B_46109042.Activate() End If
Public Class Form40_B_46109042 Dim batari As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=8") Dim dt As New DataTable Dim novi As New ByIskandar.CariKeDataBaseByIskandar Dim cm As New OleDb.OleDbCommand
Public Sub novi2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & nt46109042.Text & "'", batari) dt.Rows.Clear() a.Fill(dt) End Sub
Public Sub novi3() Dim total As Integer = 0 For Each x As DataRow In dt.Rows total += x("Jumlah") Next Tot46109042.Text = total End Sub
Private Sub novi4() If nt46109042.Text.Length = 0 Then MsgBox("Isi Notransnya..") Exit Sub End If
If jt46109042.Text.Length = 0 Then MsgBox("Isi Jenis Transaksinya..") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Isi datatable k..") Exit Sub End If End Sub
Private Sub tambah() novi4() novi.AturPencarianDataBase("mastertransaksi", "notrans", nt46109042.Text, 1, batari) If novi.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each x As DataRow In dt.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109042.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", batari) batari.Open() cm.ExecuteNonQuery() batari.Close() Next cm.Dispose()
Public Class Latihan40A_46109015 Dim imah As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\datamajemuk.accdb;jet OLEDB:database password=015") Dim dt1 As New DataTable Dim dt2 As New DataTable Dim ds As New DataSet Dim bs1 As New BindingSource Dim bs2 As New BindingSource
Public Sub uni1() Dim a As New OleDb.OleDbDataAdapter dt2.Rows.Clear() dt1.Rows.Clear() a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", imah) a.Fill(dt1) a = New OleDb.OleDbDataAdapter("select detailtransaksi.notrans, barang.kodebarang, barang.namabarang, detailtransaksi.aidilt, detailtransaksi.harga, detailtransaksi.aidilt*harga as jumlah from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang", imah) a.Fill(dt2) End Sub
Private Sub Latihan40A_46109015_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load uni1()
Dim dc(1) As DataColumn dc(0) = dt1.Columns("notrans") dt1.PrimaryKey = dc
dgv1_46109015.DataSource = bs1 dgv2_46109015.DataSource = bs2 End Sub
Private Sub Button1_46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_46109015.Click Dim cm As New OleDb.OleDbCommand cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv1_46109015.CurrentRow.Cells("notrans").Value & "'", imah) imah.Open() cm.ExecuteNonQuery() imah.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv1_46109015.CurrentRow.Cells("notrans").Value & "'", imah) imah.Open() cm.ExecuteNonQuery() imah.Close() cm.Dispose() uni1() End Sub
Private Sub Button2_46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2_46109015.Click If Latihan040B_46109015.Visible = False Then Latihan040B_46109015.Show() Else Latihan040B_46109015.Activate() End If
Latihan040B_46109015.uni2() Latihan040B_46109015.uni3() End Sub
Private Sub Button3_46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3_46109015.Click If Latihan040B_46109015.Visible = False Then Latihan040B_46109015.Show() Else Latihan040B_46109015.Activate() End If
Public Class Latihan040B_46109015 Dim imah As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\datamajemuk.accdb;jet OLEDB:database password=015") Dim dt As New DataTable Dim uni As New ByIskandar.CariKeDataBaseByIskandar Dim cm As New OleDb.OleDbCommand
Public Sub uni2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & nt46109015.Text & "'", imah) dt.Rows.Clear() a.Fill(dt) End Sub
Public Sub uni3() Dim total As Integer = 0 For Each x As DataRow In dt.Rows total += x("Jumlah") Next Tot46109015.Text = total End Sub
Private Sub uni4() If nt46109015.Text.Length = 0 Then MsgBox("Isi Notransnya..") Exit Sub End If
If jt46109015.Text.Length = 0 Then MsgBox("Isi Jenis Transaksinya..") Exit Sub End If
If dt.Rows.Count = 0 Then MsgBox("Isi datatable k..") Exit Sub End If End Sub
Private Sub tambah() uni4() uni.AturPencarianDataBase("mastertransaksi", "notrans", nt46109015.Text, 1, imah) If uni.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each x As DataRow In dt.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109015.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", imah) imah.Open() cm.ExecuteNonQuery() imah.Close() Next cm.Dispose()
Public Sub edit() uni4() If nt46109015.Text <> StatusStrip1.Text Then uni.AturPencarianDataBase("mastertransaksi", "notrans", nt46109015.Text, 1, imah) If uni.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 = '" & StatusStrip1.Text & "'", imah) imah.Open() cm.ExecuteNonQuery() imah.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip1.Text & "'", imah) imah.Open() cm.ExecuteNonQuery() imah.Close()
For Each x As DataRow In dt.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt46109015.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", imah) imah.Open() cm.ExecuteNonQuery() imah.Close() Next cm.Dispose()
Private Sub dgv_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv46109015.CellEndEdit If dgv46109015.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
uni.AturPencarianDataBase("barang", "kodebarang", dgv46109015.CurrentRow.Cells("KODEBARANG").Value, 1, imah) If uni.JumlanBaris > 0 Then dgv46109015.CurrentRow.Cells("NAMABARANG").Value = uni.DataTablenya.Rows(0).Item("NAMABARANG") Else dgv46109015.CurrentRow.Cells("NAMABARANG").Value = "" If Latihan383940_46109015.ShowDialog = Windows.Forms.DialogResult.OK Then dgv46109015.CurrentRow.Cells("KODEBARANG").Value = Latihan383940_46109015.dgv46109015.CurrentRow.Cells("KODEBARANG").Value dgv46109015.CurrentRow.Cells("NAMABARANG").Value = Latihan383940_46109015.dgv46109015.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf dgv46109015.Columns(e.ColumnIndex).Name = "UNIT" Or dgv46109015.Columns(e.ColumnIndex).Name = "HARGA" Then dgv46109015.CurrentRow.Cells("JUMLAH").Value = dgv46109015.CurrentRow.Cells("UNIT").Value * dgv46109015.CurrentRow.Cells("HARGA").Value uni3() End If End Sub
Private Sub Simpan_46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_46109015.Click If StatusStrip1.Text = "-" Then tambah() Else edit() End If End Sub
Private Sub dgv46109015_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgv46109015.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub End Class
Private Sub tambah() diva4() diva.AturPencarianDataBase("mastertransaksi", "notrans", nt46109043.Text, 1, fara) If diva.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each x As DataRow In dt.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109043.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", fara) fara.Open() cm.ExecuteNonQuery() fara.Close() Next cm.Dispose()
Public Sub edit() diva4() If nt46109043.Text <> StatusStrip1.Text Then diva.AturPencarianDataBase("mastertransaksi", "notrans", nt46109043.Text, 1, fara) If diva.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 = '" & StatusStrip1.Text & "'", fara) fara.Open() cm.ExecuteNonQuery() fara.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip1.Text & "'", fara) fara.Open() cm.ExecuteNonQuery() fara.Close()
For Each x As DataRow In dt.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt46109043.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", fara) fara.Open() cm.ExecuteNonQuery() fara.Close() Next cm.Dispose()
Public Class Latihan_40B_46109044 Dim hma As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/dataMajemuk.accdb") Dim dt As New DataTable Dim syahril As New ByIskandar.CariKeDataBaseByIskandar Dim cm As New OleDb.OleDbCommand
Public Sub syahril2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & NT46109044.Text & "'", hma) dt.Rows.Clear() a.Fill(dt) End Sub
Public Sub syahril3() Dim total As Integer = 0 For Each x As DataRow In dt.Rows total += x("Jumlah") Next TOT46109044.Text = total End Sub
Private Sub syahril4() If NT46109044.Text.Length = 0 Then MsgBox("Isi rong itu Notransnya..") Exit Sub End If
If JT46109044.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() syahril4() syahril.AturPencarianDataBase("mastertransaksi", "notrans", NT46109044.Text, 1, hma) If syahril.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If
For Each x As DataRow In dt.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & NT46109044.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", hma) hma.Open() cm.ExecuteNonQuery() hma.Close() Next cm.Dispose()
Public Sub edit() syahril4() If NT46109044.Text <> ff.Text Then syahril.AturPencarianDataBase("mastertransaksi", "notrans", NT46109044.Text, 1, hma) If syahril.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 = '" & ff.Text & "'", hma) hma.Open() cm.ExecuteNonQuery() hma.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ff.Text & "'", hma) hma.Open() cm.ExecuteNonQuery() hma.Close()
For Each x As DataRow In dt.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & NT46109044.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", hma) hma.Open() cm.ExecuteNonQuery() hma.Close() Next cm.Dispose()
Private Sub dgv_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV46109044.CellEndEdit If DGV46109044.Columns(e.ColumnIndex).Name = "KODEBARANG" Then 'If dgv.CurrentRow.Cells(0) = "KODEBARANG" Then (rumus lain)
'untuk mencari nama barang DGV46109044.CurrentRow.Cells("NAMABARANG").Value = "" DGV46109044.CurrentRow.Cells("UNIT").Value = 0 DGV46109044.CurrentRow.Cells("HARGA").Value = 0 DGV46109044.CurrentRow.Cells("JUMLAH").Value = 0
syahril.AturPencarianDataBase("barang", "kodebarang", DGV46109044.CurrentRow.Cells("KODEBARANG").Value, 1, hma) If syahril.JumlanBaris > 0 Then '(menampilkan nama barang jika kolom kode barang ditemukan oleh proses di atas DGV46109044.CurrentRow.Cells("NAMABARANG").Value = syahril.DataTablenya.Rows(0).Item("NAMABARANG") Else DGV46109044.CurrentRow.Cells("NAMABARANG").Value = "" If Latihan_38_39_40_46109044.ShowDialog = Windows.Forms.DialogResult.OK Then DGV46109044.CurrentRow.Cells("KODEBARANG").Value = Latihan_38_39_40_46109044.DGV46109044.CurrentRow.Cells("KODEBARANG").Value DGV46109044.CurrentRow.Cells("NAMABARANG").Value = Latihan_38_39_40_46109044.DGV46109044.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf DGV46109044.Columns(e.ColumnIndex).Name = "UNIT" Or DGV46109044.Columns(e.ColumnIndex).Name = "HARGA" Then DGV46109044.CurrentRow.Cells("JUMLAH").Value = DGV46109044.CurrentRow.Cells("UNIT").Value * DGV46109044.CurrentRow.Cells("HARGA").Value syahril3() End If End Sub
Private Sub ee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S46109044.Click If ff.Text = "-" Then tambah() Else edit() End If End Sub
Private Sub dgv_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DGV46109044.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub End Class
Public Class Latihan_40A_46109044 Dim hma 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 ds As New DataSet Dim bs1 As New BindingSource Dim bs2 As New BindingSource
Public Sub syahril1() Dim a As New OleDb.OleDbDataAdapter dt2.Rows.Clear() dt1.Rows.Clear() a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", hma) a.Fill(dt1) a = 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", hma) a.Fill(dt2) End Sub
Private Sub Latihan_40A_46109044_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load syahril1()
Private Sub H46109044_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles H46109044.Click Dim cm As New OleDb.OleDbCommand cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv146109044.CurrentRow.Cells("notrans").Value & "'", hma) hma.Open() cm.ExecuteNonQuery() hma.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv146109044.CurrentRow.Cells("notrans").Value & "'", hma) hma.Open() cm.ExecuteNonQuery() hma.Close() cm.Dispose() syahril1() End Sub
Private Sub T46109044_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T46109044.Click If Latihan_40B_46109044.Visible = False Then Latihan_40B_46109044.Show() Else Latihan_40B_46109044.Activate() End If
Latihan_40B_46109044.syahril2() Latihan_40B_46109044.syahril3() End Sub
Private Sub E46109044_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles E46109044.Click If Latihan_40B_46109044.Visible = False Then Latihan_40B_46109044.Show() Else Latihan_40B_46109044.Activate() End If
Private Sub dgv46109046_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv46109046.CellEndEdit If dgv46109046.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
amhy.AturPencarianDataBase("barang", "kodebarang", dgv46109046.CurrentRow.Cells("KODEBARANG").Value, 1, asmi) If amhy.JumlanBaris > 0 Then dgv46109046.CurrentRow.Cells("NAMABARANG").Value = amhy.DataTablenya.Rows(0).Item("NAMABARANG") Else dgv46109046.CurrentRow.Cells("NAMABARANG").Value = "" If latihan38_39_40_46109046.ShowDialog = Windows.Forms.DialogResult.OK Then dgv46109046.CurrentRow.Cells("KODEBARANG").Value = latihan38_39_40_46109046.dgv46109046.CurrentRow.Cells("KODEBARANG").Value dgv46109046.CurrentRow.Cells("NAMABARANG").Value = latihan38_39_40_46109046.dgv46109046.CurrentRow.Cells("NAMABARANG").Value End If End If
dgv46109046.Columns(e.ColumnIndex).Name = "UNIT" Or dgv46109046.Columns(e.ColumnIndex).Name = "HARGA" Then dgv46109046.CurrentRow.Cells("JUMLAH").Value = dgv46109046.CurrentRow.Cells("UNIT").Value * dgv46109046.CurrentRow.Cells("HARGA").Value amhy3() End If End Sub
Private Sub Button146109046_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109046.Click If StatusStrip1.Text = "-" Then tambah() Else edit() End If End Sub
Private Sub dgv46109046_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgv46109046.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub End Class
LATIHAN40B46109026.ibhe3() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If LATIHAN40B46109026.Visible = False Then LATIHAN40B46109026.Show() Else LATIHAN40B46109026.Activate() End If
Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=26") Dim ibeng As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim cm As New OleDb.OleDbCommand Public Sub ibhe2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & nomor46109026.Text & "'", CONECT) ibeng.Rows.Clear() a.Fill(ibeng) End Sub Public Sub ibhe3() Dim total As Integer = 0 For Each x As DataRow In ibeng.Rows total += x("Jumlah") Next total46109026.Text = total End Sub Private Sub ibhe4() If nomor46109026.Text.Length = 0 Then MsgBox("Isi Notransnya..") Exit Sub End If
If jenis46109026.Text.Length = 0 Then MsgBox("Isi Jenis Transaksinya..") Exit Sub End If
If ibeng.Rows.Count = 0 Then MsgBox("Isi datatable k..") Exit Sub End If End Sub Private Sub tambah() ibhe4() cari.AturPencarianDataBase("mastertransaksi", "notrans", nomor46109026.Text, 1, CONECT) If cari.JumlanBaris > 0 Then MsgBox("sudah ada notrans seperti itu..") Exit Sub End If
For Each x As DataRow In ibeng.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nomor46109026.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", CONECT)
CONECT.Open() cm.ExecuteNonQuery() CONECT.Close() Next cm.Dispose()
Private Sub data46109026_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles data46109026.CellEndEdit If data46109026.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
cari.AturPencarianDataBase("barang", "kodebarang", data46109026.CurrentRow.Cells("KODEBARANG").Value, 1, CONECT) If cari.JumlanBaris > 0 Then data46109026.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else data46109026.CurrentRow.Cells("NAMABARANG").Value = "" If latihan3839400026.ShowDialog = Windows.Forms.DialogResult.OK Then data46109026.CurrentRow.Cells("KODEBARANG").Value = latihan3839400026.DATA46109026.CurrentRow.Cells("KODEBARANG").Value data46109026.CurrentRow.Cells("NAMABARANG").Value = latihan3839400026.DATA46109026.CurrentRow.Cells("NAMABARANG").Value End If End If
ElseIf data46109026.Columns(e.ColumnIndex).Name = "UNIT" Or data46109026.Columns(e.ColumnIndex).Name = "HARGA" Then data46109026.CurrentRow.Cells("JUMLAH").Value = data46109026.CurrentRow.Cells("UNIT").Value * data46109026.CurrentRow.Cells("HARGA").Value ibhe3() End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If StatusStrip46109026.Text = "-" Then tambah() Else edit() End If End Sub Private Sub data46109026_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles data46109026.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub
Public Class tugas40b46109033 Dim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=033") Dim tofiq As New DataTable Dim cari As New ByIskandar.CariKeDataBaseByIskandar Dim cm As New OleDb.OleDbCommand Public Sub tm2() Dim a As New OleDb.OleDbDataAdapter a = 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 = '" & nt46109033.Text & "'", CONECT) tofiq.Rows.Clear() a.Fill(tofiq) End Sub Public Sub tm3() Dim total As Integer = 0 For Each x As DataRow In tofiq.Rows total += x("Jumlah") Next tot46109033.Text = total End Sub Private Sub tm4() If nt46109033.Text.Length = 0 Then MsgBox("Isi Notransnya..") Exit Sub End If If jt46109033.Text.Length = 0 Then MsgBox("Isi Jenis Transaksinya..") Exit Sub End If If tofiq.Rows.Count = 0 Then MsgBox("Isi datatable k..") Exit Sub End If End Sub Private Sub tambah() tm4() cari.AturPencarianDataBase("mastertransaksi", "notrans", nt46109033.Text, 1, CONECT) If cari.JumlanBaris > 0 Then MsgBox("Adami notrans seperti itu..") Exit Sub End If cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109033.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt46109033.Text & "')", CONECT) CONECT.Open() cm.ExecuteNonQuery() CONECT.Close()
For Each x As DataRow In tofiq.Rows cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109033.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", CONECT) CONECT.Open() cm.ExecuteNonQuery() CONECT.Close() Next cm.Dispose() nt46109033.Text = "" jt46109033.Text = "" tot46109033.Text = "" StatusStrip46109033.Text = "-" tofiq.Rows.Clear() TUGAS40A46109033.tofiq() End Sub
Private Sub datagridview1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit If DataGridView1.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, CONECT) If cari.JumlanBaris > 0 Then DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG") Else DataGridView1.CurrentRow.Cells("NAMABARANG").Value = "" If tugas38394046109033.ShowDialog = Windows.Forms.DialogResult.OK Then DataGridView1.CurrentRow.Cells("KODEBARANG").Value = tugas38394046109033.DataGridView146109033.CurrentRow.Cells("KODEBARANG").Value DataGridView1.CurrentRow.Cells("NAMABARANG").Value = tugas38394046109033.DataGridView146109033.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 tm3() End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If StatusStrip46109033.Text = "-" Then tambah() Else edit() End If End Sub Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError MsgBox("Terjadi sedikit kesalahan...") End Sub
Sambungan latihan40b_46109035
BalasHapusTOTALJUMLAH()
End Sub
Private Sub bt1_46109035_bt2_46109035()
If nt_46109035.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt_46109035.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 StatusStrip1.Text <> nt_46109035.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_46109035.Text, 1, Asrini)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_46109035.Text & "', #" & dtp_46109035.Value.Month & "/" & dtp_46109035.Value.Day & "/" & dtp_46109035.Value.Year & "#, '" & jt_46109035.Text & "')", Asrini)
Asrini.Open()
T.ExecuteNonQuery()
Asrini.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_46109035.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", Asrini)
Asrini.Open()
T.ExecuteNonQuery()
Asrini.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
nt_46109035.Text = ""
jt_46109035.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40a_46109035.diaz()
End Sub
Private Sub Button1_edit()
If nt_46109035.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt_46109035.Text.Length = 0 Then
BalasHapusMsgBox("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 StatusStrip1.Text <> nt_46109035.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt_46109035.Text, 1, Asrini)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & nt_46109035.Text & "'", Asrini)
Asrini.Open()
T.ExecuteNonQuery()
Asrini.Close()
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt_46109035.Text & "', #" & dtp_46109035.Value.Month & "/" & dtp_46109035.Value.Day & "/" & dtp_46109035.Value.Year & "#, '" & jt_46109035.Text & "')", Asrini)
Asrini.Open()
T.ExecuteNonQuery()
Asrini.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & nt_46109035.Text & "'", Asrini)
Asrini.Open()
T.ExecuteNonQuery()
Asrini.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt_46109035.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", Asrini)
Asrini.Open()
T.ExecuteNonQuery()
Asrini.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
nt_46109035.Text = ""
jt_46109035.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40a_46109035.diaz()
End Sub
Private Sub bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt1_46109035.Click
If StatusStrip1.Text = "-" Then
bt1_46109035_bt2_46109035()
Else
Button1_edit()
End If
End Sub
End Class
FARADILLAH AMALIA RIVAI
BalasHapusLATIHAN 40 A
Public Class LATIHAN040A_46109010
Dim faradillah As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46")
Dim fara1 As New DataTable
Dim fara2 As New DataTable
Dim dset As New DataSet
Dim bs1 As New BindingSource
Dim bs2 As New BindingSource
Public Sub faradillahrivai()
Dim a As New OleDb.OleDbDataAdapter
fara2.Rows.Clear()
fara1.Rows.Clear()
a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", faradillah)
a.Fill(fara1)
a = 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", faradillah)
a.Fill(fara2)
End Sub
Private Sub latihan040A_46109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
faradillahrivai()
dset.Tables.Add(fara1)
dset.Tables.Add(fara2)
fara1.TableName = "farah"
fara2.TableName = "farah2"
dset.Relations.Add(New DataRelation("a", dset.Tables("farah").Columns("NOTRANS"), dset.Tables("farah2").Columns("NOTRANS")))
bs1.DataSource = dset
bs1.DataMember = "farah"
bs2.DataSource = bs1
bs2.DataMember = "a"
Dim dc(1) As DataColumn
dc(0) = fara1.Columns("NOTRANS")
fara1.PrimaryKey = dc
dgv146109010.DataSource = bs1
dgv246109010.DataSource = bs2
End Sub
Private Sub hapus46109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus46109010.Click
Dim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv146109010.CurrentRow.Cells("notrans").Value & "'", faradillah)
faradillah.Open()
cm.ExecuteNonQuery()
faradillah.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv146109010.CurrentRow.Cells("notrans").Value & "'", faradillah)
faradillah.Open()
cm.ExecuteNonQuery()
faradillah.Close()
cm.Dispose()
faradillahrivai()
End Sub
LANJUTAN LATIHAN 40 A BY FARADILLAH AMALIA RIVAI
BalasHapusPrivate Sub tambah46109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tambah46109010.Click
If LATIHAN040B_46109010.Visible = False Then
LATIHAN040B_46109010.Show()
Else
LATIHAN040B_46109010.Activate()
End If
LATIHAN040B_46109010.nt46109010.Text = ""
LATIHAN040B_46109010.jt46109010.Text = ""
LATIHAN040B_46109010.Statusstrip46109010.Text = "-"
LATIHAN040B_46109010.faradillahrivai2()
LATIHAN040B_46109010.faradillahrivai3()
End Sub
Private Sub edit46109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles edit46109010.Click
If LATIHAN040B_46109010.Visible = False Then
LATIHAN040B_46109010.Show()
Else
LATIHAN040B_46109010.Activate()
End If
LATIHAN040B_46109010.nt46109010.Text = dgv146109010.CurrentRow.Cells("notrans").Value
LATIHAN040B_46109010.dtp46109010.Value = dgv146109010.CurrentRow.Cells("tanggaltransaksi").Value
LATIHAN040B_46109010.jt46109010.Text = dgv146109010.CurrentRow.Cells("jenistransaksi").Value
LATIHAN040B_46109010.Statusstrip46109010.Text = dgv146109010.CurrentRow.Cells("notrans").Value
LATIHAN040B_46109010.faradillahrivai2()
LATIHAN040B_46109010.faradillahrivai3()
End Sub
End Class
FARADILLAH AMALIA RIVAI
BalasHapusLATIHAN 40 B
Public Class LATIHAN040B_46109010
Dim faradillah As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46")
Dim fara As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Public Sub faradillahrivai2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & nt46109010.Text & "'", faradillah)
fara.Rows.Clear()
a.Fill(fara)
End Sub
Public Sub faradillahrivai3()
Dim total As Integer = 0
For Each x As DataRow In fara.Rows
total += x("Jumlah")
Next
Tot46109010.Text = total
End Sub
Private Sub faradillahrivai4()
If nt46109010.Text.Length = 0 Then
MsgBox("Isi Notransnya..")
Exit Sub
End If
If jt46109010.Text.Length = 0 Then
MsgBox("Isi Jenis Transaksinya..")
Exit Sub
End If
If fara.Rows.Count = 0 Then
MsgBox("Isi datatable k..")
Exit Sub
End If
End Sub
LANJUTAN LATIHAN 40 B BY FARADILLAH AMALIA RIVAI
BalasHapusPrivate Sub faradillahrivai4()
If nt46109010.Text.Length = 0 Then
MsgBox("Isi Notransnya..")
Exit Sub
End If
If jt46109010.Text.Length = 0 Then
MsgBox("Isi Jenis Transaksinya..")
Exit Sub
End If
If fara.Rows.Count = 0 Then
MsgBox("Isi datatable k..")
Exit Sub
End If
End Sub
Private Sub tambah()
faradillahrivai4()
cari.AturPencarianDataBase("mastertransaksi", "notrans", nt46109010.Text, 1, faradillah)
If cari.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109010.Text & "',#" & dtp46109010.Value.Month & "/" & dtp46109010.Value.Day & "/" & dtp46109010.Value.Year & "#, '" & jt46109010.Text & "')", faradillah)
faradillah.Open()
cm.ExecuteNonQuery()
faradillah.Close()
For Each x As DataRow In fara.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109010.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", faradillah)
faradillah.Open()
cm.ExecuteNonQuery()
faradillah.Close()
Next
cm.Dispose()
nt46109010.Text = ""
jt46109010.Text = ""
Tot46109010.Text = ""
Statusstrip46109010.Text = "-"
fara.Rows.Clear()
LATIHAN040A_46109010.faradillahrivai()
End Sub
LANJUTAN LATIHAN 40 B BY FARADILLAH AMALIA RIVAI
BalasHapusPublic Sub edit()
faradillahrivai4()
If nt46109010.Text <> Statusstrip46109010.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", nt46109010.Text, 1, faradillah)
If cari.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 = '" & Statusstrip46109010.Text & "'", faradillah)
faradillah.Open()
cm.ExecuteNonQuery()
faradillah.Close()
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109010.Text & "',#" & dtp46109010.Value.Month & "/" & dtp46109010.Value.Day & "/" & dtp46109010.Value.Year & "#, '" & jt46109010.Text & "')", faradillah)
faradillah.Open()
cm.ExecuteNonQuery()
faradillah.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & Statusstrip46109010.Text & "'", faradillah)
faradillah.Open()
cm.ExecuteNonQuery()
faradillah.Close()
For Each x As DataRow In fara.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt46109010.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", faradillah)
faradillah.Open()
cm.ExecuteNonQuery()
faradillah.Close()
Next
cm.Dispose()
nt46109010.Text = ""
jt46109010.Text = ""
Tot46109010.Text = ""
Statusstrip46109010.Text = "-"
fara.Rows.Clear()
LATIHAN040A_46109010.faradillahrivai()
End Sub
Private Sub latihan040B_46109010_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
faradillahrivai2()
Dim dc(1) As DataColumn
dc(0) = fara.Columns("kodebarang")
fara.PrimaryKey = dc
fara.Columns("unit").DefaultValue = 0
fara.Columns("harga").DefaultValue = 0
fara.Columns("jumlah").DefaultValue = 0
dtg46109010.DataSource = fara
End Sub
LANJUTAN 40 B BY FARADILLAH AMALIA RIVAI
BalasHapusPrivate Sub dtg46109010_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dtg46109010.CellEndEdit
If dtg46109010.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
dtg46109010.CurrentRow.Cells("NAMABARANG").Value = ""
dtg46109010.CurrentRow.Cells("UNIT").Value = 0
dtg46109010.CurrentRow.Cells("HARGA").Value = 0
dtg46109010.CurrentRow.Cells("JUMLAH").Value = 0
cari.AturPencarianDataBase("barang", "kodebarang", dtg46109010.CurrentRow.Cells("KODEBARANG").Value, 1, faradillah)
If cari.JumlanBaris > 0 Then
dtg46109010.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dtg46109010.CurrentRow.Cells("NAMABARANG").Value = ""
If Latihan383940_46109010.ShowDialog = Windows.Forms.DialogResult.OK Then
dtg46109010.CurrentRow.Cells("KODEBARANG").Value = Latihan383940_46109010.DGV46109010.CurrentRow.Cells("KODEBARANG").Value
dtg46109010.CurrentRow.Cells("NAMABARANG").Value = Latihan383940_46109010.DGV46109010.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf dtg46109010.Columns(e.ColumnIndex).Name = "UNIT" Or dtg46109010.Columns(e.ColumnIndex).Name = "HARGA" Then
dtg46109010.CurrentRow.Cells("JUMLAH").Value = dtg46109010.CurrentRow.Cells("UNIT").Value * dtg46109010.CurrentRow.Cells("HARGA").Value
faradillahrivai3()
End If
End Sub
Private Sub simpan46109010_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan46109010.Click
If Statusstrip46109010.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub dtg46109010_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dtg46109010.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class
Public Class TUGAS40A
BalasHapusDim SRY As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.accdb;Jet OLEDB:Database Password=11")
Dim REJEKI1 As New DataTable
Dim REJEKI2 As New DataTable
Dim CARI As New ByIskandar.CariKeDataBaseByIskandar
Public Sub KIKIE1()
Dim r As New OleDb.OleDbDataAdapter
REJEKI1.Rows.Clear()
REJEKI1.Rows.Clear()
r = New OleDb.OleDbDataAdapter("select * from mastertransaksi", SRY)
r.Fill(REJEKI1)
r = 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", SRY)
r.Fill(REJEKI2)
End Sub
Private Sub TUGAS40_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim DS As New DataSet
Dim BS1 As New BindingSource
Dim BS2 As New BindingSource
KIKIE1()
DS.Tables.Add(REJEKI1)
DS.Tables.Add(REJEKI2)
REJEKI1.TableName = "QIQI1"
REJEKI2.TableName = "QIQI2"
DS.Relations.Add(New DataRelation("Z", DS.Tables("QIQI1").Columns("notrans"), DS.Tables("QIQI2").Columns("notrans")))
BS1.DataSource = DS
BS1.DataMember = "QIQI1"
bs2.DataSource = bs1
BS2.DataMember = "Z"
Dim dc(1) As DataColumn
dc(0) = REJEKI1.Columns("notrans")
REJEKI1.PrimaryKey = dc
DGV146109006.DataSource = BS1
DGV246109006.DataSource = BS2
End Sub
Private Sub TOMBOL1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL1.Click
If TUGAS40B.Visible = False Then
TUGAS40B.Show()
Else
TUGAS40B.Activate()
End If
TUGAS40B.T146109006.Text = ""
TUGAS40B.T246109006.Text = ""
TUGAS40B.TS46109006.Text = "-"
TUGAS40B.KIKIE2()
TUGAS40B.KIKIE3()
End Sub
LANJUTAN 40A
BalasHapusPrivate Sub TOMBOL2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL2.Click
If TUGAS40B.Visible = False Then
TUGAS40B.Show()
Else
TUGAS40B.Activate()
End If
TUGAS40B.T146109006.Text = DGV146109006.CurrentRow.Cells("notrans").Value
TUGAS40B.DATE46109006.Value = DGV146109006.CurrentRow.Cells("tanggaltransaksi").Value
TUGAS40B.T246109006.Text = DGV146109006.CurrentRow.Cells("jenistransaksi").Value
TUGAS40B.TS46109006.Text = DGV146109006.CurrentRow.Cells("notrans").Value
TUGAS40B.KIKIE2()
TUGAS40B.KIKIE3()
End Sub
Private Sub TOMBOL3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL3.Click
Dim KI2 As New OleDb.OleDbCommand
KI2 = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & DGV146109006.CurrentRow.Cells("notrans").Value & "'", SRY)
SRY.Open()
KI2.ExecuteNonQuery()
SRY.Close()
KI2 = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & DGV146109006.CurrentRow.Cells("notrans").Value & "'", SRY)
SRY.Open()
KI2.ExecuteNonQuery()
SRY.Close()
KI2.Dispose()
KIKIE1()
End Sub
End Class
Public Class TUGAS40B
BalasHapusDim SRY As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DataMajemuk.aT246109006db;Jet OLEDB:Database Password=11")
Dim REJEKI As New DataTable
Dim CARI As New ByIskandar.CariKeDataBaseByIskandar
Dim QQ As New OleDb.OleDbCommand
Public Sub KIKIE2()
Dim Q As New OleDb.OleDbDataAdapter
Q = 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 = '" & T146109006.Text & "'", SRY)
REJEKI.Rows.Clear()
Q.Fill(REJEKI)
End Sub
Public Sub KIKIE3()
Dim total As Integer = 0
For Each x As DataRow In REJEKI.Rows
total += x("Jumlah")
Next
TOT46109006.Text = total
End Sub
Private Sub KIKIE4()
If T146109006.Text.Length = 0 Then
MsgBox("no.transaksi belum terisi")
Exit Sub
End If
If T246109006.Text.Length = 0 Then
MsgBox("jenis transaksi belum terisi")
Exit Sub
End If
If REJEKI.Rows.Count = 0 Then
MsgBox("Data tidak tersedia")
Exit Sub
End If
End Sub
Private Sub tambah()
KIKIE4()
CARI.AturPencarianDataBase("mastertransaksi", "notrans", T146109006.Text, 1, SRY)
If CARI.JumlanBaris > 0 Then
MsgBox("NO.TRANSAKSI sudah ada")
Exit Sub
End If
QQ = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & T146109006.Text & "',#" & DATE46109006.Value.Month & "/" & DATE46109006.Value.Day & "/" & DATE46109006.Value.Year & "#, '" & T246109006.Text & "')", SRY)
SRY.Open()
QQ.ExecuteNonQuery()
SRY.Close()
For Each x As DataRow In REJEKI.Rows
QQ = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & T146109006.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", SRY)
SRY.Open()
QQ.ExecuteNonQuery()
SRY.Close()
Next
QQ.Dispose()
T146109006.Text = ""
T246109006.Text = ""
TOT46109006.Text = ""
TS46109006.Text = "-"
REJEKI.Rows.Clear()
TUGAS40A.KIKIE1()
End Sub
LANJUTAN 40B
BalasHapusPublic Sub edit()
KIKIE4()
If T146109006.Text <> TS46109006.Text Then
CARI.AturPencarianDataBase("mastertransaksi", "notrans", T146109006.Text, 1, SRY)
If CARI.JumlanBaris > 0 Then
MsgBox("Adami Notrans seperti itu,,mohon ganti..")
Exit Sub
End If
End If
QQ = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & TS46109006.Text & "'", SRY)
SRY.Open()
QQ.ExecuteNonQuery()
SRY.Close()
QQ = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & T146109006.Text & "',#" & DATE46109006.Value.Month & "/" & DATE46109006.Value.Day & "/" & DATE46109006.Value.Year & "#, '" & T246109006.Text & "')", SRY)
SRY.Open()
QQ.ExecuteNonQuery()
SRY.Close()
QQ = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & TS46109006.Text & "'", SRY)
SRY.Open()
QQ.ExecuteNonQuery()
SRY.Close()
For Each x As DataRow In REJEKI.Rows
QQ = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & T146109006.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", SRY)
SRY.Open()
QQ.ExecuteNonQuery()
SRY.Close()
Next
QQ.Dispose()
T146109006.Text = ""
T246109006.Text = ""
TOT46109006.Text = ""
TS46109006.Text = "-"
REJEKI.Rows.Clear()
TUGAS40A.KIKIE1()
End Sub
Private Sub TUGAS40B_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
KIKIE2()
Dim dc(1) As DataColumn
dc(0) = REJEKI.Columns("kodebarang")
REJEKI.PrimaryKey = dc
REJEKI.Columns("unit").DefaultValue = 0
REJEKI.Columns("harga").DefaultValue = 0
REJEKI.Columns("jumlah").DefaultValue = 0
DGV46109006.DataSource = REJEKI
End Sub
LANJUTAN 2 40B
BalasHapusPrivate Sub DGV46109006_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV46109006.CellEndEdit
If DGV46109006.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DGV46109006.CurrentRow.Cells("NAMABARANG").Value = ""
DGV46109006.CurrentRow.Cells("UNIT").Value = 0
DGV46109006.CurrentRow.Cells("HARGA").Value = 0
DGV46109006.CurrentRow.Cells("JUMLAH").Value = 0
CARI.AturPencarianDataBase("barang", "kodebarang", DGV46109006.CurrentRow.Cells("KODEBARANG").Value, 1, SRY)
If CARI.JumlanBaris > 0 Then
DGV46109006.CurrentRow.Cells("NAMABARANG").Value = CARI.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV46109006.CurrentRow.Cells("NAMABARANG").Value = ""
If TUGAS383940.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV46109006.CurrentRow.Cells("KODEBARANG").Value = TUGAS383940.DGV46109006.CurrentRow.Cells("KODEBARANG").Value
DGV46109006.CurrentRow.Cells("NAMABARANG").Value = TUGAS383940.DGV46109006.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DGV46109006.Columns(e.ColumnIndex).Name = "UNIT" Or DGV46109006.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV46109006.CurrentRow.Cells("JUMLAH").Value = DGV46109006.CurrentRow.Cells("UNIT").Value * DGV46109006.CurrentRow.Cells("HARGA").Value
KIKIE3()
End If
End Sub
Private Sub TOMBOL1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TOMBOL1.Click
If TS46109006.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub DGV46109006_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DGV46109006.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class
Public Class Latihan40A46109047
BalasHapusDim Muhitha As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=12345")
Dim dt As New DataTable
Dim dt1 As New DataTable
Dim dset As New DataSet
Dim Bsource1 As New BindingSource
Dim Bsource2 As New BindingSource
Public Sub itha()
dt1.Rows.Clear()
dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter
B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", Muhitha)
B1.Fill(dt)
B1 = 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", Muhitha)
B1.Fill(dt1)
B1.Dispose()
End Sub
Private Sub Latihan40A46109047_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
itha()
dset.Tables.Add(dt)
dset.Tables.Add(dt1)
dt.TableName = "T01"
dt1.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"
dgv146109047.DataSource = Bsource1
dgv246109047.DataSource = Bsource2
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & dgv146109047.CurrentRow.Cells("NOTRANS").Value & "'", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & dgv146109047.CurrentRow.Cells("NOTRANS").Value & "'", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
T.Dispose()
itha()
End Sub
Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
BalasHapusIf Latihan40B46109047.Visible = False Then
Latihan40B46109047.Show()
Else
Latihan40B46109047.Activate()
End If
Latihan40B46109047.StatusStrip1.Text = dgv146109047.CurrentRow.Cells("NOTRANS").Value
Latihan40B46109047.nt46109047.Text = dgv146109047.CurrentRow.Cells("NOTRANS").Value
Latihan40B46109047.jt46109047.Text = dgv146109047.CurrentRow.Cells("JENISTRANSAKSI").Value
Latihan40B46109047.faster()
Latihan40B46109047.TOTALJUMLAH()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Latihan40B46109047.Visible = False Then
Latihan40B46109047.Show()
Else
Latihan40B46109047.Activate()
End If
Latihan40B46109047.StatusStrip1.Text = "-"
Latihan40B46109047.nt46109047.Text = ""
Latihan40B46109047.jt46109047.Text = ""
Latihan40B46109047.faster()
Latihan40B46109047.TOTALJUMLAH()
End Sub
End Class
Public Class Latihan40B46109047
BalasHapusDim Muhitha As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=12345")
Dim DATA As New DataTable
Public Sub faster()
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= '" & nt46109047.Text & "'", Muhitha)
DATA.Rows.Clear()
X.Fill(DATA)
End Sub
Private Sub Latihan40B46109047_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
dgv46109047.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
Tot46109047.Text = TOT
End Sub
Private Sub dgv46109047_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv46109047.CellContentClick
If dgv46109047.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
dgv46109047.CurrentRow.Cells("NAMABARANG").Value = ""
dgv46109047.CurrentRow.Cells("UNIT").Value = 0
dgv46109047.CurrentRow.Cells("HARGA").Value = 0
dgv46109047.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", dgv46109047.CurrentRow.Cells("KODEBARANG").Value, 1, Muhitha)
If Pencari.JumlanBaris > 0 Then
dgv46109047.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dgv46109047.CurrentRow.Cells("KODEBARANG").Value = ""
If Latihan3839400047.ShowDialog = Windows.Forms.DialogResult.OK Then
dgv46109047.CurrentRow.Cells("KODEBARANG").Value = Latihan3839400047.DGV46109047.CurrentRow.Cells("KODEBARANG").Value
dgv46109047.CurrentRow.Cells("NAMABARANG").Value = Latihan3839400047.DGV46109047.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf dgv46109047.Columns(e.ColumnIndex).Name = "UNIT" Or dgv46109047.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv46109047.CurrentRow.Cells("JUMLAH").Value = dgv46109047.CurrentRow.Cells("UNIT").Value * dgv46109047.CurrentRow.Cells("HARGA").Value
End If
TOTALJUMLAH()
End Sub
Private Sub Button1_Button2()
BalasHapusIf nt46109047.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt46109047.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 StatusStrip1.Text <> nt46109047.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109047.Text, 1, Muhitha)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt46109047.Text & "', #" & dtp46109047.Value.Month & "/" & dtp46109047.Value.Day & "/" & dtp46109047.Value.Year & "#, '" & jt46109047.Text & "')", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109047.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
nt46109047.Text = ""
jt46109047.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40A46109047.itha()
End Sub
Private Sub Button1_edit()
BalasHapusIf nt46109047.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt46109047.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 StatusStrip1.Text <> nt46109047.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109047.Text, 1, Muhitha)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & nt46109047.Text & "'", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt46109047.Text & "', #" & dtp46109047.Value.Month & "/" & dtp46109047.Value.Day & "/" & dtp46109047.Value.Year & "#, '" & jt46109047.Text & "')", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & nt46109047.Text & "'", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109047.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", Muhitha)
Muhitha.Open()
T.ExecuteNonQuery()
Muhitha.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
nt46109047.Text = ""
jt46109047.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40A46109047.itha()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If StatusStrip1.Text = "-" Then
Button1_Button2()
Else
Button1_edit()
End If
End Sub
End Class
Public Class LATIHAN040B_46109002
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=1234")
Dim wawan As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Public Sub riswan2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & nomor46109002.Text & "'", CONECT)
wawan.Rows.Clear()
a.Fill(wawan)
End Sub
Public Sub riswan3()
Dim total As Integer = 0
For Each x As DataRow In wawan.Rows
total += x("Jumlah")
Next
total46109002.Text = total
End Sub
Private Sub riswan4()
If nomor46109002.Text.Length = 0 Then
MsgBox("Isi Notransnya..")
Exit Sub
End If
If jenis46109002.Text.Length = 0 Then
MsgBox("Isi Jenis Transaksinya..")
Exit Sub
End If
If wawan.Rows.Count = 0 Then
MsgBox("Isi datatable k..")
Exit Sub
End If
End Sub
Private Sub tambah()
riswan4()
cari.AturPencarianDataBase("mastertransaksi", "notrans", nomor46109002.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nomor46109002.Text & "',#" & tanggal46109002.Value.Month & "/" & tanggal46109002.Value.Day & "/" & tanggal46109002.Value.Year & "#, '" & jenis46109002.Text & "')", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
For Each x As DataRow In wawan.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nomor46109002.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
Next
cm.Dispose()
nomor46109002.Text = ""
jenis46109002.Text = ""
total46109002.Text = ""
StatusStrip46109002.Text = "-"
wawan.Rows.Clear()
LATIHAN040A_46109002.riswan()
End Sub
Public Sub edit()
BalasHapusriswan4()
If nomor46109002.Text <> StatusStrip46109002.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", nomor46109002.Text, 1, CONECT)
If cari.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 = '" & StatusStrip46109002.Text & "'", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nomor46109002.Text & "',#" & tanggal46109002.Value.Month & "/" & tanggal46109002.Value.Day & "/" & tanggal46109002.Value.Year & "#, '" & jenis46109002.Text & "')", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip46109002.Text & "'", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
For Each x As DataRow In wawan.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nomor46109002.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
Next
cm.Dispose()
nomor46109002.Text = ""
jenis46109002.Text = ""
total46109002.Text = ""
StatusStrip46109002.Text = "-"
wawan.Rows.Clear()
LATIHAN040A_46109002.riswan()
End Sub
Private Sub LATIHAN040B_46109002_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
riswan2()
Dim dc(1) As DataColumn
dc(0) = wawan.Columns("kodebarang")
wawan.PrimaryKey = dc
wawan.Columns("unit").DefaultValue = 0
wawan.Columns("harga").DefaultValue = 0
wawan.Columns("jumlah").DefaultValue = 0
data46109002.DataSource = wawan
End Sub
Public Sub edit()
BalasHapusriswan4()
If nomor46109002.Text <> StatusStrip46109002.Text Then
cari.AturPencarianDataBase("mastertransaksi", "notrans", nomor46109002.Text, 1, CONECT)
If cari.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 = '" & StatusStrip46109002.Text & "'", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nomor46109002.Text & "',#" & tanggal46109002.Value.Month & "/" & tanggal46109002.Value.Day & "/" & tanggal46109002.Value.Year & "#, '" & jenis46109002.Text & "')", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip46109002.Text & "'", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
For Each x As DataRow In wawan.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nomor46109002.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
Next
cm.Dispose()
nomor46109002.Text = ""
jenis46109002.Text = ""
total46109002.Text = ""
StatusStrip46109002.Text = "-"
wawan.Rows.Clear()
LATIHAN040A_46109002.riswan()
End Sub
Private Sub LATIHAN040B_46109002_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
riswan2()
Dim dc(1) As DataColumn
dc(0) = wawan.Columns("kodebarang")
wawan.PrimaryKey = dc
wawan.Columns("unit").DefaultValue = 0
wawan.Columns("harga").DefaultValue = 0
wawan.Columns("jumlah").DefaultValue = 0
data46109002.DataSource = wawan
End Sub
PublicClass Latihan40B_46109050
BalasHapusDim CONECT AsNew OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= "& Application.StartupPath &"\DATAMAJEMUK.accdb;jet oledb:database Password=KYKY")
Dim DATA AsNew DataTable
PublicSub faster()
Dim X AsNew 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= '"& NT_46109050.Text &"'", CONECT)
DATA.Rows.Clear()
X.Fill(DATA)
EndSub
PrivateSub Latihan40B_46109050_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
Dim dataPrimary(1) As DataColumn
dataPrimary(0) = DATA.Columns("NOTRANS")
DATA.PrimaryKey = dataPrimary
DGV_46109050.DataSource = DATA
TOTALJUMLAH()
EndSub
PublicSub TOTALJUMLAH()
Dim TOT AsDouble = 0
ForEach x As DataRow In DATA.Rows
TOT = TOT + x("JUMLAH")
Next
TOT_46109050.Text = TOT
EndSub
PrivateSub DGV_46109050_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_46109050.CellContentClick
If DGV_46109050.Columns(e.ColumnIndex).Name = "KODEBARANG"Then
DGV_46109050.CurrentRow.Cells("NAMABARANG").Value = ""
DGV_46109050.CurrentRow.Cells("UNIT").Value = 0
DGV_46109050.CurrentRow.Cells("HARGA").Value = 0
DGV_46109050.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari AsNew ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DGV_46109050.CurrentRow.Cells("KODEBARANG").Value, 1, CONECT)
If Pencari.JumlanBaris > 0 Then
DGV_46109050.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV_46109050.CurrentRow.Cells("KODEBARANG").Value = ""
If Latihan383940_46109050.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV_46109050.CurrentRow.Cells("KODEBARANG").Value = Latihan383940_46109050.DGV_46109050.CurrentRow.Cells("KODEBARANG").Value
DGV_46109050.CurrentRow.Cells("NAMABARANG").Value = Latihan383940_46109050.DGV_46109050.CurrentRow.Cells("NAMABARANG").Value
EndIf
EndIf
ElseIf DGV_46109050.Columns(e.ColumnIndex).Name = "UNIT"Or DGV_46109050.Columns(e.ColumnIndex).Name = "HARGA"Then
DGV_46109050.CurrentRow.Cells("JUMLAH").Value = DGV_46109050.CurrentRow.Cells("UNIT").Value * DGV_46109050.CurrentRow.Cells("HARGA").Value
EndIf
TOTALJUMLAH()
EndSub
PrivateSub Button1_Button2()
If NT_46109050.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
ExitSub
EndIf
If JT_46109050.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
ExitSub
EndIf
If DATA.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
ExitSub
EndIf
If StatusStrip1.Text <> NT_46109050.Text Then
Dim pencari AsNew ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT_46109050.Text, 1, CONECT)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
ExitSub
EndIf
EndIf
Lanjutan Latihan40B:
BalasHapusDim T AsNew OleDb.OleDbCommand
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('"& NT_46109050.Text &"', #"& TGL_46109050.Value.Month &"/"&TGL_46109050.Value.Day &"/"& TGL_46109050.Value.Year &"#, '"& JT_46109050.Text &"')", CONECT)
CONECT.Open()
T.ExecuteNonQuery()
CONECT.Close()
ForEach X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('"& NT_46109050.Text &"', '"& X("KODEBARANG") &"',"& X("UNIT") &", "& X("HARGA") &")", CONECT)
CONECT.Open()
T.ExecuteNonQuery()
CONECT.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
NT_46109050.Text = ""
JT_46109050.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40A_46109050.kiki()
EndSub
PrivateSub Button1_edit()
If NT_46109050.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
ExitSub
EndIf
If JT_46109050.Text.Length = 0 Then
MsgBox("Maaf, Jenis transaksi harus diisi dulu")
ExitSub
EndIf
If DATA.Rows.Count() = 0 Then
MsgBox("Maaf, Proses tidak dapat dilanjutkan")
ExitSub
EndIf
If StatusStrip1.Text <> NT_46109050.Text Then
Dim pencari AsNew ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT_46109050.Text, 1, CONECT)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
ExitSub
EndIf
EndIf
Dim T AsNew OleDb.OleDbCommand
T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '"& NT_46109050.Text &"'", CONECT)
CONECT.Open()
T.ExecuteNonQuery()
CONECT.Close()
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('"& NT_46109050.Text &"', #"& TGL_46109050.Value.Month &"/"& TGL_46109050.Value.Day &"/"& TGL_46109050.Value.Year &"#, '"& JT_46109050.Text &"')", CONECT)
CONECT.Open()
T.ExecuteNonQuery()
CONECT.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '"& NT_46109050.Text &"'", CONECT)
CONECT.Open()
T.ExecuteNonQuery()
CONECT.Close()
ForEach XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('"& NT_46109050.Text &"', '"& XX("KODEBARANG") &"', "& XX("UNIT") &", "& XX("HARGA") &")", CONECT)
CONECT.Open()
T.ExecuteNonQuery()
CONECT.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
NT_46109050.Text = ""
JT_46109050.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40A_46109050.kiki()
EndSub
PrivateSub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If StatusStrip1.Text = "-"Then
Button1_Button2()
Else
Button1_edit()
EndIf
EndSub
EndClass
Public Class Latihan40b_46109004
BalasHapusDim yayu As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=Parandangi")
Dim DATA As New DataTable
Public Sub faster()
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= '" & nt46109004.Text & "'", yayu)
DATA.Rows.Clear()
X.Fill(DATA)
End Sub
Private Sub Latihan40b_46109004_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
dgv46109004.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
Tot46109004.Text = TOT
End Sub
Private Sub dgv46109004_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv46109004.CellContentClick
If dgv46109004.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
dgv46109004.CurrentRow.Cells("NAMABARANG").Value = ""
dgv46109004.CurrentRow.Cells("UNIT").Value = 0
dgv46109004.CurrentRow.Cells("HARGA").Value = 0
dgv46109004.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", dgv46109004.CurrentRow.Cells("KODEBARANG").Value, 1, yayu)
If Pencari.JumlanBaris > 0 Then
dgv46109004.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dgv46109004.CurrentRow.Cells("KODEBARANG").Value = ""
If Latihan383940004.ShowDialog = Windows.Forms.DialogResult.OK Then
dgv46109004.CurrentRow.Cells("KODEBARANG").Value = Latihan3839400004.DGV46109004.CurrentRow.Cells("KODEBARANG").Value
dgv46109004.CurrentRow.Cells("NAMABARANG").Value = Latihan3839400004.DGV46109004.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf dgv46109004.Columns(e.ColumnIndex).Name = "UNIT" Or dgv46109004.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv46109004.CurrentRow.Cells("JUMLAH").Value = dgv46109004.CurrentRow.Cells("UNIT").Value * dgv46109004.CurrentRow.Cells("HARGA").Value
End If
TOTALJUMLAH()
End Sub
Private Sub Button1_Button2()
If nt46109004.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt46109004.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 StatusStrip1.Text <> nt46109004.Text Then
BalasHapusDim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109004.Text, 1, yayu)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt46109004.Text & "', #" & dtp46109004.Value.Month & "/" & dtp46109004.Value.Day & "/" & dtp46109004.Value.Year & "#, '" & jt46109004.Text & "')", yayu)
yayu.Open()
T.ExecuteNonQuery()
yayu.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109004.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", yayu)
yayu.Open()
T.ExecuteNonQuery()
yayu.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
nt46109004.Text = ""
jt46109004.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40a_46109004.ayu()
End Sub
Private Sub Button1_edit()
If nt46109004.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If jt46109004.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 StatusStrip1.Text <> nt46109004.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", nt46109004.Text, 1, yayu)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & nt46109004.Text & "'", yayu)
yayu.Open()
T.ExecuteNonQuery()
yayu.Close()
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & nt46109004.Text & "', #" & dtp46109004.Value.Month & "/" & dtp46109004.Value.Day & "/" & dtp46109004.Value.Year & "#, '" & jt46109004.Text & "')", yayu)
yayu.Open()
T.ExecuteNonQuery()
yayu.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & nt46109004.Text & "'", yayu)
yayu.Open()
T.ExecuteNonQuery()
yayu.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & nt46109004.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", yayu)
yayu.Open()
T.ExecuteNonQuery()
yayu.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
nt46109004.Text = ""
jt46109004.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40A46109004.ayu()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If StatusStrip1.Text = "-" Then
Button1_Button2()
Else
Button1_edit()
End If
End Sub
End Class
andi muh. yusri
BalasHapusPublic Class Latihan40B_46109038
Dim conect As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=yusri")
Dim DATA As New DataTable
Public Sub uchy()
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= '" & NoTrans_46109038.Text & "'", conect)
DATA.Rows.Clear()
X.Fill(DATA)
End Sub
Private Sub Latihan40B_46109038_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
DGV_46109038.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
Total_46109038.Text = TOT
End Sub
Private Sub DGV_46109038_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_46109038.CellContentClick
If DGV_46109038.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DGV_46109038.CurrentRow.Cells("NAMABARANG").Value = ""
DGV_46109038.CurrentRow.Cells("UNIT").Value = 0
DGV_46109038.CurrentRow.Cells("HARGA").Value = 0
DGV_46109038.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DGV_46109038.CurrentRow.Cells("KODEBARANG").Value, 1, conect)
If Pencari.JumlanBaris > 0 Then
DGV_46109038.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV_46109038.CurrentRow.Cells("KODEBARANG").Value = ""
If Latihan38_39_40_46109038.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV_46109038.CurrentRow.Cells("KODEBARANG").Value = Latihan38_39_40_46109038.DGV46109047.CurrentRow.Cells("KODEBARANG").Value
DGV_46109038.CurrentRow.Cells("NAMABARANG").Value = Latihan38_39_40_46109038.DGV46109047.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DGV_46109038.Columns(e.ColumnIndex).Name = "UNIT" Or DGV_46109038.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV_46109038.CurrentRow.Cells("JUMLAH").Value = DGV_46109038.CurrentRow.Cells("UNIT").Value * DGV_46109038.CurrentRow.Cells("HARGA").Value
End If
TOTALJUMLAH()
End Sub
andi muh yusri
BalasHapussambungan
Private Sub Button1_Button2()
If NoTrans_46109038.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If JenTrans_46109038.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 StatusStrip1.Text <> NoTrans_46109038.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NoTrans_46109038.Text, 1, conect)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NoTrans_46109038.Text & "', #" & Tgl_46109038.Value.Month & "/" & Tgl_46109038.Value.Day & "/" & Tgl_46109038.Value.Year & "#, '" & JenTrans_46109038.Text & "')", conect)
conect.Open()
T.ExecuteNonQuery()
conect.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NoTrans_46109038.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", conect)
conect.Open()
T.ExecuteNonQuery()
conect.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
NoTrans_46109038.Text = ""
JenTrans_46109038.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40A_46109038.mirza()
End Sub
andi muh. yusri
BalasHapussambungan2
Private Sub Button1_edit()
If NoTrans_46109038.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If JenTrans_46109038.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 StatusStrip1.Text <> NoTrans_46109038.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NoTrans_46109038.Text, 1, conect)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & NoTrans_46109038.Text & "'", conect)
conect.Open()
T.ExecuteNonQuery()
conect.Close()
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NoTrans_46109038.Text & "', #" & Tgl_46109038.Value.Month & "/" & Tgl_46109038.Value.Day & "/" & Tgl_46109038.Value.Year & "#, '" & JenTrans_46109038.Text & "')", conect)
conect.Open()
T.ExecuteNonQuery()
conect.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & NoTrans_46109038.Text & "'", conect)
conect.Open()
T.ExecuteNonQuery()
conect.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NoTrans_46109038.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", conect)
conect.Open()
T.ExecuteNonQuery()
conect.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
NoTrans_46109038.Text = ""
JenTrans_46109038.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
Latihan40A_46109038.mirza()
End Sub
Private Sub Simpan_46109038_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_46109038.Click
If StatusStrip1.Text = "-" Then
Button1_Button2()
Else
Button1_edit()
End If
End Sub
End Class
Public Class Latihan40A46109052
BalasHapusDim Vero As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=allah swt")
Dim dt As New DataTable
Dim dt1 As New DataTable
Dim dset As New DataSet
Dim Bsource1 As New BindingSource
Dim Bsource2 As New BindingSource
Public Sub nika()
dt1.Rows.Clear()
dt.Rows.Clear()
Dim B1 As New OleDb.OleDbDataAdapter
B1 = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", Vero)
B1.Fill(dt)
B1 = 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", Vero)
B1.Fill(dt1)
B1.Dispose()
End Sub
Private Sub Latihan40A46109052_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
nika()
dset.Tables.Add(dt)
dset.Tables.Add(dt1)
dt.TableName = "T01"
dt1.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"
dgv146109052.DataSource = Bsource1
dgv246109052.DataSource = Bsource2
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
BalasHapusDim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & dgv146109052.CurrentRow.Cells("NOTRANS").Value & "'", Vero)
Vero.Open()
T.ExecuteNonQuery()
Vero.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & dgv146109052.CurrentRow.Cells("NOTRANS").Value & "'", Vero)
Vero.Open()
T.ExecuteNonQuery()
Vero.Close()
T.Dispose()
nika()
End Sub
Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Latihan40B46109052.Visible = False Then
Latihan40B46109052.Show()
Else
Latihan40B46109052.Activate()
End If
Latihan40B46109052.StatusStrip1.Text = dgv146109052.CurrentRow.Cells("NOTRANS").Value
Latihan40B46109052.nt46109052.Text = dgv146109052.CurrentRow.Cells("NOTRANS").Value
Latihan40B46109052.jt46109052.Text = dgv146109052.CurrentRow.Cells("JENISTRANSAKSI").Value
Latihan40B46109052.faster()
Latihan40B46109052.TOTALJUMLAH()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Latihan40B46109052.Visible = False Then
Latihan40B46109052.Show()
Else
Latihan40B46109052.Activate()
End If
Latihan40B46109052.StatusStrip1.Text = "-"
Latihan40B46109052.nt46109052.Text = ""
Latihan40B46109052.jt46109052.Text = ""
Latihan40B46109052.faster()
Latihan40B46109052.TOTALJUMLAH()
End Sub
End Class
Public Class LATIHAN040A_46109020
BalasHapusDim HUBUNG As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46")
Dim TARI1 As New DataTable
Dim TARI2 As New DataTable
Dim DS As New DataSet
Dim BS1 As New BindingSource
Dim BS2 As New BindingSource
Public Sub hardiyanti()
TARI1.Rows.Clear()
TARI2.Rows.Clear()
Dim adapter As New OleDb.OleDbDataAdapter
adapter = New OleDb.OleDbDataAdapter("Select * From MASTERTRANSAKSI", HUBUNG)
adapter.Fill(TARI1)
adapter = 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", HUBUNG)
adapter.Fill(TARI2)
adapter.Dispose()
End Sub
Private Sub LATIHAN040A_46109020_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
hardiyanti()
DS.Tables.Add(TARI1)
DS.Tables.Add(TARI2)
TARI1.TableName = "T1"
TARI2.TableName = "T2"
DS.Relations.Add(New DataRelation("X", DS.Tables("T1").Columns("NOTRANS"), DS.Tables("T2").Columns("NOTRANS")))
BS1.DataSource = DS
BS1.DataMember = "T1"
BS2.DataSource = BS1
BS2.DataMember = "X"
DGV46109020.DataSource = BS1
DGV246109020.DataSource = BS2
End Sub
Lanjutannya....
BalasHapusPrivate Sub HAPUS46109020_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HAPUS46109020.Click
Dim com As New OleDb.OleDbCommand
com = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS='" & DGV46109020.CurrentRow.Cells("NOTRANS").Value & "'", HUBUNG)
HUBUNG.Open()
com.ExecuteNonQuery()
HUBUNG.Close()
com = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS='" & DGV46109020.CurrentRow.Cells("NOTRANS").Value & "'", HUBUNG)
HUBUNG.Open()
com.ExecuteNonQuery()
HUBUNG.Close()
com.Dispose()
hardiyanti()
End Sub
Private Sub edit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EDIT46109020.Click
If LATIHAN040B_46109020.Visible = False Then
LATIHAN040B_46109020.Show()
Else
LATIHAN040B_46109020.Activate()
End If
LATIHAN040B_46109020.StatusStrip1.Text = DGV246109020.CurrentRow.Cells("NOTRANS").Value
LATIHAN040B_46109020.NT46109020.Text = DGV246109020.CurrentRow.Cells("NOTRANS").Value
LATIHAN040B_46109020.JT46109020.Text = DGV246109020.CurrentRow.Cells("JENISTRANSAKSI").Value
LATIHAN040B_46109020.somsek()
LATIHAN040B_46109020.TOTALJUMLAH()
End Sub
Private Sub tambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TAMBAH46109020.Click
If LATIHAN040B_46109020.Visible = False Then
LATIHAN040B_46109020.Show()
Else
LATIHAN040B_46109020.Activate()
End If
LATIHAN040B_46109020.StatusStrip1.Text = "-"
LATIHAN040B_46109020.NT46109020.Text = ""
LATIHAN040B_46109020.JT46109020.Text = ""
LATIHAN040B_46109020.somsek()
LATIHAN040B_46109020.TOTALJUMLAH()
End Sub
End Class
Untuk Latihan40B....
BalasHapusPublic Class LATIHAN040B_46109020
Dim HUBUNG As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=46")
Dim DATA As New DataTable
Public Sub somsek()
Dim adapter As New OleDb.OleDbDataAdapter
adapter = 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= '" & NT46109020.Text & "'", HUBUNG)
DATA.Rows.Clear()
adapter.Fill(DATA)
End Sub
Private Sub LATIHAN040B_46109020_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
DGV46109020.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
TOT46109020.Text = TOT
End Sub
Private Sub DGV46109020_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV46109020.CellContentClick
If DGV46109020.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
DGV46109020.CurrentRow.Cells("NAMABARANG").Value = ""
DGV46109020.CurrentRow.Cells("UNIT").Value = 0
DGV46109020.CurrentRow.Cells("HARGA").Value = 0
DGV46109020.CurrentRow.Cells("JUMLAH").Value = 0
Dim Pencari As New ByIskandar.CariKeDataBaseByIskandar
Pencari.AturPencarianDataBase("BARANG", "KODEBARANG", DGV46109020.CurrentRow.Cells("KODEBARANG").Value, 1, HUBUNG)
If Pencari.JumlanBaris > 0 Then
DGV46109020.CurrentRow.Cells("NAMABARANG").Value = Pencari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV46109020.CurrentRow.Cells("KODEBARANG").Value = ""
If Latihan383940_46109020.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV46109020.CurrentRow.Cells("KODEBARANG").Value = Latihan383940_46109020.DGV46109020.CurrentRow.Cells("KODEBARANG").Value
DGV46109020.CurrentRow.Cells("NAMABARANG").Value = Latihan383940_46109020.DGV46109020.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DGV46109020.Columns(e.ColumnIndex).Name = "UNIT" Or DGV46109020.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV46109020.CurrentRow.Cells("JUMLAH").Value = DGV46109020.CurrentRow.Cells("UNIT").Value * DGV46109020.CurrentRow.Cells("HARGA").Value
End If
TOTALJUMLAH()
End Sub
Private Sub Button1_Button2()
BalasHapusIf NT46109020.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If JT46109020.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 StatusStrip1.Text <> NT46109020.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT46109020.Text, 1, HUBUNG)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI(NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT46109020.Text & "', #" & DT46109020.Value.Month & "/" & DT46109020.Value.Day & "/" & DT46109020.Value.Year & "#, '" & JT46109020.Text & "')", HUBUNG)
HUBUNG.Open()
T.ExecuteNonQuery()
HUBUNG.Close()
For Each X As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT46109020.Text & "', '" & X("KODEBARANG") & "'," & X("UNIT") & ", " & X("HARGA") & ")", HUBUNG)
HUBUNG.Open()
T.ExecuteNonQuery()
HUBUNG.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
NT46109020.Text = ""
JT46109020.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
LATIHAN040A_46109020.hardiyanti()
End Sub
Lanjutannya....
BalasHapusPrivate Sub Button1_edit()
If NT46109020.Text.Length = 0 Then
MsgBox("Maaf, Nomor transaksi harus diisi dulu")
Exit Sub
End If
If JT46109020.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 StatusStrip1.Text <> NT46109020.Text Then
Dim pencari As New ByIskandar.CariKeDataBaseByIskandar
pencari.AturPencarianDataBase("MASTERTRANSAKSI", "NOTRANS", NT46109020.Text, 1, HUBUNG)
If pencari.JumlanBaris > 0 Then
MsgBox("Nomor transaksi sudah ada")
Exit Sub
End If
End If
Dim T As New OleDb.OleDbCommand
T = New OleDb.OleDbCommand("DELETE * FROM MASTERTRANSAKSI WHERE NOTRANS= '" & NT46109020.Text & "'", HUBUNG)
HUBUNG.Open()
T.ExecuteNonQuery()
HUBUNG.Close()
T = New OleDb.OleDbCommand("INSERT INTO MASTERTRANSAKSI (NOTRANS, TANGGALTRANSAKSI, JENISTRANSAKSI) VALUES ('" & NT46109020.Text & "', #" & DT46109020.Value.Month & "/" & DT46109020.Value.Day & "/" & DT46109020.Value.Year & "#, '" & JT46109020.Text & "')", HUBUNG)
HUBUNG.Open()
T.ExecuteNonQuery()
HUBUNG.Close()
T = New OleDb.OleDbCommand("DELETE * FROM DETAILTRANSAKSI WHERE NOTRANS= '" & NT46109020.Text & "'", HUBUNG)
HUBUNG.Open()
T.ExecuteNonQuery()
HUBUNG.Close()
For Each XX As DataRow In DATA.Rows
T = New OleDb.OleDbCommand("INSERT INTO DETAILTRANSAKSI (NOTRANS, KODEBARANG, UNIT, HARGA) VALUES ('" & NT46109020.Text & "', '" & XX("KODEBARANG") & "', " & XX("UNIT") & ", " & XX("HARGA") & ")", HUBUNG)
HUBUNG.Open()
T.ExecuteNonQuery()
HUBUNG.Close()
T.Dispose()
Next
StatusStrip1.Text = "-"
NT46109020.Text = ""
JT46109020.Text = ""
DATA.Rows.Clear()
TOTALJUMLAH()
LATIHAN040A_46109020.hardiyanti()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN46109020.Click
If StatusStrip1.Text = "-" Then
Button1_Button2()
Else
Button1_edit()
End If
End Sub
End Class
Public Class Form40_A_46109042
BalasHapusDim batari As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=8")
Dim dt1 As New DataTable
Dim dt2 As New DataTable
Dim ds As New DataSet
Dim bs1 As New BindingSource
Dim bs2 As New BindingSource
Public Sub novi1()
Dim a As New OleDb.OleDbDataAdapter
dt2.Rows.Clear()
dt1.Rows.Clear()
a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", batari)
a.Fill(dt1)
a = 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", batari)
a.Fill(dt2)
End Sub
Private Sub Form40_A_46109042_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
novi1()
ds.Tables.Add(dt1)
ds.Tables.Add(dt2)
dt1.TableName = "novi"
dt2.TableName = "novi2"
ds.Relations.Add(New DataRelation("a", ds.Tables("novi").Columns("notrans"), ds.Tables("novindra2").Columns("notrans")))
bs1.DataSource = ds
bs1.DataMember = "novi"
bs2.DataSource = bs1
bs2.DataMember = "a"
Dim dc(1) As DataColumn
dc(0) = dt1.Columns("notrans")
dt1.PrimaryKey = dc
dgv146109042.DataSource = bs1
dgv246109042.DataSource = bs2
End Sub
Private Sub Button146109042_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109042.Click
Dim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv146109042.CurrentRow.Cells("notrans").Value & "'", batari)
batari.Open()
cm.ExecuteNonQuery()
batari.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv146109042.CurrentRow.Cells("notrans").Value & "'", batari)
batari.Open()
cm.ExecuteNonQuery()
batari.Close()
cm.Dispose()
novi1()
End Sub
Private Sub Button246109042_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button246109042.Click
If Form40_B_46109042.Visible = False Then
Form40_B_46109042.Show()
Else
Form40_B_46109042.Activate()
End If
Form40_B_46109042.nt46109042.Text = ""
Form40_B_46109042.jt46109042.Text = ""
Form40_B_46109042.StatusStrip1.Text = "-"
Form40_B_46109042.novi2()
Form40_B_46109042.novi3()
End Sub
Private Sub Button346109042_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button346109042.Click
If Form40_B_46109042.Visible = False Then
Form40_B_46109042.Show()
Else
Form40_B_46109042.Activate()
End If
Form40_B_46109042.nt46109042.Text = dgv146109042.CurrentRow.Cells("notrans").Value
Form40_B_46109042.dtp46109042.Value = dgv146109042.CurrentRow.Cells("tanggaltransaksi").Value
Form40_B_46109042.jt46109042.Text = dgv146109042.CurrentRow.Cells("jenistransaksi").Value
Form40_B_46109042.StatusStrip1.Text = dgv146109042.CurrentRow.Cells("notrans").Value
Form40_B_46109042.novi2()
Form40_B_46109042.novi3()
End Sub
End Class
Public Class Form40_B_46109042
BalasHapusDim batari As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=8")
Dim dt As New DataTable
Dim novi As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Public Sub novi2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & nt46109042.Text & "'", batari)
dt.Rows.Clear()
a.Fill(dt)
End Sub
Public Sub novi3()
Dim total As Integer = 0
For Each x As DataRow In dt.Rows
total += x("Jumlah")
Next
Tot46109042.Text = total
End Sub
Private Sub novi4()
If nt46109042.Text.Length = 0 Then
MsgBox("Isi Notransnya..")
Exit Sub
End If
If jt46109042.Text.Length = 0 Then
MsgBox("Isi Jenis Transaksinya..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Isi datatable k..")
Exit Sub
End If
End Sub
Private Sub tambah()
novi4()
novi.AturPencarianDataBase("mastertransaksi", "notrans", nt46109042.Text, 1, batari)
If novi.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109042.Text & "',#" & dtp46109042.Value.Month & "/" & dtp46109042.Value.Day & "/" & dtp46109042.Value.Year & "#, '" & jt46109042.Text & "')", batari)
batari.Open()
cm.ExecuteNonQuery()
batari.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109042.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", batari)
batari.Open()
cm.ExecuteNonQuery()
batari.Close()
Next
cm.Dispose()
nt46109042.Text = ""
jt46109042.Text = ""
Tot46109042.Text = ""
StatusStrip1.Text = "-"
dt.Rows.Clear()
Form40_A_46109042.novi1()
End Sub
Public Class Latihan40A_46109015
BalasHapusDim imah As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\datamajemuk.accdb;jet OLEDB:database password=015")
Dim dt1 As New DataTable
Dim dt2 As New DataTable
Dim ds As New DataSet
Dim bs1 As New BindingSource
Dim bs2 As New BindingSource
Public Sub uni1()
Dim a As New OleDb.OleDbDataAdapter
dt2.Rows.Clear()
dt1.Rows.Clear()
a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", imah)
a.Fill(dt1)
a = New OleDb.OleDbDataAdapter("select detailtransaksi.notrans, barang.kodebarang, barang.namabarang, detailtransaksi.aidilt, detailtransaksi.harga, detailtransaksi.aidilt*harga as jumlah from barang inner join detailtransaksi on barang.kodebarang = detailtransaksi.kodebarang", imah)
a.Fill(dt2)
End Sub
Private Sub Latihan40A_46109015_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
uni1()
ds.Tables.Add(dt1)
ds.Tables.Add(dt2)
dt1.TableName = "aidil"
dt2.TableName = "aidil2"
ds.Relations.Add(New DataRelation("a", ds.Tables("aidil").Columns("notrans"), ds.Tables("uni").Columns("notrans")))
bs1.DataSource = ds
bs1.DataMember = "aidil"
bs2.DataSource = bs1
bs2.DataMember = "a"
Dim dc(1) As DataColumn
dc(0) = dt1.Columns("notrans")
dt1.PrimaryKey = dc
dgv1_46109015.DataSource = bs1
dgv2_46109015.DataSource = bs2
End Sub
Private Sub Button1_46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1_46109015.Click
Dim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv1_46109015.CurrentRow.Cells("notrans").Value & "'", imah)
imah.Open()
cm.ExecuteNonQuery()
imah.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv1_46109015.CurrentRow.Cells("notrans").Value & "'", imah)
imah.Open()
cm.ExecuteNonQuery()
imah.Close()
cm.Dispose()
uni1()
End Sub
Private Sub Button2_46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2_46109015.Click
If Latihan040B_46109015.Visible = False Then
Latihan040B_46109015.Show()
Else
Latihan040B_46109015.Activate()
End If
Latihan040B_46109015.nt46109015.Text = ""
Latihan040B_46109015.jt46109015.Text = ""
Latihan040B_46109015.StatusStrip1.Text = "-"
Latihan040B_46109015.uni2()
Latihan040B_46109015.uni3()
End Sub
Private Sub Button3_46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3_46109015.Click
If Latihan040B_46109015.Visible = False Then
Latihan040B_46109015.Show()
Else
Latihan040B_46109015.Activate()
End If
Latihan040B_46109015.nt46109015.Text = dgv1_46109015.CurrentRow.Cells("notrans").Value
Latihan040B_46109015.tgl46109015.Value = dgv1_46109015.CurrentRow.Cells("tanggaltransaksi").Value
Latihan040B_46109015.jt46109015.Text = dgv1_46109015.CurrentRow.Cells("jenistransaksi").Value
Latihan040B_46109015.StatusStrip1.Text = dgv1_46109015.CurrentRow.Cells("notrans").Value
Latihan040B_46109015.uni2()
Latihan040B_46109015.uni3()
End Sub
End Class
Public Class Latihan040B_46109015
BalasHapusDim imah As New OleDb.OleDbConnection("provider = microsoft.ace.oledb.12.0;data source=" & Application.StartupPath & "\datamajemuk.accdb;jet OLEDB:database password=015")
Dim dt As New DataTable
Dim uni As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Public Sub uni2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & nt46109015.Text & "'", imah)
dt.Rows.Clear()
a.Fill(dt)
End Sub
Public Sub uni3()
Dim total As Integer = 0
For Each x As DataRow In dt.Rows
total += x("Jumlah")
Next
Tot46109015.Text = total
End Sub
Private Sub uni4()
If nt46109015.Text.Length = 0 Then
MsgBox("Isi Notransnya..")
Exit Sub
End If
If jt46109015.Text.Length = 0 Then
MsgBox("Isi Jenis Transaksinya..")
Exit Sub
End If
If dt.Rows.Count = 0 Then
MsgBox("Isi datatable k..")
Exit Sub
End If
End Sub
Private Sub tambah()
uni4()
uni.AturPencarianDataBase("mastertransaksi", "notrans", nt46109015.Text, 1, imah)
If uni.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109015.Text & "',#" & tgl46109015.Value.Month & "/" & tgl46109015.Value.Day & "/" & tgl46109015.Value.Year & "#, '" & jt46109015.Text & "')", imah)
imah.Open()
cm.ExecuteNonQuery()
imah.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109015.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", imah)
imah.Open()
cm.ExecuteNonQuery()
imah.Close()
Next
cm.Dispose()
nt46109015.Text = ""
jt46109015.Text = ""
Tot46109015.Text = ""
StatusStrip1.Text = "-"
dt.Rows.Clear()
Latihan040A_46109015.uni1()
End Sub
Public Sub edit()
BalasHapusuni4()
If nt46109015.Text <> StatusStrip1.Text Then
uni.AturPencarianDataBase("mastertransaksi", "notrans", nt46109015.Text, 1, imah)
If uni.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 = '" & StatusStrip1.Text & "'", imah)
imah.Open()
cm.ExecuteNonQuery()
imah.Close()
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109015.Text & "',#" & tgl46109015.Value.Month & "/" & tgl46109015.Value.Day & "/" & tgl46109015.Value.Year & "#, '" & jt46109015.Text & "')", imah)
imah.Open()
cm.ExecuteNonQuery()
imah.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip1.Text & "'", imah)
imah.Open()
cm.ExecuteNonQuery()
imah.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt46109015.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", imah)
imah.Open()
cm.ExecuteNonQuery()
imah.Close()
Next
cm.Dispose()
nt46109015.Text = ""
jt46109015.Text = ""
Tot46109015.Text = ""
StatusStrip1.Text = "-"
dt.Rows.Clear()
Latihan040A_46109015.uni1()
End Sub
Private Sub Latihan040B_46109015_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
uni2()
Dim dc(1) As DataColumn
dc(0) = dt.Columns("kodebarang")
dt.PrimaryKey = dc
dt.Columns("unit").DefaultValue = 0
dt.Columns("harga").DefaultValue = 0
dt.Columns("jumlah").DefaultValue = 0
dgv46109015.DataSource = dt
End Sub
Private Sub dgv_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv46109015.CellEndEdit
BalasHapusIf dgv46109015.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
dgv46109015.CurrentRow.Cells("NAMABARANG").Value = ""
dgv46109015.CurrentRow.Cells("UNIT").Value = 0
dgv46109015.CurrentRow.Cells("HARGA").Value = 0
dgv46109015.CurrentRow.Cells("JUMLAH").Value = 0
uni.AturPencarianDataBase("barang", "kodebarang", dgv46109015.CurrentRow.Cells("KODEBARANG").Value, 1, imah)
If uni.JumlanBaris > 0 Then
dgv46109015.CurrentRow.Cells("NAMABARANG").Value = uni.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dgv46109015.CurrentRow.Cells("NAMABARANG").Value = ""
If Latihan383940_46109015.ShowDialog = Windows.Forms.DialogResult.OK Then
dgv46109015.CurrentRow.Cells("KODEBARANG").Value = Latihan383940_46109015.dgv46109015.CurrentRow.Cells("KODEBARANG").Value
dgv46109015.CurrentRow.Cells("NAMABARANG").Value = Latihan383940_46109015.dgv46109015.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf dgv46109015.Columns(e.ColumnIndex).Name = "UNIT" Or dgv46109015.Columns(e.ColumnIndex).Name = "HARGA" Then
dgv46109015.CurrentRow.Cells("JUMLAH").Value = dgv46109015.CurrentRow.Cells("UNIT").Value * dgv46109015.CurrentRow.Cells("HARGA").Value
uni3()
End If
End Sub
Private Sub Simpan_46109015_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan_46109015.Click
If StatusStrip1.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub dgv46109015_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgv46109015.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class
Private Sub tambah()
BalasHapusdiva4()
diva.AturPencarianDataBase("mastertransaksi", "notrans", nt46109043.Text, 1, fara)
If diva.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109043.Text & "',#" & dtp46109043.Value.Month & "/" & dtp46109043.Value.Day & "/" & dtp46109043.Value.Year & "#, '" & jt46109043.Text & "')", fara)
fara.Open()
cm.ExecuteNonQuery()
fara.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109043.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", fara)
fara.Open()
cm.ExecuteNonQuery()
fara.Close()
Next
cm.Dispose()
nt46109043.Text = ""
jt46109043.Text = ""
Tot46109043.Text = ""
StatusStrip1.Text = "-"
dt.Rows.Clear()
Form40_A_46109043.diva1()
End Sub
Public Sub edit()
diva4()
If nt46109043.Text <> StatusStrip1.Text Then
diva.AturPencarianDataBase("mastertransaksi", "notrans", nt46109043.Text, 1, fara)
If diva.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 = '" & StatusStrip1.Text & "'", fara)
fara.Open()
cm.ExecuteNonQuery()
fara.Close()
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109043.Text & "',#" & dtp46109043.Value.Month & "/" & dtp46109043.Value.Day & "/" & dtp46109043.Value.Year & "#, '" & jt46109043.Text & "')", fara)
fara.Open()
cm.ExecuteNonQuery()
fara.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip1.Text & "'", fara)
fara.Open()
cm.ExecuteNonQuery()
fara.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt46109043.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", fara)
fara.Open()
cm.ExecuteNonQuery()
fara.Close()
Next
cm.Dispose()
nt46109043.Text = ""
jt46109043.Text = ""
Tot46109043.Text = ""
StatusStrip1.Text = "-"
dt.Rows.Clear()
Form40_A_46109043.diva1()
End Sub
Public Class Latihan_40B_46109044
BalasHapusDim hma As New OleDb.OleDbConnection("PROVIDER = MICROSOFT.ACE.OLEDB.12.0; DATA SOURCE =" & Application.StartupPath & "/dataMajemuk.accdb")
Dim dt As New DataTable
Dim syahril As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Public Sub syahril2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & NT46109044.Text & "'", hma)
dt.Rows.Clear()
a.Fill(dt)
End Sub
Public Sub syahril3()
Dim total As Integer = 0
For Each x As DataRow In dt.Rows
total += x("Jumlah")
Next
TOT46109044.Text = total
End Sub
Private Sub syahril4()
If NT46109044.Text.Length = 0 Then
MsgBox("Isi rong itu Notransnya..")
Exit Sub
End If
If JT46109044.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()
syahril4()
syahril.AturPencarianDataBase("mastertransaksi", "notrans", NT46109044.Text, 1, hma)
If syahril.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & NT46109044.Text & "',#" & T46109044.Value.Month & "/" & T46109044.Value.Day & "/" & T46109044.Value.Year & "#, '" & JT46109044.Text & "')", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & NT46109044.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
Next
cm.Dispose()
NT46109044.Text = ""
JT46109044.Text = ""
TOT46109044.Text = ""
ff.Text = "-"
dt.Rows.Clear()
Latihan_40A_46109044.syahril1()
End Sub
Public Sub edit()
BalasHapussyahril4()
If NT46109044.Text <> ff.Text Then
syahril.AturPencarianDataBase("mastertransaksi", "notrans", NT46109044.Text, 1, hma)
If syahril.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 = '" & ff.Text & "'", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & NT46109044.Text & "',#" & T46109044.Value.Month & "/" & T46109044.Value.Day & "/" & T46109044.Value.Year & "#, '" & JT46109044.Text & "')", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & ff.Text & "'", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & NT46109044.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
Next
cm.Dispose()
NT46109044.Text = ""
JT46109044.Text = ""
TOT46109044.Text = ""
ff.Text = "-"
dt.Rows.Clear()
Latihan_40A_46109044.syahril1()
End Sub
Private Sub Latihan_40B_022_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
syahril2()
Dim dc(1) As DataColumn
dc(0) = dt.Columns("kodebarang")
dt.PrimaryKey = dc
dt.Columns("unit").DefaultValue = 0
dt.Columns("harga").DefaultValue = 0
dt.Columns("jumlah").DefaultValue = 0
DGV46109044.DataSource = dt
End Sub
Private Sub dgv_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV46109044.CellEndEdit
BalasHapusIf DGV46109044.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
'If dgv.CurrentRow.Cells(0) = "KODEBARANG" Then (rumus lain)
'untuk mencari nama barang
DGV46109044.CurrentRow.Cells("NAMABARANG").Value = ""
DGV46109044.CurrentRow.Cells("UNIT").Value = 0
DGV46109044.CurrentRow.Cells("HARGA").Value = 0
DGV46109044.CurrentRow.Cells("JUMLAH").Value = 0
syahril.AturPencarianDataBase("barang", "kodebarang", DGV46109044.CurrentRow.Cells("KODEBARANG").Value, 1, hma)
If syahril.JumlanBaris > 0 Then '(menampilkan nama barang jika kolom kode barang ditemukan oleh proses di atas
DGV46109044.CurrentRow.Cells("NAMABARANG").Value = syahril.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DGV46109044.CurrentRow.Cells("NAMABARANG").Value = ""
If Latihan_38_39_40_46109044.ShowDialog = Windows.Forms.DialogResult.OK Then
DGV46109044.CurrentRow.Cells("KODEBARANG").Value = Latihan_38_39_40_46109044.DGV46109044.CurrentRow.Cells("KODEBARANG").Value
DGV46109044.CurrentRow.Cells("NAMABARANG").Value = Latihan_38_39_40_46109044.DGV46109044.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf DGV46109044.Columns(e.ColumnIndex).Name = "UNIT" Or DGV46109044.Columns(e.ColumnIndex).Name = "HARGA" Then
DGV46109044.CurrentRow.Cells("JUMLAH").Value = DGV46109044.CurrentRow.Cells("UNIT").Value * DGV46109044.CurrentRow.Cells("HARGA").Value
syahril3()
End If
End Sub
Private Sub ee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S46109044.Click
If ff.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub dgv_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DGV46109044.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class
Public Class Latihan_40A_46109044
BalasHapusDim hma 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 ds As New DataSet
Dim bs1 As New BindingSource
Dim bs2 As New BindingSource
Public Sub syahril1()
Dim a As New OleDb.OleDbDataAdapter
dt2.Rows.Clear()
dt1.Rows.Clear()
a = New OleDb.OleDbDataAdapter("select * from mastertransaksi", hma)
a.Fill(dt1)
a = 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", hma)
a.Fill(dt2)
End Sub
Private Sub Latihan_40A_46109044_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
syahril1()
ds.Tables.Add(dt1)
ds.Tables.Add(dt2)
dt1.TableName = "lirhas"
dt2.TableName = "lirhas2"
ds.Relations.Add(New DataRelation("a", ds.Tables("lirhas").Columns("notrans"), ds.Tables("lirhas2").Columns("notrans")))
bs1.DataSource = ds
bs1.DataMember = "lirhas"
bs2.DataSource = bs1
bs2.DataMember = "a"
Dim dc(1) As DataColumn
dc(0) = dt1.Columns("notrans")
dt1.PrimaryKey = dc
dgv146109044.DataSource = bs1
DGV246109044.DataSource = bs2
End Sub
Private Sub H46109044_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles H46109044.Click
BalasHapusDim cm As New OleDb.OleDbCommand
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & dgv146109044.CurrentRow.Cells("notrans").Value & "'", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & dgv146109044.CurrentRow.Cells("notrans").Value & "'", hma)
hma.Open()
cm.ExecuteNonQuery()
hma.Close()
cm.Dispose()
syahril1()
End Sub
Private Sub T46109044_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles T46109044.Click
If Latihan_40B_46109044.Visible = False Then
Latihan_40B_46109044.Show()
Else
Latihan_40B_46109044.Activate()
End If
Latihan_40B_46109044.NT46109044.Text = ""
Latihan_40B_46109044.JT46109044.Text = ""
Latihan_40B_46109044.ff.Text = "-"
Latihan_40B_46109044.syahril2()
Latihan_40B_46109044.syahril3()
End Sub
Private Sub E46109044_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles E46109044.Click
If Latihan_40B_46109044.Visible = False Then
Latihan_40B_46109044.Show()
Else
Latihan_40B_46109044.Activate()
End If
Latihan_40B_46109044.NT46109044.Text = dgv146109044.CurrentRow.Cells("notrans").Value
Latihan_40B_46109044.T46109044.Value = dgv146109044.CurrentRow.Cells("tanggaltransaksi").Value
Latihan_40B_46109044.JT46109044.Text = dgv146109044.CurrentRow.Cells("jenistransaksi").Value
Latihan_40B_46109044.ff.Text = dgv146109044.CurrentRow.Cells("notrans").Value
Latihan_40B_46109044.syahril2()
Latihan_40B_46109044.syahril3()
End Sub
End Class
cm = New OleDb.OleDbCommand("delete * from mastertransaksi where notrans = '" & StatusStrip1.Text & "'", asmi)
BalasHapusasmi.Open()
cm.ExecuteNonQuery()
asmi.Close()
cm = New OleDb.OleDbCommand("insert into mastertransaksi(notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109046.Text & "',#" & dtp46109046.Value.Month & "/" & dtp46109046.Value.Day & "/" & dtp46109046.Value.Year & "#, '" & jt46109046.Text & "')", asmi)
asmi.Open()
cm.ExecuteNonQuery()
asmi.Close()
cm = New OleDb.OleDbCommand("delete * from detailtransaksi where notrans = '" & StatusStrip1.Text & "'", asmi)
asmi.Open()
cm.ExecuteNonQuery()
asmi.Close()
For Each x As DataRow In dt.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi(notrans, kodebarang, unit, harga) values ('" & nt46109046.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "')", asmi)
asmi.Open()
cm.ExecuteNonQuery()
asmi.Close()
Next
cm.Dispose()
nt46109046.Text = ""
jt46109046.Text = ""
Tot46109046.Text = ""
StatusStrip1.Text = "-"
dt.Rows.Clear()
latihan40A_46109046.asmianti1()
End Sub
Private Sub latihan40B_46109046_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
amhy2()
Dim dc(1) As DataColumn
dc(0) = dt.Columns("kodebarang")
dt.PrimaryKey = dc
dt.Columns("unit").DefaultValue = 0
dt.Columns("harga").DefaultValue = 0
dt.Columns("jumlah").DefaultValue = 0
dgv46109046.DataSource = dt
End Sub
Private Sub dgv46109046_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv46109046.CellEndEdit
If dgv46109046.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
dgv46109046.CurrentRow.Cells("NAMABARANG").Value = ""
dgv46109046.CurrentRow.Cells("UNIT").Value = 0
dgv46109046.CurrentRow.Cells("HARGA").Value = 0
dgv46109046.CurrentRow.Cells("JUMLAH").Value = 0
amhy.AturPencarianDataBase("barang", "kodebarang", dgv46109046.CurrentRow.Cells("KODEBARANG").Value, 1, asmi)
If amhy.JumlanBaris > 0 Then
dgv46109046.CurrentRow.Cells("NAMABARANG").Value = amhy.DataTablenya.Rows(0).Item("NAMABARANG")
Else
dgv46109046.CurrentRow.Cells("NAMABARANG").Value = ""
If latihan38_39_40_46109046.ShowDialog = Windows.Forms.DialogResult.OK Then
dgv46109046.CurrentRow.Cells("KODEBARANG").Value = latihan38_39_40_46109046.dgv46109046.CurrentRow.Cells("KODEBARANG").Value
dgv46109046.CurrentRow.Cells("NAMABARANG").Value = latihan38_39_40_46109046.dgv46109046.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf
dgv46109046.Columns(e.ColumnIndex).Name = "UNIT" Or dgv46109046.Columns(e.ColumnIndex).Name = "HARGA" Then
BalasHapusdgv46109046.CurrentRow.Cells("JUMLAH").Value = dgv46109046.CurrentRow.Cells("UNIT").Value * dgv46109046.CurrentRow.Cells("HARGA").Value
amhy3()
End If
End Sub
Private Sub Button146109046_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button146109046.Click
If StatusStrip1.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub dgv46109046_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgv46109046.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
BalasHapusIf LATIHAN40B46109026.Visible = False Then
LATIHAN40B46109026.Show()
Else
LATIHAN40B46109026.Activate()
End If
LATIHAN40B46109026.nomor46109026.Text = ""
LATIHAN40B46109026.jenis46109026.Text = ""
LATIHAN40B46109026.StatusStrip46109026.Text = "-"
LATIHAN40B46109026.ibhe2()
LATIHAN40B46109026.ibhe3()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If LATIHAN40B46109026.Visible = False Then
LATIHAN40B46109026.Show()
Else
LATIHAN40B46109026.Activate()
End If
LATIHAN40B46109026.nomor46109026.Text = data146109026.CurrentRow.Cells("notrans").Value
LATIHAN40B46109026.tanggal46109026.Value = data146109026.CurrentRow.Cells("tanggaltransaksi").Value
LATIHAN40B46109026.jenis46109026.Text = data146109026.CurrentRow.Cells("jenistransaksi").Value
LATIHAN40B46109026.StatusStrip46109026.Text = data146109026.CurrentRow.Cells("notrans").Value
LATIHAN40B46109026.ibhe2()
LATIHAN40B46109026.ibhe3()
End Sub
End Class
Public Class LATIHAN40B46109026
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=26")
Dim ibeng As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Public Sub ibhe2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & nomor46109026.Text & "'", CONECT)
ibeng.Rows.Clear()
a.Fill(ibeng)
End Sub
Public Sub ibhe3()
Dim total As Integer = 0
For Each x As DataRow In ibeng.Rows
total += x("Jumlah")
Next
total46109026.Text = total
End Sub
Private Sub ibhe4()
If nomor46109026.Text.Length = 0 Then
MsgBox("Isi Notransnya..")
Exit Sub
End If
If jenis46109026.Text.Length = 0 Then
MsgBox("Isi Jenis Transaksinya..")
Exit Sub
End If
If ibeng.Rows.Count = 0 Then
MsgBox("Isi datatable k..")
Exit Sub
End If
End Sub
Private Sub tambah()
ibhe4()
cari.AturPencarianDataBase("mastertransaksi", "notrans", nomor46109026.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("sudah ada notrans seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nomor46109026.Text & "',#" & tanggal46109026.Value.Month & "/" & tanggal46109026.Value.Day & "/" & tanggal46109026.Value.Year & "#, '" & jenis46109026.Text & "')", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
For Each x As DataRow In ibeng.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nomor46109026.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
Next
cm.Dispose()
nomor46109026.Text = ""
jenis46109026.Text = ""
total46109026.Text = ""
StatusStrip46109026.Text = "-"
ibeng.Rows.Clear()
LATIHAN40A46109026.ibhe()
End Sub
Private Sub data46109026_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles data46109026.CellEndEdit
BalasHapusIf data46109026.Columns(e.ColumnIndex).Name = "KODEBARANG" Then
data46109026.CurrentRow.Cells("NAMABARANG").Value = ""
data46109026.CurrentRow.Cells("UNIT").Value = 0
data46109026.CurrentRow.Cells("HARGA").Value = 0
data46109026.CurrentRow.Cells("JUMLAH").Value = 0
cari.AturPencarianDataBase("barang", "kodebarang", data46109026.CurrentRow.Cells("KODEBARANG").Value, 1, CONECT)
If cari.JumlanBaris > 0 Then
data46109026.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
data46109026.CurrentRow.Cells("NAMABARANG").Value = ""
If latihan3839400026.ShowDialog = Windows.Forms.DialogResult.OK Then
data46109026.CurrentRow.Cells("KODEBARANG").Value = latihan3839400026.DATA46109026.CurrentRow.Cells("KODEBARANG").Value
data46109026.CurrentRow.Cells("NAMABARANG").Value = latihan3839400026.DATA46109026.CurrentRow.Cells("NAMABARANG").Value
End If
End If
ElseIf data46109026.Columns(e.ColumnIndex).Name = "UNIT" Or data46109026.Columns(e.ColumnIndex).Name = "HARGA" Then
data46109026.CurrentRow.Cells("JUMLAH").Value = data46109026.CurrentRow.Cells("UNIT").Value * data46109026.CurrentRow.Cells("HARGA").Value
ibhe3()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If StatusStrip46109026.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub data46109026_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles data46109026.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class
Public Class tugas40b46109033
BalasHapusDim CONECT As New OleDb.OleDbConnection("provider=microsoft.ace.oledb.12.0;data source= " & Application.StartupPath & "\DATAMAJEMUK.accdb;Jet OLEDB:Database Password=033")
Dim tofiq As New DataTable
Dim cari As New ByIskandar.CariKeDataBaseByIskandar
Dim cm As New OleDb.OleDbCommand
Public Sub tm2()
Dim a As New OleDb.OleDbDataAdapter
a = 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 = '" & nt46109033.Text & "'", CONECT)
tofiq.Rows.Clear()
a.Fill(tofiq)
End Sub
Public Sub tm3()
Dim total As Integer = 0
For Each x As DataRow In tofiq.Rows
total += x("Jumlah")
Next
tot46109033.Text = total
End Sub
Private Sub tm4()
If nt46109033.Text.Length = 0 Then
MsgBox("Isi Notransnya..")
Exit Sub
End If
If jt46109033.Text.Length = 0 Then
MsgBox("Isi Jenis Transaksinya..")
Exit Sub
End If
If tofiq.Rows.Count = 0 Then
MsgBox("Isi datatable k..")
Exit Sub
End If
End Sub
Private Sub tambah()
tm4()
cari.AturPencarianDataBase("mastertransaksi", "notrans", nt46109033.Text, 1, CONECT)
If cari.JumlanBaris > 0 Then
MsgBox("Adami notrans seperti itu..")
Exit Sub
End If
cm = New OleDb.OleDbCommand("insert into mastertransaksi (notrans, tanggaltransaksi, jenistransaksi) values ('" & nt46109033.Text & "',#" & DateTimePicker1.Value.Month & "/" & DateTimePicker1.Value.Day & "/" & DateTimePicker1.Value.Year & "#, '" & jt46109033.Text & "')", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
For Each x As DataRow In tofiq.Rows
cm = New OleDb.OleDbCommand("insert into detailtransaksi (notrans, kodebarang, unit, harga) values ('" & nt46109033.Text & "', '" & x("kodebarang") & "', '" & x("unit") & "', '" & x("harga") & "') ", CONECT)
CONECT.Open()
cm.ExecuteNonQuery()
CONECT.Close()
Next
cm.Dispose()
nt46109033.Text = ""
jt46109033.Text = ""
tot46109033.Text = ""
StatusStrip46109033.Text = "-"
tofiq.Rows.Clear()
TUGAS40A46109033.tofiq()
End Sub
Private Sub datagridview1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit
BalasHapusIf 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
cari.AturPencarianDataBase("barang", "kodebarang", DataGridView1.CurrentRow.Cells("KODEBARANG").Value, 1, CONECT)
If cari.JumlanBaris > 0 Then
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = cari.DataTablenya.Rows(0).Item("NAMABARANG")
Else
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = ""
If tugas38394046109033.ShowDialog = Windows.Forms.DialogResult.OK Then
DataGridView1.CurrentRow.Cells("KODEBARANG").Value = tugas38394046109033.DataGridView146109033.CurrentRow.Cells("KODEBARANG").Value
DataGridView1.CurrentRow.Cells("NAMABARANG").Value = tugas38394046109033.DataGridView146109033.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
tm3()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If StatusStrip46109033.Text = "-" Then
tambah()
Else
edit()
End If
End Sub
Private Sub datagridview1_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError
MsgBox("Terjadi sedikit kesalahan...")
End Sub
End Class