因table中記錄不多故用 Locate
代碼如下:
-----client -----
procedure TFormOrder_in.BitDOKClick(Sender: TObject);
var Pset:string;
begin
...
//Add finished goods part code
Pset:='pcode';
Fptno:=DataModule3.TBeforePrint.dataRequest(VarArrayof([Pset,SLotNo]));
if Fptno='0' then
showmessage('PartCode not find!')
else
if Fptno<>'100' then
showmessage('PartCode error!'+#13+Fptno);
...
end
---------server-------
function TReceiveOrder.PTodataDataRequest(Sender: TObject;
Input: OleVariant): OleVariant;
var flotno,Fcode,Ftype,FFwatt,FFpercent,FFpack,FFmemo,FFspec:string;
Fcode12345,Fcode6789,Fcode10112,Pohmcode:string;
N
K:char;
begin
if VarisArray(input) then
begin
// FOrdServer.LabelProc.Caption:=input[0]+'->'+input[1];
Flotno:=Input[1];
with QOdatado
begin
close;
with SQLdo
begin
clear;
Add('select *');
Add('from dbo.orderohm');///royalsys/poc/orderohm.dbf');
Add('where Lot_no=:Sflotno');
end;
parambyname('Sflotno').asstring:=Flotno;
prepare;
open;
end;
if input[0]='pcode' then
begin
//before Print
Torder.Open;
Tcode2112.Open;
//ChgCode
Tcode34.open;
Tcode5.open;
Tcode10.open;
if Torder.Locate('lot_no',Flotno,[])then
begin
with Torderdo
begin
Ftype:=fieldbyname('type1').asstring;
//+fmemo=02
FFwatt:=fieldbyname('watt').asstring;
//34
FFpercent:=fieldbyname('per_cent').asstring;
//05
FFpack:=fieldbyname('pack_type').asstring;
//10
FFmemo:=fieldbyname('memo').asstring;
//1112
FFspec:=fieldbyname('special').asstring;
//1112
{以上變量都有空可能)
end;
{H->Chip, I->Network, B->Coated, A-Cement}
Fcode:='B';
//fcode:1
N
K:='Y';
Fcode12345:=Fcode;
////////////////(當Ftype為空時, 找不到)
if Tcode2112.Locate('type;memo',VarArrayOf([Ftype,FFmemo]),[])then
Fcode12345:=Fcode12345+Tcode2112.fieldbyname('FO2').asstring //focde:2
else
begin
N
K:='N';
Fcode12345:=Fcode12345+'=';
end;
//////////////
if Tcode34.locate('FWatt;Ftype',vararrayof([FFwatt,Fcode]),[])then
Fcode12345:=Fcode12345+Tcode34.fieldbyname('FNO34').asstring //fcode:3,4
else
begin
N
K:='N';
Fcode12345:=Fcode12345+'==';
end;
/////////// 賦值時, 得到下一條記錄值
if Tcode5.Locate('Fpercent;Ftype',vararrayof([FFpercent,Fcode]),[])then
Fcode12345:=Fcode12345+Tcode5.fieldbyname('FNO5').asstring //fcode:5
else
begin
N
K:='N';
Fcode12345:=Fcode12345+'=';
end;
if Tcode10.Locate('Fpack;Ftype',vararrayof([FFpack,Fcode]),[])then
Fcode10112:=Tcode10.fieldbyname('FNO10').asstring //fcode:10
else
begin
N
K:='N';
Fcode10112:='=';
end;
....
if N
K<>'N' then
result:='100'
else
begin
FOrdServer.LabelProc.Caption:=Fcode12345+fcode10112;
result:=Fcode;
//'000';
end;
end
else
result:='0';
end
...
end;