📄 u_645_command.pas
字号:
f_645.f_ini.readsection('日时段',f_645.ListBox1.Items);
m := f_645.ListBox1.Items.Count;
IF m <> 0 then
begin
for i := 1 to m do
begin
str := trim(f_645.f_ini.ReadString('日时段',listbox1.Items.Strings[i-1], 'E'));
delete(str,1,6);
Str := trim(listbox1.Items.Strings[i-1])+str ;
Rzchecklist2.Items.Add(trim(str));
end;
end
else
begin
MyMsgBox('【日时段】编程项设置不完整!','系 统 错 误', 0);
exit;
end;
end;
edit2.Text := inttostr(strtoint(trim(edit2.Text))+m);
h := h+m+1;
END
ELSE IF STR1 ='C41X' then
begin
h := h-1;
Rzchecklist2.Items.Delete(h);
str1:='公共假日时段命令集';
Rzchecklist2.Items.Add(str1);
Rzchecklist2.ItemToGroup(h);
Rzchecklist2.Items.Add(str);
inc(h);
//读取ini文件数据
filename:=extractfilepath(paramstr(0))+F_645.EDIT1.TEXT+'_programme.ini'; //////得到完整的INI文件路径名///
f_645.f_ini:=tinifile.Create(filename);
if fileexists(Filename) then
begin
f_645.f_ini.readsection('公共假日时段',f_645.ListBox1.Items);
m := f_645.ListBox1.Items.Count;
IF m <> 0 then
begin
for i := 1 to m do
begin
str := trim(f_645.f_ini.ReadString('公共假日时段',listbox1.Items.Strings[i-1], 'E'));
delete(str,1,6);
Str := trim(listbox1.Items.Strings[i-1])+str ;
Rzchecklist2.Items.Add(trim(str));
end;
end
else
begin
MyMsgBox('【公共假日时段】编程项设置不完整!','系 统 错 误', 0);
exit;
end;
end;
edit2.Text := inttostr(strtoint(trim(edit2.Text))+m);
h := h+m+1;
end;
datam.ADOQ1.Next;
end;
Rzstringgrid1.RowCount := strtoint(trim(edit2.Text));
end;
procedure TF_645.movedata(sourcetable:string;objecttable:string);
var
sqlstr:string;
begin
datam.ADOT1.TableName := sourcetable;
datam.ADOT2.TableName := objecttable;
datam.ADOT1.Open;
datam.ADOT2.Open;
if datam.ADOT1.RecordCount <= 0 then
begin
MyMsgBox(' 未查询到"源表"【'+sourcetable+'】的数据!','系 统 错 误', 0);
exit;
end
else
begin
datam.ADOT1.First;
while not datam.ADOT1.Eof do
begin
datam.ADOT2.Insert;
datam.ADOT2.FieldByName('表号').Text := TRIM(datam.ADOT1.FieldByName('表号').AsString);
datam.ADOT2.FieldByName('录入日期').Text := TRIM(datam.ADOT1.FieldByName('录入日期').AsString);
datam.ADOT2.FieldByName('命令').Text := TRIM(datam.ADOT1.FieldByName('命令').AsString);
datam.ADOT2.FieldByName('抄表日期').Text := TRIM(datam.ADOT1.FieldByName('抄表日期').AsString);
datam.ADOT2.FieldByName('data1').Text := TRIM(datam.ADOT1.FieldByName('data1').AsString);
datam.ADOT2.FieldByName('data2').Text := TRIM(datam.ADOT1.FieldByName('data2').AsString);
datam.ADOT2.FieldByName('data3').Text := TRIM(datam.ADOT1.FieldByName('data3').AsString);
datam.ADOT2.FieldByName('data4').Text := TRIM(datam.ADOT1.FieldByName('data4').AsString);
datam.ADOT2.FieldByName('data5').Text := TRIM(datam.ADOT1.FieldByName('data5').AsString);
datam.ADOT2.FieldByName('data6').Text := TRIM(datam.ADOT1.FieldByName('data6').AsString);
datam.ADOT2.FieldByName('data7').Text := TRIM(datam.ADOT1.FieldByName('data7').AsString);
datam.ADOT2.FieldByName('data8').Text := TRIM(datam.ADOT1.FieldByName('data8').AsString);
datam.ADOT2.FieldByName('data9').Text := TRIM(datam.ADOT1.FieldByName('data9').AsString);
datam.ADOT2.FieldByName('data10').Text := TRIM(datam.ADOT1.FieldByName('data10').AsString);
datam.ADOT2.FieldByName('data11').Text := TRIM(datam.ADOT1.FieldByName('data11').AsString);
datam.ADOT2.FieldByName('data12').Text := TRIM(datam.ADOT1.FieldByName('data12').AsString);
datam.ADOT2.FieldByName('data13').Text := TRIM(datam.ADOT1.FieldByName('data13').AsString);
datam.ADOT2.FieldByName('data14').Text := TRIM(datam.ADOT1.FieldByName('data14').AsString);
datam.ADOT2.FieldByName('data15').Text := TRIM(datam.ADOT1.FieldByName('data15').AsString);
datam.ADOT2.FieldByName('data16').Text := TRIM(datam.ADOT1.FieldByName('data16').AsString);
datam.ADOT2.FieldByName('data17').Text := TRIM(datam.ADOT1.FieldByName('data17').AsString);
datam.ADOT2.FieldByName('data18').Text := TRIM(datam.ADOT1.FieldByName('data18').AsString);
datam.ADOT2.FieldByName('data19').Text := TRIM(datam.ADOT1.FieldByName('data19').AsString);
datam.ADOT2.FieldByName('data20').Text := TRIM(datam.ADOT1.FieldByName('data20').AsString);
datam.ADOT2.Append;
datam.ADOT1.Next;
end;
end;
datam.ADOT1.Close;
datam.ADOT2.Close;
with datam.ADOQ1 do
begin
close;
sql.Clear;
sql.Add('delete from temp');
execsql;
end;
end;
//数据 掩码格式 数据长度 块标志
procedure TF_645.disposal_data(bh:string;revc:string;ymgs:string;len_data:integer;k_flag:string;lrrq:string;cbrq:string;autosave:Boolean);
var
sqlstr,str,c_str,zs,xs,zd,zdz,s:string;
point,ixs,izs:integer;
i,j,m,k:integer;
datas : array[1..20] of string;
begin
point := 0;
c_str := tzstrx(copy(revc,1,4));
delete(revc,1,4);
j := (length(ymgs)-1) div 2;
point := pos('.',ymgs);
if point > 0 then
begin
ixs := length(ymgs) - point ; //小数长度
izs:= point - 1; //整数长度
if k_flag= '0' then
begin
xs := tzstrx(copy(revc,1,ixs));
delete(revc,1,ixs);
zs := tzstrx(copy(revc,1,izs));
datas[1] := zs+'.'+xs;
j := 1;
end
else
begin
j := len_data div j; //数据块数目
for i := 1 to j do
begin
xs := tzstrx(copy(revc,1,ixs));
delete(revc,1,ixs);
zs := tzstrx(copy(revc,1,izs));
delete(revc,1,izs);
datas[i] := zs+'.'+xs;
end;
end;
s := 'data';
zd :='';
for m := 1 to j do
begin
zd := zd+s+inttostr(m)+',';
end;
zd := copy(zd,1,length(zd)-1);
s:='datas[';
zdz:='';
for m := 1 to j do
zdz :=zdz +', '''+datas[m]+'''';
end
else
begin
izs:= length(ymgs); //数据长度
if k_flag= '0' then
begin
zs := tzstrx(copy(revc,1,izs));
datas[1] := zs;
j := 1;
end
else
begin
j := len_data div j; //数据块数目
for i := 1 to j do
begin
zs := tzstrx(copy(revc,1,izs));
delete(revc,1,izs);
datas[i] := zs;
end;
end;
s := 'data';
zd :='';
for m := 1 to j do
begin
zd := zd+s+inttostr(m)+',';
end;
zd := copy(zd,1,length(zd)-1);
s:='datas[';
zdz:='';
for m := 1 to j do
zdz :=zdz +', '''+datas[m]+'''';
end;
//入库
sqlstr :='insert into temp (表号,录入日期,命令,抄表日期,'+zd+')'+
' values ( '''+bh+''','''+trim(lrrq)+''', '''+c_str+''','''+trim(cbrq)+''' '+
zdz+' )';
with datam.ADOQ4 do
begin
close;
sql.Clear;
sql.Add(sqlstr);
execsql;
IF autosave then
begin
sqlstr :='insert into '+trim(F_645.Edit1.Text)+'_data (表号,录入日期,命令,抄表日期,'+zd+')'+
' values ( '''+bh+''','''+trim(lrrq)+''', '''+c_str+''','''+trim(cbrq)+''' '+
zdz+' )';
close;
sql.Clear;
sql.Add(sqlstr);
execsql;
end;
sqlstr :='select * from temp order by 抄表日期 desc';
close;
sql.Clear;
sql.Add(sqlstr);
execsql;
open;
Rzdbgrid2.Update;
end;
end;
procedure TF_645.Tree_show;
var
s,filename:string;
i,m:integer;
f:textfile;
begin
filename := extractfilepath(paramstr(0))+'\meter.txt';
m := 0;
assignfile(f,filename);
reset(f);
while not EOF(f) do
begin
readln(f,s);
f_645.RzTreeView1.Items.AddChild(f_645.RzTreeView1.Items[0],s) ;
m := m+1;
end;
closefile(f);
m_sum := m;
f_645.RzStatusPane2.Caption := '共'+inttostr(m)+'个被选表型';
for i := 1 to m do
begin
f_645.RzTreeView1.Items[i].ImageIndex := 45;
f_645.RzTreeView1.Items[i].SelectedIndex := 44;
end;
end;
function TF_645.Tree_Boolean(str:string):Boolean;
var
i:integer;
s:string;
begin
for i := 1 to m_sum do
begin
s := f_645.RzTreeView1.Items.Item[i].Text;
if str = s then
begin
result := true;
break;
end
else
result := false;
end;
end;
procedure TF_645.Dbgrid_show(tablename:string);
begin
lst := TStringList.Create;
datam.ADOQ2.Close;
datam.ADOQ2.SQL.Clear;
datam.ADOQ2.SQL.text :='select * from '+tablename+ ' order by 命令';
datam.ADOQ2.Open;
while not datam.ADOQ2.Eof do
begin
if trim(datam.ADOQ2.FieldByName('标识').AsString) = '0' THEN
lst.Values[datam.ADOQ2.FieldByName('标识').AsString] := '规约'
else
lst.Values[datam.ADOQ2.FieldByName('标识').AsString] := '自定义' ;
datam.ADOQ2.Next;
end;
datam.ADOQ2.Close;
datam.ADOQ2.Open;
datam.ADOQ2.FieldByName('标识').OnGetText :=MyGet;
dbgrid1.Invalidate;
f_645.DBGrid1.Columns[0].Width := 60;
f_645.DBGrid1.Columns[1].Width := 220;
f_645.DBGrid1.Columns[2].Width := 40;
f_645.DBGrid1.Columns[3].Width := 50;
f_645.DBGrid1.Columns[4].Width := 50;
f_645.DBGrid1.Columns[5].Width := 90;
f_645.DBGrid1.Columns[6].Width := 60;
f_645.DBEdit1.DataField := '命令';
end;
procedure TF_645.MyGet(Sender: TField; var Text: String;
DisplayText: Boolean);
begin
text := lst.Values[sender.AsString];
end;
procedure TF_645.FormCreate(Sender: TObject);
begin
f_645.top := 0;
f_645.Left := 0;
f_645.Width := 800;
f_645.Height := 570;
end;
procedure TF_645.FormShow(Sender: TObject);
var
s,filename,str,com,btl:string;
i:integer;
f:textfile;
begin
option := 0;
list2_sum:=1;
Tree_show;
filename:=extractfilepath(paramstr(0))+'\COM.dat';
try
assignfile(f,filename);
reset(f);
while not EOF(f) do
begin
readln(f,s);
Rzcombobox1.Items.Add(s);
end;
closefile(f);
except
for i:=1 to 4 do
begin
s := 'COM '+inttostr(i);
Rzcombobox1.Items.Add(s);
RWdatfile('X', Filename, S);
end;
end;
filename:=extractfilepath(paramstr(0))+'Parameter.ini'; //////得到完整的INI文件路径名///
if fileexists(filename) then //////判断INI文件是否存在///////
begin
f_ini:=tinifile.create(filename); //////打开INI文/////////////
com:=f_ini.readString('COM','COM','1');
Rzcombobox1.ItemIndex := strtoint(com)-1;
BTL:=f_ini.readString('RATE','RATE','6');
Rzcombobox8.ItemIndex := strtoint(BTL);
s:=f_ini.readString('SOUND','SOUND','0');
if s = '1' then
begin
Rzradiobutton4.Checked := true;
sound := true;
end
else
begin
Rzradiobutton5.Checked := true;
sound := false;
end;
COPY_fs:=f_ini.readString('MODE','MODE','1');
if copy_fs = '1' then
begin
Rzradiobutton1.Checked := true;
party:=EVEN;
end
else if copy_fs = '2' then
begin
Rzradiobutton2.Checked := true;
party:=EVEN;
end
else if copy_fs = '3' then
begin
Rzradiobutton3.Checked := true;
party:=None;
end;
end
else
begin
sound := false;
Rzcombobox1.ItemIndex := 0;
com := '1';
end;
case Rzcombobox1.ItemIndex of
0: com_NO := pncom1;
1: com_NO := pncom2;
2: com_NO := pncom3;
3: com_NO := pncom4;
4: com_NO := pncom5;
5: com_NO := pncom6;
6: com_NO := pncom7;
7: com_NO := pncom8;
8: com_NO := pncom9;
9: com_NO := pncom10;
10: com_NO := pncom11;
11: com_NO := pncom12;
end;
case Rzcombobox8.ItemIndex of
0: baud := br110;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -