P
Paul Ilacqua
I'm using VB .NET and I'm trying to "roll my own" report subtotals. I'm
building a string from a datareader top pass to a reporting class and I want
to break and subtotal QTY at each change in shipper and I have struggled
with the code to do so for days and just can't seem to get it. I can get it
to insert a draw a line at a shipper change, but I can't get the subtotals.
The actual Code is down below data sample. I appreciate any advice I can
receive.
Paul
SHIP PART QTY
----------------------------------------------------
01082153 54472 180
01082155 54472 40
01082156 51166 8
01082156 51167 16
01082156 51168 8
01082156 51169 184
01082156 53442 8
01082157 51167 16
01082157 51168 8
01082157 51169 192
01082157 53442 8
01082158 51167 24
01082158 51168 8
01082158 51169 184
01082158 53442 8
01082159 50120 15
01082159 54827 90
01082159 54829 15
01082159 54830 225
01082160 54827 90
'code
While dr.Read
If iCounter = 0 Then
FirstPass = dr.GetString(0)
iCounter = CShort(iCounter + 1)
End If
iTotal = iTotal + dr.GetInt32(2)
CurrentPass = dr.GetString(0)
If CurrentPass <> FirstPass Then
FirstPass = CurrentPass
sb.Append(StrDup(80, "-") & vbCrLf)
sb.Append("Sub Total: " & SubTotal & vbCrLf)
sb.Append(StrDup(80, "-") & vbCrLf)
SubTotal = 0
sb.Append(dr.GetString(0).PadRight(15) _
& dr.GetString(1).PadRight(15) _
& dr.GetInt32(2).ToString.PadRight(15) _
& dr.GetString(3).PadRight(15) & dr.GetString(4) & vbCrLf)
Else
SubTotal = SubTotal + dr.GetInt32(2)
sb.Append(dr.GetString(0).PadRight(15) _
& dr.GetString(1).PadRight(15) _
& dr.GetInt32(2).ToString.PadRight(15) _
& dr.GetString(3).PadRight(15) & dr.GetString(4) & vbCrLf)
End If
End While
building a string from a datareader top pass to a reporting class and I want
to break and subtotal QTY at each change in shipper and I have struggled
with the code to do so for days and just can't seem to get it. I can get it
to insert a draw a line at a shipper change, but I can't get the subtotals.
The actual Code is down below data sample. I appreciate any advice I can
receive.
Paul
SHIP PART QTY
----------------------------------------------------
01082153 54472 180
01082155 54472 40
01082156 51166 8
01082156 51167 16
01082156 51168 8
01082156 51169 184
01082156 53442 8
01082157 51167 16
01082157 51168 8
01082157 51169 192
01082157 53442 8
01082158 51167 24
01082158 51168 8
01082158 51169 184
01082158 53442 8
01082159 50120 15
01082159 54827 90
01082159 54829 15
01082159 54830 225
01082160 54827 90
'code
While dr.Read
If iCounter = 0 Then
FirstPass = dr.GetString(0)
iCounter = CShort(iCounter + 1)
End If
iTotal = iTotal + dr.GetInt32(2)
CurrentPass = dr.GetString(0)
If CurrentPass <> FirstPass Then
FirstPass = CurrentPass
sb.Append(StrDup(80, "-") & vbCrLf)
sb.Append("Sub Total: " & SubTotal & vbCrLf)
sb.Append(StrDup(80, "-") & vbCrLf)
SubTotal = 0
sb.Append(dr.GetString(0).PadRight(15) _
& dr.GetString(1).PadRight(15) _
& dr.GetInt32(2).ToString.PadRight(15) _
& dr.GetString(3).PadRight(15) & dr.GetString(4) & vbCrLf)
Else
SubTotal = SubTotal + dr.GetInt32(2)
sb.Append(dr.GetString(0).PadRight(15) _
& dr.GetString(1).PadRight(15) _
& dr.GetInt32(2).ToString.PadRight(15) _
& dr.GetString(3).PadRight(15) & dr.GetString(4) & vbCrLf)
End If
End While