You are on page 1of 3

Corrigé synthèse Delphi

Unit1

procedure TForm1.SpeedButton1Click(Sender: TObject);

var

TotalSalary: Double;

begin

sqlquery1.Open;

sqlquery1.First;

TotalSalary := 0;

DBGRID1.DataSource:=datasource1;

while not SQLQuery1.Eof do

begin

TotalSalary := TotalSalary + SQLQuery1.FieldByName('SALARY').AsFloat;

SQLQuery1.Next;

end;

label2.Caption :=FloatToStr(TotalSalary);

//ShowMessage('Total Salary: ' + ));

end;

procedure TForm1.SpeedButton2Click(Sender: TObject);

var i: integer;

begin

sqlquery1.Close;

SQLQuery2.open; //SQLQuery1.Close;

for i := DBGrid1.Columns.Count - 1 downto 0 do


DBGrid1.Columns[i].Free;

DBGrid1.Columns[0].FieldName := 'DEPartment';

DBGrid1.Columns[1].FieldName := 'AVG_SALARY';

DBGRID1.DataSource:=datasource2;

label1.caption := 'Départements et salaires'

end;

procedure TForm1.SpeedButton4Click(Sender: TObject);

begin

RvProject1.Open;

RvProject1.SelectReport('Report1', False);

RvProject1.Execute;

RvProject1.Close;

end;

unit 2

procedure TForm2_2.DBLookupComboBox1Click(Sender: TObject);

begin

simpledataset1.SetKey;

simpledataset1.FieldByName('DEPT_NO').AsInteger:= dblookupcombobox1.keyvalue;

if simpledataset1.GotoKey then

dbedit1.Text :=inttostr( simpledataset1.RecordCount)

else

// Gérer le cas où aucun enregistrement n'est retourné pour la sélection

begin

clientdataset1.First;

dbedit1.Text := inttostr( simpledataset1.RecordCount);


end;

end;

You might also like