📄 unit10.pas
字号:
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB,DateUtils,ShellAPI;
type
TForm10 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
ADOCommand1: TADOCommand;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form10: TForm10;
implementation
{$R *.dfm}
procedure TForm10.FormShow(Sender: TObject);
type
student_num=array[1..12] of integer;
student_info=array[1..200] of string;
grade_name=array[1..12] of string;
//TValueRelationship = -1..1;
r1=_recordset;
var
r2:r1;
i:integer;
grade_num:integer;
school_yd,school_sd,school_cd,school_wd:integer;
grade:grade_name;
yd,sd,cd,wd:student_num;
cd_student,wd_student:student_info;
t1,zc_in,zc_out,am_in,am_out,pm_in,pm_out,ws_in,ws_out:ttime;
t1_name:string;
html,htmltext:string;
dt:string;
compare1,compare2,compare3,compare4,compare5:integer;
htmlfile:textfile;
//test1,test2:longint;
//teststr1,teststr2:string;
file_path:pchar;
begin
//---------------------initialise---------------------
t1:=time;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:='select * from schedule';
adoquery1.Open;
zc_in:=adoquery1.fieldbyname('zc_in').AsDateTime;
zc_out:=adoquery1.fieldbyname('zc_out').AsDateTime;
am_in:=adoquery1.fieldbyname('am_in').AsDateTime;
am_out:=adoquery1.fieldbyname('am_out').AsDateTime;
pm_in:=adoquery1.fieldbyname('pm_in').AsDateTime;
pm_out:=adoquery1.fieldbyname('pm_out').AsDateTime;
ws_in:=adoquery1.fieldbyname('ws_in').AsDateTime;
ws_out:=adoquery1.fieldbyname('ws_out').AsDateTime;
//test1:=$ffbc;
//test2:=$fff3;
//teststr1:=inttostr(test1);
//teststr2:=inttostr(test2);
//compare1:=strtoint(teststr1)-strtoint(teststr2);
//compare2:=-2345;
compare1:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(strtotime('00:00:00')));
compare2:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(zc_out));// CompareTime(t1,zc_out);
compare3:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(am_out));// CompareTime(t1,am_out);
compare4:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(pm_out));// CompareTime(t1,pm_out);
compare5:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(ws_out));// CompareTime(t1,ws_out);
//showmessage( inttostr(longint(SecondOfTheDay(strtotime('00:00:00'))))+'----'+inttostr(longint(SecondOfTheDay(ws_out))));
if (compare1>=0) and (compare2<0) then t1_name:='zc';
if (compare2>=0) and (compare3<0) then t1_name:='am';
if (compare3>=0) and (compare4<0) then t1_name:='pm';
if (compare4>=0) and (compare5<0) then t1_name:='ws';
////showmessage(t1_name);
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:='select distinct grade from class_info';// select distinct grade from class_info';
////showmessage('sql1');
adoquery1.Open;
////showmessage('while begin!');
i:=1;
while not adoquery1.Eof do
begin
////showmessage('ring!');
grade[i]:=adoquery1.fieldbyname('grade').AsString;
i:=i+1;
adoquery1.Next;
end;
grade_num:=i-1;
////showmessage('grade_num='+inttostr(grade_num));
//----------------------compute yd---------------------
i:=1;
while i<=grade_num do
begin
adoquery1.Close;
adoquery1.SQL.Clear;
////showmessage(grade[i]);
adoquery1.SQL.Text:='select sum(student_num)as num from class_info where grade='+quotedstr(grade[i]);
adoquery1.Open;
yd[i]:=adoquery1.fieldbyname('num').AsInteger;
i:=i+1;
end;
//-----------------------------compute sd,cd,wd-----------------
////showmessage(t1_name);
if t1_name='zc' then
begin
//------------------------compute sd-------------------------
////showmessage('---compute zc.sd---');
i:=1;
while i<=grade_num do
begin
adocommand1.CommandText:='select count(*)as num from student_info where grade=:grade_name and card_id in(select card_id from daily where time>=:t1 and time<:t2)';
adocommand1.Parameters.ParamByName('grade_name').Value:=quotedstr(grade[i]);
adocommand1.Parameters.ParamByName('t1').Value:=datetostr(date)+' 0:00:01';
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(zc_in);
r2:=adocommand1.Execute;
////showmessage('open');
sd[i]:=r2.Fields.Item[0].value;
i:=i+1;
end;
//------------------------------compute cd-------------------------
////showmessage('---compute pm.cd---');
i:=1;
while i<=grade_num do
begin
adocommand1.CommandText:='select name,class from student_info where grade=:grade_name and card_id in (select card_id from daily where time>=:t1 and time<:t2)';
adocommand1.Parameters.ParamByName('grade_name').Value:=grade[i];
adocommand1.Parameters.ParamByName('t1').Value:=datetostr(date)+' '+timetostr(zc_in);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(zc_out);
r2:=adocommand1.Execute;
cd[i]:=0;
cd_student[i]:='';
while not r2.Eof do
begin
cd[i]:=cd[i]+1;
cd_student[i]:=cd_student[i]+ r2.Fields.Item[0].value +'('+ r2.Fields.Item[1].value +'),';
r2.MoveNext;
end;
i:=i+1;
end;
//--------------------------------- compute wd-----------------------
//showmessage('----pm.wd------');
i:=1;
while i<=grade_num do
begin
adocommand1.CommandText:='select name,class from student_info where grade=:grade_name and card_id not in (select card_id from daily where time between :t1 and :t2)';
adocommand1.Parameters.ParamByName('grade_name').Value:=grade[i];
adocommand1.Parameters.ParamByName('t1').Value:=datetostr(date)+' '+timetostr(zc_out);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(zc_out);
//showmessage(adocommand1.CommandText);
r2:=adocommand1.Execute;
wd[i]:=0;
wd_student[i]:='';
while not r2.EOF do
begin
wd[i]:=wd[i]+1;
wd_student[i]:=wd_student[i]+ r2.Fields.Item[0].value +'('+ r2.Fields.Item[1].value +'),';
r2.MoveNext;
end;
//showmessage(inttostr(wd[i])+' '+wd_student[i]);
i:=i+1;
end;
end
else if t1_name='am' then
begin
//------------------------compute sd-------------------------
////showmessage('---compute am.sd---');
i:=1;
while i<=grade_num do
begin
adocommand1.CommandText:='select count(*)as num from student_info where grade=:grade_name and card_id in(select card_id from daily where time>=:t1 and time<:t2)';
adocommand1.Parameters.ParamByName('grade_name').Value:=quotedstr(grade[i]);
adocommand1.Parameters.ParamByName('t1').Value:=datetostr(date)+' '+timetostr(zc_out);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(am_in);
r2:=adocommand1.Execute;
////showmessage('open');
sd[i]:=r2.Fields.Item[0].value;
i:=i+1;
end;
//------------------------------compute cd-------------------------
////showmessage('---compute pm.cd---');
i:=1;
while i<=grade_num do
begin
adocommand1.CommandText:='select name,class from student_info where grade=:grade_name and card_id in (select card_id from daily where time>=:t1 and time<:t2)';
adocommand1.Parameters.ParamByName('grade_name').Value:=grade[i];
adocommand1.Parameters.ParamByName('t1').Value:=datetostr(date)+' '+timetostr(am_in);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(am_out);
r2:=adocommand1.Execute;
cd[i]:=0;
cd_student[i]:='';
while not r2.Eof do
begin
cd[i]:=cd[i]+1;
cd_student[i]:=cd_student[i]+ r2.Fields.Item[0].value +'('+ r2.Fields.Item[1].value +'),';
r2.MoveNext;
end;
i:=i+1;
end;
//--------------------------------- compute wd-----------------------
//showmessage('----am.wd------');
i:=1;
while i<=grade_num do
begin
adocommand1.CommandText:='select name,class from student_info where grade=:grade_name and card_id not in (select card_id from daily where time between :t1 and :t2)';
adocommand1.Parameters.ParamByName('grade_name').Value:=grade[i];
adocommand1.Parameters.ParamByName('t1').Value:=datetostr(date)+' '+timetostr(zc_out);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(am_out);
//showmessage(adocommand1.CommandText);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -