-
ASK How to
I need help...please..Urgent
How do I enter the data from textbox to datagridview like the example image below
http://img545.imageshack.us/img545/9782/askforum.png
I'm using Visual Basic 2005 and acces 2003
sourcecode which I make like this
Code:
Imports System.Data.OleDb
Public Class aski
Dim con As New OleDbConnection
Private Sub aski_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0; data source = ..\ASKI.mdb"
con.Open()
con.Close()
Showitem()
End Sub
'-----PErhitungan AFINITY K07A COVER TOP R--------'
Private Sub AFQT1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AFQT1.TextChanged
Dim Qtpro, Qtl1, Bom1, Weight1, GI1, Total1 As Decimal
Const Konstan As Single = 1000
Qtpro = Val(AFRTOP_QTPRO.Text)
Qtl1 = Val(AFQT1.Text)
Bom1 = Val(AFRTOP_BOM1.Text)
Weight1 = Val(AFRTOP_WG1.Text)
GI1 = Val(AFRTOP_GI1.Text)
Total1 = Val(AF_TWG1.Text)
Weight1 = Qtpro * Bom1
Total1 = Weight1 + 0
GI1 = (Weight1 / Total1) * (Qtl1 * Konstan)
AFRTOP_WG1.Text = Format(Weight1, "###,###.")
AF_TWG1.Text = Format(Total1, "###,###.#0")
AFRTOP_GI1.Text = Format(GI1, "###,###.#0")
End Sub
Private Sub Showitem()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
con.Open()
da = New OleDbDataAdapter("Select * from AFINITY", con)
da.Fill(dt)
DataGridView1.DataSource = dt.DefaultView
con.Close()
End Sub
Private Sub BTHAPUS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTHAPUS.Click
AFRTOP_QTPRO.Text = ""
AFQT1.Text = ""
AFRTOP_NOPRO.Text = ""
AFRTOP_GI1.Text = ""
AF_TWG1.Text = ""
End Sub
Private Sub BTSAVER_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTSAVER.Click
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("Select * From AFINITY", con)
da.Fill(dt)
dt.Columns.Add("pp", GetType(System.Int64))
Me.DataGridView1.DataSource = dt
Me.DataGridView1.Columns("Good_Issue").DefaultCellStyle.Format = "###,###.#0"
Dim newrow As DataRow = dt.NewRow
With newrow
.Item("No_PRO") = AFRTOP_NOPRO.Text
.Item("Qty_PRO") = AFRTOP_QTPRO.Text
.Item("Bom_Weight") = AFRTOP_WG1.Text
.Item("Good_Issue") = AFRTOP_GI1.Text
.Item("Description") = LBCAT.Text
.Item("Tgl_Bln_Thn") = DateTimePicker1.Value
End With
dt.Rows.Add(newrow)
Dim cb As New OleDbCommandBuilder(da)
da.Update(dt)
con.Close()
Showitem()
End Sub
Private Sub BTGIR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTGIR.Click
Clipboard.SetText(AFRTOP_GI1.Text & vbCrLf & AFRTOP_GI2.Text & vbCrLf & AFRTOP_GI3.Text & vbCrLf & AFRTOP_GI4.Text & vbCrLf & AFRTOP_GI5.Text)
End Sub
Private Sub AFQT2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AFQT2.TextChanged
Dim Qtpro, Qtl2, Bom2, Weight2, GI2, Total2 As Decimal
Const Konstan As Single = 1000
Qtpro = Val(AFRTOP_QTPRO.Text)
Qtl2 = Val(AFQT2.Text)
Bom2 = Val(AFRTOP_BOM2.Text)
Weight2 = Val(AFRTOP_WG2.Text)
GI2 = Val(AFRTOP_GI2.Text)
Total2 = Val(AF_TWG2.Text)
Weight2 = Qtpro * Bom2
Total2 = Weight2 + 0
GI2 = (Weight2 / Total2) * (Qtl2 * Konstan)
AFRTOP_WG2.Text = Format(Weight2, "###,###.")
AF_TWG2.Text = Format(Total2, "###,###.#0")
AFRTOP_GI2.Text = Format(GI2, "###,###.#0")
End Sub
Private Sub AFQT3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AFQT3.TextChanged
Dim Qtpro, Qtl3, Bom3, Weight3, GI3, Total3 As Decimal
Const Konstan As Single = 1000
Qtpro = Val(AFRTOP_QTPRO.Text)
Qtl3 = Val(AFQT3.Text)
Bom3 = Val(AFRTOP_BOM3.Text)
Weight3 = Val(AFRTOP_WG3.Text)
GI3 = Val(AFRTOP_GI3.Text)
Total3 = Val(AF_TWG3.Text)
Weight3 = Qtpro * Bom3
Total3 = Weight3 + 0
GI3 = (Weight3 / Total3) * (Qtl3 * Konstan)
AFRTOP_WG3.Text = Format(Weight3, "###,###.")
AF_TWG3.Text = Format(Total3, "###,###.#0")
AFRTOP_GI3.Text = Format(GI3, "###,###.#0")
End Sub
Private Sub AFQT4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AFQT4.TextChanged
Dim Qtpro, Qtl4, Bom4, Weight4, GI4, Total4 As Decimal
Const Konstan As Single = 1000
Qtpro = Val(AFRTOP_QTPRO.Text)
Qtl4 = Val(AFQT4.Text)
Bom4 = Val(AFRTOP_BOM4.Text)
Weight4 = Val(AFRTOP_WG4.Text)
GI4 = Val(AFRTOP_GI4.Text)
Total4 = Val(AF_TWG4.Text)
Weight4 = Qtpro * Bom4
Total4 = Weight4 + 0
GI4 = (Weight4 / Total4) * (Qtl4 * Konstan)
AFRTOP_WG4.Text = Format(Weight4, "###,###.")
AF_TWG4.Text = Format(Total4, "###,###.#0")
AFRTOP_GI4.Text = Format(GI4, "###,###.#0")
End Sub
Private Sub AFQT5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AFQT5.TextChanged
Dim Qtpro, Qtl5, Bom5, Weight5, GI5, Total5 As Decimal
Const Konstan As Single = 1000
Qtpro = Val(AFRTOP_QTPRO.Text)
Qtl5 = Val(AFQT5.Text)
Bom5 = Val(AFRTOP_BOM5.Text)
Weight5 = Val(AFRTOP_WG5.Text)
GI5 = Val(AFRTOP_GI5.Text)
Total5 = Val(AF_TWG5.Text)
Weight5 = Qtpro * Bom5
Total5 = Weight5 + 5
GI5 = (Weight5 / Total5) * (Qtl5 * Konstan)
AFRTOP_WG5.Text = Format(Weight5, "###,###.")
AF_TWG5.Text = Format(Total5, "###,###.#0")
AFRTOP_GI5.Text = Format(GI5, "###,###.#0")
End Sub
End Class