📄 info.pas
字号:
ListItem.SubItems.Add(DM1.DataDB.FieldByname('SF').AsString);
DM1.ModuleDB.First;
if DM1.ModuleDB.Locate('DNO;UNO', VarArrayOf([DNOstr,ListItem.Caption]), [loPartialKey]) then
begin
ListItem.SubItems.Add(DM1.ModuleDB.FieldByname('NAME').AsString);
ListItem.SubItems.Add(DM1.ModuleDB.FieldByname('ADDRESS').AsString);
end
else
begin
ListItem.SubItems.Add('');
ListItem.SubItems.Add('');
end;
// StrFIG := Trim(Format('%8.2f', [DM1.DataDB.FieldByname('FIG').AsFloat]));
StrFIG := Format('%8.2f', [DM1.DataDB.FieldByname('FIG').AsFloat]);
ListItem.SubItems.add(StrFIG);
ListItem.SubItems.Add(Format('%8.2f', [DM1.DataDB.FieldByname('DIF').AsFloat]));
ListItem.SubItems.Add(Format('%8.2f', [DM1.DataDB.FieldByname('peakfig').AsFloat]));
ListItem.SubItems.Add(Format('%8.2f', [DM1.DataDB.FieldByname('shoulderfig').AsFloat]));
ListItem.SubItems.Add(Format('%8.2f', [DM1.DataDB.FieldByname('offpeakfig').AsFloat]));
ListItem.SubItems.Add(Format('%8.2f', [DM1.DataDB.FieldByname('sharpfig').AsFloat]));
ListItem.SubItems.Add(Format('%8.2f', [DM1.DataDB.FieldByname('FREFIG').AsFloat]));
ListItem.SubItems.Add(DM1.DataDB.FieldByname('PHS').AsString);
ListItem.SubItems.Add(DM1.DataDB.FieldByname('BYS').AsString);
ListItem.SubItems.Add(DM1.DataDB.FieldByname('BY').AsString);
ListItem.SubItems.Add(DM1.DataDB.FieldByname('DTR').AsString);
ListItem.SubItems.Add(DM1.DataDB.FieldByname('RDT').AsString);
DM1.DataDB.Next;
end;
frmRead.Caption := '当前操作台区 [' + dNameStr + ']';
frmRead.DataListView.Visible := TRUE;
SearchFlag:=True;
end;
procedure TfrmInfo.Timer1Timer(Sender: TObject);
begin
if RunShape.Left < BorderShape.Left + BorderShape.Width -8 then
RunShape.Left := RunShape.Left + 1
else
RunShape.Left := BorderShape.Left;
end;
procedure TfrmInfo.SpeedButton5Click(Sender: TObject);
begin
frmInfo.ListView1.Visible := TRUE;
frmInfo.Panel1.Visible := TRUE;
Monitorflag:=false;
frmInfo.MonitorPanel.Top := 0;
frmInfo.MonitorPanel.Visible := FALSE;
frmInfo.Timer1.Enabled := FALSE;
//Hide CheckBox for selection
frmRead.DataListView.Checkboxes := FALSE;
Frminfo.rmax.caption:='';
Frminfo.rint.caption:='';
Frminfo.pulse.caption:='';
Frminfo.cnst.caption:='';
Frminfo.lmax.caption:='';
Frminfo.rkwh.caption:='';
Frminfo.img1.Visible:=false;
Frminfo.img2.Visible:=false;
Frminfo.img3.Visible:=false;
Frminfo.img4.Visible:=false;
Frminfo.img5.Visible:=false;
Frminfo.img6.Visible:=false;
Frminfo.img7.Visible:=false;
Frminfo.img8.Visible:=false;
frmMain.Monitor_T.Enabled := TRUE;
CHARTFLAG := USEREDIT;
activecommand:=false;
end;
procedure TfrmInfo.btnMonitorClick(Sender: TObject);
var
sBuf, rStr: string;
password:string;
begin
Frminfo.img1.Visible:=true;
Frminfo.img2.Visible:=true;
Frminfo.img3.Visible:=true;
Frminfo.img4.Visible:=true;
Frminfo.img5.Visible:=true;
Frminfo.img6.Visible:=true;
Frminfo.img7.Visible:=true;
Frminfo.img8.Visible:=true;
Timer1.Enabled := TRUE;
BreakRead := false;
btnMonitor.Enabled := false;
activecommand:=true;
//Read SCALE and CONSTANT
while TRUE do
begin
if not ActiveCommand then exit;
Application.ProcessMessages;
if not ActiveCommand then exit;
if BreakRead then
begin
ShowLab.Caption := '停止监控电表!';
activecommand:=false;
exit;
end;
sBuf := 'S' + UNOstr + '5500' + _CR;
if PutTXD(sBuf, 22, rStr,2500) and (Copy(rStr, 1, 4) = _OK) and (Copy(rStr, 17, 4) = _YES) then
try
ShowLab.Caption := 'REGISTER: ' + Copy(rStr, 5, 8);
rMAX.Caption := IntToStr(StrToInt(Copy(rStr, 5, 8)));
ShowLab.Caption := 'CONSTANT: ' + Copy(rStr, 13, 4);
CNST.Caption := IntToStr(StrToInt(Copy(rStr, 13, 4)));
break;
except
rStr := '';
end
else
if Copy(rStr, 1, 4) = _Lock then
begin
password:= InputBox('请输入集中器口令', '口令为6个字符','666666');
if PutTXD('PWR'+password+chr(13), 8, rStr, 2000) and (Copy(rStr, 1, 6) = _Unlock) then continue;
end;
end;
//Read INT and PULSE
while TRUE do
begin
if not ActiveCommand then break;
Application.ProcessMessages;
if not ActiveCommand then break;
if BreakRead then
begin
ShowLab.Caption := '停止监控电表!';
activecommand:=false;
exit;
end;
sBuf := 'S' + UNOstr + '5000' + _CR;
if PutTXD(sBuf, 22, rStr,3000) and (Copy(rStr, 1, 4) = _OK) and (Copy(rStr, 17, 4) = _YES) then
try
ShowLab.Caption := 'COSUMPTION: ' + Copy(rStr, 5, 12);
rINT.Caption := IntToStr(StrToInt(Copy(rStr, 5, 8)));
Pulse.Caption := Copy(rStr, 13, 4);
frmInfo.ShowDigit(Copy(rStr, 5, 8));
except
rStr := '';
end;
end;
end;
procedure TfrmInfo.btnStopClick(Sender: TObject);
begin
Timer1.Enabled := FALSE;
BreakRead := TRUE;
btnMonitor.Enabled := TRUE;
activecommand:=false;
end;
procedure TfrmInfo.SpeedButton3Click(Sender: TObject);
var
I, tStatus: Integer;
ListItem: TListItem;
begin
if DM1.DSTdb.Locate('DNO', DNOed.Text, [loPartialKey]) then
begin
tStatus := 1;
frmPromot.Hide;
frmPromot.Promot.Caption := '是否修改[' + DNOed.Text + '] ?';
if frmPromot.ShowModal <> mrOK then exit;
end
else
begin
tStatus := 2;
frmPromot.Hide;
frmPromot.Promot.Caption := '是否添加[' + DNOed.Text + '] ?';
if frmPromot.ShowModal <> mrOK then exit;
end;
if Length(DNOed.Text) <> 5 then
begin
WarnAbout.Hide;
WarnAbout.Promot.Caption := '台区编号必须为5个字符.';
WarnAbout.ShowModal;
exit;
end;
if tStatus = 1 then
with Listview1 do
begin
I := ListView1.Selected.index;
DM1.dstdb.Edit;
DM1.dstDB.FieldByName('NAME').AsString := NAMEed.Text;
DM1.dstDB.FieldByName('TEL').AsString := TELed.Text;
DM1.dstDB.FieldByName('CRM').AsString := CRMed.Text;
Items[I].Caption := NAMEed.Text;
Items[I].SubItems.Strings[0] := TELed.Text;
Items[I].SubItems.Strings[5] := CRMed.Text;
Items[I].Selected := True;
Items[I].Focused := True;
end;
//Add Items
if tStatus = 2 then
with Listview1 do
begin
ListItem := Items.add;
ListItem.Caption := NAMEed.Text;
ListItem.ImageIndex := -1;
ListItem.SubItems.add(TELed.Text);
ListItem.SubItems.add('');
ListItem.SubItems.add(DNOed.Text);
ListItem.SubItems.add('');
ListItem.SubItems.add('');
ListItem.SubItems.add(CRMed.Text);
ListItem.SubItems.add('');
DM1.dstdb.append;
DM1.dstDB.FieldByName('DNO').AsString := DNOed.Text;
DM1.dstDB.FieldByName('NAME').AsString := NAMEed.Text;
DM1.dstDB.FieldByName('TEL').AsString := TELed.Text;
DM1.dstDB.FieldByName('CRM').AsString := CRMed.Text;
end;
DM1.DSTdb.Post;
DM1.DSTdb.FlushBuffers ;
DM1.DSTdb.refresh;
DNOstr := DNOed.Text;
dNAMEstr := NAMEed.Text;
dTELstr := TELed.Text;
end;
procedure TfrmInfo.SpeedButton4Click(Sender: TObject);
var
I: Integer;
begin
if DM1.DSTdb.Locate('DNO', DNOed.Text, [loPartialKey]) then
begin
frmPromot.Hide;
frmPromot.Promot.Caption := '[是否删除' + DNOed.Text + ']?';
if frmPromot.ShowModal <> mrOK then exit;
//exit;
end
else
begin
frmPromot.Hide;
frmPromot.Promot.Caption := '[数据库中无此台区或未选择台区]!';
if frmPromot.ShowModal <> mrOK then exit;
exit;
end;
//for I := 0 to Listview1.Items.Count - 1 do
//if Listview1.Items[I].SubItems.Strings[2] = DNOed.Text then
//begin
i:=ListView1.Selected.index;
DM1.dstdb.delete;
Listview1.Items[I].ImageIndex := -1;
CheckIndex := 0;
Listview1.Items[I].Delete;
exit;
// end;
end;
procedure TfrmInfo.btnAddTSClick(Sender: TObject);
begin
//WTMcb.Items.Clear;
//WTMcb.Text := '';
if length(wtmcb.Text)=0 then
begin
frmPromot.Hide;
frmPromot.Promot.Caption := '抄表时段为空,请重新输入!';
frmPromot.ShowModal;
exit;
end;
if length(wtmcb.Text)<>11 then
begin
frmPromot.Hide;
frmPromot.Promot.Caption := '抄表时段格式错误!';
frmPromot.ShowModal;
exit;
end;
if strtoint(copy(wtmcb.Text,1,2)+copy(wtmcb.text,4,2))>=strtoint(copy(wtmcb.Text,7,2)+copy(wtmcb.text,10,2)) then
begin
frmPromot.Hide;
frmPromot.Promot.Caption := '抄表时段格式错误';
frmPromot.ShowModal;
exit;
end;
DM1.WTMdb.Filter := 'DNO = ' + '''' + DNOstr + '''';
if DM1.WTMdb.Locate('timeseg', wtmcb.Text, [loPartialKey]) then
begin
frmPromot.Hide;
frmPromot.Promot.Caption := '抄表时段['+wtmcb.text+'] 已经存在!';
frmPromot.ShowModal;
exit;
end;
frmPromot.Hide;
frmPromot.Promot.Caption := '是否添加[' +wtmcb.Text + ']抄表时段?';
if frmPromot.ShowModal <> mrOK then exit;
WTMcb.items.Add(wtmcb.text);
dm1.wtmdb.append ;
DM1.wtmDB.FieldByName('dno').AsString := dnostr;
DM1.wtmDB.FieldByName('timeseg').AsString := wtmcb.text;
dm1.wtmdb.post;
dm1.wtmDB.FlushBuffers ;
dm1.wtmdb.refresh;
frmMain.StatusBar.Panels[0].Text := '添加抄表时段成功.';
end;
procedure TfrmInfo.WTMcbKeyPress(Sender: TObject; var Key: Char);
begin
if key = Chr(13) then frmInfo.btnAddTSClick(sender);
end;
procedure TfrmInfo.RDTcbKeyPress(Sender: TObject; var Key: Char);
begin
if key = Chr(13) then frmInfo.btnFindClick(Sender);
end;
procedure TfrmInfo.ShowDigit(Consumption: string);
var
i:Real;
DecimalStr:string;
begin
//Integer part
frmInfo.showimage(StrToInt(Copy(Consumption, 3, 1)), img8);
frmInfo.showimage(StrToInt(Copy(Consumption, 4, 1)), img7);
frmInfo.showimage(StrToInt(Copy(Consumption, 5, 1)), img6);
frmInfo.showimage(StrToInt(Copy(Consumption, 6, 1)), img5);
frmInfo.showimage(StrToInt(Copy(Consumption, 7, 1)), img4);
frmInfo.showimage(StrToInt(Copy(Consumption, 8, 1)), img3);
//Decimal part
if StrToInt(CNST.Caption) = 0 then
exit
else
begin
DecimalStr := copy(pulse.caption,3,2);
frmInfo.showimage(StrToInt(Copy(DecimalStr, 1, 1)), img2);
frmInfo.showimage(StrToInt(Copy(DecimalStr, 2, 1)), img1);
end;
end;
procedure TfrmInfo.Showimage(Num: Integer; Images:Timage);
begin
case Num of
0:Images.Picture:= frmInfo.imgs0.Picture;
1:Images.Picture:= frmInfo.imgs1.Picture;
2:Images.Picture:= frmInfo.imgs2.Picture;
3:Images.Picture:= frmInfo.imgs3.Picture;
4:Images.Picture:= frmInfo.imgs4.Picture;
5:Images.Picture:= frmInfo.imgs5.Picture;
6:Images.Picture:= frmInfo.imgs6.Picture;
7:Images.Picture:= frmInfo.imgs7.Picture;
8:Images.Picture:= frmInfo.imgs8.Picture;
9:Images.Picture:= frmInfo.imgs9.Picture;
end;
end;
procedure TfrmInfo.ListView1DblClick(Sender: TObject);
begin
with ListView1 do
if SelCount > 0 then
begin
if Items[Selected.Index].SubItems.Strings[6] <> 'On' then
Items[Selected.Index].SubItems.Strings[6] := 'On'
else
Items[Selected.Index].SubItems.Strings[6] := '';
if DM1.DSTdb.Locate('DNO', Items[Selected.Index].SubItems.Strings[2], [loPartialKey]) then
begin
DM1.DSTdb.Edit;
DM1.DSTdb.FieldByName('AutoRead').AsString := Items[ListView1.Selected.Index].SubItems.Strings[6];
DM1.DSTdb.Post;
dm1.DSTdb.FlushBuffers;
dm1.dstdb.Refresh;
end;
end
end;
procedure TfrmInfo.SpeedButton1Click(Sender: TObject);
begin
frmMain.DeleteHistoryClick(Sender);
end;
procedure TfrmInfo.SpeedButton2Click(Sender: TObject);
begin
frmMain.N10Click(Sender);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -