spellinputdmunit.pas

来自「仓库管理」· PAS 代码 · 共 73 行

PAS
73
字号
unit SpellInputDMUnit;

interface

uses
  SysUtils, Classes, DB, DBClient, SimpleDS;

type
  TSpellInputDM = class(TDataModule)
    sdsSpellInput: TSimpleDataSet;
    dsSpellInput: TDataSource;
 private
    { Private declarations }
    Str_Sql:string;
  public
    { Public declarations }
    procedure OfferAllRecord(const ATableName,Name,ID,ASpell:string);
    {提供表中所有的记录}
    procedure Locatebyspell(ASpell:string);
    {根据拼音简码进行定位}
    procedure OfferSelectRecord(var ACode,AName:string);
    {返回当前选中记录内容}
    procedure MovePoint(const ADirct:string);
  end;

var
  SpellInputDM: TSpellInputDM;

implementation

{$R *.DFM}

{ TSpellInputDM }

procedure TSpellInputDM.Locatebyspell(ASpell: string);
begin
   if length(ASpell) <= sdsSpellInput.FieldByName('Name').size then
     begin
       sdsSpellInput.Locate('Name',ASpell,[lopartialkey]);
     end;
end;

procedure TSpellInputDM.MovePoint(const ADirct: string);
begin
if ADirct='up' then
begin
 if not sdsSpellInput.bof then
        sdsSpellInput.Prior;
end;
if ADirct='down' then
begin
if not sdsSpellInput.eof then
       sdsSpellInput.next;
end;
end;

procedure TSpellInputDM.OfferAllRecord(const ATableName,Name,ID,ASpell: string);
begin
  Str_Sql:='select '+Name+ ' as Name,'+ID+' as ID from '+ATableName+' '+
           'where '+Name+' like '''+'%'+Aspell+'%'+''' order by '+ID;
  sdsSpellInput.Close;
  sdsSpellInput.DataSet.CommandText := str_sql;
  sdsSpellInput.Open;
end;

procedure TSpellInputDM.OfferSelectRecord(var ACode, AName: string);
begin
  ACode:=sdsSpellInput.fieldbyname('ID').asstring;
  AName:=sdsSpellInput.fieldbyname('Name').asstring;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?