MBHEY131
asked on
Referencing a (dataset variable in code)
vs2012 vb.net
Here's me code:
Public Sub btnApply_Click(sender As Object, e As EventArgs) Handles btnApply.Click
Dim frm As New RO_PartsL1
Dim dstest As System.Data.DataSet = New Database1DataSet11
dstest.Tables("PrtsLn1").C olumns.Add ("Parts_Qu antitySold ")
Dim i As Integer = 0
Dim TtlPrtsSellingPriceLn1 As Decimal = 0
Dim TtlPrtsCostLn1 As Decimal = 0
For Each row As DataGridViewRow In DataGridView1.Rows
Dim chkboxcell As DataGridViewCheckBoxCell = row.Cells("Parts_PutOnRO")
If chkboxcell.Value = True Then
Dim m_PartNum_ForRO As String = Me.Database1DataSet11.Tabl es("PartsI nv").Rows( i).Item("P arts_Num")
Dim m_PartDesc_ForRO As String = Me.Database1DataSet11.Tabl es("PartsI nv").Rows( i).Item("P arts_Desc" )
Dim m_SoldQty_ForRO As Decimal = 1
Dim m_SellingPrice_ForRO As Decimal = Me.Database1DataSet11.Tabl es("PartsI nv").Rows( i).Item("P arts_List" )
Dim m_PartCost_ForRO As Decimal = Me.Database1DataSet11.Tabl es("PartsI nv").Rows( i).Item("P arts_Cost" )
'Your insert query to save to database table
Dim myDr As DataRow
myDr = dstest.Tables("PrtsLn1").N ewRow()
myDr("Parts_Num") = m_PartNum_ForRO
myDr("Parts_Desc") = m_PartDesc_ForRO
myDr("Parts_QuantitySold") = m_SoldQty_ForRO
myDr("Parts_SellingPrice") = m_SellingPrice_ForRO
TtlPrtsSellingPriceLn1 = TtlPrtsSellingPriceLn1 + m_SellingPrice_ForRO
myDr("Parts_Cost") = m_PartCost_ForRO
TtlPrtsCostLn1 = TtlPrtsCostLn1 + m_PartCost_ForRO
dstest.Tables("PrtsLn1").R ows.Add(my Dr)
End If
i = i + 1
Next
If TtlPrtsSellingPriceLn1 <> 0 Then
UpdtePrtsSellingPriceLn1(T tlPrtsSell ingPriceLn 1)
Else
End If
If TtlPrtsCostLn1 <> 0 Then
UpdtePrtsCostLn1(TtlPrtsCo stLn1)
Else
End If
'TODO: This line of code loads data into the 'Database1DataSet11.PrtsLn 1' table. You can move, or remove it, as needed.
frm.DGV_Line1.DataSource = dstest.Tables("PrtsLn1")
Me.Close()
frm.Show()
End Sub
everything seems to be working up to here
? is when I exit the "SUB" - How do I reference the DATA IN "frm.DGV_Line1.DataSource = dstest.Tables("PrtsLn1")"
if "dstest" is a block declared VARIABLE "data in the datagridview I mean"
I don't want to declare it DSTEST as a Global variable if I don't have to.
Here's me code:
Public Sub btnApply_Click(sender As Object, e As EventArgs) Handles btnApply.Click
Dim frm As New RO_PartsL1
Dim dstest As System.Data.DataSet = New Database1DataSet11
dstest.Tables("PrtsLn1").C
Dim i As Integer = 0
Dim TtlPrtsSellingPriceLn1 As Decimal = 0
Dim TtlPrtsCostLn1 As Decimal = 0
For Each row As DataGridViewRow In DataGridView1.Rows
Dim chkboxcell As DataGridViewCheckBoxCell = row.Cells("Parts_PutOnRO")
If chkboxcell.Value = True Then
Dim m_PartNum_ForRO As String = Me.Database1DataSet11.Tabl
Dim m_PartDesc_ForRO As String = Me.Database1DataSet11.Tabl
Dim m_SoldQty_ForRO As Decimal = 1
Dim m_SellingPrice_ForRO As Decimal = Me.Database1DataSet11.Tabl
Dim m_PartCost_ForRO As Decimal = Me.Database1DataSet11.Tabl
'Your insert query to save to database table
Dim myDr As DataRow
myDr = dstest.Tables("PrtsLn1").N
myDr("Parts_Num") = m_PartNum_ForRO
myDr("Parts_Desc") = m_PartDesc_ForRO
myDr("Parts_QuantitySold")
myDr("Parts_SellingPrice")
TtlPrtsSellingPriceLn1 = TtlPrtsSellingPriceLn1 + m_SellingPrice_ForRO
myDr("Parts_Cost") = m_PartCost_ForRO
TtlPrtsCostLn1 = TtlPrtsCostLn1 + m_PartCost_ForRO
dstest.Tables("PrtsLn1").R
End If
i = i + 1
Next
If TtlPrtsSellingPriceLn1 <> 0 Then
UpdtePrtsSellingPriceLn1(T
Else
End If
If TtlPrtsCostLn1 <> 0 Then
UpdtePrtsCostLn1(TtlPrtsCo
Else
End If
'TODO: This line of code loads data into the 'Database1DataSet11.PrtsLn
frm.DGV_Line1.DataSource = dstest.Tables("PrtsLn1")
Me.Close()
frm.Show()
End Sub
everything seems to be working up to here
? is when I exit the "SUB" - How do I reference the DATA IN "frm.DGV_Line1.DataSource = dstest.Tables("PrtsLn1")"
if "dstest" is a block declared VARIABLE "data in the datagridview I mean"
I don't want to declare it DSTEST as a Global variable if I don't have to.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
don't like using Global Variables but I have to access that data from another form
Open in new window
Which produces the following output --saige-