📄 unit10.pas
字号:
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='pm' then
begin
//------------------------compute sd-------------------------
////showmessage('---compute pm.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(am_out);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(pm_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(pm_in);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(pm_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(am_out);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(pm_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='ws' then
begin
//------------------------compute sd-------------------------
////showmessage('---compute ws.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(pm_out);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(ws_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(ws_in);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(ws_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(pm_out);
adocommand1.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(ws_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;
i:=1;
school_yd:=0;
school_sd:=0;
school_cd:=0;
school_wd:=0;
while i<=grade_num do
begin
school_yd:=school_yd+yd[i];
school_sd:=school_sd+sd[i];
school_cd:=school_cd+cd[i];
school_wd:=school_wd+wd[i];
i:=i+1;
end;
i:=1;
html:='';
htmltext:='';
memo1.Clear;
dt:=datetostr(date)+' '+timetostr(time);
memo1.lines.Add(' 应到 实到 迟到 未到');
memo1.lines.Add('全校 '+inttostr(school_yd)+' '+inttostr(school_sd)+' '+inttostr(school_cd)+' '+inttostr(school_wd));
while i<=grade_num do
begin
memo1.lines.Add(grade[i]+' '+inttostr(yd[i])+' '+inttostr(sd[i])+' 共'+inttostr(cd[i])+'人 共'+inttostr(wd[i])+'人');
i:=i+1;
end;
memo1.Lines.Add('--------------------------') ;
memo1.Lines.Add(' 迟到 ') ;
memo1.Lines.Add('--------------------------') ;
i:=1;
while i<=grade_num do
begin
memo1.Lines.Add(cd_student[i]);
i:=i+1;
end;
memo1.Lines.Add('--------------------------') ;
memo1.Lines.Add(' 未到 ') ;
memo1.Lines.Add('--------------------------') ;
i:=1;
while i<=grade_num do
begin
memo1.Lines.Add(wd_student[i]);
i:=i+1;
end;
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Text:='select * from school';
adoquery1.Open;
html:=html+'<html><head><script language=javascript>window.print();</script></head><body>';
html:=html+'<center><font size=5 color=#3333ff>'+adoquery1.Fields.fieldbyname('name').AsString+'学生出勤表</font></center>'+dt+'<br>';
html:=html+'<table width=100% border=1 cellspacing=0 cellpadding=0 bordercolor=green>';
html:=html+'<tr><td width=15%> </td><td width=15%>应到</td><td width=15%>实到</td><td width=20%>迟到</td><td width=20%>未到</td></tr>';
html:=html+'<tr><td width=15% height=30>全校</td><td width=15%>'+inttostr(school_yd)+'</td><td width=15%>'+inttostr(school_sd)+'</td><td width=20%>'+inttostr(school_cd)+'</td><td width=20%>'+inttostr(school_wd)+'</td></tr>';
i:=1;
while i<=grade_num do
begin
html:=html+'<tr><td width=15% height=30>'+grade[i]+'</td><td width=15%>'+inttostr(yd[i])+'</td><td width=15%>'+inttostr(sd[i])+'</td><td width=20%><font color=red>共'+inttostr(cd[i])+'人</font><br>'+cd_student[i]+'</td><td width=20%><font color=red>共'+inttostr(wd[i])+'人</font><br>'+wd_student[i]+'</td></tr>';
i:=i+1;
end;
html:=html+'</table><br> ';
html:=html+'制作:home-school ver1.0 审查:</body></html>';
label2.Caption:=dt;
assignfile(htmlfile,'001.html');
////showmessage('file io');
rewrite(htmlfile);
////showmessage('writeln');
writeln(htmlfile,html);
closefile(htmlfile);
(*if(filecreate(file_path+'\'+dt+'.html')=-1)then showmessage('filecreate error!');
rewrite(f1);
if(fileopen(dt+'.html',$0001)=-1)then showmessage('file open error!');
if(filewrite(1,html,2048)=-1) then showmessage('write file error!');
fileclose(1); *)
end;
procedure TForm10.Button1Click(Sender: TObject);
var
file_path:pchar;
begin
//file_path:='D:/DownLoads/家校通/test/test007/';
file_path:=StrAlloc(255);
//GetTempPath(255,file_path);
windows.GetCurrentDirectory(255,file_path);
ShellExecute(Handle, 'open', PChar('iexplore.exe'), PChar(file_path+'\001.html'), nil, SW_SHOW);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -