📄 umain.pas
字号:
lstitem.SubItems.Add(qlist.fieldbyname('sender').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('content').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('senddate').AsString);
qlist.Next;
end;
{qlistup.Close;
qlistup.SQL.Clear;
qlistup.SQL.Text:='update revsms set status=1 where status=0';
qlistup.ExecSQL; }
end;
//结束加数据
//开始更新数据即读过的应将其状态改为1表示已读过了
//结束对状态的更改
//application.MessageBox('你双击了垃圾箱!',':提示:',mb_ok)
end;
//结束垃圾箱的显示
end;
procedure Tmainform.N31Click(Sender: TObject);
var
strsql:string;
i:integer;
lstitem:Tlistitem;
name: array[0..10] of string;
begin
runsql(qrlist,'select * from dxgl where status=4');
if qrlist.RecordCount >0 then
begin
if application.MessageBox('请确认是否要清空垃圾箱?',':提示:',mb_yesno)=idyes then
begin
qrlist.Close;
qrlist.SQL.Clear;
qrlist.SQL.Text:='delete from dxgl where status=4';
qrlist.ExecSQL;
//刷新一次对垃圾箱的操作
memo1.Clear;
listview1.Items.Clear;
listview1.Columns.Clear;
name[0]:='接收者手机号';
name[1]:='发送者';
name[2]:='短信内容';
name[3]:='发信时间';
for i:= 0 to 3 do
begin
listview1.columns.add;
listview1.Column[i].Caption:=name[i];
listview1.Column[i].Width:=115;
listview1.Column[i].Alignment:=tacenter;
end;
strsql:='select * from dxgl where status=4';
runsql(qlist,strsql);
if qlist.RecordCount >0 then
begin
for i:=0 to qlist.RecordCount-1 do
begin
lstitem:=listview1.Items.Add;
lstitem.Caption:=qlist.fieldbyname('receiver').AsString;
lstitem.ImageIndex:=0;
lstitem.SubItems.Add(qlist.fieldbyname('sender').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('content').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('senddate').AsString);
qlist.Next;
end;
end;
//结束加数据
//开始更新数据即读过的应将其状态改为1表示已读过了
//结束对状态的更改
//application.MessageBox('你刷新了垃圾箱!',':提示:',mb_ok)
//结束刷新
end
else
begin
exit;
end;
end;
end;
procedure Tmainform.N29Click(Sender: TObject);
var
delid:string; //用于操作表中的记录id号
deltab:string;//用于标识所在操作的表;
delstr:string;
ljxbd:string;//用于说明是否操作的是垃圾箱,如果是则删除从数据库.
namebd:string;
//下面是用于刷新操作用到的局部变量
i:integer;
lstitem:Tlistitem;
name: array[0..10] of string;
strsql:string;
begin
//在删除之前要分析一下是否有项被选中,选中才执行下面的操作,否则exit;
if listview1.SelCount >0 then
begin
delid:=idall[listview1.selected.index];
deltab:=taball;
ljxbd:=ljxdel;
namebd:=nameall;//将全局变量类别名称赋给naemebd便于做删除操作后对此模块进行刷新;
//首先在界面上要显示删除的情况
//listview1.Selected.Delete;
//结束界面的删除显示
//开始检查原表中是否有这样的一条记录有才能执行删除操作;
if namebd='草稿短信' then
begin
runsql(qrlist,'select * from dxgl where id='+delid);
if qrlist.RecordCount >0 then
begin
if application.MessageBox('请确认是否要删除?',':提示:',mb_yesno)=idyes then
begin
delstr:='update dxgl set status=4 where id='+delid ;
qrlist.Close;
qrlist.SQL.Clear;
qrlist.SQL.Text:=delstr;
qrlist.ExecSQL;
listview1.Selected.Delete;
memo1.Clear;
end;
end;
end;//结束草稿短信的删除
if namebd='垃圾箱' then
begin
runsql(qrlist,'select * from dxgl where id='+delid);
if qrlist.RecordCount >0 then
begin
if application.MessageBox('请确认是否要删除?',':提示:',mb_yesno)=idyes then
begin
delstr:='delete from dxgl where id='+delid;
qrlist.Close;
qrlist.SQL.Clear;
qrlist.SQL.Text:=delstr;
qrlist.ExecSQL;
listview1.Selected.Delete;
memo1.Clear;
end;
end;
end;//结束草稿短信的删除
//分析我们所在删除的对象,根据不同的namebd来做不同的删除操作;
if namebd='接收短信' then
begin
runsql(qrlist,'select * from revsms where id='+delid);
if qrlist.RecordCount >0 then
begin
if application.MessageBox('请确认是否要删除?',':提示:',mb_yesno)=idyes then
begin
delstr:='delete from revsms where id='+delid;
qrlist.Close;
qrlist.SQL.Clear;
qrlist.SQL.Text:=delstr;
qrlist.ExecSQL;
listview1.Selected.Delete;
memo1.Clear;
end;
end;
end; //结束接收短信的删除;
if namebd='已收短信' then
begin
runsql(qrlist,'select * from revsms where id='+delid);
if qrlist.RecordCount >0 then
begin
if application.MessageBox('请确认是否要删除?',':提示:',mb_yesno)=idyes then
begin
delstr:='delete from revsms where id='+delid;
qrlist.Close;
qrlist.SQL.Clear;
qrlist.SQL.Text:=delstr;
qrlist.ExecSQL;
listview1.Selected.Delete;
memo1.Clear;
end;
end;
end; //结束已收短信的删除
if ((namebd='待发短信')or(namebd='已发短信')or(namebd='失败短信')) then
begin
runsql(qrlist,'select * from sendsms where id='+delid);
if qrlist.RecordCount >0 then
begin
if application.MessageBox('请确认是否要删除?',':提示:',mb_yesno)=idyes then
begin
//首先要把它放到表dxgl中并将其status设为4
delstr:='update sendsms set status=4 where id='+delid;
qrlist.Close;
qrlist.SQL.Clear;
qrlist.SQL.Text:=delstr;
qrlist.ExecSQL;
//先更新了sendsms表中的状态,再将其放到dxgl中
delstr:='insert into dxgl (sender,receiver,content,status,senddate,lb) select sender,receiver,content,status,senddate,lb from sendsms where status=4';
qrlist.Close;
qrlist.SQL.Clear;
qrlist.SQL.Text:=delstr;
qrlist.ExecSQL;
delstr:='delete from sendsms where status=4';
qrlist.Close;
qrlist.SQL.Clear;
qrlist.SQL.Text:=delstr;
qrlist.ExecSQL;
listview1.Selected.Delete;
memo1.Clear;
end;
end;
end;
//当删除操作完后做此类的刷新
if namebd='接收短信' then
begin
//开始向listview中加数据
taball:='revsms';
ljxdel:='no';
nameall:='接收短信';
listview1.Items.Clear;
listview1.Columns.Clear;
name[0]:='来自手机号';
name[1]:='短信内容';
name[2]:='接收时间';
for i:= 0 to 2 do
begin
listview1.columns.add;
listview1.Column[i].Caption:=name[i];
listview1.Column[i].Width:=115;
listview1.Column[i].Alignment:=tacenter;
end;
strsql:='select * from revsms where status=0';
runsql(qlist,strsql);
if qlist.RecordCount >0 then
begin
for i:=0 to qlist.RecordCount-1 do
begin
lstitem:=listview1.Items.Add;
idall[i]:=qlist.fieldbyname('id').AsString;//用于删除时的标识付
lstitem.Caption:=qlist.fieldbyname('fromaddress').AsString;
lstitem.ImageIndex:=0;
lstitem.SubItems.Add(qlist.fieldbyname('content').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('revtime').AsString);
qlist.Next;
end;
qlistup.Close;
qlistup.SQL.Clear;
qlistup.SQL.Text:='update revsms set status=1 where status=0';
qlistup.ExecSQL;
end;
//结束加数据
//开始更新数据即读过的应将其状态改为1表示已读过了
//结束对状态的更改
//application.MessageBox('你双击了接收短信!',':提示:',mb_ok)
end;
//结结束用户的分析
if namebd='已收短信' then
begin
//开始向listview中加数据
taball:='revsms';
ljxdel:='no';
nameall:='已收短信';
listview1.Items.Clear;
listview1.Columns.Clear;
name[0]:='来自手机号';
name[1]:='短信内容';
name[2]:='接收时间';
for i:= 0 to 2 do
begin
listview1.columns.add;
listview1.Column[i].Caption:=name[i];
listview1.Column[i].Width:=115;
listview1.Column[i].Alignment:=tacenter;
end;
strsql:='select * from revsms ';
runsql(qlist,strsql);
if qlist.RecordCount >0 then
begin
for i:=0 to qlist.RecordCount-1 do
begin
lstitem:=listview1.Items.Add;
idall[i]:=qlist.fieldbyname('id').AsString;//用于删除时的标识付
lstitem.Caption:=qlist.fieldbyname('fromaddress').AsString;
lstitem.ImageIndex:=0;
lstitem.SubItems.Add(qlist.fieldbyname('content').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('revtime').AsString);
qlist.Next;
end;
end;
//结束加数据
//开始更新数据即读过的应将其状态改为1表示已读过了
//结束对状态的更改
//application.MessageBox('你双击了已收短信!',':提示:',mb_ok)
end;
//结结束用户的分析
//开始测试是否点击了待发短信
if namebd='待发短信' then
begin
//开始向listview中加数据
taball:='sendsms';
ljxdel:='no';
nameall:='待发短信';
listview1.Items.Clear;
listview1.Columns.Clear;
name[0]:='接收者手机号';
name[1]:='发送者';
name[2]:='短信内容';
name[3]:='发信时间';
for i:= 0 to 3 do
begin
listview1.columns.add;
listview1.Column[i].Caption:=name[i];
listview1.Column[i].Width:=115;
listview1.Column[i].Alignment:=tacenter;
end;
strsql:='select * from sendsms where status=0';
runsql(qlist,strsql);
if qlist.RecordCount >0 then
begin
for i:=0 to qlist.RecordCount-1 do
begin
lstitem:=listview1.Items.Add;
idall[i]:=qlist.fieldbyname('id').AsString;//用于删除时的标识付
lstitem.Caption:=qlist.fieldbyname('receiver').AsString;
lstitem.ImageIndex:=0;
lstitem.SubItems.Add(qlist.fieldbyname('sender').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('content').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('senddate').AsString);
qlist.Next;
end;
end;
//结束加数据
//开始更新数据即读过的应将其状态改为1表示已读过了
//结束对状态的更改
//application.MessageBox('你双击了待发短信!',':提示:',mb_ok)
end;
//结束待发短信的编写;
//开始已发短信的显示
if namebd='已发短信' then
begin
//开始向listview中加数据
taball:='sendsms';
ljxdel:='no';
nameall:='已发短信';
listview1.Items.Clear;
listview1.Columns.Clear;
name[0]:='接收者手机号';
name[1]:='发送者';
name[2]:='短信内容';
name[3]:='发信时间';
for i:= 0 to 3 do
begin
listview1.columns.add;
listview1.Column[i].Caption:=name[i];
listview1.Column[i].Width:=115;
listview1.Column[i].Alignment:=tacenter;
end;
strsql:='select * from sendsms where status=1';
runsql(qlist,strsql);
if qlist.RecordCount >0 then
begin
for i:=0 to qlist.RecordCount-1 do
begin
lstitem:=listview1.Items.Add;
idall[i]:=qlist.fieldbyname('id').AsString;//用于删除时的标识付
lstitem.Caption:=qlist.fieldbyname('receiver').AsString;
lstitem.ImageIndex:=0;
lstitem.SubItems.Add(qlist.fieldbyname('sender').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('content').AsString);
lstitem.SubItems.Add(qlist.fieldbyname('senddate').AsString);
qlist.Next;
end;
end;
//结束加数据
//开始更新数据即读过的应将其状态改为1表示已读过了
//结束对状态的更改
//application.MessageBox('你双击了已发短信!',':提示:',mb_ok)
end;
//结束已发短信的显示
//失败短信的显示
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -