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 Penjualan

 

Sub TampilBarang()
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 Penjualan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
Call TampilBarang()
End Sub

 

Private Sub DGV1_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV1.CellMouseClick

Dim baris As Integer = DGV.RowCount - 1
On Error Resume Next
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 ganda
For barisatas As Integer = 0 To DGV.RowCount - 1
For barisbawah As Integer = barisatas + 1 To DGV.RowCount - 1
If DGV.Rows(barisbawah).Cells(0).Value = DGV.Rows(barisatas).Cells(0).Value Then
DGV.Rows(barisatas).Cells(3).Value = DGV.Rows(barisatas).Cells(3).Value + 1
DGV.Rows(barisatas).Cells(4).Value = DGV.Rows(barisatas).Cells(2).Value * DGV.Rows(barisatas).Cells(3).Value
DGV.Rows.RemoveAt(barisbawah)
Exit Sub
End If
Next
Next
'======================================================
DGV.Rows(baris).Cells(4).Value = DGV.Rows(baris).Cells(2).Value * DGV.Rows(baris).Cells(3).Value
End Sub

 

End Class