-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathudmCust.pas
89 lines (75 loc) · 2.69 KB
/
udmCust.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
unit udmCust;
interface
uses
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.SQLite,
FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs, FireDAC.VCLUI.Wait, FireDAC.Phys.SQLiteWrapper.Stat,
FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.Client, Data.DB, FireDAC.Comp.DataSet;
type
TdmCust = class(TDataModule)
FDConnChinook: TFDConnection;
FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink;
qryUserVerify: TFDQuery;
qryCustCount: TFDQuery;
qryCustCountCustCount: TLargeintField;
qryCustomers: TFDQuery;
qryCustomersCustomerId: TFDAutoIncField;
qryCustomersFirstName: TWideStringField;
qryCustomersLastName: TWideStringField;
qryCustomersInvCount: TLargeintField;
qryCustomersTotalInvoices: TFloatField;
qryCustomersCompany: TWideStringField;
qryCustDetails: TFDQuery;
qryCustDetailsCustomerId: TFDAutoIncField;
qryCustDetailsFirstName: TWideStringField;
qryCustDetailsLastName: TWideStringField;
qryCustDetailsCompany: TWideStringField;
qryCustDetailsAddress: TWideStringField;
qryCustDetailsCity: TWideStringField;
qryCustDetailsState: TWideStringField;
qryCustDetailsCountry: TWideStringField;
qryCustDetailsPostalCode: TWideStringField;
qryCustDetailsPhone: TWideStringField;
qryCustDetailsEmail: TWideStringField;
qryCustomersIsBusiness: TBooleanField;
procedure qryCustomersCalcFields(DataSet: TDataSet);
public
function LoginCheck(const Username, Password: string): Boolean;
function CustCount: Integer;
procedure OpenCustDetails(const CustID: Integer);
procedure CloseCustDetails;
end;
var
dmCust: TdmCust;
implementation
{%CLASSGROUP 'Vcl.Controls.TControl'}
{$R *.dfm}
{ TdmCust }
function TdmCust.CustCount: Integer;
begin
qryCustCount.Open;
Result := qryCustCountCustCount.AsInteger;
qryCustCount.Close;
end;
function TdmCust.LoginCheck(const Username, Password: string): Boolean;
begin
qryUserVerify.ParamByName('FName').AsString := UpperCase(Username);
qryUserVerify.ParamByName('Password').AsString := Password;
qryUserVerify.Open;
Result := qryUserVerify.RecordCount > 0;
qryUserVerify.Close;
end;
procedure TdmCust.OpenCustDetails(const CustID: Integer);
begin
qryCustDetails.ParamByName('CustID').AsInteger := CustID;
qryCustDetails.Open;
end;
procedure TdmCust.qryCustomersCalcFields(DataSet: TDataSet);
begin
qryCustomersIsBusiness.AsBoolean := qryCustomersCompany.AsString.Length > 0;
end;
procedure TdmCust.CloseCustDetails;
begin
qryCustDetails.Close;
end;
end.