📄 llow.~pas
字号:
unit llow;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, DB, ADODB;
type
TDataVar = array of string;
Tllowf = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Memo3: TMemo;
Memo4: TMemo;
Memo5: TMemo;
GOOD: TLabel;
POOR: TLabel;
Label1: TLabel;
Memo6: TMemo;
Memo7: TMemo;
Memo8: TMemo;
Button2: TButton;
Q_productinfo: TADOQuery;
DS_productinfo: TDataSource;
Memo9: TMemo;
Memo10: TMemo;
Button1: TButton;
Memo11: TMemo;
procedure FormCreate(Sender: TObject);
function compact(l: integer): TDataVar;
function compact1: TDataVar;
procedure ResetValue(col: integer);
function PosEx(const SubStr, S: string): integer;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
llowf:Tllowf;
a: array[0..5, 0..3] of string;
i, j, k: integer;
DataVar: TDataVar;
DataVar1: TDataVar;
DataVar2: TDataVar;
DataVar3: TDataVar;
DataVar4: TDataVar;
DataVar_decision,DataVar_decisionexx,DataVar_goodex,DataVar_Poorex,DataVar_Excelex,DataVar_good1ex,DataVar_Poor1ex,DataVar_Excel1ex: TDataVar;
str, str_temp: string;
wz, lenth, m: integer;
DataVar_good, DataVar_Poor, DataVar_Excel, DataVar_good1, DataVar_Poor1, DataVar_Excel1,DataVar_decisionex: TDataVar;
implementation
{$R *.dfm}
uses dm, lproductex;
procedure Tllowf.FormCreate(Sender: TObject);
var i:integer;
begin
Q_productinfo.Close;
Q_productinfo.SQL.Text:='select * FROM '+DatabaseName+'decision ';
Q_productinfo.Open;
Q_productinfo.First;
i:=0;
while not Q_productinfo.Eof do
begin
a[i][0]:=Q_productinfo.FieldByName('price').asstring;
a[i][1]:=Q_productinfo.FieldByName('Mileage').asstring;
a[i][2]:=Q_productinfo.FieldByName('size').asstring;
a[i][3]:=Q_productinfo.FieldByName('Max-speed').asstring;
i:=i+1;
if i=6 then break;
Q_productinfo.Next;
end;
DataVar := compact1;
DataVar1 := compact(0);
DataVar2 := compact(1);
DataVar3 := compact(2);
DataVar4 := compact(3);
for i := 0 to 5 do
begin
Memo1.Lines.Add(DataVar[i]);
Memo2.Lines.Add(DataVar1[i]);
Memo3.Lines.Add(DataVar2[i]);
Memo4.Lines.Add(DataVar3[i]);
Memo5.Lines.Add(DataVar4[i]);
end;
if DataVar = DataVar1 then ResetValue(0);
end;
function Tllowf.compact(l: integer): TDataVar;
var DataVar_sat: TDataVar;
bj: Boolean;
begin
SetLength(DataVar_sat, 6);
for k := 0 to 5 do
begin
for i := 0 to 5 do
begin
bj := True;
for j := 0 to 3 do
begin
if j <> l then
begin
if ((a[k, j] <> a[i, j]) and (a[k, j] <> '*') and (a[i, j] <> '*')) then
begin
bj := false;
break;
end;
end;
end;
if bj = True then
begin
DataVar_sat[k] := DataVar_sat[k] + (IntToStr(i + 1));
end;
end;
end;
Result := DataVar_sat;
end;
function Tllowf.compact1: TDataVar;
var DataVar_sat: TDataVar;
bj: Boolean;
begin
SetLength(DataVar_sat, 6);
for k := 0 to 5 do
begin
for i := 0 to 5 do
begin
bj := True;
for j := 0 to 3 do
begin
if ((a[k, j] <> a[i, j]) and (a[k, j] <> '*') and (a[i, j] <> '*')) then
begin
bj := false;
break;
end;
end;
if bj = True then
begin
DataVar_sat[k] := DataVar_sat[k] + (IntToStr(i + 1));
end;
end;
end;
Result := DataVar_sat;
end;
procedure Tllowf.ResetValue(col: integer);
begin
a[0, col] := '*';
a[1, col] := '*';
a[2, col] := '*';
a[3, col] := '*';
a[4, col] := '*';
a[5, col] := '*';
end;
function Tllowf.PosEx(const SubStr, S: string): integer; //取出第一个已知字符的位置
var
i, X: integer;
begin
i := 1;
while i <= Length(S) do
begin
if S[i] <> SubStr then Inc(i);
if S[i] = SubStr then
begin
Result := i;
exit;
end;
end;
end;
procedure Tllowf.Button2Click(Sender: TObject);
var good:string;
var poor:string;
var excel:string;
begin
Q_productinfo.Close;
Q_productinfo.SQL.Text:='select * FROM '+DatabaseName+'decision where decision=''good''';
Q_productinfo.Open;
Q_productinfo.First;
good:='';
while not Q_productinfo.Eof do
begin
good:=good+Q_productinfo.FieldByName('product_no').asstring;
Q_productinfo.Next;
end;
Q_productinfo.Close;
Q_productinfo.SQL.Text:='select * FROM '+DatabaseName+'decision where decision=''poor''';
Q_productinfo.Open;
Q_productinfo.First;
poor:='';
while not Q_productinfo.Eof do
begin
poor:=poor+Q_productinfo.FieldByName('product_no').asstring;
Q_productinfo.Next;
end;
Q_productinfo.Close;
Q_productinfo.SQL.Text:='select * FROM '+DatabaseName+'decision where decision=''excel''';
Q_productinfo.Open;
Q_productinfo.First;
excel:='';
while not Q_productinfo.Eof do
begin
excel:=excel+Q_productinfo.FieldByName('product_no').asstring;
Q_productinfo.Next;
end;
SetLength(DataVar_decision, 3);
DataVar_decision[0] := good;
DataVar_decision[1] := poor;
DataVar_decision[2] := excel;
SetLength(DataVar_good, 0);
SetLength(DataVar_Poor, 0);
SetLength(DataVar_Excel, 0);
for j := 0 to 5 do
begin
m := 0;
lenth := Length(DataVar[j]);
if lenth > 0 then
begin
for i := 1 to lenth do
begin
str_temp := Copy(DataVar[j], i, 1);
wz := PosEx(str_temp, DataVar_decision[0]);
if wz <> 0 then m := m + 1;
end;
if m = lenth then
begin
SetLength(DataVar_good, Length(DataVar_good) + 1);
DataVar_good[Length(DataVar_good) - 1] := IntToStr(j + 1);
Memo6.Lines.Add(IntToStr(j + 1));
end;
end;
end;
for j := 0 to 5 do
begin
m := 0;
lenth := Length(DataVar[j]);
if lenth > 0 then
begin
for i := 1 to lenth do
begin
str_temp := Copy(DataVar[j], i, 1);
wz := PosEx(str_temp, DataVar_decision[1]);
if wz <> 0 then m := m + 1;
end;
if m = lenth then
begin
SetLength(DataVar_Poor, Length(DataVar_Poor) + 1);
DataVar_Poor[Length(DataVar_Poor) - 1] := IntToStr(j + 1);
Memo7.Lines.Add(IntToStr(j + 1));
end;
end;
end;
for j := 0 to 5 do
begin
m := 0;
lenth := Length(DataVar[j]);
if lenth > 0 then
begin
for i := 1 to lenth do
begin
str_temp := Copy(DataVar[j], i, 1);
wz := PosEx(str_temp, DataVar_decision[2]);
if wz <> 0 then m := m + 1;
end;
if m = lenth then
begin
SetLength(DataVar_Excel, Length(DataVar_Excel) + 1);
DataVar_Excel[Length(DataVar_Excel) - 1] := IntToStr(j + 1);
Memo8.Lines.Add(IntToStr(j + 1));
end;
end;
end;
end;
procedure Tllowf.Button1Click(Sender: TObject);
begin
SetLength(DataVar_good1, 0);
SetLength(DataVar_Poor1, 0);
SetLength(DataVar_Excel1, 0);
for j := 0 to 5 do
begin
lenth := Length(DataVar[j]);
if lenth > 0 then
begin
for i := 1 to lenth do
begin
str_temp := Copy(DataVar[j], i, 1);
wz := PosEx(str_temp, DataVar_decision[0]);
if wz <> 0 then
begin
SetLength(DataVar_good1, Length(DataVar_good1) + 1);
DataVar_good1[Length(DataVar_good1) - 1] := IntToStr(j + 1);
Memo9.Lines.Add(IntToStr(j + 1));
break;
end;
end;
end;
end;
for j := 0 to 5 do
begin
lenth := Length(DataVar[j]);
if lenth > 0 then
begin
for i := 1 to lenth do
begin
str_temp := Copy(DataVar[j], i, 1);
wz := PosEx(str_temp, DataVar_decision[1]);
if wz <> 0 then
begin
SetLength(DataVar_Poor1, Length(DataVar_Poor1) + 1);
DataVar_Poor1[Length(DataVar_Poor1) - 1] := IntToStr(j + 1);
Memo10.Lines.Add(IntToStr(j + 1));
break;
end;
end;
end;
end;
for j := 0 to 5 do
begin
lenth := Length(DataVar[j]);
if lenth > 0 then
begin
for i := 1 to lenth do
begin
str_temp := Copy(DataVar[j], i, 1);
wz := PosEx(str_temp, DataVar_decision[2]);
if wz <> 0 then
begin
SetLength(DataVar_excel1, Length(DataVar_excel1) + 1);
DataVar_excel1[Length(DataVar_excel1) - 1] := IntToStr(j + 1);
Memo11.Lines.Add(IntToStr(j + 1));
break;
end;
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -