FormFind.pas
上传用户:etonglee
上传日期:2014-03-01
资源大小:698k
文件大小:2k
源码类别:

Internet/IE编程

开发平台:

Delphi

  1. unit FormFind;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, Grids, DBGrids, ExtCtrls, DB, DBClient, StdCtrls, ComCtrls;
  6. type
  7.   TFrmFind = class(TForm)
  8.     Panel1: TPanel;
  9.     DBGrid1: TDBGrid;
  10.     Label1: TLabel;
  11.     Label2: TLabel;
  12.     edtBegin: TDateTimePicker;
  13.     edtEnd: TDateTimePicker;
  14.     btnFind: TButton;
  15.     cltdsFind: TClientDataSet;
  16.     dsFind: TDataSource;
  17.     StatusBar: TStatusBar;
  18.     cltdsFindOrderID: TIntegerField;
  19.     cltdsFindCompanyName: TWideStringField;
  20.     cltdsFindOrderDate: TDateTimeField;
  21.     cltdsFindRequiredDate: TDateTimeField;
  22.     cltdsFindShippedDate: TDateTimeField;
  23.     cltdsFindShipName: TWideStringField;
  24.     procedure btnFindClick(Sender: TObject);
  25.     procedure DBGrid1DblClick(Sender: TObject);
  26.     procedure cltdsFindAfterScroll(DataSet: TDataSet);
  27.   private
  28.     { Private declarations }
  29.     FResult:integer;
  30.     Procedure OpenFind(BeginDate,EndDate:TDateTime);
  31.   public
  32.     { Public declarations }
  33.     Class Function ShowFind():integer;
  34.   end;
  35. var
  36.   FrmFind: TFrmFind;
  37. implementation
  38. uses SvrObj_Orders_TLB, UnitShare;
  39. {$R *.dfm}
  40. Class Function TFrmFind.ShowFind():integer;
  41. begin
  42.   result:=-1;
  43.   FrmFind.FResult:=-1;
  44.   FrmFind.ShowModal();
  45.   if FrmFind.FResult<>-1 then
  46.     result:=FrmFind.FResult;
  47. end;
  48. Procedure TFrmFind.OpenFind(BeginDate,EndDate:TDateTime);
  49. var
  50.   RetData:OleVariant;
  51.   Orders:IOrders;
  52. begin
  53.   Orders:=CoOrders.CreateRemote(APPSVR);
  54.   Orders.GetOrders(BeginDate,EndDate,RetData);
  55.   cltdsFind.Data:=RetData;
  56.   cltdsFind.ReadOnly:=true;
  57. end;
  58. procedure TFrmFind.btnFindClick(Sender: TObject);
  59. begin
  60.   OpenFind(edtBegin.Date,edtEnd.Date);
  61. end;
  62. procedure TFrmFind.DBGrid1DblClick(Sender: TObject);
  63. begin
  64.   if not cltdsFind.Active then
  65.     exit;
  66.   if cltdsFindOrderID.IsNull then
  67.   begin
  68.     StatusBar.Panels[0].Text:='没有选中订单。';
  69.     exit;
  70.   end;
  71.   FResult:=cltdsFindOrderID.AsInteger;
  72.   close();
  73. end;
  74. procedure TFrmFind.cltdsFindAfterScroll(DataSet: TDataSet);
  75. begin
  76.   StatusBar.Panels[0].Text:=inttostr(cltdsFind.RecNo)+'/'+inttostr(cltdsFind.RecordCount);
  77. end;
  78. end.