?? ulivemarrowpicture.pas
字號:
unit uLiveMarrowPicture;
interface
uses Windows, Messages, SysUtils, Variants, Classes,uPublicConnection,uPubFun,
DB,ADODB,ExtCtrls,jpeg;
type
TLiveMarrowPicture=class(TObject)
private
FQuery:TADOQuery;
public
constructor Create;
destructor Destroy;override;
//獲得設(shè)置為打印的圖片
function GetPrintedPicture:string;
//根據(jù)病人ID號查詢
function QueryByPatientIDS(PatientIDS:TStrings):Boolean;
//根據(jù)病人編號選擇檢驗結(jié)果
procedure SelectTestResultByPatientID(iPatientID:Integer);
//刪除當前所有的記錄
function DeleteCurrentAllPicture:Boolean;
//獲得最大的ID號
function GetMaxID:Integer;
//設(shè)置當前圖片為打印標志
procedure SetPicturePrinted;
//設(shè)置當前圖片為非打印打印標志
procedure SetPictureUnprinted;
property Query:TADOQuery read FQuery;
end;
implementation
{ TLiveMarrowPicture }
constructor TLiveMarrowPicture.Create;
begin
inherited;
FQuery:=TADOQuery.Create(nil);
FQuery.Connection:=GlobalConnection.Connection;
end;
function TLiveMarrowPicture.DeleteCurrentAllPicture: Boolean;
var
i:integer;
begin
Result:=False;
if FQuery.Active=False then Exit;
if FQuery.RecordCount<1 then Exit;
FQuery.DisableControls;
try
FQuery.First;
for i:=1 to FQuery.RecordCount do
begin
FQuery.Delete;
end;
Result:=True;
finally
FQuery.EnableControls;
end;
end;
destructor TLiveMarrowPicture.Destroy;
begin
if FQuery.Active then FQuery.Active:=False;
FQuery.Free;
inherited;
end;
function TLiveMarrowPicture.GetMaxID: Integer;
var
ADOQuery:TADOQuery;
begin
ADOQuery:=TADOQuery.Create(nil);
try
ADOQuery.Connection:=GlobalConnection.Connection;
ADOQuery.SQL.Text:='Select max(id) as maxid from LIVING_MARROW_PICTURE';
ADOQuery.Active:=true;
result:=TBasoUtils.GetDataFromField(ADOQuery,'maxid',-1);
if Result<1 then
begin
Result:=1;
end else
begin
Result:=Result+1;
end;
finally
ADOQuery.Free;
end;
end;
function TLiveMarrowPicture.GetPrintedPicture: string;
var
i:Integer;
OriginBookMark:string;
begin
Result:='';
if (FQuery.Active=False)or(FQuery.RecordCount<1) then Exit;
OriginBookMark:=FQuery.Bookmark;
FQuery.DisableControls;
try
FQuery.First;
for i:=1 to FQuery.RecordCount do
begin
if FQuery.FieldByName('Printed').AsInteger=1 then
begin
if Result='' then
begin
Result:='當前選擇打印圖片序號為:'+IntToStr(FQuery.RecNo);
end else
begin
Result:=Result+'、'+IntToStr(FQuery.RecNo);
end;
end;
FQuery.Next;
end;
finally
FQuery.Bookmark := OriginBookMark;
FQuery.EnableControls;
end;
end;
function TLiveMarrowPicture.QueryByPatientIDS(
PatientIDS: TStrings): Boolean;
var
sSQL:string;
sInSQL:string;
function GetInSQL:string;
var
i:integer;
tem:string;
begin
Result:='';
if PatientIDS.Count<1 then Exit;
for i:=0 to PatientIDS.Count-1 do
begin
tem:=Trim(PatientIDS[i]);
if tem<>'' then
begin
if i=0 then
begin
result:=tem;
end else
begin
Result:=Result+','+tem;
end;
end;
end;
end;
begin
sInSQL:=GetInSQL;
sSQL:='select*from LIVING_MARROW_PICTURE';
if sInSQL='' then
begin
sSQL:=sSQL+' where 1=2 order by id';//若為空則取數(shù)據(jù)結(jié)構(gòu)
end else
begin
sSQL:=sSQL+' where PatientID in ('+sInSQL+') order by id';
end;
if FQuery.Active then FQuery.Active:=False;
FQuery.SQL.Text:=sSQL;
try
FQuery.Active:=True;
finally
Result:=FQuery.Active;
end;
end;
procedure TLiveMarrowPicture.SelectTestResultByPatientID(
iPatientID: Integer);
var
sFilter:string;
begin
if FQuery.Active=False then Exit;
FQuery.DisableControls;
try
sFilter:='PatientID = '+IntToStr(iPatientID);
if FQuery.Filtered then FQuery.Filtered:=False;
FQuery.Filter:=sFilter;
FQuery.Filtered:=True;
finally
FQuery.EnableControls;
end;
end;
procedure TLiveMarrowPicture.SetPicturePrinted;
begin
if (FQuery.Active=False)or(FQuery.RecordCount<1) then Exit;
if FQuery.FieldByName('Printed').AsInteger=1 then Exit;
if FQuery.State=dsBrowse then FQuery.Edit;
FQuery.FieldByName('Printed').AsInteger:=1;
FQuery.Post;
end;
procedure TLiveMarrowPicture.SetPictureUnprinted;
begin
if (FQuery.Active=False)or(FQuery.RecordCount<1) then Exit;
if FQuery.FieldByName('Printed').AsInteger=0 then Exit;
if FQuery.State=dsBrowse then FQuery.Edit;
FQuery.FieldByName('Printed').AsInteger:=0;
FQuery.Post;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -