📄 unit9.pas
字号:
unit Unit9;
interface
uses
windows,SysUtils,Classes,Dialogs,ADODB,db,ActiveX{必须要有};
type
Tsendshortmessage = class(TThread)
private
// ADOConnection1: TADOConnection;
// ADOQuery1: TADOQuery;
// ADOQuery2: TADOQuery;
// ADOCommand1: TADOCommand;
{ Private declarations }
protected
procedure Execute; override;
public
constructor create; //自己写的
end;
implementation
uses unit7,main;
var
sendshortmessage:Tsendshortmessage;
constructor Tsendshortmessage.create;
begin
CoInitialize( nil );//使用com对象必须要初始化
inherited create(true);
// ADOConnection1.LoginPrompt :=false;
//ADOConnection1.KeepConnection :=true;
// ADOQuery1.Connection:=ADOConnection1;
// ADOQuery2.Connection :=ADOConnection1;
// ADOConnection1.ConnectionString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=home_school_2.mdb;Mode=cmReadWrite;Persist Security Info=False';
end;
procedure Tsendshortmessage.Execute;
var
mobile1:pchar;
p1:string;
p2:string;
str1:pchar;
str2:pchar;
j:integer;
k:integer;
card_id1:string;
id:integer;
//handle:hwnd;
begin
//messagebox(Handle,'test',nil,MB_OK);
//dialogs.showmessage('循环开始0');
p1:='您好!你的小孩于'+timetostr(time)+'进校门';
p2:='您好!你的小孩于'+timetostr(time)+'出校门';
str1:=pchar(p1);
str2:=pchar(p2);
//mobile1:='0000';
repeat
//dialogs.showmessage();
mainform.memo1.Lines.Add('循环开始1');
sleep(200);
mainform.ADOQuery2.Close;
//dialogs.showmessage('循环开始1.01');
mainform.memo1.Lines.Add('循环开始1.01'); sleep(200);
mainform.ADOQuery2.sql.clear;
mainform.memo1.Lines.Add('循环开始1.02'); sleep(200);//('循环开始1.02');
mainform.ADOQuery2.sql.text:='select * from message';
mainform.memo1.Lines.Add('循环开始1.03'); sleep(200);//('循环开始1.03');
mainform.ADOQuery2.open;
mainform.memo1.Lines.Add('循环开始2'); sleep(200);//('循环开始2');
if not mainform.ADOQuery2.Eof then
begin
mainform.memo1.Lines.Add('循环开始2.1'); sleep(200);//('循环开始2.1');
id:=mainform.ADOQuery2.fieldbyname('id').AsInteger;
mobile1:=pchar(mainform.ADOQuery2.fieldbyname('mobile').AsString);
card_id1:=mainform.ADOQuery2.fieldbyname('card_id').AsString;
mainform.memo1.Lines.Add('循环开始3'+inttostr(id)); sleep(200);//('循环开始3 '+inttostr(id));
mainform.adocommand3.CommandType:=cmdtext;
mainform.memo1.Lines.Add('循环开始3.000'); sleep(200);//('循环开始3.000');
mainform.adocommand3.CommandText:='delete * from message where id=:id';
mainform.memo1.Lines.Add('循环开始3.001'); sleep(200);//('循环开始3.001');
mainform.adocommand3.Parameters.ParamByName('id').Value:=(inttostr(id));
mainform.memo1.Lines.Add('循环开始3.01'); sleep(200);//('循环开始3.01');
mainform.adocommand3.Execute;
mainform.memo1.Lines.Add('循环开始3.02'); sleep(200);//('循环开始3.02');
with mainform.ADOQuery3 do
begin
mainform.memo1.Lines.Add('循环开始4'); sleep(200);//('循环开始4');
close;
sql.text:='select num from status where card_id='+quotedstr(card_id1)+'and day='+datetostr(date);
open;
mainform.memo1.Lines.Add('循环开始5'); sleep(200);//('循环开始5');
k:=fieldbyname('num').AsInteger;
if (k mod 2) <> 0 then
begin
j:=SendSms(mainform.msg_com,mobile1,str1,length(str1));
mainform.memo1.Lines.Add('循环开始6'); sleep(200);//('循环开始6');
if j<>0 then
// showmessage(mobile+' send error! with error code:'+inttostr(j));
mainform.memo1.Lines.Add(mobile1+' send error! with error code:'+inttostr(j)); sleep(200);
mainform.memo1.Lines.Add('循环开始7'); sleep(200);//('循环开始7');
end
else
j:=SendSms(mainform.msg_com,mobile1,str2,length(str2));
mainform.memo1.Lines.Add('循环开始8'); sleep(200);//('循环开始8');
if j<>0 then
mainform.memo1.Lines.Add(mobile1+' send error! with error code:'+inttostr(j)+'str2='+str2); sleep(200);
//showmessage(mobile+' send error! with error code:'+inttostr(j));
sql.clear;
sql.text:='delete status where mobile='+quotedstr(mobile1);
ExecSQL;
mainform.memo1.Lines.Add('循环开始9'); sleep(200);//('循环开始9');
end;
end;
mainform.ADOQuery2.Next;
sleep(1000);
until 0=1;
//result:= 1;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -