Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

New to C# need to change where table of data is pulled from

New to C# need to change where table of data is pulled from

New to C# need to change where table of data is pulled from


I'm new to c# and have spent the last day or so trying to change where this info is pulled from for creating a PDF within our application.

Below within the **** I need to change the data to look at a QuoteOption table instead of a Quote table.
I have traced the below code back to the red line below.

As i'm now running out of ideas just thought I would post here for some beginners help!


_options = (optionService.GetQuoteOptions(_quote.Id) ?? new List<QuoteOptionDto>()).ToList();

foreach (var o in _options)
decimal price = _quote.FastTrack ? o.FastTrackPrice ?? 0 : o.ListPrice ?? 0;
tblPriceList.AddCell(DataCell(o.Quantity + " X " + o.OptionDescription));
tblPriceList.AddCell(DataCell(o.Quantity * price, 2));

**** decimal chassisCost = o.Quantity * (o.ChassisMaterialCost ?? 0); ****
decimal bodyCost = o.Quantity * (o.BodyMaterialCost?? 0);
tblPriceList.AddCell(DataCell(chassisCost + bodyCost, 2));
tblPriceList.AddCell(DataCell(o.Quantity * o.BodyHours ?? 0, 2));
tblPriceList.AddCell(DataCell(o.Quantity * o.ChassisHours ?? 0, 2));

//Total trailer material cost
decimal totalMaterial = _options.Sum(x => (x.ChassisMaterialCost ?? 0) * x.Quantity)
+ _options.Sum(x => (x.BodyMaterialCost ?? 0) * x.Quantity)
+ (_trailer.ChassisMaterialCost ?? 0)
+ (_trailer.BodyMaterialCost ?? 0);

//Total body hrs
decimal totalBodyHours = _trailer.BodyHours.GetValueOrDefault()
+ _options.Sum(x => x.Quantity * x.BodyHours.GetValueOrDefault());

//Total chassis hrs
decimal totalChassisHours = _trailer.ChassisHours.GetValueOrDefault()
+ _options.Sum(x => x.Quantity * x.ChassisHours.GetValueOrDefault());

//Total body + chassis hrs
decimal labourHours = totalChassisHours + totalBodyHours;

RE: New to C# need to change where table of data is pulled from

Well, find out where optionService is getting _options from. From the naming I'd guess it is some web service, which itself will get data from some database, most probably.

Bye, Olaf.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close