![]() |
|
الفلترة باكثر من خيار - نسخة قابلة للطباعة +- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum) +-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3) +--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15) +--- الموضوع : الفلترة باكثر من خيار (/showthread.php?tid=9864) |
الفلترة باكثر من خيار - احمد العراقي - 13-11-2018 مرحبا شباب عندي جدول فية ثلاث حقول هي ( اسم الموظف - الشهر - السنة) اريد ان يكون الفلترة حسب رغبة المستخدم اي 1- الفلترة حسب اسم الموظف فقط 2- الفلترة حسب الشهر فقط 3- الفلترة حسب السنة فقط 4- الفلترة حيب اسم الموظف و الشهر 5- الفلترة حسب اسم الموظف و السنة 6- الفلترة حسب الشهر و السنة 7- الفلترة حسب اسم الموظف و الشهر و السنة فما هو الكود لفعل ذلك؟؟؟؟؟ مع العلم انني استخدم checkbox لتحديد حالات الفلترة التي ذكرتها RE: الفلترة باكثر من خيار - محمد عبد العزيز - 13-11-2018 السلام عليكم عليك بمجموعة من الجمل الشرطية if ... then يمكن ان تستفيد من موضوع سابق: [تمرين] فلترة بيانات جدول حسب الشهر في سنة معينة http://delphi4arab.net/forum/showthread.php?tid=338 RE: الفلترة باكثر من خيار - احمد العراقي - 14-11-2018 (13-11-2018, 01:03 PM)B.M.AbdelAziZ كتب : السلام عليكم وعليكم السلام ورحمة الله اخي العزيز انا استخدم هذا الكود ولكن لا يعمل ولا اعلم لماذا كود : procedure Tfrmmain.SpeedButton1Click(Sender: TObject);
var
ch1,ch2,ch3:Boolean;
a,b,c,ab,ac,bc,abc:string;
begin
ch1:=checkbox1.Checked;
ch2:=checkbox2.Checked;
ch3:=checkbox.Checked;
a:='codofperson ='+QuotedStr(edtgiab1.Text);
b:='themonth ='+QuotedStr(cobgiab1.Text);
c:='theyeare ='+QuotedStr(cobgiab2.Text);
ab:='codofperson ='+QuotedStr(edtgiab1.Text)+'and themonth ='+QuotedStr(cobgiab1.Text);
ac:='codofperson ='+QuotedStr(edtgiab1.Text)+'and theyeare ='+QuotedStr(cobgiab2.Text);
bc:='themonth ='+QuotedStr(edtgiab1.Text)+'and theyeare ='+QuotedStr(cobgiab2.Text);
abc:='codofperson ='+QuotedStr(edtgiab1.Text)+'and themonth ='+QuotedStr(cobgiab1.Text)+
'and theyeare ='+QuotedStr(cobgiab2.Text);
if ch1=true and ch2=true and ch3=true then
begin
tabel1.Filtered:=true;
tabel1.Filter:=abc;
end;
if ch1=true and ch2=true then
begin
tabel1.Filtered:=true;
tabel1.Filter:=ab;
end;
if ch1=true and ch3=true then
begin
tabel1.Filtered:=true;
tabel1.Filter:=ac;
end;
if ch2=true and ch3=true then
begin
tabel1.Filtered:=true;
tabel1.Filter:=bc;
end;
if ch1=true then
begin
tabel1.Filtered:=true;
tabel1.Filter:=a;
end;
if ch2=true then
begin
tabel1.Filtered:=true;
tabel1.Filter:=b;
end;
if ch3=true then
begin
tabel1.Filtered:=true;
tabel1.Filter:=c;
end;
if tabel1.IsEmpty then
begin
tabel1.Filtered:=false;
ShowMessage('لم يتم العثور على نتيجة');
end;
end;RE: الفلترة باكثر من خيار - محمد عبد العزيز - 14-11-2018 كود : var
a,b,c,fl:string;
begin
fl:='';
a:='(codofperson='+QuotedStr(edtgiab1.Text)+')';
b:='(themonth='+QuotedStr(cobgiab1.Text)+')';
c:='(theyeare='+QuotedStr(cobgiab2.Text)+')';
if CheckBox1.Checked then fl:=fl+a;
if CheckBox2.Checked then begin
if fl<>'' then fl:=fl+' and ';
fl:=fl+b;
end;
if CheckBox3.Checked then Begin
if fl<>'' then fl:=fl+' and ';
fl:=fl+c;
end;
if fl<>'' then tabel1.Filter:=fl;
tabel1.Filtered:=fl<>'';
if tabel1.IsEmpty then showmessage('لم يتم العثور على نتيجة'); |