SHARE
TWEET

LISTBOXBEDAFORM

a guest May 20th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.Data.OleDb
  2.  
  3. Public Class ListBoxBedaForm
  4.  
  5.     Sub HitungBarang()
  6.         Dim Hitung As Integer = 0
  7.         For Baris As Integer = 0 To Penjualan2.DGV.RowCount - 1
  8.             Hitung = Hitung + Penjualan2.DGV.Rows(Baris).Cells(3).Value
  9.         Next
  10.         Penjualan2.LBLTotalBarang.Text = Hitung
  11.     End Sub
  12.  
  13.     Sub HitungHarga()
  14.         Dim Hitung As Integer = 0
  15.         For Baris As Integer = 0 To Penjualan2.DGV.RowCount - 1
  16.             Hitung = Hitung + Penjualan2.DGV.Rows(Baris).Cells(4).Value
  17.         Next
  18.         Penjualan2.LBLTotalHarga.Text = Hitung
  19.     End Sub
  20.  
  21.     Private Sub ListBoxBedaForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  22.         Call Koneksi()
  23.         cmd = New OleDbCommand("Select * from tbl_barang", conn)
  24.         dr = cmd.ExecuteReader
  25.         Do While dr.Read
  26.             ListBox1.Items.Add(dr.Item(0) & Space(2) & dr(1))
  27.         Loop
  28.     End Sub
  29.  
  30.     Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
  31.         Dim Baris As Integer = Penjualan2.DGV.RowCount - 1
  32.         Penjualan2.DGV.Rows.Add(Microsoft.VisualBasic.Left(ListBox1.Text, 5))
  33.  
  34.         For barisatas As Integer = 0 To Penjualan2.DGV.RowCount - 1
  35.             For barisbawah As Integer = barisatas + 1 To Penjualan2.DGV.RowCount - 1
  36.                 If Penjualan2.DGV.Rows(barisbawah).Cells(0).Value = Penjualan2.DGV.Rows(barisatas).Cells(0).Value Then
  37.                     Penjualan2.DGV.Rows(barisatas).Cells(3).Value = Penjualan2.DGV.Rows(barisatas).Cells(3).Value + 1
  38.                     Penjualan2.DGV.Rows(barisatas).Cells(4).Value = Penjualan2.DGV.Rows(barisatas).Cells(2).Value * Penjualan2.DGV.Rows(barisatas).Cells(3).Value
  39.                     Call HitungBarang()
  40.                     Call HitungHarga()
  41.                     Penjualan2.DGV.Rows.RemoveAt(barisbawah)
  42.                     Exit Sub
  43.                 End If
  44.             Next
  45.         Next
  46.  
  47.         cmd = New OleDbCommand("Select * from tbl_barang where Kode_Barang='" & Penjualan2.DGV.Rows(Baris).Cells(0).Value & "'", conn)
  48.         dr = cmd.ExecuteReader
  49.         dr.Read()
  50.         If dr.HasRows Then
  51.             Penjualan2.DGV.Rows(Baris).Cells(1).Value = dr.Item("Nama_Barang")
  52.             Penjualan2.DGV.Rows(Baris).Cells(2).Value = dr.Item("Harga_Jual")
  53.             Penjualan2.DGV.Rows(Baris).Cells(3).Value = 1
  54.             Penjualan2.DGV.Rows(Baris).Cells(4).Value = Penjualan2.DGV.Rows(Baris).Cells(2).Value * Penjualan2.DGV.Rows(Baris).Cells(3).Value
  55.         End If
  56.     End Sub
  57. End Class
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top