⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit11.pas

📁 学校短信息系统 采用华域科技的SzgmtSms 通讯模块
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Unit11;

interface

uses
  windows,SysUtils,Classes,Dialogs,DateUtils,ADODB,db,ActiveX{必须要有};

type
  Tsendmessage = class(TThread)
  private

  protected
    procedure Execute; override;
  public
     constructor create;      //自己写的
  end;
implementation
uses unit7,main;

constructor Tsendmessage.create;
    begin
      CoInitialize( nil );//使用com对象必须要初始化
      inherited create(true);
    end;
procedure Tsendmessage.Execute;
type
tt=TDateTime;
var
    mobile1:pchar;
    p1:string;
    p2:string;
    str1:pchar;
    str2:pchar;
    j:integer;
    k:integer;
    card_id1:string;
    id:integer;
    t1,zc_in,zc_out,am_in,am_out,pm_in,pm_out,ws_in,ws_out:tt;
    compare1,compare2,compare3,compare4,compare5,compare6,compare7,compare8:integer;
    t1_name:string;
    counter:integer;
begin
p1:='您好!你的小孩迟到了';
p2:='您好!你的小孩未到';
str1:=pchar(p1);
str2:=pchar(p2);
counter:=1;
mainform.memo1.Lines.Add('repeat begin');
repeat
mainform.memo1.Lines.Add(inttostr(counter));
counter:=counter+1;
t1:=time;
mainform.memo1.Lines.Add(timetostr(t1));
mainform.adoquery1.Close;
mainform.adoquery1.SQL.Clear;
mainform.adoquery1.SQL.Text:='select * from schedule';
mainform.memo1.Lines.Add('select * from schedule');
mainform.adoquery1.Open;
mainform.memo1.Lines.Add('open');
zc_in:=mainform.adoquery1.fieldbyname('zc_in').AsDateTime;
zc_out:=mainform.adoquery1.fieldbyname('zc_out').AsDateTime;
am_in:=mainform.adoquery1.fieldbyname('am_in').AsDateTime;
am_out:=mainform.adoquery1.fieldbyname('am_out').AsDateTime;
pm_in:=mainform.adoquery1.fieldbyname('pm_in').AsDateTime;
pm_out:=mainform.adoquery1.fieldbyname('pm_out').AsDateTime;
ws_in:=mainform.adoquery1.fieldbyname('ws_in').AsDateTime;
ws_out:=mainform.adoquery1.fieldbyname('ws_out').AsDateTime;
mainform.memo1.Lines.Add(datetimetostr(zc_in));
compare1:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(zc_in));
compare2:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(zc_out));
compare3:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(am_in));
compare4:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(am_out));
compare5:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(pm_in));
compare6:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(pm_out));
compare7:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(ws_in));
compare8:=longint(SecondOfTheDay(t1))-longint(SecondOfTheDay(ws_out));
mainform.memo1.Lines.Add(inttostr(compare1));
if (compare1>=0) and (compare1<60) then t1_name:='zc_in';
if (compare2>=0) and (compare2<60) then t1_name:='zc_out';
if (compare3>=0) and (compare3<60) then t1_name:='am_in';
if (compare4>=0) and (compare4<60) then t1_name:='am_out';
if (compare5>=0) and (compare5<60) then t1_name:='pm_in';
if (compare6>=0) and (compare6<60) then t1_name:='pm_out';
if (compare7>=0) and (compare7<60) then t1_name:='ws_in';
if (compare8>=0) and (compare8<60) then t1_name:='ws_out';
mainform.memo1.Lines.Add(t1_name);
if (t1_name='zc_in') then
begin
mainform.adocommand3.CommandText:='insert into student_absent_status select name,class,grade,'+quotedstr('cd')+' as status,'+quotedstr(datetostr(date)+'zc')+' as operate_time from student_info where card_id not in (select card_id from daily where time>=:t1 and time<:t2)';
mainform.adocommand3.Parameters.ParamByName('t1').Value:=datetostr(date)+' 0:00:01';
mainform.adocommand3.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(zc_in);
mainform.adocommand3.Execute;
mainform.adocommand3.CommandText:='insert into message select mobile1,card_id as mobile from student_info where name in (select name from student_absent_status where status='+quotedstr('cd')+' and operate_time='+quotedstr(datetostr(date)+'zc')+')';
mainform.adocommand3.Execute;

mainform.ADOQuery2.Close;
mainform.ADOQuery2.sql.clear;
mainform.ADOQuery2.sql.text:='select * from message';
mainform.ADOQuery2.open;
while not mainform.ADOQuery2.Eof do
begin
//id:=mainform.ADOQuery2.fieldbyname('id').AsInteger;
mobile1:=pchar(mainform.ADOQuery2.fieldbyname('mobile').AsString);
card_id1:=mainform.ADOQuery2.fieldbyname('card_id').AsString;
mainform.adocommand3.CommandType:=cmdtext;
mainform.adocommand3.CommandText:='delete * from message where card_id=:id'; //here MS access is not like MS SQL
mainform.adocommand3.Parameters.ParamByName('id').Value:=card_id1;
mainform.adocommand3.Execute;
j:=SendSms(mainform.msg_com,mobile1,str1,length(str1));
if j<>0 then mainform.memo1.Lines.Add(mobile1+' send error! with error code:'+inttostr(j));
mainform.ADOQuery2.Next;
end;
end
else if (t1_name='zc_out') then
begin
mainform.adocommand3.CommandText:='insert into student_absent_status select name,class,grade,'+quotedstr('wd')+' as status,'+quotedstr(datetostr(date)+'zc')+' as operate_time from student_info where card_id not in (select card_id from daily  where time>=:t1 and time<:t2)';
mainform.adocommand3.Parameters.ParamByName('t1').Value:=datetostr(date)+' '+timetostr(zc_in);
mainform.adocommand3.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(zc_out);
mainform.adocommand3.Execute;
mainform.adocommand3.CommandText:='insert into message select mobile1,card_id as mobile from student_info where name in (select name from student_absent_status where status='+quotedstr('wd')+' and operate_time='+quotedstr(datetostr(date)+'zc')+')';
mainform.adocommand3.Execute;
mainform.ADOQuery2.Close;
mainform.ADOQuery2.sql.clear;
mainform.ADOQuery2.sql.text:='select * from message';
mainform.ADOQuery2.open;
while not mainform.ADOQuery2.Eof do
begin
//id:=mainform.ADOQuery2.fieldbyname('id').AsInteger;
mobile1:=pchar(mainform.ADOQuery2.fieldbyname('mobile').AsString);
card_id1:=mainform.ADOQuery2.fieldbyname('card_id').AsString;
mainform.adocommand3.CommandType:=cmdtext;
mainform.adocommand3.CommandText:='delete * from message where card_id=:id'; //here MS access is not like MS SQL
mainform.adocommand3.Parameters.ParamByName('id').Value:=card_id1;
mainform.adocommand3.Execute;
j:=SendSms(mainform.msg_com,mobile1,str2,length(str2));
if j<>0 then mainform.memo1.Lines.Add(mobile1+' send error! with error code:'+inttostr(j));
mainform.ADOQuery2.Next;
end;
end
else if (t1_name='am_in') then
begin
mainform.adocommand3.CommandText:='insert into student_absent_status select name,class,grade,'+quotedstr('cd')+' as status,'+quotedstr(datetostr(date)+'am')+' as operate_time from student_info where card_id not in (select card_id from daily where time>=:t1 and time<:t2)';
mainform.adocommand3.Parameters.ParamByName('t1').Value:=datetostr(date)+' '+timetostr(zc_out);
mainform.adocommand3.Parameters.ParamByName('t2').Value:=datetostr(date)+' '+timetostr(am_in);
mainform.adocommand3.Execute;
mainform.adocommand3.CommandText:='insert into message select mobile1,card_id as mobile from student_info where name in (select name from student_absent_status where status='+quotedstr('cd')+' and operate_time='+quotedstr(datetostr(date)+'am')+')';
mainform.adocommand3.Execute;
mainform.ADOQuery2.Close;
mainform.ADOQuery2.sql.clear;
mainform.ADOQuery2.sql.text:='select * from message';
mainform.ADOQuery2.open;
while not mainform.ADOQuery2.Eof do
begin
//id:=mainform.ADOQuery2.fieldbyname('id').AsInteger;
mobile1:=pchar(mainform.ADOQuery2.fieldbyname('mobile').AsString);
card_id1:=mainform.ADOQuery2.fieldbyname('card_id').AsString;
mainform.adocommand3.CommandType:=cmdtext;
mainform.adocommand3.CommandText:='delete * from message where card_id=:id'; //here MS access is not like MS SQL
mainform.adocommand3.Parameters.ParamByName('id').Value:=card_id1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -