home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 March / Chip_2002-03_cd1.bin / zkuste / delphi / kolekce / d5 / sStyleFree.exe / sSharedIB.pas < prev    next >
Pascal/Delphi Source File  |  2001-11-23  |  2KB  |  71 lines

  1. unit sSharedIB;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, IBQuery, db;
  7.  
  8. type
  9.   TSharedIBForm = class(TForm)
  10.   private
  11.     { Private declarations }
  12.   public
  13.     { Public declarations }
  14.   end;
  15.  
  16. var
  17.   SharedIBForm: TSharedIBForm;
  18.  
  19. procedure SelectIBQuery(Query:TIBQuery; Par:string);         //┬√∩εδφσφΦσ τα∩≡ε±α SQL
  20. procedure ExecuteIBQuery(Query:TIBQuery; Par:string);        //┬√∩εδφσφΦσ Ωε∞αφΣ√ SQL
  21. function GetMaxIBFieldValue(Query:TIBQuery; TableName, FieldName:string):integer;
  22. function GetFirstField(Query:TIBQuery; Par:string): TField;
  23.  
  24. implementation
  25.  
  26. {$R *.DFM}
  27.  
  28. procedure SelectIBQuery(Query:TIBQuery; Par:string);
  29. begin
  30.   Query.DisableControls;
  31.   Query.Close;
  32.   Query.SQL.Text:=Par;
  33.   try begin
  34.     Query.Open;
  35.   end
  36.   except on E: Exception do begin
  37.     MessageDlg('╬°ΦßΩα ∩≡Φ Γ√∩εδφσφΦΦ τα∩≡ε±α (' + E.Message + ') :  "'+Query.SQL.Text+'".', mtError, [mbOK], 0);
  38.   end;
  39.   end;
  40.   Query.EnableControls;
  41. end;
  42.  
  43. procedure ExecuteIBQuery(Query:TIBQuery; Par:string);
  44. begin
  45.   Query.Close;
  46.   Query.SQL.Text:=Par;
  47.   try begin
  48.     Query.ExecSQL;
  49.   end
  50.   except on E: Exception do begin
  51.     MessageDlg('╬°ΦßΩα ∩≡Φ Γ√∩εδφσφΦΦ τα∩≡ε±α (' + E.Message + ') :  "'+Query.SQL.Text+'".', mtError, [mbOK], 0);
  52.   end;
  53.   end;
  54. end;
  55.  
  56. function GetMaxIBFieldValue(Query:TIBQuery; TableName, FieldName:string):integer;
  57. begin
  58.   SelectIBQuery(Query, 'select max('+FieldName+') from '+TableName+';');
  59.   GetMaxIBFieldValue:=Query.Fields[0].asInteger;
  60. end;
  61.  
  62. function GetFirstField(Query:TIBQuery; Par:string): TField;
  63. begin
  64.   SelectIBQuery(Query, Par);
  65.   Result := Query.Fields[0];
  66. end;
  67.  
  68. end.
  69.  
  70.  
  71.