⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sfc_mnlistrequest_hint.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Sfc_MnListRequest_Hint;
  
Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base, StdCtrls, Grids, DBGridEh, ExtCtrls, Db, AdODB;

Type
  TFrm_Sfc_MnListRequest_Hint = Class(TFrm_Base)
    Panel: TPanel;
    DBGridEh: TDBGridEh;
    Btn_OK: TButton;
    Btn_Cancel: TButton;
    AdoQuery: TAdoQuery;
    DataSource: TDataSource;
    Label1: TLabel;
    Edt_Locate: TEdit;
    procedure DBGridEhDblClick(Sender: TObject);
    procedure DBGridEhKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edt_LocateChange(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: ChAr);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure InitForm(Connection:TAdOConnection;SQLText:String);
    function GetValueByFieldIndex(Index:Integer):String;
  end;

var
  Frm_Sfc_MnListRequest_Hint: TFrm_Sfc_MnListRequest_Hint;

implementation

{$R *.DFM}

function TFrm_Sfc_MnListRequest_Hint.GetValueByFieldIndex(Index:Integer): String;
begin
  Result:=AdoQuery.Fields[Index].AsString;
end;

procedure TFrm_Sfc_MnListRequest_Hint.InitForm(Connection: TAdOConnection;
  SQLText: String);
begin
  AdoQuery.Close;
  AdoQuery.Connection:=Connection;
  AdoQuery.SQL.Text:=SQLText;
  AdoQuery.Open;
  AdoQuery.Sort:=AdoQuery.Fields[0].FieldName;
end;

procedure TFrm_Sfc_MnListRequest_Hint.DBGridEhDblClick(Sender: TObject);
begin
  inherited;
  ModalResult:=mrOk;
end;

procedure TFrm_Sfc_MnListRequest_Hint.DBGridEhKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if Key=13 then
    ModalResult:=mrOk;
end;

procedure TFrm_Sfc_MnListRequest_Hint.Edt_LocateChange(Sender: TObject);
begin
  inherited;
  AdoQuery.Locate(AdoQuery.Fields[0].FieldName,TEdit(Sender).Text,[loPArtialKey]);
end;

procedure TFrm_Sfc_MnListRequest_Hint.FormKeyPress(Sender: TObject; var Key: ChAr);
begin
  inherited;
  if (Self.Showing)and(not Edt_Locate.Focused) then
  begin
    Edt_Locate.SetFocus;
    Edt_Locate.Text:=Key;
    Edt_Locate.SelStArt:=1;
  end;
end;

procedure TFrm_Sfc_MnListRequest_Hint.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if Self.Showing then
  begin
    if not DBGridEh.Focused then
    begin
      if Key=VK_DOWN then
      begin
        DBGridEh.SetFocus;
        AdoQuery.Next;
      end
      else if Key=VK_UP then
      begin
        DBGridEh.SetFocus;
        AdoQuery.Prior;
      end;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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