Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.Odbc
- Public Class Form_pembelian
- Private Sub Form_pembelian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Call koneksi()
- Call faktur_auto()
- Ltanggal.Text = Format(Today)
- Me.CenterToScreen()
- End Sub
- Sub faktur_auto()
- Call koneksi()
- cmd = New OdbcCommand("select nomor_faktur_beli from transaksi_pembelian order by nomor_faktur_beli desc", conn)
- dr = cmd.ExecuteReader
- dr.Read()
- If Not dr.HasRows Then
- Lfaktur.Text = Format(Now, "yyMMdd") + "0001"
- Else
- If Microsoft.VisualBasic.Left(dr.Item("nomor_faktur_beli"), 6) = Format(Now, "yyMMdd") Then
- Lfaktur.Text = dr.Item("nomor_faktur_beli") + 1
- Else
- Lfaktur.Text = Format(Now, "yyMMdd") + "0001"
- End If
- End If
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- view_supplier.ShowDialog()
- End Sub
- Sub bersihkan()
- cmbsupplier.Text = ""
- Lnamasupplier.Text = ""
- Ltotalharga.Text = ""
- Tdibayar.Clear()
- Lkembali.Text = ""
- Ltotalbarang.Text = ""
- DGV.Rows.Clear()
- End Sub
- Sub hitungtotal()
- Dim x As Double
- For baris As Integer = 0 To DGV.RowCount - 1
- '0=0+30000
- '30000=30000+20000
- x = x + DGV.Rows(baris).Cells(4).Value
- Next
- Ltotalharga.Text = x
- End Sub
- Sub total_barang()
- Dim x As Integer
- For baris As Integer = 0 To DGV.RowCount - 1
- x = x + DGV.Rows(baris).Cells(3).Value
- Next
- Ltotalbarang.Text = x
- End Sub
- Private Sub DGV_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV.CellEndEdit
- If e.ColumnIndex = 0 Then
- '======================== prevent code yang sama
- For ba As Integer = 0 To DGV.RowCount - 1
- For bb As Integer = ba + 1 To DGV.RowCount - 1
- If DGV.Rows(bb).Cells(0).Value = DGV.Rows(ba).Cells(0).Value Then
- DGV.Rows(ba).Cells(3).Value = DGV.Rows(ba).Cells(3).Value + 1
- DGV.Rows(ba).Cells(4).Value = DGV.Rows(ba).Cells(2).Value * DGV.Rows(ba).Cells(3).Value
- Call hitungtotal()
- Call total_barang()
- DGV.Rows.RemoveAt(bb)
- 'SendKeys.Send("{down}")
- Exit Sub
- End If
- Next
- Next
- Call koneksi()
- cmd = New OdbcCommand("select * from barang where id_barang='" & DGV.Rows(e.RowIndex).Cells(0).Value & "'", conn)
- dr = cmd.ExecuteReader
- dr.Read()
- If dr.HasRows Then
- DGV.Rows(e.RowIndex).Cells(1).Value = dr("nama_barang")
- DGV.Rows(e.RowIndex).Cells(2).Value = dr("harga_beli")
- DGV.Rows(e.RowIndex).Cells(3).Value = 1
- DGV.Rows(e.RowIndex).Cells(4).Value = DGV.Rows(e.RowIndex).Cells(2).Value * DGV.Rows(e.RowIndex).Cells(3).Value
- Else
- MsgBox("Kode barang tidak terdaftar")
- DGV.Rows.Remove(DGV.CurrentRow)
- SendKeys.Send("{down}")
- DGV.Rows(e.RowIndex).Cells(0).Value = ""
- End If
- End If
- Call hitungtotal()
- Call total_barang()
- End Sub
- Private Sub DGV_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DGV.KeyDown
- On Error Resume Next
- If e.KeyCode = Keys.Delete Or e.KeyCode = Keys.Escape Then
- DGV.Rows.Remove(DGV.CurrentRow)
- Call hitungtotal()
- Call total_barang()
- End If
- If e.KeyCode = Keys.Enter Then
- Tdibayar.Clear()
- Tdibayar.Focus()
- End If
- End Sub
- Private Sub Tdibayar_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Tdibayar.KeyDown
- If e.KeyCode = Keys.Enter Then
- If Val(Tdibayar.Text) < Val(Ltotalharga.Text) Then
- MsgBox("Pembayaran Kurang")
- Exit Sub
- ElseIf Val(Tdibayar.Text) >= (Ltotalharga.Text) Then
- Lkembali.Text = Val(Tdibayar.Text) - Val(Ltotalharga.Text)
- Button1.Focus()
- End If
- End If
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- 'validasi
- If cmbsupplier.Text = "" Or Ltotalharga.Text = "" Or Tdibayar.Text = "" Or Lkembali.Text = "" Then
- MsgBox("Transaksi belum lengkap")
- Exit Sub
- End If
- '2 simpan ke tabel penjualan
- Call koneksi()
- Dim simpan As String = "insert into transaksi_pembelian values ('" & Lfaktur.Text & "','" & Format(DateValue(Ltanggal.Text), "yyyy-MM-dd") & "','" & cmbsupplier.Text & "', '" & Ltotalbarang.Text & "', '" & Ltotalharga.Text & "','" & Tdibayar.Text & "', '" & Lkembali.Text & "', '" & Menuutama.PanelKode.Text & "')"
- cmd = New OdbcCommand(simpan, conn)
- cmd.ExecuteNonQuery()
- '3 Simpan ketabel detailjual
- For baris As Integer = 0 To DGV.RowCount - 2
- Dim simpandetail As String = "insert into transaksi_detail_pembelian values ('" & Lfaktur.Text & "','" & DGV.Rows(baris).Cells(0).Value & "','" & DGV.Rows(baris).Cells(2).Value & "', '" & DGV.Rows(baris).Cells(3).Value & "', '" & DGV.Rows(baris).Cells(4).Value & "')"
- cmd = New OdbcCommand(simpandetail, conn)
- cmd.ExecuteNonQuery()
- '4 tambah stok barang
- Call koneksi()
- cmd = New OdbcCommand("select * from barang where id_barang='" & DGV.Rows(baris).Cells(0).Value & "'", conn)
- dr = cmd.ExecuteReader
- dr.Read()
- If dr.HasRows Then
- Call koneksi()
- Dim kurangi As String = "update barang set stok='" & dr("stok") + DGV.Rows(baris).Cells("jumlah").Value & "' where id_barang='" & DGV.Rows(baris).Cells(0).Value & "'"
- cmd = New OdbcCommand(kurangi, conn)
- cmd.ExecuteNonQuery()
- End If
- Next
- If MessageBox.Show("Cetak Faktur ?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
- cetak.show()
- cetak.CRV.ReportSource = Nothing
- cetak.CRV.ReportSource = "Faktur_pembelian.rpt"
- cetak.CRV.RefreshReport()
- cetak.CRV.RefreshReport()
- End If
- Call faktur_auto()
- Call bersihkan()
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- Call bersihkan()
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- Me.Close()
- Menuutama.Show()
- End Sub
- End Class
- Imports System.Data.Odbc
- Module Module1
- Public conn As OdbcConnection
- Public cmd As OdbcCommand
- Public da As OdbcDataAdapter
- Public ds As DataSet
- Public dr As OdbcDataReader
- Public lokasidata As String
- Sub koneksi()
- conn = New OdbcConnection("dsn=penjualan_pras")
- conn.Open()
- End Sub
- End Module
- Imports System.Data.Odbc
- Public Class view_supplier
- Private Sub view_supplier_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Call koneksi()
- Call tampillist()
- Me.CenterToScreen()
- End Sub
- Sub tampillist()
- Call koneksi()
- cmd = New OdbcCommand("select * from supplier", conn)
- dr = cmd.ExecuteReader
- ListBox1.Items.Clear()
- Do While dr.Read
- ListBox1.Items.Add(dr.Item("id_supplier") & Space(5) & dr.Item("nama_supplier"))
- Loop
- End Sub
- Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
- Call koneksi()
- cmd = New OdbcCommand("select * from supplier where id_supplier='" & Microsoft.VisualBasic.Left(ListBox1.Text, 1) & "'", conn)
- dr = cmd.ExecuteReader
- dr.Read()
- If dr.HasRows Then
- Form_pembelian.cmbsupplier.Text = dr.Item("id_supplier")
- Form_pembelian.Lnamasupplier.Text = dr.Item("nama_supplier")
- End If
- Me.Close()
- Form_pembelian.Show()
- End Sub
- End Class
- Public Class Laporan_Pembelian_Transaksi
- Private Sub Laporan_Pembelian_Transaksi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- CRV.SelectionFormula = "Totext ({transaksi_pembelian.tanggal_jual})= '" & DTP1.Text & "'"
- CRV.ReportSource = "Laporan_Pembelian_Harian.rpt"
- CRV.RefreshReport()
- CRV.RefreshReport()
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- CRV.SelectionFormula = "{transaksi_pembelian.tanggal_jual} in date ('" & DTP2.Text & "') to date ('" & DTP3.Text & "')"
- CRV.ReportSource = "Laporan_Pembelian_Periodik.rpt"
- CRV.RefreshReport()
- CRV.RefreshReport()
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- CRV.SelectionFormula = "month ({transaksi_pembelian.tanggal_jual}) = (" & Month(DTP4.Text) & ") and year ({transaksi_pembelian.tanggal_jual}) = (" & Year(DTP4.Text) & ")"
- CRV.ReportSource = "Laporan_Pembelian_Bulanan.rpt"
- CRV.RefreshReport()
- CRV.RefreshReport()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement