|
@@ -619,17 +619,36 @@ end;
|
|
|
|
|
|
procedure TProjectData.UpdatePhaseData;
|
|
|
|
|
|
- procedure UpdateGLPriceData;
|
|
|
+ function GetUpdateGLPriceSql(AAuditStatus, APhaseCount: Integer): string;
|
|
|
const
|
|
|
- sUpdateSql = 'Update GLPrice Set PM_Quantity%d = PM_Quantity%d, PM_TotalPrice%d = PM_TotalPrice%d'+
|
|
|
- ' Where PhaseID = %d';
|
|
|
+ vFields: array [0..5] of String = ('PM_Quantity', 'PM_TotalPrice', 'PAL_UsedQuantity', 'PAL_UsedTotalPrice', 'PAL_DeltaPrice', 'PAL_Total');
|
|
|
+ sUpdateSql = 'Update GLPrice Set %s Where PhaseID = %d';
|
|
|
+ {sUpdateSql = 'Update GLPrice Set PM_Quantity%d = PM_Quantity%d, PM_TotalPrice%d = PM_TotalPrice%d,'+
|
|
|
+ ' PAL_UsedQuantity%d = PAL_UsedQuantity%d, PAL_UsedTotalPrice%d = PAL_UsedTotalPrice%d,'+
|
|
|
+ ' PAL_DeltaPrice%d = PAL_DeltaPrice%d, PAL_Total%d = PAL_Total%d'+
|
|
|
+ ' Where PhaseID = %d';}
|
|
|
+ var
|
|
|
+ sField: string;
|
|
|
+ i: Integer;
|
|
|
+ begin
|
|
|
+ sField := '';
|
|
|
+ for i := Low(vFields) to High(vFields) do
|
|
|
+ begin
|
|
|
+ if i = High(vFields) then
|
|
|
+ sField := sField + Format('%s%d = %s%d', [vFields[i], AAuditStatus, vFields[i], AAuditStatus-1])
|
|
|
+ else
|
|
|
+ sField := sField + Format('%s%d = %s%d, ', [vFields[i], AAuditStatus, vFields[i], AAuditStatus-1])
|
|
|
+ end;
|
|
|
+ Result := Format(sUpdateSql, [sField, APhaseCount]);
|
|
|
+ end;
|
|
|
+
|
|
|
+ procedure UpdateGLPriceData;
|
|
|
var
|
|
|
sSql: string;
|
|
|
begin
|
|
|
if (ProjProperties.PhaseCount < 1) or (ProjProperties.AuditStatus < 1) then Exit;
|
|
|
|
|
|
- with ProjProperties do
|
|
|
- sSql := Format(sUpdateSql, [AuditStatus, AuditStatus-1, AuditStatus, AuditStatus-1, PhaseCount]);
|
|
|
+ sSql := GetUpdateGLPriceSql(ProjProperties.AuditStatus, ProjProperties.PhaseCount);
|
|
|
ExecuteSql(sSql);
|
|
|
end;
|
|
|
|