?? ufrmlivemarrowquery.pas
字號(hào):
unit ufrmLiveMarrowQuery;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls,uPubFun,uPublicConnection,ADODB,DB,DateUtils,
uDictionary;
type
TQueryReturn=record
Succeed:Boolean;
SQL:string;
end;
TfrmLiveMarrowQuery = class(TForm)
Label4: TLabel;
dtpStart: TDateTimePicker;
Label1: TLabel;
dtpEnd: TDateTimePicker;
GroupBox4: TGroupBox;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label19: TLabel;
edtCaseCode: TEdit;
edtName: TEdit;
edtSicknessBed: TEdit;
cboDepartment: TComboBox;
cboSex: TComboBox;
cboDiagnosis: TComboBox;
cboSicknessSection: TComboBox;
cboOutOrIn: TComboBox;
GroupBox5: TGroupBox;
Label14: TLabel;
Label16: TLabel;
Label18: TLabel;
Label23: TLabel;
Label24: TLabel;
Label13: TLabel;
cboSampleSource: TComboBox;
cboSendDoctor: TComboBox;
cboTestDoctor: TComboBox;
edtTestNo: TEdit;
btnQuery: TButton;
btnReset: TButton;
btnClose: TButton;
memReport: TMemo;
procedure FormCreate(Sender: TObject);
procedure btnQueryClick(Sender: TObject);
procedure btnResetClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure cboDepartmentExit(Sender: TObject);
procedure cboSicknessSectionExit(Sender: TObject);
procedure cboDiagnosisExit(Sender: TObject);
procedure cboSendDoctorExit(Sender: TObject);
procedure cboTestDoctorExit(Sender: TObject);
private
FQueryReturn:TQueryReturn;
FADOQuery:TADOQuery;
//產(chǎn)生SQL語句
procedure ProductSQL;
procedure InitialQuery;
procedure LookUpByName(cobItem: TComboBox;Dictionary: TDictionary);
public
//以下為字典對(duì)象
TestDoctor:TDictionary;
SicknessSection:TDictionary;
Diagnostic:TDictionary;
Department:TDictionary;
SendDoctor:TDictionary;
procedure LoadDictionary;
property QueryReturn:TQueryReturn read FQueryReturn;
end;
var
frmLiveMarrowQuery: TfrmLiveMarrowQuery;
implementation
{$R *.dfm}
{ TfrmLiveMarrowQuery }
procedure TfrmLiveMarrowQuery.InitialQuery;
var
i:Integer;
begin
for i:=0 to Self.ComponentCount-1 do
begin
if Self.Components[i] is TComboBox then
begin
TComboBox(Self.Components[i]).Text:='';
end;
if Self.Components[i] is TEdit then
begin
TEdit(Self.Components[i]).Text:='';
end;
if Self.Components[i] is TMemo then
begin
TMemo(Self.Components[i]).Text:='';
end;
end;
//默認(rèn)為住院
cboOutOrIn.ItemIndex:=1;
dtpEnd.Date:=Today;
dtpStart.Date:=IncMonth(Today,-5);
end;
procedure TfrmLiveMarrowQuery.LoadDictionary;
begin
Department.LoadAllDictionNames(cboDepartment.Items);
SicknessSection.LoadAllDictionNames(cboSicknessSection.Items);
Diagnostic.LoadAllDictionNames(cboDiagnosis.Items);
TestDoctor.LoadAllDictionNames(cboTestDoctor.Items);
SendDoctor.LoadAllDictionNames(cboSendDoctor.Items);
end;
procedure TfrmLiveMarrowQuery.LookUpByName(cobItem: TComboBox;
Dictionary: TDictionary);
var
tem:string;
begin
if cobItem.Items.IndexOf(Trim(cobItem.Text))>-1 then Exit;
tem:=Trim(Dictionary.FindNameByCode(Trim(cobItem.Text)));
if tem='' then Exit;
cobItem.Text:=tem;
end;
procedure TfrmLiveMarrowQuery.ProductSQL;
var
sql:string;
procedure GetSQL(sText:string;sFieldName:string);
begin
if Trim(sText)<>'' then
begin
sql:=sql+' and ('+sFieldName+'='+QuotedStr(Trim(sText))+')';
end;
end;
begin
FQueryReturn.SQL:='';
FQueryReturn.Succeed:=False;
//日期
SQL:='(TestDate>=#%s#) and (TestDate<=#%s#)';
SQL:=Format(SQL,[DateToStr(dtpStart.Date),DateToStr(dtpEnd.Date)]);
GetSQL(edtCaseCode.Text,'PatientCode');
if Trim(edtName.Text)<>'' then
begin
sql:=sql+' and (PatientName like '+QuotedStr(Trim(edtName.Text))+')';
end;
GetSQL(cboSex.Text,'Sex');
GetSQL(cboSicknessSection.Text,'SickSection');
GetSQL(cboDepartment.Text,'Department');
GetSQL(edtSicknessBed.Text,'BedCode');
GetSQL(cboDiagnosis.Text,'Diagnositic');
GetSQL(edtTestNo.Text,'TestNumber');
GetSQL(cboSampleSource.Text,'SampleSource');
GetSQL(cboSendDoctor.Text,'SendDoctor');
GetSQL(cboTestDoctor.Text,'TestDoctor');
GetSQL(memReport.Text,'ReportMemo');
FQueryReturn.SQL:=sql;
try
if FADOQuery.Active then FADOQuery.Active:=False;
FADOQuery.SQL.Text:='select count(*) as QueryCount from LIVING_MARROW_PATIENT where '+sql;
FADOQuery.Active:=True;
FQueryReturn.Succeed:=TBasoUtils.GetDataFromField(FADOQuery,'QueryCount',0)>=1;
finally
if FADOQuery.Active then FADOQuery.Active:=False;
end;
end;
procedure TfrmLiveMarrowQuery.FormCreate(Sender: TObject);
begin
FADOQuery:=TADOQuery.Create(Self);
FADOQuery.Connection:=GlobalConnection.Connection;
FQueryReturn.SQL:='';
FQueryReturn.Succeed:=False;
InitialQuery;
end;
procedure TfrmLiveMarrowQuery.btnQueryClick(Sender: TObject);
begin
Screen.Cursor:=crHourGlass;
try
ProductSQL;
finally
Screen.Cursor:=crDefault;
end;
if FQueryReturn.Succeed then
begin
Close;
end else
begin
if TBasoUtils.SysMessage('未查詢到符合條件的檢驗(yàn)報(bào)告,是否重新查詢?',YESNO+QUST)=NO then
begin
Close;
end else
begin
edtCaseCode.SetFocus;
end;
end;
end;
procedure TfrmLiveMarrowQuery.btnResetClick(Sender: TObject);
begin
InitialQuery;
edtCaseCode.SetFocus;
end;
procedure TfrmLiveMarrowQuery.btnCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmLiveMarrowQuery.cboDepartmentExit(Sender: TObject);
begin
LookUpByName(cboDepartment,Department);
end;
procedure TfrmLiveMarrowQuery.cboSicknessSectionExit(Sender: TObject);
begin
LookUpByName(cboSicknessSection,SicknessSection);
end;
procedure TfrmLiveMarrowQuery.cboDiagnosisExit(Sender: TObject);
begin
LookUpByName(cboDiagnosis,Diagnostic);
end;
procedure TfrmLiveMarrowQuery.cboSendDoctorExit(Sender: TObject);
begin
LookUpByName(cboSendDoctor,SendDoctor);
end;
procedure TfrmLiveMarrowQuery.cboTestDoctorExit(Sender: TObject);
begin
LookUpByName(cboTestDoctor,TestDoctor);
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -