📄 mainprofile.pas.~559~
字号:
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;
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:string;
si,ei,ti,tj,sj:integer;
t1,t2: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:='$';
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;
// statusbar2.Panels[1].Text:=inttostr(si)+inttostr(ei)+s1;
{here deal with the busnumber}
busnumber:=StrToInt(Copy(s1,si,ei-si));
if CompareText(temps,'gj') =0
then
begin
statusbar2.Panels[1].Text:=inttostr(busnumber);
if busnumber<220 then
begin
smcontent:=buslines[busnumber];
if length(smcontent)>140 then
begin
sm:=Copy(smcontent,141,length(smcontent)-140);
// statusbar2.Panels[1].Text:=sm;
smcontent:=Copy(smcontent,1,140);
//statusbar2.Panels[1].Text:='12'+smcontent;
end
else
begin
;//sm:=null;
end;
end
else
begin
smcontent:=inttostr(busnumber)+'路尚未开通';
end;
end
else
begin
smcontent:='请用gj或GJ开头编辑短信';
end;
// s1:=Copy(S1,1,length(s1)-1);
//if it too lang cut this for more
//get the just content of reback message
//get the same results for bus line
setofstringgrid1[1]:=stringgrid3.Cells[0,tempi];
setofstringgrid1[2]:=smcontent;
setofstringgrid1[3]:=datetostr(date());
setofstringgrid1[4]:=timetostr(time());
setofstringgrid1[5]:=datetostr(date());
setofstringgrid1[6]:=timetostr(time());
setofstringgrid1[7]:='administrator';
setofstringgrid1[8]:='未处理';
if CompareText(Trim(stringgrid3.Cells[7,tempi]),'未处理')=0
then
begin
insertstringgrid1();
stringgrid3.Cells[7,tempi]:='已处理';
smcontent:=' ';
if length(Trim(sm))>0 then
begin
setofstringgrid1[1]:=stringgrid3.Cells[0,tempi];
setofstringgrid1[2]:=sm;
insertstringgrid1();
stringgrid3.Cells[7,tempi]:='已处理';
sm:='$';
end;
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:=rowcount+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
else
begin
subs:=Copy(s,0,pts-1);
j:=pts+1;
s:=Copy(s,j,(i-pts));
StringGrid1.Cells[colofgrid,rowofgrid1]:=subs;
colofgrid:=colofgrid+1;
end;
end; //end while here
rowofgrid1:=rowofgrid1+1;
colofgrid:=0;
Readln(f,s);
end; //end if
//another if here
if AnsiCompareText(filename,'gj.txt')=0 then
begin
if pts<24 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
if pts=23 then
begin
pts:=26;
end;
end
else
if pts<29 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
if pts=28 then
begin
pts:=30;
end;
end
else
if pts<40 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
if pts=39 then
pts:=41;
end
else
if pts<61 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
if pts=60 then
pts:=62;
end
else
if pts<70 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
if pts=69 then
pts:=70;
end
else
if pts<106 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
if pts=105 then
pts:=106;
end
else
if pts<126 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
if pts=125 then
pts:=127;
end
else
if pts<130 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
if pts=129 then
pts:=201;
end
else
//if pts>200 then
begin
buslines[pts]:=s;
Readln(f,s);
inc(tempi);
inc(pts);
end;
// showmessage(buslines[pts-1]+' '+inttostr(pts)+' '+inttostr(tempi));
end;
//end another if for read bus herer
end;
// showmessage(buslines[24]+''+buslines[130]+''+buslines[68]+' '+inttostr(pts));
closefile(f);
end;
{用于读取文件,一行行的初始化问题内容}
procedure TForm1.initstringgrid();
var i,j:integer;
{ONLY FOR input valuse for the stringgrids and more}
begin
{ with StringGrid1 do
begin
For i:=0 to ColCount do
For j:=0 to RowCount do
if (i<>0) and (j<>0) then
begin
Cells[i,j]:=IntToStr(i)+'|'+IntToStr(j);
end
else
begin
end;
end;
}
end;
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -