AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'"))');
AdoQuery1.Active:=True;
k1:=AdoQuery1.fieldbyname('Count1').AsInteger;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count2] FROM ozenka where (((ozenka.ozenka)>0))GROUP BY ozenka.mes, ozenka.god ');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'"))');
AdoQuery1.Active:=True;
k2:=AdoQuery1.fieldbyname('Count2').AsInteger;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count3] FROM ozenka where (((ozenka.ozenka)>2))GROUP BY ozenka.mes, ozenka.god ');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'"))');
AdoQuery1.Active:=True;
k3:=AdoQuery1.fieldbyname('Count3').AsInteger;
k4:=Round((k3/k2*100)*100)/100;
k:=Round((k1/k2*100)*100)/100;
Edit1.Text:=FloatToStr(k4);
Edit2.Text:=FloatToStr(k);
end;
end;
procedure TForm18.BitBtn2Click(Sender: TObject);
var n: OleVariant;
i:integer;
//S:String;
begin
if radiogroup3.ItemIndex=0 then begin
AdoQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT ozenka.ozenka, ozenka.stud, ozenka.gruppa, ozenka.koddis, ozenka.kodspez, ozenka.mes, ozenka.god FROM ozenka WHERE (((ozenka.ozenka)=2))');
ADOQuery1.SQL.Add('and mes="'+ combobox3.Text+'" and god="'+combobox6.Text+'"');
//Showmessage(adoquery1.SQL.Text);
ADOQuery1.Open;
ADOQuery1.First;
n:='d:\55\spisok55.xls';
ExcelApplication1.Workbooks.Add(n,0);
Excelworkbook1.ConnectTo(ExcelApplication1.ActiveWorkbook);
i:=3;
ExcelApplication1.Cells.Item[1,1].Value:='Cписок неуспевающих';
ExcelApplication1.Cells.Item[1,2].Value:=Combobox3.Text;
ExcelApplication1.Cells.Item[1,3].Value:=Combobox6.Text;
ExcelApplication1.Visible[0]:=true;
While not ADOQuery1.Eof do
begin;
ExcelApplication1.Cells.Item[i,1].Value:=ADOQuery1.FieldByName('Stud').AsString;
ExcelApplication1.Cells.Item[i,2].Value:=ADOQuery1.FieldByName('koddis').AsString;
ExcelApplication1.Cells.Item[i,3].Value:=ADOQuery1.FieldByName('ozenka').AsString;
ExcelApplication1.Cells.Item[i,4].Value:=ADOQuery1.FieldByName('gruppa').AsString;
ADOQUERY1.Next;
//ADOQUERY1.Post;
i:=i+1;
end;
end;
if radiogroup3.ItemIndex=1 then begin
AdoQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT ozenka.stud, Avg(ozenka.ozenka) AS [Avg-ozenka], ozenka.mes,ozenka.gruppa, ozenka.god FROM ozenka');
ADOQuery1.SQL.Add('GROUP BY ozenka.stud, ozenka.mes,ozenka.gruppa, ozenka.god');
ADOQuery1.SQL.Add('HAVING (((Avg(ozenka.ozenka))=5));');
//ADOQuery1.SQL.Add('and mes="'+ combobox3.Text+'" and god="'+combobox6.Text+'"');
ADOQuery1.Open;
ADOQuery1.First;
n:='d:\55\spisok55.xls';
ExcelApplication1.Workbooks.Add(n,0);
Excelworkbook1.ConnectTo(ExcelApplication1.ActiveWorkbook);
i:=3;
ExcelApplication1.Cells.Item[1,1].Value:='Cписок успевающих на отлично';
ExcelApplication1.Cells.Item[1,2].Value:=Combobox3.Text;
ExcelApplication1.Cells.Item[1,3].Value:=Combobox6.Text;
ExcelApplication1.Visible[0]:=true;
While not ADOQuery1.Eof do
begin;
ExcelApplication1.Cells.Item[i,1].Value:=ADOQuery1.FieldByName('Stud').AsString;
ExcelApplication1.Cells.Item[i,2].Value:='все';
ExcelApplication1.Cells.Item[i,3].Value:='5';
ExcelApplication1.Cells.Item[i,4].Value:=ADOQuery1.FieldByName('gruppa').AsString;
ADOQUERY1.Next;
//ADOQUERY1.Post;
i:=i+1;
end;
end;
end;
procedure TForm18.BitBtn3Click(Sender: TObject);
var
n: OleVariant;
i:integer;
k1:integer;
k2:integer;
k3:integer;
k4,k:double;
begin
ADOQuery4.SQL.Text:='drop table ots1';
ADOQuery4.ExecSQL;
//ADoQuery.Active:=false;
ADoQuery2.Active:=true;
ADOQuery2.Edit;
ADoQuery2.First;
ADoQuery5.Active:=true;
ADoQuery5.First;
ADOQuery2.insert;
ADoQuery3.SQL.Text:='Select* from spez';
ADOQuery3.Active:=true;
While not ADoQuery3.Eof do
begin
ADOQuery2.FieldByName('Gruppa').AsString:=ADOQuery3.FieldByName('Grupa').AsString;
ADOQuery2.FieldByName('Spez').AsString:=ADOQuery3.FieldByName('Spez').AsString;
ADOQuery2.FieldByName('kolledg').AsString:='koledg';
Combobox1.Text:=Combobox7.Text;
Combobox2.Text:=Combobox8.Text;
Combobox5.Text:=ADOQuery2.FieldByName('Gruppa').AsString;
Combobox4.Text:=ADOQuery2.FieldByName('Spez').AsString;
//Combobox1.Text:=Combobox7.Text;
//Combobox2.Text:=Combobox8.Text;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count1] FROM ozenka where (((ozenka.ozenka)>3))GROUP BY ozenka.mes, ozenka.god, ozenka.gruppa ');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'") AND ((ozenka.gruppa)="'+Combobox5.Text+'"))');
AdoQuery1.Active:=True;
k1:=AdoQuery1.fieldbyname('Count1').AsInteger;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count2] FROM ozenka where (((ozenka.ozenka)>0))GROUP BY ozenka.mes, ozenka.god, ozenka.gruppa ');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'") AND ((ozenka.gruppa)="'+Combobox5.Text+'"))');
AdoQuery1.Active:=True;
k2:=AdoQuery1.fieldbyname('Count2').AsInteger;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count3] FROM ozenka where (((ozenka.ozenka)>2))GROUP BY ozenka.mes, ozenka.god, ozenka.gruppa ');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'") AND ((ozenka.gruppa)="'+Combobox5.Text+'"))');
AdoQuery1.Active:=True;
k3:=AdoQuery1.fieldbyname('Count3').AsInteger;
//ShowMessage(FloatToStr(k4));
// ShowMessage(FloatToStr(k));
IF K2>0 then begin
k4:=Round((k3/k2*100));
k:=Round((k1/k2*100));
//Edit1.Text:=FloatToStr(k4);
//Edit2.Text:=FloatToStr(k);
ADOQuery2.FieldByName('usp').AsString:=FloatToStr(k4);
ADOQuery2.FieldByName('kas').AsString:=FloatToStr(k);
ADOQuery2.FieldByName('kol').AsString:=FloatToStr(k2);
end;
ADOQuery2.Insert;
ADOQuery3.Next;
end;
//по специальностям
ADoQuery2.Active:=true;
ADOQuery2.Edit;
ADoQuery2.First;
ADoQuery3.SQL.Text:='Select spez from spez';
ADoQuery3.Active:=true;
ADoQuery3.First;
ADOQuery2.insert;
While not ADoQuery3.Eof do
begin
//ADOQuery2.FieldByName('Gruppa').AsString:=ADOQuery3.FieldByName('Grupa').AsString;
ADOQuery2.FieldByName('Spez').AsString:=ADOQuery3.FieldByName('Spez').AsString;
ADOQuery2.FieldByName('kolledg').AsString:='koledg';
Combobox1.Text:=Combobox7.Text;
Combobox2.Text:=Combobox8.Text;
//Combobox5.Text:=ADOQuery2.FieldByName('Gruppa').AsString;
Combobox4.Text:=ADOQuery2.FieldByName('Spez').AsString;
//Combobox1.Text:=Combobox7.Text;
//Combobox2.Text:=Combobox8.Text;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count1] FROM ozenka where (((ozenka.ozenka)>3))GROUP BY ozenka.mes, ozenka.god, ozenka.kodspez');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'") AND ((ozenka.kodspez)="'+Combobox4.Text+'"))');
AdoQuery1.Active:=True;
k1:=AdoQuery1.fieldbyname('Count1').AsInteger;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count2] FROM ozenka where (((ozenka.ozenka)>0))GROUP BY ozenka.mes, ozenka.god, ozenka.kodspez ');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'") AND ((ozenka.kodspez)="'+Combobox4.Text+'"))');
AdoQuery1.Active:=True;
k2:=AdoQuery1.fieldbyname('Count2').AsInteger;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count3] FROM ozenka where (((ozenka.ozenka)>2))GROUP BY ozenka.mes, ozenka.god, ozenka.kodspez ');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'") AND ((ozenka.kodspez)="'+Combobox4.Text+'"))');
AdoQuery1.Active:=True;
k3:=AdoQuery1.fieldbyname('Count3').AsInteger;
//ShowMessage(FloatToStr(k4));
//ShowMessage(FloatToStr(k));
IF K2>0 then begin
k4:=Round((k3/k2*100));
k:=Round((k1/k2*100));
//Edit1.Text:=FloatToStr(k4);
//Edit2.Text:=FloatToStr(k);
ADOQuery2.FieldByName('usp').AsString:=FloatToStr(k4);
ADOQuery2.FieldByName('kas').AsString:=FloatToStr(k);
ADOQuery2.FieldByName('kol').AsString:=FloatToStr(k2);
end;
ADOQuery2.Insert;
ADOQuery3.Next;
end;
//по колледжу
ADOQuery2.insert;
//ADOQuery2.FieldByName('Gruppa').AsString:=ADOQuery3.FieldByName('Grupa').AsString;
//ADOQuery2.FieldByName('Spez').AsString:=ADOQuery3.FieldByName('Spez').AsString;
ADOQuery2.FieldByName('kolledg').AsString:='koledg';
Combobox1.Text:=Combobox7.Text;
Combobox2.Text:=Combobox8.Text;
//Combobox5.Text:=ADOQuery2.FieldByName('Gruppa').AsString;
Combobox4.Text:=ADOQuery2.FieldByName('Spez').AsString;
//Combobox1.Text:=Combobox7.Text;
//Combobox2.Text:=Combobox8.Text;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count1] FROM ozenka where (((ozenka.ozenka)>3))GROUP BY ozenka.mes, ozenka.god');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'"))');
AdoQuery1.Active:=True;
k1:=AdoQuery1.fieldbyname('Count1').AsInteger;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count2] FROM ozenka where (((ozenka.ozenka)>0))GROUP BY ozenka.mes, ozenka.god ');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'"))');
AdoQuery1.Active:=True;
k2:=AdoQuery1.fieldbyname('Count2').AsInteger;
ADOQuery1.SQL.Clear;
AdoQuery1.SQL.Add('SELECT Count(ozenka.stud) AS [Count3] FROM ozenka where (((ozenka.ozenka)>2))GROUP BY ozenka.mes, ozenka.god');
AdoQuery1.SQL.Add('HAVING (((ozenka.mes)="'+Combobox1.Text+'") AND ((ozenka.god)="'+Combobox2.Text+'"))');
AdoQuery1.Active:=True;
k3:=AdoQuery1.fieldbyname('Count3').AsInteger;
//ShowMessage(FloatToStr(k4));
//ShowMessage(FloatToStr(k));
IF K2>0 then begin
k4:=Round((k3/k2*100));
k:=Round((k1/k2*100));
//Edit1.Text:=FloatToStr(k4);
//Edit2.Text:=FloatToStr(k);
ADOQuery2.FieldByName('usp').AsString:=FloatToStr(k4);
ADOQuery2.FieldByName('kas').AsString:=FloatToStr(k);
ADOQuery2.FieldByName('kol').AsString:=FloatToStr(k2);
ADOQuery2.Post;
end;
//S:String;
begin
//if radiogroup3.ItemIndex=0 then begin
AdoQuery6.Close;
ADOQuery6.SQL.Clear;
ADOQuery6.SQL.Add('SELECT ots.kolledg, ots.spez, ots.gruppa, ots.kol, ots.usp, ots.kas into ots1 FROM ots GROUP BY ots.kolledg, ots.spez, ots.gruppa, ots.kol, ots.usp, ots.kas');
//ORDER BY ots.kolledg DESC , ots.spez DESC , ots.gruppa DESCSELECT ozenka.ozenka, ozenka.stud, ozenka.gruppa, ozenka.koddis, ozenka.kodspez, ozenka.mes, ozenka.god FROM ozenka WHERE (((ozenka.ozenka)=2))');
ADOQuery6.SQL.Add('ORDER BY ots.kolledg DESC , ots.spez DESC , ots.gruppa DESC');
//Showmessage(adoquery1.SQL.Text);
ADOQuery6.ExecSQL;
{ADOTable6.TableName:='ots1';
ADOTable6.Active:=true;
ADOTable6.Active:=false;
ADOTable6.Active:=true;
//ADOTable6.First;
n:='d:\55\usp.xls';
ExcelApplication1.Workbooks.Add(n,0);
Excelworkbook1.ConnectTo(ExcelApplication1.ActiveWorkbook);
i:=10;
ExcelApplication1.Cells.Item[1,2].Value:=Combobox7.Text;
ExcelApplication1.Cells.Item[1,3].Value:=Combobox8.Text;
ADOTable6.First;
//
If ADOTable6.FieldByName('gruppa').AsString<>'' then
ExcelApplication1.Cells.Item[i,2].Value:=ADOTable6.FieldByName('gruppa').AsString
else
// If (ADOQuery6.FieldByName('Spez').AsString<>'') then
ExcelApplication1.Cells.Item[i,2].Value:='итого по специальности '+ADOTable6.FieldByName('Spez').AsString;
If (ADOTable6.FieldByName('Spez').AsString='') then
ExcelApplication1.Cells.Item[i,2].Value:='итого по колледжу ';//+ADOQuery1.FieldByName('Kolledg').AsString;
ExcelApplication1.Cells.Item[i,3].Value:=ADOTable6.FieldByName('kol').AsString;
ExcelApplication1.Cells.Item[i,4].Value:=ADOTable6.FieldByName('usp').AsString;
ExcelApplication1.Cells.Item[i,5].Value:=ADOTable6.FieldByName('kas').AsString;
//While not ADOTable6.Eof do
begin;
ShowMessage('fdgiiii');
k4:= ADOTable6.FieldByName('usp').AsFloat;
k:=ADOTable6.FieldByName('kas').AsFloat;
ShowMessage(FloatToStr(k4));
If ADOTable6.FieldByName('gruppa').AsString<>'' then
ExcelApplication1.Cells.Item[i,2].Value:=ADOTable6.FieldByName('gruppa').AsString
else
// If (ADOQuery6.FieldByName('Spez').AsString<>'') then
ExcelApplication1.Cells.Item[i,2].Value:='итого по специальности '+ADOTable6.FieldByName('Spez').AsString;
If (ADOTable6.FieldByName('Spez').AsString='') then
ExcelApplication1.Cells.Item[i,2].Value:='итого по колледжу ';//+ADOQuery1.FieldByName('Kolledg').AsString;
ExcelApplication1.Cells.Item[i,3].Value:=ADOTable6.FieldByName('kol').AsString;
ExcelApplication1.Cells.Item[i,4].Value:=k4;
ExcelApplication1.Cells.Item[i,5].Value:=k;
ADOTable6.Next;
//ADOQUERY1.Post;
i:=i+1;
end;
end;
//ExcelApplication1.Visible[0]:=true; }
ADOQuery4.SQL.Clear;
ADOQuery4.SQL.Text:='delete * from ots';
ADOQuery4.ExecSQL;
ADOQuery4.SQL.Text:='drop table ots1';
//ADOQuery4.ExecSQL;
//end;
end;
ShowMessage('Перерасчет данных успешно выполнен можно делать отчет!');
end;
procedure TForm18.Button1Click(Sender: TObject);
var
n:Olevariant;
i:Integer;
k1:integer;
k2:integer;
k3:integer;
k4,k:double;
begin
ADOTable6.TableName:='ots1';
ADOTable6.Active:=true;
ADOTable6.Active:=false;
ADOTable6.Active:=true;
//ADOTable6.First;
n:='d:\55\usp.xls';
ExcelApplication1.Workbooks.Add(n,0);
Excelworkbook1.ConnectTo(ExcelApplication1.ActiveWorkbook);
i:=10;
ExcelApplication1.Cells.Item[1,2].Value:=Combobox7.Text;
ExcelApplication1.Cells.Item[1,3].Value:=Combobox8.Text;
ADOTable6.First;
// If ADOTable6.FieldByName('gruppa').AsString<>'' then
ExcelApplication1.Cells.Item[i,2].Value:=ADOTable6.FieldByName('gruppa').AsString
else
// If (ADOQuery6.FieldByName('Spez').AsString<>'') then
ExcelApplication1.Cells.Item[i,2].Value:='итого по специальности '+ADOTable6.FieldByName('Spez').AsString;
If (ADOTable6.FieldByName('Spez').AsString='') then
ExcelApplication1.Cells.Item[i,2].Value:='итого по колледжу ';//+ADOQuery1.FieldByName('Kolledg').AsString;