| 1 | unit UFormGenerate;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
|---|
| 9 | Spin, UContact;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TFormGenerate }
|
|---|
| 14 |
|
|---|
| 15 | TFormGenerate = class(TForm)
|
|---|
| 16 | ButtonGenerate: TButton;
|
|---|
| 17 | Label1: TLabel;
|
|---|
| 18 | SpinEditCount: TSpinEdit;
|
|---|
| 19 | procedure ButtonGenerateClick(Sender: TObject);
|
|---|
| 20 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 21 | procedure FormCreate(Sender: TObject);
|
|---|
| 22 | procedure FormShow(Sender: TObject);
|
|---|
| 23 | public
|
|---|
| 24 | Contacts: TContacts;
|
|---|
| 25 | procedure UpdateInterface;
|
|---|
| 26 | end;
|
|---|
| 27 |
|
|---|
| 28 | var
|
|---|
| 29 | FormGenerate: TFormGenerate;
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | implementation
|
|---|
| 33 |
|
|---|
| 34 | {$R *.lfm}
|
|---|
| 35 |
|
|---|
| 36 | uses
|
|---|
| 37 | UCore;
|
|---|
| 38 |
|
|---|
| 39 | { TFormGenerate }
|
|---|
| 40 |
|
|---|
| 41 | procedure TFormGenerate.ButtonGenerateClick(Sender: TObject);
|
|---|
| 42 | var
|
|---|
| 43 | I: Integer;
|
|---|
| 44 | Contact: TContact;
|
|---|
| 45 | begin
|
|---|
| 46 | for I := 1 to SpinEditCount.Value do begin
|
|---|
| 47 | Contact := Contacts.AddNew;
|
|---|
| 48 | Contact.Fields[cfVersion] := '2.1';
|
|---|
| 49 | Contact.Fields[cfFirstName] := 'First ' + IntToStr(Random(10000));
|
|---|
| 50 | Contact.Fields[cfLastName] := 'Last ' + IntToStr(Random(10000));
|
|---|
| 51 | Contact.Fields[cfFullName] := 'FullName ' + IntToStr(Random(100));
|
|---|
| 52 | Contact.Fields[cfTelCell] := IntToStr(Random(1000000000));
|
|---|
| 53 | Contact.Fields[cfTelHome] := IntToStr(Random(1000000000));
|
|---|
| 54 | end;
|
|---|
| 55 | Close;
|
|---|
| 56 | end;
|
|---|
| 57 |
|
|---|
| 58 | procedure TFormGenerate.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
|---|
| 59 | );
|
|---|
| 60 | begin
|
|---|
| 61 | Core.GenerateCount := SpinEditCount.Value;
|
|---|
| 62 | Core.PersistentForm1.Save(Self);
|
|---|
| 63 | end;
|
|---|
| 64 |
|
|---|
| 65 | procedure TFormGenerate.FormCreate(Sender: TObject);
|
|---|
| 66 | begin
|
|---|
| 67 | Core.Translator.TranslateComponentRecursive(Self);
|
|---|
| 68 | Core.ThemeManager1.UseTheme(Self);
|
|---|
| 69 | end;
|
|---|
| 70 |
|
|---|
| 71 | procedure TFormGenerate.FormShow(Sender: TObject);
|
|---|
| 72 | begin
|
|---|
| 73 | Core.PersistentForm1.Load(Self);
|
|---|
| 74 | SpinEditCount.Value := Core.GenerateCount;
|
|---|
| 75 | UpdateInterface;
|
|---|
| 76 | end;
|
|---|
| 77 |
|
|---|
| 78 | procedure TFormGenerate.UpdateInterface;
|
|---|
| 79 | begin
|
|---|
| 80 | ButtonGenerate.Enabled := Assigned(Contacts);
|
|---|
| 81 | end;
|
|---|
| 82 |
|
|---|
| 83 | end.
|
|---|
| 84 |
|
|---|