SearchFme.pas 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. unit SearchFme;
  2. interface
  3. uses
  4. SearchDm,
  5. Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  6. Dialogs, StdCtrls, ExtCtrls, ZjGridDBA, ZJGrid, JimLabels;
  7. type
  8. TSearchFrame = class(TFrame)
  9. zaSearchResult: TZjGridDBA;
  10. pnlTitle: TPanel;
  11. labTitle: TJimGradLabel;
  12. pnlSearch: TPanel;
  13. pnlSearchType: TPanel;
  14. gbType: TGroupBox;
  15. rbOverRange: TRadioButton;
  16. rbCommon: TRadioButton;
  17. pnlSearchKey: TPanel;
  18. edtKeyword: TEdit;
  19. btnSearch: TButton;
  20. pnlSearchResult: TPanel;
  21. zgSearchResult: TZJGrid;
  22. rbBelowRange: TRadioButton;
  23. procedure rbCommonClick(Sender: TObject);
  24. procedure btnSearchClick(Sender: TObject);
  25. procedure zgSearchResultMouseDown(Sender: TObject;
  26. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  27. private
  28. FSearchData: TSearchData;
  29. FLocateType: TLocateType;
  30. public
  31. constructor Create(AParent: TFrame; ASearchData: TSearchData);
  32. destructor Destroy; override;
  33. property LocateType: TLocateType read FLocateType write FLocateType;
  34. end;
  35. implementation
  36. {$R *.dfm}
  37. { TSearchFrame }
  38. constructor TSearchFrame.Create(AParent: TFrame; ASearchData: TSearchData);
  39. begin
  40. inherited Create(AParent);
  41. FSearchData := ASearchData;
  42. zaSearchResult.DataSet := FSearchData.cdsSearch;
  43. end;
  44. destructor TSearchFrame.Destroy;
  45. begin
  46. inherited;
  47. end;
  48. procedure TSearchFrame.rbCommonClick(Sender: TObject);
  49. begin
  50. edtKeyword.Enabled := rbCommon.Checked;
  51. if rbCommon.Checked then
  52. zaSearchResult.Column('Code').Width := 80
  53. else
  54. zaSearchResult.Column('Code').Width := 0;
  55. end;
  56. procedure TSearchFrame.btnSearchClick(Sender: TObject);
  57. begin
  58. if rbCommon.Checked then
  59. FSearchData.SearchKeyword(edtKeyword.Text)
  60. else if rbOverRange.Checked then
  61. FSearchData.SearchOverRange
  62. else if rbBelowRange.Checked then
  63. FSearchData.SearchBelowRange;
  64. end;
  65. procedure TSearchFrame.zgSearchResultMouseDown(Sender: TObject;
  66. Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  67. begin
  68. if (Button = mbLeft) and (ssDouble in Shift) then
  69. FSearchData.LocateCurrent(LocateType);
  70. end;
  71. end.