Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

markd885

Technical User
Jan 5, 2016
3
0
0
GB
Hi,

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!

Thanks

_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;
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top