SumHours Procedure
The SumHours 3GL procedure calculates the time and cost for projects. The following is the C code for this procedure:
/**
** Sum_hours.sc: Sum the total hours in
** the tasktable.hours column in emptasks.
**
** Arguments:
** hourly_rate: the current hourly rate;
**
** Side Effects:
** Computes and displays total hours
** and cost in emptasks form.
** Changes tot_hours to blink if over
** 40 hours assigned.
**
** Returns:
** Nothing.
**/
void
sum_hours(hourly_rate)
double hourly_rate;
{
exec sql begin declare section;
long hours, tot_hours;
double tot_cost;
short ni, overhours, state;
exec sql end declare section;
tot_hours = 0; overhours= 0;
exec frs unloadtable emptasks tasktable(:hours:ni=hours,
:state=_STATE);
exec frs begin;
if (state != 4 && state !=0
&& ni != -1)
tot_hours = tot_hours + hours;
exec frs end;
tot_cost = tot_hours * hourly_rate;
exec frs putform emptasks
(tot_hours=:tot_hours,tot_cost=:tot_cost);
if (tot_hours 40)
overhours=1;
exec frsset_frs field emptasks (blink(tot_hours) =
:overhours);
return;
}
Last modified date: 04/03/2024