ClientForm.pas
上传用户:fh681027
上传日期:2022-07-23
资源大小:1959k
文件大小:2k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. unit ClientForm;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  5.   StdCtrls, DBCtrls, ExtCtrls, Db, Mask, DBTables, ScktComp;
  6. type
  7.   TForm1 = class(TForm)
  8.     EditServer: TEdit;
  9.     Server: TLabel;
  10.     Table1: TTable;
  11.     Table1Company: TStringField;
  12.     Table1CompID: TFloatField;
  13.     Table1Address: TStringField;
  14.     Table1State: TStringField;
  15.     Table1Country: TStringField;
  16.     Table1Email: TStringField;
  17.     Table1Contact: TStringField;
  18.     Label1: TLabel;
  19.     DBEdit1: TDBEdit;
  20.     DataSource1: TDataSource;
  21.     Label2: TLabel;
  22.     Label3: TLabel;
  23.     DBEdit3: TDBEdit;
  24.     Label4: TLabel;
  25.     DBEdit4: TDBEdit;
  26.     Label5: TLabel;
  27.     DBEdit5: TDBEdit;
  28.     Label6: TLabel;
  29.     DBEdit6: TDBEdit;
  30.     Label7: TLabel;
  31.     DBEdit7: TDBEdit;
  32.     DBNavigator1: TDBNavigator;
  33.     DBText1: TDBText;
  34.     lbLog: TListBox;
  35.     BtnDelete: TButton;
  36.     Label8: TLabel;
  37.     Bevel1: TBevel;
  38.     Button2: TButton;
  39.     procedure FormCreate(Sender: TObject);
  40.     procedure BtnDeleteClick(Sender: TObject);
  41.     procedure Button2Click(Sender: TObject);
  42.   private
  43.     procedure OnLog(Sender: TObject; LogMsg: String);
  44.   end;
  45. var
  46.   Form1: TForm1;
  47. implementation
  48. {$R *.DFM}
  49. uses
  50.   ClientThread;
  51. procedure TForm1.FormCreate(Sender: TObject);
  52. begin
  53.   // use a table in the current directory
  54.   Table1.DatabaseName :=
  55.     ExtractFilePath (Application.ExeName);
  56.   // create it if it doesn't exist
  57.   if not Table1.Exists then
  58.     Table1.CreateTable;
  59.   Table1.Active := True;
  60. end;
  61. procedure TForm1.BtnDeleteClick(Sender: TObject);
  62. begin
  63.   table1.First;
  64.   while not Table1.Eof do
  65.   begin
  66.     // if the record is still logged
  67.     if not Table1CompID.IsNull and (Table1CompId.AsInteger <> 0) then
  68.       Table1.Delete;
  69.     Table1.Next;
  70.   end;
  71. end;
  72. procedure TForm1.Button2Click(Sender: TObject);
  73. var
  74.   SendThread: TSendThread;
  75. begin
  76.   SendThread := TSendThread.Create(Table1);
  77.   SendThread.OnLog := OnLog;
  78.   SendThread.ServerAddress := EditServer.Text;
  79.   SendThread.Resume;
  80. end;
  81. procedure TForm1.OnLog(Sender: TObject; LogMsg: String);
  82. begin
  83.   lbLog.Items.Add(LogMsg);
  84. end;
  85. end.