82 lines
2.1 KiB
ObjectPascal
82 lines
2.1 KiB
ObjectPascal
unit PurchasePlan;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
wItem,
|
|
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.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt,
|
|
FireDAC.Phys.PGDef, FireDAC.VCLUI.Wait, FireDAC.Comp.UI, FireDAC.Phys.PG,
|
|
Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client
|
|
;
|
|
|
|
type
|
|
TPurchasePlan = class(TwItem)
|
|
private
|
|
{ Private declarations }
|
|
FOrdNum: string;
|
|
FQty: string;
|
|
FUnitt: string;
|
|
FUnitPrice: string;
|
|
FAmount: string;
|
|
protected
|
|
{ Protected declarations }
|
|
public
|
|
{ Public declarations }
|
|
class function xGetPurchasePlanLastNumber(AQuery: TFDQuery; column: string): string;
|
|
class function LoadFromStringsQuery(AQuery: TFDQuery; column: string): TStrings;
|
|
published
|
|
{ Published declarations }
|
|
property OrdNum: string read FOrdNum write FOrdNum;
|
|
property Qty: string read FQty write FQty;
|
|
property Unitt: string read FUnitt write FUnitt;
|
|
property UnitPrice: string read FUnitPrice write FUnitPrice;
|
|
property Amount: string read FAmount write FAmount;
|
|
end;
|
|
|
|
implementation
|
|
|
|
{ TPurchasePlan }
|
|
|
|
class function TPurchasePlan.LoadFromStringsQuery(AQuery: TFDQuery;
|
|
column: string): TStrings;
|
|
var
|
|
valStr: string;
|
|
begin
|
|
Result := TStringList.Create;
|
|
while not AQuery.Eof do begin
|
|
valStr := AQuery.FieldByName(column).AsString;
|
|
Result.Add(valStr);
|
|
|
|
AQuery.Next;
|
|
end;
|
|
end;
|
|
|
|
class function TPurchasePlan.xGetPurchasePlanLastNumber(AQuery: TFDQuery;
|
|
column: string): string;
|
|
var
|
|
sql: string;
|
|
resStrs: TStrings;
|
|
begin
|
|
Result := '';
|
|
sql := 'SELECT COUNT(*) FROM "PurchasePlan"';
|
|
try
|
|
AQuery.Close;
|
|
AQuery.SQL.Text := sql;
|
|
AQuery.Open;
|
|
except
|
|
on E: Exception do ShowMessage('xGetPurchasePlanLastNumber Äõ¸® ½ÇÇà ¿À·ù: ' + E.Message);
|
|
end;
|
|
resStrs := LoadFromStringsQuery(AQuery, column);
|
|
if resStrs.Count > 0 then begin
|
|
Result := resStrs.Strings[0];
|
|
end;
|
|
resStrs.Free;
|
|
end;
|
|
|
|
end.
|
|
|