download gratis video tutorial vb 6 dan vb.net plus contoh aplikasi

cara entri data dari datagrid ke datagrid lain pada form yang sama

 



Imports System.Data.SqlClient

 

Public Class BarangGrid

 

Private Sub BarangGrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Koneksi()
da = New SqlDataAdapter("select * from tblbarang where stok>0", conn)
ds = New DataSet
da.Fill(ds)
DGV1.DataSource = ds.Tables(0)
DGV1.ReadOnly = True
End Sub

 

Private Sub DGV1_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV1.CellMouseClick
Dim baris As Integer = Penjualan.DGV.RowCount - 1
On Error Resume Next
Penjualan.DGV.Rows.Add(DGV1.Rows(e.RowIndex).Cells(0).Value, DGV1.Rows(e.RowIndex).Cells(1).Value, DGV1.Rows(e.RowIndex).Cells(3).Value, 1)
'============ cegah data jika sama
For barisatas As Integer = 0 To Penjualan.DGV.RowCount - 1
For barisbawah As Integer = barisatas + 1 To Penjualan.DGV.RowCount - 1
If Penjualan.DGV.Rows(barisbawah).Cells(0).Value = Penjualan.DGV.Rows(barisatas).Cells(0).Value Then
Penjualan.DGV.Rows(barisatas).Cells(3).Value = Penjualan.DGV.Rows(barisatas).Cells(3).Value + 1
Penjualan.DGV.Rows(barisatas).Cells(4).Value = Penjualan.DGV.Rows(barisatas).Cells(2).Value * Penjualan.DGV.Rows(barisatas).Cells(3).Value
Penjualan.DGV.Rows.RemoveAt(barisbawah)
Call Penjualan.HitungHarga()
Exit Sub
End If
Next
Next

Penjualan.DGV.Rows(baris).Cells(4).Value = Penjualan.DGV.Rows(baris).Cells(2).Value * Penjualan.DGV.Rows(baris).Cells(3).Value
Call Penjualan.HitungHarga()
TextBox2.Clear()
End Sub

 

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Call Koneksi()
da = New SqlDataAdapter("select * from tblbarang where stok>0 and nama_barang like '%" & TextBox2.Text & "%'", conn)
ds = New DataSet
da.Fill(ds)
DGV1.DataSource = ds.Tables(0)
DGV1.ReadOnly = True
End Sub
End Class