bogdanpolak / bogdanpolak/delphi-dataproxy
Build new sample - DataModule
- Dominant language
- Pascal
- Stars
- 19
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Use code snippets to build new sample project: `03-datamodule`
```pas
procedure TDataModule1.OnCreate(Sender: TObject);
begin
fOrdersProxy := TOrdersProxy.Create(fOwner);
fOrdersDataSource := fOrdersProxy.ConstructDataSource;
end;
procedure TDataModule1.InitOrders(aYear, aMonth: word);
begin
fOrdersProxy.WithFiredacSQL( FDConnection1,
'SELECT OrderID, CustomerID, OrderDate, Freight' +
' FROM {id Orders} WHERE OrderDate between' +
' :StartDate and :EndDate',
[ GetMonthStart(aYear, aMonth),
GetMonthEnd(aYear, aMonth) ],
[ftDate, ftDate])
.Open;
fOrdersInitialized := True;
end;
procedure TDataModule1.InitOrders(aDataSet: TDataSet);
begin
fOrdersProxy.WithDataSet(aDataSet).Open;
fOrdersInitialized := True;
end;
```
```pas
function TDataModule.CalculateTotalOrders (const aCustomerID: string): Currency;
begin
Result := 0;
procedure ForEach(OnElem: TProc);
fOrdersProxy.ForEach(procedure
begin
if fOrdersProxy.CustomerID.Value = aCustomerID then
Result := Result + fOrdersProxy.GetTotalOrderValue;
end;
end;
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.