BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can it be done

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Charlie
Guest





PostPosted: Wed Jun 08, 2005 2:11 pm    Post subject: Can it be done Reply with quote



Hi all. I hope that you can help me with my learning curve.
I'm using Delphi 5 with dBase files with TQuery and TDataSource. Grid is
TDBGrid.
I need to populate a grid with data from the orders table as follows:
Column1 would be the Order Due Date.
Column2 would be the Total of Widgets ordered for that day if any
Column3 would be the Total of Gidgets ordered for that day if any
Column4 would be the Total of WhatsIts ordered for that day if any
In the Orders table are Boolean fields set to True if that order is for
Widgets, Gidgets or WhatsIts. The field ItemTotal contains the total of
Widgets, Gidgets, or WhatsIts as applicable.

The following code gives me a grid with the Order Due Dates but nothing for
the other columns.

with qryDueDate_, SQL do
begin
dWidgetsBalance := 0;
dGidgetsBalance := 0;
dWhatsItsBalance := 0;
dtpDueDate.Date := (Now + 1);
Clear;
Add('SELECT DueDate, ItemTotal, bWidgets, bGidgets, bWhatsIts From
Orders');
Add('WHERE DueDate >= :sDueDate');
qryDueDate_.ParamByName('sDueDate').AsDate := dtpDueDate.Date;
Add('Group By DueDate, BoxTotal, bWidgets, bGidgets, bWhatsIts');
Add('Order by DueDate');

Open;
while not EOF do
begin
if (qryDueDate_.FieldByName('bWidgets').AsString = 'True') then
dWidgetsBalance := dWidgetsBalance +
qryDueDate_ItemTotal.AsInteger
else if (qryDueDate_.FieldByName('bGidgets').AsString = 'True') then
dGidgetsBalance := dGidgetsBalance +
qryDueDate_ItemTotal.AsInteger
else if (qryDueDate_.FieldByName('bWhatsIts').AsString = 'True')
then
dWhatsItsBalance := dWhatsItsBalance +
qryDuedate_ItemTotal.AsInteger;
Next;
end;

Thank you,
Charlie


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.