Advertisement
Guest User

Untitled

a guest
May 5th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. procedure TForm3.Button1Click(Sender: TObject);
  2. var
  3. k, b, c, d: string;
  4. begin
  5. ADOQuery1.SQL.Clear;
  6. ADOQuery1.SQL.Add('SELECT Trim(Fam) + '' '' + Trim(Name) + '' '' + Trim (Otch) AS OEI, Naimenovanie AS Aenoeieeia, Mark AS Ioaiea, Gr AS A?oiia, Date AS Aaoa');
  7. ADOQuery1.SQL.Add('FROM (Student LEFT JOIN Svod_Vedom ON Student.ID_Stud = Svod_Vedom.ID_Stud) LEFT JOIN Disciplins ON Svod_Vedom.ID_Disc=Disciplins.ID_Disc ');
  8.  
  9. k := '';
  10. if CheckBox1.Checked then k := ' (Mark='+CheckBox1.Caption+')';
  11. if CheckBox2.Checked then if k <>'' then k:= k+' OR '+' (Mark='+CheckBox2.Caption+')'
  12. else k := ' (Mark='+CheckBox2.Caption+')';
  13.  
  14. if CheckBox3.Checked then if k<>'' then k := k+' OR '+'(Mark='+CheckBox3.Caption+')'
  15. else k:= ' (Mark='+CheckBox4.Caption+')';
  16. if CheckBox4.Checked then if k <>'' then k:=k+' OR '+' (Mark='+CheckBox4.Caption+')'
  17. else k := ' ( Mark='+CheckBox4.Caption+')';
  18. b := '';
  19. if CheckBox5.Checked then b := ' (Naimenovanie='+#39+CheckBox5.Caption+#39+')';
  20. if CheckBox6.Checked then if b<>'' then b:=b+' OR (Naimenovanie ='+#39+CheckBox6.Caption+#39+')'
  21. else b:=' (Naimenovanie = '+#39+CheckBox6.Caption+#39+')';
  22. if CheckBox7.Checked then if b<>'' then b:=b+' OR (Naimenovanie = '+#39+CheckBox7.Caption+#39+')'
  23. else b:= ' (Naimenovanie= '+#39+CheckBox7.Caption+ #39+ ')';
  24. c := '';
  25.  
  26. if CheckBox8.Checked then c := ' (Gr= '+#39+ CheckBox8.Caption+#39+')';
  27. if CheckBox9.Checked then if c<>'' then c := c+' OR (Gr='+#39+CheckBox9.Caption+#39+')'
  28. else c := ' (Gr='+#39+CheckBox9.Caption+#39+')';
  29. if (k <>'') AND (b<>'') and (c<>'') then d := '('+k+')'+' AND '+'('+b+')'+' AND '+'('+c+')'
  30. else if (b<>'') AND (c<>'') then d := b+' AND '+c
  31. else if (k<>'') AND (b<>'')then d := '('+k+ ')'+' AND '+ '('+b+ ')'
  32. else if (k<>'') AND (c<>'') then d := '('+k+')'+' AND '+c
  33. else
  34. if k<>'' then d := k else
  35. if b<>'' then d := b else
  36. if c<>'' then d := c;
  37. ShowMessage(d);
  38. ADOQuery1.SQL.Add('WHERE ' + d);
  39.  
  40.  
  41.  
  42. //
  43. ADOQuery1.SQL.Add('ORDER BY ' + Sort + ', ' + Sort1 + ', ' + Sort2 + ', ' + Sort3);
  44. ShowMessage(ADOQuery1.SQL.Text);
  45. ADOQuery1.Active := True;
  46. DBGrid1.Columns.Items[0].Width := 260;
  47. DBGrid1.Columns.Items[1].Width := 120;
  48. DBGrid1.Columns.Items[2].Width := 90;
  49. DBGrid1.Columns.Items[2].Width := 90;
  50. StatusBar1.Panels[2].Text := 'Eiee?aonai caienae:' + IntToStr(ADOQuery1.RecordCount);
  51.  
  52. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement