1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| implementation
{$R *.lfm}
{ TForm1 }
type
Personne = record
Identite : string [70];
Prive : string [20];
Bureau : string [20];
Fax : string [20];
Portable : string [20];
NET : string [100];
EMail : string [100];
Adresse : string [250]; {250 étant souvent insuffisant j'ai ajouté "Notes"}
Notes : string [250];
Autres1 : string [20];
Autres2 : string [20];
Autres3 : string [20];
Autres4 : string [20];
end;
FichierPersonnes = file of Personne;
BeansMaster :
procedure TForm1.FormCreate(Sender: TObject);
const
titres:array[0..12]of string = ('Identité', 'Privé',
'Bureau', 'Fax', 'Portable', 'NET', 'EMail', 'Adresse',
'Notes', 'Autres1', 'Autres2', 'Autres3', 'Autres4');
var
i, j:integer;
quelquun : Personne;
fichier : FichierPersonnes;
n : integer;
begin
for i:=0 to 12 do
StringGrid1.Cells[i,0]:=titres[i];
AssignFile(fichier, 'C:\Tools\Ptt\Memo.rep');
Reset(fichier);
n:=1; // n=2 Pour laisser la première ligne vide
while not eof(fichier) do
begin
read(fichier, quelquun);
with StringGrid1, quelquun do
begin
Cells [0,n] := Identite;
Cells [1,n] := Prive;
Cells [2,n] := Bureau;
Cells [3,n] := Fax;
Cells [4,n] := Portable;
Cells [5,n] := NET;
Cells [6,n] := EMail;
Cells [7,n] := Adresse;
Cells [8,n] := Notes;
Cells [9,n] := Autres1;
Cells [10,n] := Autres2;
Cells [11,n] := Autres3;
Cells [12,n] := Autres4;
if Cells [0,n]<>'' then
StringGrid1.RowCount:= StringGrid1.RowCount+1; // Sinon OutOfRange
for j:= 1 to StringGrid1.RowCount-1 do
ComboBox1.Items.Add(Cells[0,j]); //Sauf les deux premières lignes qui restent inaccessibles ???
ActiveControl:=ComboBox1;
// StringGrid1.Row:= 2; // Initialisée avec 4 Rows dans Inspecteur Objets
end;
inc(n);
end;
System.Close(fichier);
end;
procedure TForm1.EnregistrerClick(Sender: TObject);
var
quelquun : Personne;
fichier : FichierPersonnes;
ligne : integer;
begin
System.Assign(fichier, 'C:\Tools\Ptt\Memo.rep');
Rewrite(fichier);
for ligne := 1 to StringGrid1.RowCount-1 do
with StringGrid1.Rows[ligne], quelquun do
begin
Identite := strings[0];
Prive := strings[1];
Bureau := strings[2];
Fax := strings [3];
Portable := strings [4];
NET := strings [5];
EMail := strings [6];
Adresse := strings[7];
Notes := strings[8];
Autres1 := strings[9];
Autres2 := strings[10];
Autres3 := strings[11];
Autres4 := strings[12];
write(fichier, quelquun);
end;
System.Close(fichier);
end; |
Partager