📄 databasequerydm.pas
字号:
unit DataBaseQueryDm;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComServ, ComObj, VCLCom, StdVcl, bdemts, DataBkr, DBClient,
MtsRdm, Mtx, DataBaseQueryData_TLB, DB, ADODB, Provider;
type
TmtsQueryObj = class(TMtsDataModule, ImtsQueryObj)
ADOQuery: TADOQuery;
dspQuery: TDataSetProvider;
procedure MtsDataModuleCreate(Sender: TObject);
private
{ Private declarations }
protected
class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
function QueryEmployeesByDepartId(const ADepartId: WideString): OleVariant;
safecall;
function QueryPerGroupByDepart(const AId: WideString): OleVariant;
safecall;
function IsBarCodeExists(const ABarCode: WideString): WordBool; safecall;
public
{ Public declarations }
end;
var
mtsQueryObj: TmtsQueryObj;
implementation
uses uDBConfig, uGlobal, StrUtils;
{$R *.DFM}
class procedure TmtsQueryObj.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
if Register then
begin
inherited UpdateRegistry(Register, ClassID, ProgID);
EnableSocketTransport(ClassID);
EnableWebTransport(ClassID);
end else
begin
DisableSocketTransport(ClassID);
DisableWebTransport(ClassID);
inherited UpdateRegistry(Register, ClassID, ProgID);
end;
end;
procedure TmtsQueryObj.MtsDataModuleCreate(Sender: TObject);
begin
ADOQuery.Close;
ADOQuery.ConnectionString := GetConnectionString;
end;
function TmtsQueryObj.QueryEmployeesByDepartId(
const ADepartId: WideString): OleVariant;
begin
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add('select id, name from t_employee '+
'where SUBSTRING(id,3,3)='+QuotedStr(RightStr(ADepartId,3)));
ADOQuery.Open;
result := dspQuery.Data;
end;
function TmtsQueryObj.QueryPerGroupByDepart(
const AId: WideString): OleVariant;
begin
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add('select id, name from t_PermissionMaster '+
'where SUBSTRING(name,1,2)='+QuotedStr(AId));
ADOQuery.Open;
result := dspQuery.Data;
end;
function TmtsQueryObj.IsBarCodeExists(
const ABarCode: WideString): WordBool;
begin
ADOQuery.Close;
ADOQuery.SQL.Clear;
ADOQuery.SQL.Add('select BarCode from t_GoodsMaster where BarCode=:BarCode');
ADOQuery.Parameters.ParamByName('BarCode').Value := ABarCode;
ADOQuery.Open;
result := (ADOQuery.RecordCount>0);
end;
initialization
TComponentFactory.Create(ComServer, TmtsQueryObj,
Class_mtsQueryObj, ciMultiInstance, tmApartment);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -