Hi all,
My name is ade, am presently working on a personal project(Drycleaning application) which has a third party control, a hierarchical datagrid control (which I download from application aspect), the control is actually like a datagrid view control but also it incorporates a treeview feature, that is treeview view node like structure which displays data in hierarchical format (that is nodes and subnodes).
Here is the thing, the way I structure the hierarchical datagrid has data displayed in this format:
Column1 Column2 Column3 Column4
- 1 blouse 400 0 ----------(node or parent node)
Blue 1 --------(Sub node or child row)
Cotton 1 --------(Sub node or child row)
- 3 Camisole 350 0 ----------(node or parent node)
White 2 --------(Sub node or child row)
Linen 2 --------(Sub node or child row)
Press Only 175 2 --------(Sub node or child row)
- 2 Dress 250 0 ----------(node or parent node)
Yellow 3 --------(Sub node or child row)
Wool 3 --------(Sub node or child row)
Press Only -125 3 --------(Sub node or child row)
- 2 Shorts 450 0 ----------(node or parent node)
Yellow 4 --------(Sub node or child row)
Wool 4 --------(Sub node or child row)
Press Only -225 4 --------(Sub node or child row)
The first column is for quantities the second is for item description, the third is for cost where relevant and third is for numbering sequence I coded and which displays in the format above.
Now after achieving this I need to have this data pushed to two different tables, the top nodes or parent rows, which has Zero entry in their fourth column cell alone and which contains entry the quantity(column1), garment name or garment type (column2) and cost(column3) goes to a particular table and the the other items like the color and material type and any other service (like in this case press only goes to another table).
I tried the code , just as i want , but it replicates this row on the amount of rows below each individual parent row.
cmdgarmentorderdetails.Connection = cnngarmentcategory
cnngarmentcategory.Open()
For i As Integer = 0 To HDGVLaundry.NewRowIndex - 1
If HDGVLaundry.Rows(i).Cells(4).Value = 0 Then
GarmentQty = HDGVLaundry.Rows(i).Cells(1).Value
GarmentDesc = HDGVLaundry.Rows(i).Cells(2).Value
Garmentcost = HDGVLaundry.Rows(i).Cells(3).Value
Orderticketid = LblOrderticketID.Text
cmdgarmentorderdetails.CommandText = "INSERT INTO TblTicketDescDetails(OrderTicketiD,GarmentDesc,GarmentQty,Garmentcost) Values('" & Orderticketid & "','" & GarmentDesc & "' ,'" & GarmentQty & "','" & Garmentcost & "')"
Else
cmdgarmentorderdetails.Cancel()
End If
cmdgarmentorderdetails.ExecuteNonQuery()
Next
End Sub
Result:
1002 1 blouse 400
1002 1 blouse 400
1002 1 blouse 400
1002 3 Camisole 350
1002 3 Camisole 350
1002 3 Camisole 350
1002 3 Camisole 350
1002 2 Dress 250
1002 2 Dress 250
1002 2 Dress 250
1002 2 Dress 250
1002 2 Shorts 450
1002 2 Shorts 450
1002 2 Shorts 450
1002 2 Shorts 450
instead of just like this:
1002 1 blouse 400
1002 3 Camisole 350
1002 2 Dress 250
1002 2 Shorts 450
please what am i doing wrong
Thank you in advance
Regards
Ade