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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
| unit UFacebiblio;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, UBibliotheque, UVirus, Buttons, Grids, lazJPG, ComCtrls;
type
{ TFormBiblio }
TFormBiblio = class(TForm)
ButtonFermer: TButton;
Buttonsuppr: TButton;
ButtonAjout: TButton;
EditNom: TEdit;
EditResistance: TEdit;
EditVirulence: TEdit;
EditTps: TEdit;
EditResistance1: TEdit;
EditImage: TEdit;
ImageLivre: TImage;
LabelDMI: TLabel;
LabelResistance: TLabel;
Labelretire: TLabel;
Labelsuppr: TLabel;
LabelNom: TLabel;
LabelVirulence: TLabel;
LabelTps: TLabel;
LabelResistance1: TLabel;
LabelImage: TLabel;
LabelMinutes: TLabel;
LabelAjout: TLabel;
LabelTitre: TLabel;
ListBiblio: TListView;
ListView1: TListView;
RadioButtonTps: TRadioButton;
RadioButtonVirulence: TRadioButton;
RadioButtonResistance: TRadioButton;
RadioButtonAlphabet: TRadioButton;
RadioGroupTri: TRadioGroup;
procedure ButtonFermerClick(Sender: TObject);
procedure ButtonAjoutClick(Sender: TObject);
procedure ButtonsupprClick(Sender: TObject);
procedure EditImageChange(Sender: TObject);
procedure EditImageKeyPress(Sender: TObject; var Key: char);
procedure EditNomChange(Sender: TObject);
procedure EditNomKeyPress(Sender: TObject; var Key: char);
procedure EditResistance1Change(Sender: TObject);
procedure EditResistanceKeyPress(Sender: TObject; var Key: char);
procedure EditTpsChange(Sender: TObject);
procedure EditTpsKeyPress(Sender: TObject; var Key: char);
procedure EditVirulenceChange(Sender: TObject);
procedure EditVirulenceKeyPress(Sender: TObject; var Key: char);
procedure FormCreate(Sender: TObject);
procedure TestEntrees;
private
{ private declarations }
public
{ public declarations }
end;
var
FormBiblio: TFormBiblio;
Nom, Virulence, TpsGeneration, Resistance1, Image: boolean;
implementation
procedure TFormBiblio.FormCreate(Sender: TObject);
Var i,j:integer;
JPEG: TJPGImage;
begin
JPEG:= TJPGImage.Create;
JPEG.LoadFromFile('C:\Documents and Settings\Utilisateur\Mes documents\Travail\INSA\Matières\Info\Projets\livre_ouvert.jpg');
ImageLivre.Picture.assign(JPEG);
ButtonSuppr.Enabled:= false;
ButtonAjout.Enabled:= false;
ButtonFermer.Enabled:= true;
EditNom.Enabled:= true;
EditVirulence.Enabled:= true;
EditTps.Enabled:= true;
EditResistance1.Enabled:= true;
EditImage.Enabled:= true;
ListBiblio.ViewStyle:=vsReport;
ListBiblio.Columns.Add.Caption:='Nom du virus';
ListBiblio.Columns.Add.Caption:='Virulence';
ListBiblio.Columns.Add.Caption:='Temps de génération';
ListBiblio.Columns.Add.Caption:='Résistance virale';
ListBiblio.columns.Add.Caption:='Emplacement de l''image';
with ListBiblio.Items.Add do
begin
Caption:='AStrovirus';
Subitems.Add('5');
Subitems.Add('10');
Subitems.Add('2');
Subitems.Add('C:\Documents and Settings\Utilisateur\Mes documents\Travail\INSA\Matières\Info\Projets\Astrovirus.jpg');
end;
end;
procedure TFormBiblio.TestEntrees;
Begin
ButtonAjout.Enabled:= Nom AND Virulence AND TpsGeneration AND Resistance1 AND Image;
end;
procedure TFormBiblio.EditImageChange(Sender: TObject);
begin
Image:=True;
TestEntrees;
end;
procedure TFormBiblio.EditImageKeyPress(Sender: TObject; var Key: char);
begin
if Key in ['0'..'9'] then
Key:=#0; // Vérification du contenu
end;
procedure TFormBiblio.EditNomChange(Sender: TObject);
begin
Nom:=True;
TestEntrees;
end;
procedure TFormBiblio.EditNomKeyPress(Sender: TObject; var Key: char);
begin
if Key in ['0'..'9'] then // Vérification du contenu
Key:=#0;
end;
procedure TFormBiblio.EditResistance1Change(Sender: TObject);
begin
Resistance1:=True;
TestEntrees;
end;
procedure TFormBiblio.EditResistanceKeyPress(Sender: TObject; var Key: char);
begin
if ((Key = '.') or (Key = ',')) then
Key:=DecimalSeparator;
if Key in [DecimalSeparator] then
Key:=#0; // Vérification du contenu
end;
procedure TFormBiblio.EditTpsChange(Sender: TObject);
begin
TpsGeneration:=True;
TestEntrees;
end;
procedure TFormBiblio.EditTpsKeyPress(Sender: TObject; var Key: char);
begin
if ((Key = '.') or (Key = ',')) then
Key:=DecimalSeparator;
if Key in [DecimalSeparator] then
Key:=#0; // Vérification du contenu
end;
procedure TFormBiblio.EditVirulenceChange(Sender: TObject);
begin
Virulence:=True;
TestEntrees;
end;
procedure TFormBiblio.EditVirulenceKeyPress(Sender: TObject; var Key: char);
begin
if ((Key = '.') or (Key = ',')) then
Key:=DecimalSeparator;
if Key in [DecimalSeparator] then
Key:=#0; // Vérification du contenu
end;
procedure TFormBiblio.ButtonFermerClick(Sender: TObject);
begin
end;
procedure TFormBiblio.ButtonAjoutClick(Sender: TObject);
Var V:CVirus;
begin
If ((EditNom.Text= '') Or
(EditImage.Text ='') Or
(EditVirulence.Text='') Or //Vérification que les champs ne sont
(EditResistance1.Text='') Or // pas vides
(EditTps.Text=''))
Then ShowMessage('Tous les champs ne sont pas renseignés')
Else begin
CVirus.Create(EditNom.Text, EditImage.Text, StrToInt(EditVirulence.Text), StrToInt(EditTps.Text), StrToInt(EditResistance1.Text));
EditNom.Text:= '';
EditImage.Text:= '';
EditVirulence.Text:= '';
EditResistance1.Text:= '';
EditTps.Text:= '';
ShowMessage('Virus ajouté à la bibliothèque');
end
end;
procedure TFormBiblio.ButtonsupprClick(Sender: TObject);
Var i:integer;
confirmation:word;
begin
i:=0;
If i=-1 then ShowMessage ('Aucun élément n''est sélectionné')
else begin
confirmation:= MessageDlg('Etes-vous sûr de vouloir supprimer cet élément?',mtConfirmation,[mbYes,mbabort],0);
Case confirmation of
mrYes: begin
ShowMessage('Elément Supprimé');
end;
mrAbort: begin
ShowMessage('Action annulée');
end;
end;
end;
end;
end. |
Partager