📄 unitcommonmodule.~pas
字号:
FillResultData();
FrmSearchResultBus_Way.Hide;
FrmSearchResult.Show;
FrmSearchResult.Caption := '周边环境查询结果';
FrmSearchResult.PanelTitle.Caption := '中心点:'+FeatureName;
FrmSearchResult.PanelResultNum.Caption := '共查出:'+IntToStr(DM.ADOQuerySearchAll.RecordCount)+'条记录';
FrmSearchResult.BBtnFind.SetFocus;
end else Application.MessageBox('在中心点周围没有满足条件的信息!', '提示', MB_OK);
end;
// 获得站点所经过的公交车次信息
procedure PickUpBus_Way(Bus_SpotName, PassWayStr: String; Bus_Spot: PassWayInf);
var
i, k: Integer;
begin
k := 1;
Bus_Spot.Bus_SpotName := Bus_SpotName;
for i := 1 to Length(PassWayStr) do
begin
if (PassWayStr[i] <> ';') or (i <> Length(PassWayStr)) then
Bus_Spot.PassWayArr[k].Bus_WayName := Bus_Spot.PassWayArr[k].Bus_WayName + PassWayStr[i]
else Inc(k);
end;
Bus_Spot.PassWayNum := k;
end;
// 获得公交车次的各站点信息
procedure PickUpBus_Spot(ArrI: Integer; InfoStr: String; Bus_Spot: PassWayInf);
var
i, k: Integer;
begin
k := 1;
for i := 1 to Length(InfoStr) do
if (InfoStr[i] <> '-') or (i <> Length(InfoStr)) then
Bus_Spot.PassWayArr[ArrI].BusSpotArr[k] := Bus_Spot.PassWayArr[ArrI].BusSpotArr[k] + InfoStr[i]
else Inc(k);
Bus_Spot.PassWayArr[ArrI].BusSpotNum := k;
end;
// 添加站点所经的车次的详细信息(车次所经的站点信息)
procedure FillBus_Spot(Query: TADOQuery; Bus_Spot: PassWayInf);
var
i, k: Integer;
begin
if Bus_Spot.PassWayNum > 0 then
begin
Query.Close;
Query.SQL.Clear;
SQLString := 'SELECT *' + #13;
SQLString := SQLString + 'FROM 公交线路' + #13;
SQLString := SQLString + 'WHERE Name = ''' + Bus_Spot.PassWayArr[1].Bus_WayName + '''' +#13;
for i := 2 to Bus_Spot.PassWayNum do
begin
SQLString := SQLString + 'OR Name = ''' + Bus_Spot.PassWayArr[i].Bus_WayName + '''' +#13;
end;
Query.SQL.Add(SQLString);
Query.Open;
Query.First;
k := 0;
while Not Query.Eof do
begin
Inc(k);
PickUpBus_Spot(k, Query.FieldByName('PassStation').AsString, Bus_Spot);
Query.Next;
end;
end;
end;
// 找转车信息
procedure FindWay();
var
Si, Ei, Sj, Ej: Integer;
begin
With FrmSearchResultBus_Way do
begin
SGrid1.Rows[0].Clear;
SGrid1.RowCount := 1;
SGrid1.Cells[0, 0] := ' 直达车次名称';
SGrid2.Rows[0].Clear;
SGrid2.RowCount := 1;
SGrid2.Cells[0, 0] := ' 车次1名称';
SGrid2.Cells[1, 0] := ' 车次2名称';
end;
for Si := 1 to Bus_SpotS.PassWayNum do
for Ei := 1 to Bus_SpotE.PassWayNum do
begin
if Bus_SpotS.PassWayArr[Si].Bus_WayName = Bus_SpotE.PassWayArr[Ei].Bus_WayName
then // 直达的
begin
With FrmSearchResultBus_Way do
begin
SGrid1.RowCount := SGrid1.RowCount + 1;
SGrid1.Cells[0, SGrid1.RowCount-1] := '乘'+Bus_SpotS.PassWayArr[Si].Bus_WayName;
BusWay1[SGrid1.RowCount] := Bus_SpotS.PassWayArr[Si].Bus_WayName;
end;
end
else // 传车的
begin
for Sj := 1 to Bus_SpotS.PassWayArr[Si].BusSpotNum do
for Ej := 1 to Bus_SpotE.PassWayArr[Ei].BusSpotNum do
begin
if Bus_SpotS.PassWayArr[Si].BusSpotArr[Sj] = Bus_SpotE.PassWayArr[Ei].BusSpotArr[Ej]
then
begin
With FrmSearchResultBus_Way do
begin
SGrid2.RowCount := SGrid1.RowCount + 1;
SGrid2.Cells[0, SGrid1.RowCount-1] :=
'乘'+Bus_SpotS.PassWayArr[Si].Bus_WayName;
SGrid2.Cells[1, SGrid1.RowCount-1] :=
'专'+Bus_SpotE.PassWayArr[Ei].Bus_WayName;
BusWay2Spot[SGrid2.RowCount] := Bus_SpotS.PassWayArr[Si].BusSpotArr[Sj];
BusWay2S[SGrid2.RowCount] := Bus_SpotS.PassWayArr[Si].Bus_WayName;
BusWay2E[SGrid2.RowCount] := Bus_SpotE.PassWayArr[Ei].Bus_WayName;
end;
end;
end;
end;
end;
end;
// 查找公交转车的车次
procedure FindBus_Way();
var
i: Integer;
begin
With FrmByBus do
begin
// 得到公交站点通过的公交线路信息
DM.ADOQueryBus_SpotS.Locate('ID', PYConvert(CBoxStartStation.Text), [loCaseInsensitive]);
PickUpBus_Way(DM.ADOQueryBus_SpotS.FieldByName('Name').AsString, DM.ADOQueryBus_SpotS.FieldByName('Introduction').AsString, Bus_SpotS);
DM.ADOQueryBus_SpotE.Locate('ID', PYConvert(CBoxStartStation.Text), [loCaseInsensitive]);
PickUpBus_Way(DM.ADOQueryBus_SpotE.FieldByName('Name').AsString, DM.ADOQueryBus_SpotE.FieldByName('Introduction').AsString, Bus_SpotE);
// 添加站点所经的车次的详细信息(车次所经的站点信息)
FillBus_Spot(DM.ADOQueryBus_WayS, Bus_SpotS);
FillBus_Spot(DM.ADOQueryBus_WayE, Bus_SpotE);
FindWay();
// 找用到的公交车次信息
DM.ADOQuerySearchAll.Close;
DM.ADOQuerySearchAll.SQL.Clear;
SQLString := 'SELECT *' + #13;
SQLString := SQLString + 'FROM 公交线路' + #13;
SQLString := SQLString + 'WHERE Name = ''' + BusWay1[1] + '''' +#13;
for i := 2 to FrmSearchResultBus_Way.SGrid1.RowCount do
SQLString := SQLString + 'OR Name = ''' + BusWay1[i] + '''' +#13;
for i := 1 to FrmSearchResultBus_Way.SGrid2.RowCount do
begin
SQLString := SQLString + 'OR Name = ''' + BusWay2S[i] + '''' +#13;
SQLString := SQLString + 'OR Name = ''' + BusWay2E[i] + '''' +#13;
end;
DM.ADOQuerySearchAll.SQL.Add(SQLString);
DM.ADOQuerySearchAll.Open;
end;
end;
// 处理画线到边上可以移动地图的操作
procedure SetMapPos(Shift: TShiftState);
begin
// 如果按下Ctrl
if Shift = [ssCtrl] then
begin
if MouseY < 15 then
begin
Move_Direction := DIRECTION_DOWN;
FrmNavigation.TimerMoveMap.Enabled := True;
end;
if MouseX < 15 then
begin
Move_Direction := DIRECTION_RIGHT;
FrmNavigation.TimerMoveMap.Enabled := True;
end;
if MouseY > FrmMain.Map1.Height-15 then
begin
Move_Direction := DIRECTION_UP;
FrmNavigation.TimerMoveMap.Enabled := True;
end;
if MouseX > FrmMain.Map1.Width-15 then
begin
Move_Direction := DIRECTION_LEFT;
FrmNavigation.TimerMoveMap.Enabled := True;
end;
end;
end;
//表复制
procedure CopyTable(LayerName: String; SourceMap: TMap);
var
lyr: MapXLib_TLB.CMapXLayer;
Ds: MapXLib_TLB.CMapXDataSet;
LayerInfo: MapXLib_TLB.CMapXLayerInfo;
NewLayerName, Path:String;
begin
Try
NewLayerName := 'NewTable';
Lyr := SourceMap.Layers.Item[LayerName];
ds := SourceMap.Datasets.Item[LayerName];
//选定图层的存放路径
Path := SourceMap.Layers.Item[LayerName].Filespec;
//复制到新表
LayerInfo := CoLayerInfo.Create;
LayerInfo.Type_ := miLayerInfoTypeNewTable;
LayerInfo.AddParameter('Filespec', ExeFilePath+'Maps\'+NewLayerName+'.TAB');
LayerInfo.AddParameter('Name', NewLayerName);
LayerInfo.AddParameter('Fields', ds.Fields);
LayerInfo.AddParameter('Features', lyr.AllFeatures);
LayerInfo.AddParameter('AutoCreateDataset', 1);
LayerInfo.AddParameter('datasetname', NewLayerName);
SourceMap.Layers.Add(LayerInfo, 0);
SourceMap.Update;
except
on E:Exception do ShowMessage(E.message);
end;
end;
// 设置显示的图层
procedure SetViewLayer();
begin
With FrmMain do
begin
if Map1.Zoom > 400 then
begin
Map1.Layers['标记'].Visible := False;
Map1.Layers['企事业'].Visible := False;
Map1.Layers['公交站点'].Visible := False;
Map1.Layers['公交线路'].Visible := False;
Map1.Layers['轻轨线路'].Visible := False;
Map1.Layers['街道'].Visible := False;
end else
if (Map1.Zoom > 200) then
begin
Map1.Layers['标记'].Visible := False;
Map1.Layers['企事业'].Visible := False;
Map1.Layers['公交站点'].Visible := False;
Map1.Layers['公交线路'].Visible := True;
Map1.Layers['轻轨线路'].Visible := True;
Map1.Layers['街道'].Visible := True;
end else
begin
Map1.Layers['标记'].Visible := True;
Map1.Layers['企事业'].Visible := True;
Map1.Layers['公交站点'].Visible := True;
Map1.Layers['公交线路'].Visible := True;
Map1.Layers['轻轨线路'].Visible := True;
Map1.Layers['街道'].Visible := True;
end;
end;
end;
// 写日志
procedure FillRecord(Level, ConStr: String);
var
i: Integer;
begin
// 查找对应的用户ID
if Level <> '管理员' then
if ClientStr[1] = 'R' then
for i := 0 to Users.Num do
begin
if (CSocketID = Users.SocketID[i]) and
(CLoginTimeStr = Users.LoginTime[i]) then
begin
SendUserNum := i;
Break;
end;
end;
OpenADOQueryAll(DM.ADOQueryRecord, 'Record');
DM.ADOQueryRecord.Append;
// ClientStr, CSocket, CIp, CLevel, CUser, CPassword: String;
DM.ADOQueryRecord.FieldByName('Levels').AsString := Level;
DM.ADOQueryRecord.FieldByName('Dates').AsString := FormatDateTime('dddddd dddd', Now);
DM.ADOQueryRecord.FieldByName('ComeTime').AsString := FormatDateTime('tt', Now);
DM.ADOQueryRecord.FieldByName('GoTime').AsString := FormatDateTime('tt', Now);
DM.ADOQueryRecord.FieldByName('Connected').AsString := ConStr;
if Level = '普通用户' then
begin
DM.ADOQueryRecord.FieldByName('UserName').AsString := '普通用户';
DM.ADOQueryRecord.FieldByName('UserIp').AsString := CIp;
DM.ADOQueryRecord.FieldByName('SocketID').AsString := CSocketID;
CLoginTimeStr := DM.ADOQueryRecord.FieldByName('ComeTime').AsString;
end
else
if Level = '高级用户' then
begin
DM.ADOQueryRecord.FieldByName('UserName').AsString := CUser;
DM.ADOQueryRecord.FieldByName('UserIp').AsString := CIp;
DM.ADOQueryRecord.FieldByName('SocketID').AsString := CSocketID;
CLoginTimeStr := DM.ADOQueryRecord.FieldByName('ComeTime').AsString;
end
else
begin
DM.ADOQueryRecord.FieldByName('UserName').AsString := '管理员';
DM.ADOQueryRecord.FieldByName('UserIp').AsString := FrmLogin.SSocket.Socket.LocalAddress;
DM.ADOQueryRecord.FieldByName('SocketID').AsString := '000';
SLoginTimeStr := DM.ADOQueryRecord.FieldByName('ComeTime').AsString;
end;
if ConStr = '成功' then
begin
DM.ADOQueryRecord.FieldByName('Connecting').AsBoolean := True;
if Level <> '管理员' then
begin
if ClientStr[1] = 'R' then // 更新重新登入的数据
Users.LoginTime[SendUserNum] := CLoginTimeStr;
if ClientStr[1] = 'L' then // 新用户
begin
// 用户数量加一, 记录用户SocketID
Users.Num := Users.Num + 1;
Users.SocketID[Users.Num] := CSocketID;
Users.LoginTime[Users.Num] := CLoginTimeStr;
SendUserNum := Users.Num;
end;
end;
end
else
begin
DM.ADOQueryRecord.FieldByName('Connecting').AsBoolean := False;
end;
DM.ADOQueryRecord.Post;
end;
// 退出写日志
procedure FillRecordE(UserName, SocketID, ComeTime: String);
var
i, j: Integer;
begin
DM.ADOQueryRecord.Close;
DM.ADOQueryRecord.SQL.Clear;
SQLString := 'SELECT *' + #13;
SQLString := SQLString + 'FROM Record'+ #13;
SQLString := SQLString + 'WHERE UserName = ''' + UserName + '''' + #13;
SQLString := SQLString + 'AND SocketID = ''' + SocketID + '''' + #13;
SQLString := SQLString + 'AND ComeTime = ''' + ComeTime + '''';
DM.ADOQueryRecord.SQL.Add(SQLString);
DM.ADOQueryRecord.Open;
DM.ADOQueryRecord.Edit;
DM.ADOQueryRecord.FieldByName('GoTime').AsString := FormatDateTime('tt', Now);
DM.ADOQueryRecord.FieldByName('Connecting').AsBoolean := False;
DM.ADOQueryRecord.Post;
// 删除退出的用户记录
for i := 0 to Users.Num do
begin
if (Users.SocketID[i] = SocketID) and
(Users.LoginTime[i] = ComeTime) then
begin
for j := i+1 to Users.Num do
begin
Users.SocketID[j-1] := Users.SocketID[j];
Users.LoginTime[j-1] := Users.LoginTime[j];
end;
Break;
end;
end;
Users.Num := Users.Num - 1;
// 刷新
FrmClientManage.BBtnRefreshClick(FrmClientManage);
end;
// 管理员退出 添日志
procedure SFillRecordE();
var
i: Integer;
begin
DM.ADOQueryRecord.Close;
DM.ADOQueryRecord.SQL.Clear;
SQLString := 'SELECT *' + #13;
SQLString := SQLString + 'FROM Record'+ #13;
SQLString := SQLString + 'WHERE Connecting = 1' + #13;
DM.ADOQueryRecord.SQL.Add(SQLString);
DM.ADOQueryRecord.Open;
While Not DM.ADOQueryRecord.Eof do
begin
DM.ADOQueryRecord.Edit;
DM.ADOQueryRecord.FieldByName('GoTime').AsString := FormatDateTime('tt', Now);
DM.ADOQueryRecord.FieldByName('Connecting').AsBoolean := False;
DM.ADOQueryRecord.Post;
DM.ADOQueryRecord.Next;
end;
// 发送客户端 管理员以退出
for i := 0 to Users.Num do
FrmLogin.SSocket.Socket.Connections[i].SendText('S');
end;
// 根据不通的用户设置窗体及权限
procedure SetUserForm(UserType: Integer);
begin
with FrmMain do
begin
case UserType of
0:
begin
NUserManage.Visible := False;
NRecordManage.Visible := False;
NDataBaseManage.Visible := False;
N11.Visible := False;
NMapControl.Visible := False;
NModifyWindows.Visible := False;
NCSCommunicate.Visible := False;
NSelectMapTool.Visible := False;
NDrawMapTool.Visible := False;
end;
1:
begin
NUserManage.Visible := False;
NRecordManage.Visible := False;
NDataBaseManage.Visible := False;
N11.Visible := False;
NMapControl.Visible := True;
NModifyWindows.Visible := True;
NCSCommunicate.Visible := False;
NSelectMapTool.Visible := True;
NDrawMapTool.Visible := True;
end;
2:
begin
NUserManage.Visible := True;
NRecordManage.Visible := True;
NDataBaseManage.Visible := True;
N11.Visible := True;
NMapControl.Visible := True;
NModifyWindows.Visible := True;
NCSCommunicate.Visible := True;
NSelectMapTool.Visible := True;
NDrawMapTool.Visible := True;
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -