📄 mainunit.~pas
字号:
myRect.Left := cCol;
myRect.Top := cRow+1;
myRect.Right := cCol;
myRect.Bottom := cRow+1;
self.StringGrid1.Selection := myRect;
RefreshChartFile;
// self.Timer1.Enabled := true;
except
ShowMessage('删除失败!');
// self.Timer1.Enabled := true;
exit;
end;
end;
procedure TFrmMain.BtnCancelClick(Sender: TObject);
begin
// self.Timer1.Enabled := false;
self.BtnStateSwitch(true);
self.DTSwitch.Enabled := true;
// self.Timer1.Enabled := true;
// self.ClearComBox;
end;
procedure TFrmMain.BtnOKClick(Sender: TObject);
var
RootNode, CurNode : IXMLNode;
cCol, index, i : integer;
begin
// self.Timer1.Enabled := false;
if self.XMLDocument1.Active = true then
begin
self.XMLDocument1.Active := false;
end;
self.XMLDocument1.FileName := self.RunMapFileName;
try
self.XMLDocument1.Active := true;
RootNode := self.XMLDocument1.DocumentElement;
except
ShowMessage('加载运行图文件失败!');
// self.Timer1.Enabled := true;
exit;
end;
if self.OperateType = 0 then //新增
begin
for i := 0 to Length(self.DTArr) -1 do
begin
if self.DTSwitch.DateTime = DTArr[i] then
begin
ShowMessage('运行图中已包含有此时间,如要修改,请点击修改按钮');
//self.BtnStateSwitch(true);
// self.Timer1.Enabled := true;
exit;
end;
end;
if self.BoxA1.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '1#发射机';
CurNode.Attributes['AName'] := self.BoxA1.Text;
end;
if self.BoxA2.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '2#发射机';
CurNode.Attributes['AName'] := self.BoxA2.Text;
end;
if self.BoxA3.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '3#发射机';
CurNode.Attributes['AName'] := self.BoxA3.Text;
end;
if self.BoxA4.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '4#发射机';
CurNode.Attributes['AName'] := self.BoxA4.Text;
end;
if self.BoxA5.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '5#发射机';
CurNode.Attributes['AName'] := self.BoxA5.Text;
end;
if self.BoxA6.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '6#发射机';
CurNode.Attributes['AName'] := self.BoxA6.Text;
end;
self.XMLDocument1.SaveToFile();
self.RefreshDBGrid;
RefreshChartFile;
self.BtnStateSwitch(true);
end;
if self.OperateType = 1 then //修改
begin
cCol := self.StringGrid1.Selection.Left;
if JudgeTimeIsInUse(self.DTSwitch.DateTime) = true then
begin
if TimeToStr(self.DTSwitch.Time) <> self.StringGrid1.Cells[cCol, 0] then
begin
ShowMessage('运行图中已经包含了此时间的设置!');
// self.Timer1.Enabled := true;
exit;
end;
end;
index := IndexInFile[0][cCol-1];
if index <> 0 then
begin
if self.BoxA1.Text = '未使用' then
begin
RootNode.ChildNodes.Delete(index -1);
end else
begin
CurNode := RootNode.ChildNodes.Get(index-1);
CurNode.Attributes['AName'] := self.BoxA1.Text;
CurNode.Attributes['RunTime'] := self.DTSwitch.DateTime;
end;
end;{ else
begin
if self.BoxA1.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '1#发射机';
CurNode.Attributes['AName'] := self.BoxA1.Text;
end;
end; }
index := IndexInFile[1][cCol-1];
if index <> 0 then
begin
if self.BoxA2.Text = '未使用' then
begin
RootNode.ChildNodes.Delete(index-1);
end else
begin
CurNode := RootNode.ChildNodes.Get(index-1);
CurNode.Attributes['AName'] := self.BoxA2.Text;
CurNode.Attributes['RunTime'] := self.DTSwitch.DateTime;
end;
end;{ else
begin
if self.BoxA2.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '2#发射机';
CurNode.Attributes['AName'] := self.BoxA2.Text;
end;
end; }
index := IndexInFile[2][cCol-1];
if index <> 0 then
begin
if self.BoxA3.Text = '未使用' then
begin
RootNode.ChildNodes.Delete(index-1);
end else
begin
CurNode := RootNode.ChildNodes.Get(index-1);
CurNode.Attributes['AName'] := self.BoxA3.Text;
CurNode.Attributes['RunTime'] := self.DTSwitch.DateTime;
end;
end;{ else
begin
if self.BoxA3.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '3#发射机';
CurNode.Attributes['AName'] := self.BoxA3.Text;
end;
end; }
index := IndexInFile[3][cCol-1];
if index <> 0 then
begin
if self.BoxA4.Text = '未使用' then
begin
RootNode.ChildNodes.Delete(index-1);
end else
begin
CurNode := RootNode.ChildNodes.Get(index-1);
CurNode.Attributes['AName'] := self.BoxA4.Text;
CurNode.Attributes['RunTime'] := self.DTSwitch.DateTime;
end;
end;{ else
begin
if self.BoxA4.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '4#发射机';
CurNode.Attributes['AName'] := self.BoxA4.Text;
end;
end; }
index := IndexInFile[4][cCol-1];
if index <> 0 then
begin
if self.BoxA5.Text = '未使用' then
begin
RootNode.ChildNodes.Delete(index-1);
end else
begin
CurNode := RootNode.ChildNodes.Get(index-1);
CurNode.Attributes['AName'] := self.BoxA5.Text;
CurNode.Attributes['RunTime'] := self.DTSwitch.DateTime;
end;
end;{ else
begin
if self.BoxA5.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '5#发射机';
CurNode.Attributes['AName'] := self.BoxA5.Text;
end;
end; }
index := IndexInFile[5][cCol-1];
if index <> 0 then
begin
if self.BoxA6.Text = '未使用' then
begin
RootNode.ChildNodes.Delete(index-1);
end else
begin
CurNode := RootNode.ChildNodes.Get(index-1);
CurNode.Attributes['AName'] := self.BoxA6.Text;
CurNode.Attributes['RunTime'] := self.DTSwitch.DateTime;
end;
end;{ else
begin
if self.BoxA6.Text <> '未使用' then
begin
CurNode := RootNode.AddChild('Access');
CurNode.Attributes['RunTime'] := DateTimeToStr(self.DTSwitch.DateTime);
CurNode.Attributes['TName'] := '6#发射机';
CurNode.Attributes['AName'] := self.BoxA6.Text;
end;
end; }
self.XMLDocument1.SaveToFile();
self.RefreshDBGrid;
RefreshChartFile;
self.BtnStateSwitch(true);
self.DTSwitch.Enabled := true;
end;
// self.Timer1.Enabled := true;
end;
procedure TFrmMain.RefreshChartFile;
var
i, TimePartCount, NodeIndex, AIndex, n : integer;
ValueArr : array[0..5] of integer;
ResultList : TStrings;
tmpStr1, tmpStr2 : string;
RootNode : IXMLNode;
dt : TDateTime;
begin
if self.XMLDocument1.Active = true then
begin
self.XMLDocument1.Active := false;
end;
self.XMLDocument1.FileName := self.RunMapFileName;
ResultList := TStringList.Create;
try
self.XMLDocument1.Active := true;
RootNode := self.XMLDocument1.DocumentElement;
TimePartCount := Length(DTArr);
for i := 0 to TimePartCount-1 do
begin
dt := StrToDateTime('2004-1-1 00:00:00');
tmpStr2 := IntToStr(self.TimeDefference(dt, DTArr[i])) + ',';
//value1
//1#发射机
n := 0;
NodeIndex := IndexInfile[0][i];
if NodeIndex = 0 then
begin
ValueArr[0] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[0].AList);
ValueArr[0] := TKDB[0].Value.value1[AIndex];
end;
n := n or ValueArr[0];
//2#发射机
NodeIndex := IndexInfile[1][i];
if NodeIndex = 0 then
begin
ValueArr[1] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[1].AList);
ValueArr[1] := TKDB[1].Value.value1[AIndex];
end;
n := n or ValueArr[1];
//3#发射机
NodeIndex := IndexInfile[2][i];
if NodeIndex = 0 then
begin
ValueArr[2] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[2].AList);
ValueArr[2] := TKDB[2].Value.value1[AIndex];
end;
n := n or ValueArr[2];
//4#发射机
NodeIndex := IndexInfile[3][i];
if NodeIndex = 0 then
begin
ValueArr[3] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[3].AList);
ValueArr[3] := TKDB[3].Value.value1[AIndex];
end;
n := n or ValueArr[3];
//5#发射机
NodeIndex := IndexInfile[4][i];
if NodeIndex = 0 then
begin
ValueArr[4] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[4].AList);
ValueArr[4] := TKDB[4].Value.value1[AIndex];
end;
n := n or ValueArr[4];
//6#发射机
NodeIndex := IndexInfile[5][i];
if NodeIndex = 0 then
begin
ValueArr[5] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[5].AList);
ValueArr[5] := TKDB[5].Value.value1[AIndex];
end;
n := n or ValueArr[5];
tmpStr2 := tmpStr2 + IntToStr(n) + ',';
//value2
//1#发射机
n := 0;
NodeIndex := IndexInfile[0][i];
if NodeIndex = 0 then
begin
ValueArr[0] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[0].AList);
ValueArr[0] := TKDB[0].Value.value2[AIndex];
end;
n := n or ValueArr[0];
//2#发射机
NodeIndex := IndexInfile[1][i];
if NodeIndex = 0 then
begin
ValueArr[1] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[1].AList);
ValueArr[1] := TKDB[1].Value.value2[AIndex];
end;
n := n or ValueArr[1];
//3#发射机
NodeIndex := IndexInfile[2][i];
if NodeIndex = 0 then
begin
ValueArr[2] := 0;
end else
begin
tmpStr1 := RootNode.ChildNodes.Nodes[NodeIndex-1].Attributes['AName'];
AIndex := FindSInSList(tmpStr1, TKDB[2].AList);
ValueArr[2] := TKDB[2].Value.value2[AIndex];
end;
n := n or ValueArr[2];
//4#发射机
NodeIndex := IndexInfile[3][i];
if NodeIndex = 0 then
begin
ValueArr[3] := 0;
end else
begin
tmpStr1 := Roo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -