Master - Detail

Stimulsoft Reports.NET discussion
Post Reply
firstlover
Posts: 1
Joined: Tue Nov 04, 2008 4:02 am

Master - Detail

Post by firstlover »

Let's go to the case :
My simple report :


-->Group Header
Cheque Number : 1, vendor : A, Extradisc: 1,000

--> Data
Item A Qty:1 Price: 50,000 Total:50,000
Item B Qty:1 Price: 50,000 Total:50,000
_________________________________________________
Subtotal:100,000
Extradisc: 1,000
Grandtotal: 99,000


Cheque Number : 2, vendor : B, Extradisc: 1,000

--> Data
Item D Qty:1 Price: 50,000 Total:50,000
_________________________________________________
Subtotal: 50,000
Extradisc: 1,000
Grandtotal: 49,000


For the summary i use :

Sum(Table.Subtotal) = 150,000 ... OK
Sum(Table.Grandtotal) = 148,000 .. OK

The problem is when i use Sum(Table.Extradisc) , the report gave me the value of 3,000 instead of 2,000
I see that when i use sum of extradisc on the first group (cheque number : 1), it calculated te extradisc twice because it has two detail)
How can i do some 'distinct' to that?

The rows return in sql
Cheque Number | Vendor | Extradisc | Product | Qty | Price | Total
1 | A | 1,000 | Item A | 1 | 50,000 | 50,000 --\ The report calculate the extradisc twice
1 | A | 1,000 | Item B | 1 | 50,000 | 50,000 --/ because it has two details, can i use
'distinct' thing?
2 | B | 1,000 | Item D | 1 | 50,000 | 50,000

Anyone can solve my problem?
sorry for my bad english :blush:

Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Master - Detail

Post by Vital »

Hello,

Create variable in report dictionary. After then in report code add following line of code:

Code: Select all

Hashtable values = new Hashtable();
After then in BeginRenderEvent of GroupHeaderBand type following code:

Code: Select all

values.Clear();
In RenderingEvent of GroupHeaderBand use following code:

Code: Select all

if (values[Table.Subtotal] == null)
{
  myVariable += Table.Subtotal;
  values[Table.Subtotal] = Table.Subtotal;
}
In text box use following expression:

Code: Select all

{Table.Subtotal}
Thank you.
Post Reply