📄 dataanalyseformunit1.pas
字号:
sheet.cells[j+1,3].value:=trim(ADOQuery1.FieldValues['地址']);
sheet.cells[j+1,4].value:=trim(ADOQuery1.FieldValues['设备上传时间']);
sheet.cells[j+1,5].value:=trim(ADOQuery1.FieldValues['本期指数']);
sheet.cells[j+1,6].value:=trim(ADOQuery1.FieldValues['区号']);
sheet.cells[j+1,7].value:=trim(ADOQuery1.FieldValues['本号']);
sheet.cells[j+1,8].value:=trim(ADOQuery1.FieldValues['牌号']);
inc(j);
adoquery1.Next;
end;
adoquery1.First;
eclApp.Visible := True;
eclApp.ActiveSheet.PrintPreview;
WorkBook.Close;
eclApp.Quit;//退出Excel Application
eclApp:=Unassigned;
end;}
end;
procedure TDataAnalyseForm.DBNavigator1Click(Sender: TObject;
Button: TNavigateBtn);
begin
if button=nbRefresh then
application.MessageBox('数据更新完毕!','提示',mb_iconinformation);
end;
procedure TDataAnalyseForm.ToolButton2Click(Sender: TObject);
begin
{if length(edit2.Text)<>0 then
begin
DataModule1.adoquery3.Connection:=datamodule1.ADOConnection1;
DataModule1.adoquery3.SQL.Clear;
DataModule1.ADOQuery3.Filtered:=false;
DataModule1.adoquery3.Close;
DataModule1.adoquery3.SQL.Add('update 问题数据分析 set 问题标记=''1'' where 注册号='''+trim(edit2.Text)+'''');
DataModule1.adoquery3.ExecSQL;
end;}
end;
procedure TDataAnalyseForm.CheckBox19Click(Sender: TObject);
begin
if checkbox19.Checked then
begin
edit9.Enabled:=true;
combobox11.Enabled:=true;
end
else
begin
edit9.Text:='';
edit9.Enabled:=false;
combobox11.Text:='';
combobox11.Enabled:=false;
end;
end;
procedure TDataAnalyseForm.CheckBox20Click(Sender: TObject);
begin
if checkbox20.Checked then
begin
edit10.Enabled:=true;
combobox9.Enabled:=true;
end
else
begin
edit10.Text:='';
edit10.Enabled:=false;
combobox9.Enabled:=false;
end;
end;
procedure TDataAnalyseForm.CheckBox21Click(Sender: TObject);
begin
if checkbox21.Checked then
begin
combobox13.Enabled:=true;
end
else
begin
combobox13.Text:='';
combobox13.Enabled:=false;
end;
end;
procedure TDataAnalyseForm.N2Click(Sender: TObject);
var
sqlstr1,sqlstr2:string;
maxflux,i,j:integer;
begin
try
if ADOQuery1.State<>dsBrowse then
begin
sqlstr1:='select 注册号,设备类型,用户名称,本期指数,本期流量,人工读数,估收水量,问题标记,故障标记,上期指数,上期流量,停转时间,电池电压,计数轮,定点时间,设备上传时间,';
sqlstr1:=sqlstr1+'设备当前时钟,数据来源,停转开始时间,当前时间,上传模式,区号,本号,牌号,抄表员号,设备ID号,地址,是否导出,备注 from 问题数据分析 where';
sqlstr1:=sqlstr1+ ' 设备ID号 like ''%''';
adoquery1.Connection:=DataModule1.ADOConnection1;
adoquery1.SQL.Clear;
ADOQuery1.Filtered:=false;
adoquery1.Close;
adoquery1.SQL.Add(sqlstr1);
adoquery1.Prepared;
adoquery1.open;
end;
if adoquery1.RecordCount <>0 then
begin
DataModule1.adocommand1.Connection:=datamodule1.ADOConnection1;
//adoquery1.First;
for j:=1 to adoquery1.RecordCount do
begin
application.ProcessMessages;
if exitloop then
exit;
//*************************************分析故障表*************************************
if (adoquery1.FieldByName('故障标记').AsString<>'000') or (adoquery1.FieldByName('问题标记').AsString='106') or (adoquery1.FieldByName('问题标记').AsString='107') or (adoquery1.FieldByName('问题标记').AsString='108') or (adoquery1.FieldByName('问题标记').AsString='109') or (adoquery1.FieldByName('问题标记').AsString='110') or (adoquery1.FieldByName('问题标记').AsString='114') or (adoquery1.FieldByName('问题标记').AsString='999') then
begin
adoquery1.Next;
continue;
end;
if checkbox22.Checked then
begin
if adoquery1.FieldValues['本期流量']>=100 then
begin
maxflux:=max(adoquery1.FieldValues['本期流量'],adoquery1.FieldValues['上期流量']);
if (abs(adoquery1.FieldValues['本期流量']-adoquery1.FieldValues['上期流量'])/maxflux*100>=strtoint(trim(edit17.Text))) then//or (adoquery1.FieldValues['本期流量'] <= 0) then
begin
DataModule1.adocommand1.CommandText:='update 问题数据分析 set 故障标记=''111'' where 注册号='''+adoquery1.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
end;
end
else if (adoquery1.FieldValues['本期流量']<100) and (adoquery1.FieldValues['本期流量']>0) then
begin
if (abs(adoquery1.FieldValues['本期流量']-adoquery1.FieldValues['上期流量'])>=strtoint(trim(edit18.Text))) then//or (adoquery1.FieldValues['本期流量']<= 0) then
begin
DataModule1.adocommand1.CommandText:='update 问题数据分析 set 故障标记=''111'' where 注册号='''+adoquery1.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
end;
end;
end;
if checkbox34.Checked then
begin
if adoquery1.FieldValues['本期流量']<0 then
begin
DataModule1.adocommand1.CommandText:='update 问题数据分析 set 问题标记=''113'' where 注册号='''+adoquery1.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
end;
end;
if checkbox1.Checked then
begin
if adoquery1.FieldValues['本期流量']=0 then
begin;
DataModule1.adocommand1.CommandText:='update 问题数据分析 set 问题标记=''112'' where 注册号='''+adoquery1.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
end;
end;
if (adoquery1.FieldByName('故障标记').AsString<>'000') or (adoquery1.FieldByName('问题标记').AsString='106') or (adoquery1.FieldByName('问题标记').AsString='107') or (adoquery1.FieldByName('问题标记').AsString='108') or (adoquery1.FieldByName('问题标记').AsString='109') or (adoquery1.FieldByName('问题标记').AsString='110') or (adoquery1.FieldByName('问题标记').AsString='111') then
begin
adoquery1.Next;
continue;
end;
if checkbox38.Checked then
begin
if adoquery1.FieldByName('停转时间').AsInteger >=strtoint(trim(edit23.text)) then
begin
DataModule1.adocommand1.CommandText:='update 故障设备分析 set 故障标记=''101'',备注=''停转'' where 注册号='''+datasource1.DataSet.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
adoquery1.Next;
continue;
end;
end;
if checkbox37.Checked then
begin
if adoquery1.FieldByName('电池电压').AsString ='低压' then
begin
DataModule1.adocommand1.CommandText:='update 故障设备分析 set 故障标记=''102'',备注=''电池电压低'' where 注册号='''+datasource1.DataSet.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
adoquery1.Next;
continue;
end;
end;
datasource1.DataSet.Refresh;
adoquery1.Next;
end;
adoquery1.First;
//*************************************分析故障表*************************************
{for j:=1 to adoquery1.RecordCount do
begin
application.ProcessMessages;
if exitloop then
exit;
if (adoquery1.FieldByName('故障标记').AsString<>'000') or (adoquery1.FieldByName('问题标记').AsString='106') or (adoquery1.FieldByName('问题标记').AsString='107') or (adoquery1.FieldByName('问题标记').AsString='108') or (adoquery1.FieldByName('问题标记').AsString='109') or (adoquery1.FieldByName('问题标记').AsString='110') or (adoquery1.FieldByName('问题标记').AsString='111') then
begin
adoquery1.Next;
continue;
end;
if checkbox38.Checked then
begin
if adoquery1.FieldByName('停转时间').AsInteger >=strtoint(trim(edit23.text)) then
begin
DataModule1.adocommand1.CommandText:='update 故障设备分析 set 故障标记=''101'',备注=''停转'' where 注册号='''+datasource1.DataSet.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
adoquery1.Next;
continue;
end;
end;
if checkbox37.Checked then
begin
if adoquery1.FieldByName('电池电压').AsString ='低压' then
begin
DataModule1.adocommand1.CommandText:='update 故障设备分析 set 故障标记=''102'',备注=''电池电压低'' where 注册号='''+datasource1.DataSet.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
adoquery1.Next;
continue;
end;
end;
datasource1.DataSet.Refresh;
adoquery1.Next;
end;}
//**************************************分析完毕**************************************
datasource1.DataSet.Refresh;
adoquery1.First;
//application.MessageBox('数据分析完毕!','确定',mb_iconinformation);
if application.MessageBox('数据分析完毕,是否需要查看分析结果?','确定',mb_yesno+mb_iconquestion)=idyes then
begin
SpeedButton6.Click;
end;
end
else
application.MessageBox('没有可供分析的数据!','确定',mb_iconinformation);
except
on e:exception do
begin
end;
end;
end;
procedure TDataAnalyseForm.ToolButton5Click(Sender: TObject);
begin
try
if datasource1.DataSet.State=dsInactive then
exit;
if datasource1.DataSet.RecordCount=0 then
exit;
if application.MessageBox('真的要更改该纪录的问题标记吗?','询问',mb_yesno+mb_iconquestion)=idyes then
begin
DataModule1.adocommand1.Connection:=datamodule1.ADOConnection1;
DataModule1.adocommand1.CommandText:='update 问题数据分析 set 问题标记='''+midbstr(trim(combobox23.Text),1,pos('-',trim(combobox23.Text))-1)+''' where 注册号='''+datasource1.DataSet.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
datasource1.DataSet.Refresh;
end
else
exit;
datasource1.DataSet.Last;
datasource1.DataSet.First;
application.MessageBox('数据更新完毕!','确定',mb_iconinformation);
{if (not varisnull(datasource1.DataSet.FieldValues['问题标记'])) and (trim(datasource1.DataSet.FieldValues['问题标记'])<>'000') then
begin
if application.MessageBox('真的要更改该纪录的问题标记吗?','询问',mb_yesno+mb_iconquestion)=idyes then
begin
DataModule1.adocommand1.Connection:=datamodule1.ADOConnection1;
DataModule1.adocommand1.CommandText:='update 问题数据分析 set 问题标记='''+midbstr(trim(combobox23.Text),1,pos('-',trim(combobox23.Text))-1)+''' where 注册号='''+datasource1.DataSet.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
datasource1.DataSet.Refresh;
end;
end
else if (not varisnull(datasource1.DataSet.FieldValues['问题标记'])) and (trim(datasource1.DataSet.FieldValues['问题标记'])='000') then
begin
if application.MessageBox('真的要把该纪录标注为问题数据吗?','询问',mb_yesno+mb_iconquestion)=idyes then
begin
DataModule1.adocommand1.Connection:=datamodule1.ADOConnection1;
DataModule1.adocommand1.CommandText:='update 问题数据分析 set 问题标记='''+midbstr(trim(combobox23.Text),1,pos('-',trim(combobox23.Text))-1)+''' where 注册号='''+datasource1.DataSet.FieldValues['注册号']+'''';
DataModule1.adocommand1.Execute;
datasource1.DataSet.Refresh;
end;
end
else if varisnull(datasource1.DataSet.FieldValues['问题标记']) then
messagedlg('请核实所选纪录!',mterror,[mbok],0);}
except
on e:exception do
begin
end;
end;
end;
procedure TDataAnalyseForm.CheckBox2Click(Sender: TObject);
begin
if checkbox2.Checked then
edit1.Enabled:=true
else
begin
edit1.Text:='';
edit1.Enabled:=false;
end;
end;
procedure TDataAnalyseForm.CheckBox7Click(Sender: TObject);
begin
if checkbox7.Checked then
edit4.Enabled:=true
else
begin
edit4.Text:='';
edit4.Enabled:=false;
end;
end;
procedure TDataAnalyseForm.CheckBox22Click(Sender: TObject);
begin
if checkbox22.Checked then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -