📄 unit7.pas
字号:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, ADODB;
type
TForm7 = class(TForm)
Panel1: TPanel;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
reasonMemo: TMemo;
soluMemo: TMemo;
Button1: TButton;
Button2: TButton;
ruler7Qry: TADOQuery;
rulerCon: TADOConnection;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm7.Button1Click(Sender: TObject);
begin
with ruler7Qry do
begin
close;
with sql do
begin
clear;
add('delete from fact_table');
end;
execsql;
with sql do
begin
clear;
add('update pre_table set known=0 where known=1');
end;
execsql;
with sql do
begin
clear;
add('update act_table set known=0 where known=1');
end;
execsql;
end;
Application.Terminate;
end;
procedure TForm7.Button2Click(Sender: TObject);
begin
with ruler7Qry do
begin
close;
with sql do
begin
clear;
add('delete from fact_table');
end;
execsql;
with sql do
begin
clear;
add('update pre_table set known=0 where known=1');
end;
execsql;
with sql do
begin
clear;
add('update act_table set known=0 where known=1');
end;
execsql;
end;
Form7.Close;
Form1.show;
end;
procedure TForm7.FormShow(Sender: TObject);
var reason,solution:String;
begin
reasonMemo.Clear;
soluMemo.Clear;
reason:='kong';
solution:='kong';
//////////////////////////
ruler7Qry.close;
ruler7Qry.SQL.Clear;
ruler7Qry.SQL.add('update pre_table set known=1 where id in (select id from fact_table)');
showmessage('故障诊断中(本诊断系统实为简易版,若有的故障不能诊断,请原谅)');
ruler7Qry.execsql;
/////////////////////////
ruler7Qry.close;
ruler7Qry.SQL.Clear;
ruler7Qry.SQL.add('update act_table a1 set a1.known=1 where a1.ruleName in ');
ruler7Qry.SQL.add('(select p1.ruleName from pre_table p1 where p1.known=1 group by p1.ruleName having count(*)=');
ruler7Qry.SQL.add('(select num from act_table a2 where a2.ruleName=p1.ruleName))');
showmessage('请等待......');
ruler7Qry.execsql;
/////////////////////////////////
ruler7Qry.close;
ruler7Qry.SQL.Clear;
ruler7Qry.SQL.add('select interpret from dict_table where id=(select id from act_table where known=1 and flag=1)');
ruler7Qry.open;
if (ruler7Qry.Eof=false) then
begin
reason:=ruler7Qry.Fields[0].AsString;
end;
//////////////////////////////
if (reason<>'kong') then
begin
ruler7Qry.close;
ruler7Qry.SQL.Clear;
ruler7Qry.SQL.add('select sugestion from sug_table where sug_table.ruleName in');
ruler7Qry.SQL.add('(select ruleName from act_table where known=1)');
ruler7Qry.open;
solution:=ruler7Qry.Fields[0].AsString;
end;
//////////////////////
if (reason<>'kong') then
begin
reasonMemo.Lines.Add(reason);
soluMemo.Lines.Add(solution);
end
else
reasonMemo.Lines.add('提供的条件不够,无法判断故障原因');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -