مرحبا شباب
عندي جدول فية ثلاث حقول هي ( اسم الموظف - الشهر - السنة)
اريد ان يكون الفلترة حسب رغبة المستخدم اي
1- الفلترة حسب اسم الموظف فقط
2- الفلترة حسب الشهر فقط
3- الفلترة حسب السنة فقط
4- الفلترة حيب اسم الموظف و الشهر
5- الفلترة حسب اسم الموظف و السنة
6- الفلترة حسب الشهر و السنة
7- الفلترة حسب اسم الموظف و الشهر و السنة
فما هو الكود لفعل ذلك؟؟؟؟؟ مع العلم انني استخدم checkbox لتحديد حالات الفلترة التي ذكرتها
(13-11-2018, 01:03 PM)B.M.AbdelAziZ كتب : [ -> ]السلام عليكم
عليك بمجموعة من الجمل الشرطية if ... then
يمكن ان تستفيد من موضوع سابق:
[تمرين] فلترة بيانات جدول حسب الشهر في سنة معينة
http://delphi4arab.net/forum/showthread.php?tid=338
وعليكم السلام ورحمة الله اخي العزيز
انا استخدم هذا الكود ولكن لا يعمل ولا اعلم لماذا
كود :
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;