📄 mainprofile.pas.~631~
字号:
unit mainProfile;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, Buttons, ExtCtrls, ToolWin, ActnMan, ActnCtrls,
ComCtrls,calldll, Grids, DBGrids;
type
TForm1 = class(TForm)
Label1: TLabel;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Panel1: TPanel;
Splitter1: TSplitter;
StringGrid1: TStringGrid;
Splitter2: TSplitter;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
Panel3: TPanel;
Panel4: TPanel;
CheckBox1: TCheckBox;
ComboBox1: TComboBox;
ListBox1: TListBox;
Panel5: TPanel;
Panel6: TPanel;
Button1: TButton;
Splitter3: TSplitter;
Panel7: TPanel;
Panel8: TPanel;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
StringGrid2: TStringGrid;
StringGrid3: TStringGrid;
Panel9: TPanel;
Splitter4: TSplitter;
Panel10: TPanel;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button10: TButton;
Label2: TLabel;
Edit1: TEdit;
Button11: TButton;
Panel11: TPanel;
Memo2: TMemo;
TabSheet3: TTabSheet;
StatusBar2: TStatusBar;
Panel2: TPanel;
Panel12: TPanel;
Panel13: TPanel;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Edit3: TEdit;
Label5: TLabel;
Edit4: TEdit;
Label6: TLabel;
Edit5: TEdit;
Label7: TLabel;
Edit6: TEdit;
Label8: TLabel;
Edit7: TEdit;
Panel14: TPanel;
CheckBox2: TCheckBox;
Timer1: TTimer;
memo1: TMemo;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
TabSheet4: TTabSheet;
procedure N7Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure StringGrid2SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure StringGrid2DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure StringGrid3DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure StringGrid3SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure SpeedButton4Click(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure FormCreate(Sender:TObject);
procedure Button5Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure initstringgrid();
procedure readfromfiles(var filename:string);
procedure insertstringgrid1();
procedure insertstringgrid3();
procedure insertstringgrid2();
procedure getstringgrid1(var str:string;id:integer);
procedure setstringgrid1(var id:integer);
procedure transgrid32grd1();
// procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
sendstr:string;
receivestr:string;
rowofgrid1:integer;
rowofgrid2:integer;
rowofgrid3:integer; //grid's line number
colofgrid:integer; //gird's colume number
setofstringgrid1:array[1..8] of string;
setofstringgrid2:array[1..5] of string;
setofstringgrid3:array[1..8] of string;
buslines:array[1..220] of string;
selectg1,selectg2,selectg3:integer;
selectg1c,selectg2c,selectg3c:integer;
searchedrowofgrid3:array[1..20]of integer;
searchedpos:integer;
// recevicecount:integer;
// sendcount:integer;
implementation
uses sendback,sendtransfer,insertclient,gprsthread,recethread,workthread;
{$R *.dfm}
procedure TForm1.transgrid32grd1();
var tempi:integer;
{for transfor from stringfrid 3 to stringfrid1 to
resend the shortmessages
use the delphi's function}
busnumber:integer;
s1,temps,ts1,ts2:string;
smcontent:string;
sm,sm1:string;
si,ei,ti,tj,sj:integer;
t1,t2:integer;
clausepos:integer;
begin
tempi:=1;
busnumber:=1;
while tempi<rowofgrid3 do
begin {处理未处理的短信,分解过长的短信到140字节以下}
s1:=Trim(stringgrid3.Cells[3,tempi]);
temps:=Copy(s1,1,2);
s1:=Trim(Copy(s1,3,length(s1)));
tj:=length(s1);
ts2:=Copy(s1,1,tj);
//deal with s1,can select one of paper
si:=0;
ei:=1;
ti:=1;
t1:=-1;
t2:=0;
sm:='$';
sm1:='$';
smcontent:='$';
while ti<=tj do
begin
ts1:=Copy(ts2,ti,1);
sj:=CompareText(ts1,'9');
t1:=CompareText(ts1,'0');
if (sj<=0)and(t1>=0)
then
begin
if si=0 then
si:=ti;
if ti=tj
then
ei:=tj+1;
//ts2:=Copy(s1,ti,tj-ti);
end
else
begin
if ei<si then
begin
ei:=ti;
ti:=tj+1;
end;
end;
inc(ti);
end; //emd while for busnumber
// statusbar2.Panels[1].Text:=inttostr(si)+inttostr(ei)+s1;
{here deal with the busnumber}
busnumber:=StrToInt(Copy(s1,si,ei-si));
clausepos:=120;
if CompareText(temps,'gj') =0
then
begin
if busnumber<220 then
begin
smcontent:=buslines[busnumber];
//deal with the caluse of ';'
end //if busnumber less than 220
else//else for big than 220
begin
smcontent:=inttostr(busnumber)+'路尚未开通';
// showmessage(inttostr(rowofgrid3)+inttostr(tempi));
end; //end busnumber num.
end
else
begin
smcontent:='请用gj或GJ开头编辑短信';
//扩展其他的内容处理方式,得到具体的之后同意处理存储或者转换过程
end; //end the if for gj search
//具体处理过程
if CompareText(Trim(stringgrid3.Cells[7,tempi]),'未处理')=0
then
begin
setofstringgrid1[1]:=stringgrid3.Cells[0,tempi];
setofstringgrid1[3]:=datetostr(date());
setofstringgrid1[4]:=timetostr(time());
setofstringgrid1[5]:=datetostr(date());
setofstringgrid1[6]:=timetostr(time());
setofstringgrid1[7]:='administrator';
setofstringgrid1[8]:='未处理';
sm:=Copy(smcontent,109,20);
while length(Trim(smcontent))>130 do
begin
clausepos:=Pos(';',sm);
if clausepos<>0
then
clausepos:=clausepos+119;
sm1:=Copy(smcontent,1,clausepos);
smcontent:='接上条:'+Copy(smcontent,clausepos+1,length(smcontent)-clausepos);
sm:=Copy(smcontent,119,28);
setofstringgrid1[2]:=sm1;
insertstringgrid1();
end; //结束while循环
if(length(smcontent)>1)
then
begin
setofstringgrid1[2]:=smcontent;
insertstringgrid1();
end;//end if
stringgrid3.Cells[7,tempi]:='已处理';
end;
inc(tempi);
end;
end;
procedure TForm1.setstringgrid1(var id:integer);
begin
with stringgrid1 do
begin
Cells[7,id]:='已处理';
end;
end;
procedure TForm1.getstringgrid1(var str:string;id:integer);
var s,s1,s2:string; {if has been dealed,}
begin
s1:='未处理';
//s1:=stringtowidechar(s1);
s2:='|';
//s2:=stringtowidechar(s2);
with stringgrid1 do
begin
s:=Cells[7,id];
if CompareText(s,s1)=0 then
begin
str:=Cells[0,id];
s:=Cells[1,id];
Appendstr(str,s2);
Appendstr(str,s);
end;
end;
end;
procedure TForm1.insertstringgrid1() ;
begin //added row by row
with stringgrid1 do
begin
Cells[0,rowofgrid1]:=setofstringgrid1[1];
Cells[1,rowofgrid1]:=setofstringgrid1[2];
Cells[2,rowofgrid1]:=setofstringgrid1[3];
Cells[3,rowofgrid1]:=setofstringgrid1[4];
Cells[4,rowofgrid1]:=setofstringgrid1[5];
Cells[5,rowofgrid1]:=setofstringgrid1[6];
Cells[6,rowofgrid1]:=setofstringgrid1[7];
Cells[7,rowofgrid1]:=setofstringgrid1[8];
rowofgrid1:=rowofgrid1+1;
if rowofgrid1<rowcount then
rowcount:=rowofgrid1+2;
end;//end with string grid1
end;
procedure TForm1.insertstringgrid2() ;
begin //added row by row
with stringgrid2 do
begin
Cells[0,rowofgrid2]:=setofstringgrid2[1];
Cells[1,rowofgrid2]:=setofstringgrid2[2];
Cells[2,rowofgrid2]:=setofstringgrid2[3];
Cells[3,rowofgrid2]:=setofstringgrid2[4];
Cells[4,rowofgrid2]:=setofstringgrid2[5];
rowofgrid2:=rowofgrid2+1;
if rowofgrid2<rowcount then
rowcount:=rowofgrid2+2;
//showmessage('rowfogrid2 '+inttostr(rowofgrid2));
end;//end with string grid1
end;
procedure TForm1.insertstringgrid3() ;
begin //added row by row
with stringgrid3 do
begin
Cells[0,rowofgrid3]:=setofstringgrid3[1];
Cells[1,rowofgrid3]:=setofstringgrid3[2];
Cells[2,rowofgrid3]:=setofstringgrid3[3];
Cells[3,rowofgrid3]:=setofstringgrid3[4];
Cells[4,rowofgrid3]:=setofstringgrid3[5];
Cells[5,rowofgrid3]:=setofstringgrid3[6];
Cells[6,rowofgrid3]:=setofstringgrid3[7];
Cells[7,rowofgrid3]:=setofstringgrid3[8];
rowofgrid3:=rowofgrid3+1;
if rowofgrid3<rowcount then
rowcount:=rowofgrid3+2;
end;//end with string grid1
end;
procedure TForm1.readfromfiles(var filename:string);
var {读取文件初始化过程}
f:textfile;
paths:string;
s,subs:string; //一行结果,每行结果作为一个文件
i,j,pts,tempi:integer;
//for grid1
//
begin
tempi:=0;
paths:=ExtractFilePath(paramstr(0))+'infos\';
assignfile(f,paths+filename);
reset(f);
Readln(f,s);
inc( tempi);
{在循环体内每一行代表一行}
pts:=1;
while Length(s)>0 do //read all linevalues
begin
// showmessage(s);
//being the 2sendtxt files
if AnsiCompareText(filename,'sm2send.txt')=0 then
begin
i:=Length(s);
j:=0;
while j < i do
begin
pts:=Pos('|',s);
if pts=0 then
begin
subs:=s;
j:=i+1;
// showmessage('hello'+inttostr(j)+' '+inttostr(i));
StringGrid1.Cells[colofgrid,rowofgrid1]:=subs;
colofgrid:=colofgrid+1;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -