2014-06-27 15:30:39 +02:00
|
|
|
unit MainDM;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2018-05-17 21:55:32 +02:00
|
|
|
System.SysUtils,
|
|
|
|
System.Classes,
|
|
|
|
FireDAC.Stan.Intf,
|
|
|
|
FireDAC.Stan.Option,
|
|
|
|
FireDAC.Stan.Error,
|
|
|
|
FireDAC.UI.Intf,
|
|
|
|
FireDAC.Phys.Intf,
|
|
|
|
FireDAC.Stan.Def,
|
|
|
|
FireDAC.Stan.Pool,
|
|
|
|
FireDAC.Stan.Async,
|
|
|
|
FireDAC.Phys,
|
|
|
|
FireDAC.Phys.FB,
|
|
|
|
Data.DB,
|
|
|
|
FireDAC.Comp.Client,
|
|
|
|
FireDAC.Stan.Param,
|
|
|
|
FireDAC.DatS,
|
|
|
|
FireDAC.DApt.Intf,
|
|
|
|
FireDAC.DApt,
|
|
|
|
FireDAC.Comp.DataSet,
|
|
|
|
FireDAC.Phys.FBDef,
|
|
|
|
FireDAC.VCLUI.Wait;
|
2014-06-27 15:30:39 +02:00
|
|
|
|
|
|
|
type
|
|
|
|
TdmMain = class(TDataModule)
|
|
|
|
Connection: TFDConnection;
|
|
|
|
dsArticles: TFDQuery;
|
|
|
|
updArticles: TFDUpdateSQL;
|
|
|
|
procedure ConnectionBeforeConnect(Sender: TObject);
|
|
|
|
private
|
|
|
|
{ Private declarations }
|
|
|
|
public
|
2018-11-21 22:11:58 +01:00
|
|
|
function SearchProducts(const SearchText: string): TDataSet;
|
2014-06-27 15:30:39 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{%CLASSGROUP 'Vcl.Controls.TControl'}
|
|
|
|
{$R *.dfm}
|
|
|
|
|
2018-11-21 22:11:58 +01:00
|
|
|
uses
|
|
|
|
System.IOUtils,
|
2023-09-01 12:49:10 +02:00
|
|
|
MVCFramework.Commons,
|
2018-11-21 22:11:58 +01:00
|
|
|
MVCFramework.DataSet.Utils;
|
|
|
|
|
2014-06-27 15:30:39 +02:00
|
|
|
procedure TdmMain.ConnectionBeforeConnect(Sender: TObject);
|
2018-11-21 22:11:58 +01:00
|
|
|
begin
|
2023-09-01 12:49:10 +02:00
|
|
|
Connection.Params.Values['Database'] := dotEnv.Env('database.path');
|
2018-11-21 22:11:58 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TdmMain.SearchProducts(const SearchText: string): TDataSet;
|
2014-06-27 15:30:39 +02:00
|
|
|
begin
|
2018-11-21 22:11:58 +01:00
|
|
|
Result := TFDMemTable.Create(nil);
|
|
|
|
if SearchText.IsEmpty then
|
|
|
|
dsArticles.Open('SELECT * FROM ARTICOLI')
|
|
|
|
else
|
|
|
|
dsArticles.Open('SELECT * FROM ARTICOLI WHERE DESCRIZIONE CONTAINING ?', [SearchText]);
|
|
|
|
TFDTable(Result).CopyDataSet(dsArticles, [coStructure, coRestart, coAppend]);
|
2014-06-27 15:30:39 +02:00
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|