delphi 7+oracle,delphi 7 联接oracle9 源码

【实例简介】

delphi 7 联接oracle9 源码

【实例截图】

delphi 7+oracle,delphi 7 联接oracle9 源码_第1张图片

【核心代码】

procedure TForm1.Button1Click(Sender: TObject);

var

sqlstr: string;

sqlstr2: string;

i, j: Integer;

k: Integer;

begin

try

OraSession1.Options.Net := True;

OraSession1.Username := trim(user_Global);

OraSession1.Password := trim(password_Global);

OraSession1.Server := trim(server_Global);

OraSession1.Connect;

except

barMessage.Panels[1].Text := '       断开';

exit;

end;

barMessage.Panels[1].Text := '       正常';

{

DISTINCT train as 车次,id as 工号,name as 姓名,room as 房间,actin as 入寓时间,'

'actout as 出寓时间,seat as 床位,worksite as 地点 '

'

}

sqlstr := ' select  room,name from s_standbytime  where  nvl2(actout,0,1)=1   '

'    and  worksite = ' QuotedStr(caption_Global)

' and dat between to_date('

QuotedStr(DateToStr(Date() - 1)) ',' QuotedStr('yyyy-mm-dd') ') and to_date('

QuotedStr(DateToStr(Date())) ',' QuotedStr('yyyy-mm-dd') ') order by room,seat';

OraQuery1.sql.clear;

OraQuery1.sql.add(sqlstr);

OraQuery1.Active := True;

sqlstr2 := 'select DISTINCT room from S_room  where worksite= ' QuotedStr(caption_Global);

OraQuery2.sql.clear;

OraQuery2.sql.add(sqlstr2);

OraQuery2.Active := True;

if (h_int = 8) and (OraQuery2.RecordCount <> 8) then begin

h_int := OraQuery2.RecordCount div 5 1;

Timer_h.Enabled := True;

end;

for i := 0 to ComponentCount - 1 do

begin

if Components[i] is TStaticText then

if TStaticText(Components[i]).Caption = 'StaticText1' then

TStaticText(Components[i]).Caption := '';

if Components[i] is TLabel then

TLabel(Components[i]).Caption := '';

if Components[i] is TPanel then

if TPanel(Components[i]).Color <> clSkyBlue then

TPanel(Components[i]).Color := clLime;

end;

OraQuery2.First;

k := 1;

while not OraQuery2.Eof do begin

for i := 0 to ComponentCount - 1 do

begin

if Components[i] is TStaticText then

begin

if TStaticText(Components[i]).Parent.Tag = k then begin

if TStaticText(Components[i]).Caption = '' then begin

TStaticText(Components[i]).Caption := trim(OraQuery2.FieldList[0].AsString);

TStaticText(Components[i]).Tag := k;

TStaticText(Components[i]).Font.Color := clBlack;

TStaticText(Components[i]).Font.Style := [fsBold];

TStaticText(Components[i]).Font.Name := '隶书';

TStaticText(Components[i]).Font.Size := 42;

TStaticText(Components[i]).Alignment := taLeftJustify;

TStaticText(Components[i]).Left := 15;

TStaticText(Components[i]).top := 15;

TStaticText(Components[i]).AutoSize := True;

end;

end;

end;

if Components[i] is TLabel then

begin

if TLabel(Components[i]).Parent.Tag = k then begin

TLabel(Components[i]).Tag := k;

TLabel(Components[i]).Caption := '';

TLabel(Components[i]).Font.Color := clBlack;

TLabel(Components[i]).Font.Style := [];

TLabel(Components[i]).Font.Size := 18;

TLabel(Components[i]).Left := TStaticText(Components[i]).Parent.Width div 2;

TLabel(Components[i]).top := TStaticText(Components[i]).Parent.Height div 3;

TLabel(Components[i]).AutoSize := True;

end; end;

end;

k := k 1;

OraQuery2.Next;

end;

OraQuery1.First;

while not OraQuery1.Eof do begin

for i := 0 to ComponentCount - 1 do

begin

k := 0;

if Components[i] is TStaticText then begin

if TStaticText(Components[i]).Caption = trim(OraQuery1.FieldList[0].AsString) then begin

k := TStaticText(Components[i]).Tag;

end;

end;

for j := 0 to ComponentCount - 1 do

begin

if Components[j] is TLabel then

begin

if (TLabel(Components[j]).Tag = k) and (k > 0) then

if TLabel(Components[j]).Caption <> trim(OraQuery1.FieldList[1].AsString) then

if TLabel(Components[j]).Caption = '' then

TLabel(Components[j]).Caption := trim(OraQuery1.FieldList[1].AsString)

else

TLabel(Components[j]).Caption := TLabel(Components[j]).Caption #13 trim(OraQuery1.FieldList[1].AsString);

end;

if Components[j] is TPanel then

begin

if (TPanel(Components[j]).Tag = k) and (k > 0) then

TPanel(Components[j]).Color := clFuchsia;

end;

end;

end;

OraQuery1.Next;

end;

end;

你可能感兴趣的:(delphi,7+oracle)