⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ulivemarrowpicture.pas

📁 一个简单得医院图像管理系统
💻 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;
    
    //获得设置为打印的图片
    function GetPrintedPicture:string;

    //根据病人ID号查询
    function QueryByPatientIDS(PatientIDS:TStrings):Boolean;
    //根据病人编号选择检验结果
    procedure SelectTestResultByPatientID(iPatientID:Integer);
    //删除当前所有的记录
    function DeleteCurrentAllPicture:Boolean;

    //获得最大的ID号
    function GetMaxID:Integer;

    //设置当前图片为打印标志
    procedure SetPicturePrinted;
    //设置当前图片为非打印打印标志
    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';//若为空则取数据结构
  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.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -