Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm3.Button1Click(Sender: TObject);
- var
- k, b, c, d: string;
- begin
- ADOQuery1.SQL.Clear;
- 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');
- 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 ');
- k := '';
- if CheckBox1.Checked then k := ' (Mark='+CheckBox1.Caption+')';
- if CheckBox2.Checked then if k <>'' then k:= k+' OR '+' (Mark='+CheckBox2.Caption+')'
- else k := ' (Mark='+CheckBox2.Caption+')';
- if CheckBox3.Checked then if k<>'' then k := k+' OR '+'(Mark='+CheckBox3.Caption+')'
- else k:= ' (Mark='+CheckBox4.Caption+')';
- if CheckBox4.Checked then if k <>'' then k:=k+' OR '+' (Mark='+CheckBox4.Caption+')'
- else k := ' ( Mark='+CheckBox4.Caption+')';
- b := '';
- if CheckBox5.Checked then b := ' (Naimenovanie='+#39+CheckBox5.Caption+#39+')';
- if CheckBox6.Checked then if b<>'' then b:=b+' OR (Naimenovanie ='+#39+CheckBox6.Caption+#39+')'
- else b:=' (Naimenovanie = '+#39+CheckBox6.Caption+#39+')';
- if CheckBox7.Checked then if b<>'' then b:=b+' OR (Naimenovanie = '+#39+CheckBox7.Caption+#39+')'
- else b:= ' (Naimenovanie= '+#39+CheckBox7.Caption+ #39+ ')';
- c := '';
- if CheckBox8.Checked then c := ' (Gr= '+#39+ CheckBox8.Caption+#39+')';
- if CheckBox9.Checked then if c<>'' then c := c+' OR (Gr='+#39+CheckBox9.Caption+#39+')'
- else c := ' (Gr='+#39+CheckBox9.Caption+#39+')';
- if (k <>'') AND (b<>'') and (c<>'') then d := '('+k+')'+' AND '+'('+b+')'+' AND '+'('+c+')'
- else if (b<>'') AND (c<>'') then d := b+' AND '+c
- else if (k<>'') AND (b<>'')then d := '('+k+ ')'+' AND '+ '('+b+ ')'
- else if (k<>'') AND (c<>'') then d := '('+k+')'+' AND '+c
- else
- if k<>'' then d := k else
- if b<>'' then d := b else
- if c<>'' then d := c;
- ShowMessage(d);
- ADOQuery1.SQL.Add('WHERE ' + d);
- //
- ADOQuery1.SQL.Add('ORDER BY ' + Sort + ', ' + Sort1 + ', ' + Sort2 + ', ' + Sort3);
- ShowMessage(ADOQuery1.SQL.Text);
- ADOQuery1.Active := True;
- DBGrid1.Columns.Items[0].Width := 260;
- DBGrid1.Columns.Items[1].Width := 120;
- DBGrid1.Columns.Items[2].Width := 90;
- DBGrid1.Columns.Items[2].Width := 90;
- StatusBar1.Panels[2].Text := 'Eiee?aonai caienae:' + IntToStr(ADOQuery1.RecordCount);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement