Kod: Tümünü seç
procedure OyunBittiKaydet;
var
i,ii:integer;
begin
try
DMoyunKaydet.ADOQuerySave.Close;
DMoyunKaydet.ADOQuerySave.SQL.Clear;
DMoyunKaydet.ADOQuerySave.SQL.Add('select * from tblOyunlar');
DMoyunKaydet.ADOQuerySave.Open;
for i:=1 to OyuncuSayisi do
begin
DMoyunKaydet.ADOQuerySave.Insert;
DMoyunKaydet.ADOQuerySave.FieldByName('Tarih').AsString:=DateTimeToStr(Now);
DMoyunKaydet.ADOQuerySave.FieldByName('OyAdi').AsString:=OyuncuAdlari[i];
if OyuncuSayisi=1 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df1puan[ii] ;
end;
end;
if OyuncuSayisi=2 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df2puan[ii] ;
end;
end;
if OyuncuSayisi=3 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df3puan[ii] ;
end;
end;
if OyuncuSayisi=4 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df4puan[ii] ;
end;
end;
if OyuncuSayisi=5 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df5puan[ii] ;
end;
end;
if OyuncuSayisi=6 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df6puan[ii] ;
end;
end;
if OyuncuSayisi=7 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df7puan[ii] ;
end;
end;
if OyuncuSayisi=8 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df8puan[ii] ;
end;
end;
if OyuncuSayisi=9 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df9puan[ii] ;
end;
end;
if OyuncuSayisi=10 then begin
for ii:=1 to 21 do
begin
DMoyunKaydet.ADOQuerySave.FieldByName('OyP'+IntToStr(ii)).AsInteger:=Df10puan[ii] ;
end;
end;
end;
//*************************************************
DMoyunKaydet.ADOQuerySave.Post;
DMoyunKaydet.ADOQuerySave.Close;
except
begin
errorKaydet('Kaydet:02');
end;
end;
end;
Df1puan[],Df2puan[],..... şeklinde 10 a kadar 10 adet dizim var içinde oyuncu puanları var
yukardaki kodu daha sadeleştirme şansımız varmı acaba?
saygılarımla