Skip to Content
0

Trouble displaying the same level listing as a list that has been Group

Feb 07 at 04:24 PM

13

avatar image
Former Member

I'm having trouble displaying the same level listing as a list that has been Group. Here I will try to explain most easily

My data is as follows:

Driver
{
0_Code: 01 | Name: A | Salary: 1000
1_Code: 02 | Name: B | Salary: 2000
}
Travel
{
0_DriverC: 01 | Name: A | Salary: 1000 | Date: 5/2 | Route: ABC 
1_DriverC: 01 | Name: A | Salary: 1000 | Date: 7/2 | Route: XYZ
2_DriverC: 02 | Name: B | Salary: 2000 | Date: 1/2 | Route: EFG
}
Expense
{
0_DriverC: 01 | ExpenseN: X | ExpenseMoney: 100
1_DriverC: 01 | ExpenseN: Y | ExpenseMoney: 500
2_DriverC: 01 | ExpenseN: Z | ExpenseMoney: 300
3_DriverC: 02 | ExpenseN: K | ExpenseMoney: 400
}

In CrystalReport i designed the following:

Section1(Report Header)
_____________________________
Section2(Page Header)
_____________________________
GroupHeaderSection2(Group Header#1: Travel.DriverC-A)
_____________________________
Section3(Details)
Driver Name: ?Name
?Date    ?DriverC     ?Nane    ?Route   ?Salary
_____________________________
GroupHeaderSection2(Group Footer#1: Travel.DriverC-A)
TotalSalary                                                 Sum of ?Salary
ExpenseN (Here i will list the costs by the Driver group)   ?ExpenseMoney
Total                                           Sum of ?Salary,?ExpenseMoney

The results Report i want can be as follows:

Driver Name: A
5/2    01     A     ABC    1000
7/2    01     A     XYZ    1000
TotalSalary                2000
X                          100
Y                          500
Z                          300
Total                      4900
_____________________________
Driver Name: B
1/2    02     B     EFG    2000
TotalSalary                2000
K                          400
Total                      2400

This is the code that assigns values to DataRow:

var travel = TravelService.GetAllQueryable().ToList();
for(int i = 0; i < travel.Count; i++)
{
    row = dt.NewRow();
    row["Date"] = travel[i].Date;
    row["DriverC"] = travel[i].DriverC;
    row["Nane"] = travel[i].Nane;
    row["Route"] = travel[i].Route;
    row["Salary"] = travel[i].Salary;
    var expense = ExpenseService.Query(p => p.DriverC == travel[i].DriverC).ToList();
    for(int k = 0; k < expense.Count; k++)
    {
       row["ExpenseN"] = expense[k].ExpenseN;
       row["ExpenseMoney"] = expense[k].ExpenseMoney;
    }
    dt.Rows.Add(row);
}

I think the code assigning value to Expense has a problem. I am confused when displaying a list of the same level. How can I display the list of Expense by Travel has been grouped?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers