主题:哪位好心的大侠能帮小弟翻译一下,代码的大致意思
unit uMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, ImgList, ExtCtrls, StdCtrls, Buttons, DB,
DBClient, MConnect, Grids, DBGrids, ADODB, IniFiles;
type
TFormMain = class(TForm)
ImageList1: TImageList;
ToolBar1: TToolBar;
ToolButtonCheckPatInfo: TToolButton;
ToolButton2: TToolButton;
ToolButtonExit: TToolButton;
ToolButton4: TToolButton;
Panel1: TPanel;
EditCardno: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
EditName: TEdit;
EditSex: TEdit;
EditBirth: TEdit;
Label5: TLabel;
ComboBoxKs: TComboBox;
BitBtnGh: TBitBtn;
GroupBox1: TGroupBox;
DBGridGhList: TDBGrid;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
dsGhlist: TDataSource;
ADODataSetGhlist: TADODataSet;
StatusGhInfo: TStatusBar;
Label6: TLabel;
ComboBoxYs: TComboBox;
RadioGroupklx: TRadioGroup;
Label1: TLabel;
EditPhone: TEdit;
Panel2: TPanel;
EditQryCardno: TEdit;
Label8: TLabel;
DateTimeGhksrq: TDateTimePicker;
DateTimeGhjsrq: TDateTimePicker;
BitBtnQry: TBitBtn;
Label9: TLabel;
BitBtnGhzf: TBitBtn;
ToolButtonTj: TToolButton;
ToolButton3: TToolButton;
CheckBoxCardno: TCheckBox;
CheckBoxName: TCheckBox;
CheckBoxKs: TCheckBox;
CheckBoxYs: TCheckBox;
EditQryName: TEdit;
ComboBoxQryKs: TComboBox;
ComboBoxQryYs: TComboBox;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure EditCardnoKeyPress(Sender: TObject; var Key: Char);
procedure ComboBoxKsKeyPress(Sender: TObject; var Key: Char);
procedure BitBtnGhClick(Sender: TObject);
procedure ToolButtonCheckPatInfoClick(Sender: TObject);
procedure ToolButtonExitClick(Sender: TObject);
procedure ComboBoxYsKeyPress(Sender: TObject; var Key: Char);
procedure BitBtnQryClick(Sender: TObject);
procedure BitBtnGhzfClick(Sender: TObject);
procedure ToolButtonTjClick(Sender: TObject);
procedure EditQryCardnoChange(Sender: TObject);
procedure CheckBoxCardnoClick(Sender: TObject);
procedure CheckBoxNameClick(Sender: TObject);
procedure CheckBoxKsClick(Sender: TObject);
procedure CheckBoxYsClick(Sender: TObject);
private
{ Private declarations }
m_isconnected : boolean;
m_patid : string;
//取数据库配置信息
procedure ConnectDataBase;
//清空数据
procedure ClearControls;
//刷新挂号列表数据
procedure RefreshGhlist;
//初始化下拉列表数据
procedure InitialComboBox;
//通过卡号取病人信息
function CheckCardno(cardno: string; patid: string): Boolean;
function getval(combobox:Tcombobox; valuetype: integer):string;
public
{ Public declarations }
end;
var
FormMain: TFormMain;
implementation
uses
uPatinfo,uWorkStatistic;
{$R *.dfm}
procedure TFormMain.FormCreate(Sender: TObject);
begin
//取数据库配置信息
ConnectDataBase;
end;
procedure TFormMain.FormShow(Sender: TObject);
begin
//取科室、医生信息
InitialComboBox;
DateTimeGhksrq.DateTime := Now;
DateTimeGhjsrq.DateTime := Now;
//取当天已挂号信息
RefreshGhlist;
EditCardno.SetFocus;
end;
procedure TFormMain.ConnectDataBase;
var
MyIniFile :TIniFile;
strServer,strDb,strUsrid,strPsd: string;
errmsg: string;
begin
MyIniFile := TIniFile.Create(extractfilepath(Application.ExeName) + 'ghsettings.ini');
strServer := MyIniFile.ReadString('center', 'server', '');
strDb := MyIniFile.ReadString('center', 'database', '');
strUsrid := MyIniFile.ReadString('center', 'usrid', '');
strPsd := MyIniFile.ReadString('center', 'password', '');
ADOConnection1.Connected := false;
ADOConnection1.ConnectionString := 'Provider=SQLOLEDB.1;Password='+strPsd+';Persist Security Info=True;User ID='+strUsrid+
';Initial Catalog='+strDb+';Data Source='+strServer;
try
ADOConnection1.Connected := True;
except
on e:exception do
begin
errmsg:='连接数据库失败!'+e.Message;
showmessage(errmsg);
exit;
end;
end;
if not ADOConnection1.Connected then
begin
showmessage('连接数据库失败!');
exit;
end;
m_isconnected := true;
end;
function TFormMain.CheckCardno(cardno: string; patid: string): Boolean;
var
strsql : string;
errmsg : string;
begin
Result := false;
strsql := 'select patid,cardno,blh,hzxm,birthday,sex,memo,phone,addr from gh_brxxk(nolock) ';
if cardno <> '' then
strsql := strsql + ' where cardno=''' + cardno + ''' and cardtype = ' + inttostr(RadioGroupklx.ItemIndex)
else
strsql := strsql + ' where patid=' + patid;
ADOQuery1.Active := false;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(strsql);
try
ADOQuery1.Active := true;
except
on e:exception do
begin
errmsg:=e.Message;
showmessage(errmsg);
exit;
end;
end;
if ADOQuery1.RecordCount = 0 then exit;
m_patid := ADOQuery1.FieldByName('patid').AsString;
EditCardno.Text := ADOQuery1.FieldByName('cardno').AsString;
EditName.Text := ADOQuery1.FieldByName('hzxm').AsString;
EditSex.Text := ADOQuery1.FieldByName('sex').AsString;
EditBirth.Text := ADOQuery1.FieldByName('birthday').AsString;
EditPhone.Text := ADOQuery1.FieldByName('phone').AsString;
Result := true;
end;
procedure TFormMain.RefreshGhlist;
var
strsql, errmsg: string;
begin
strsql := ' select xh, patid, blh 病历号, cardno 卡号, case cardtype when 0 then ''自费卡'' when 1 then ''医保卡'' else '''' end 卡类型,'
+ ' hzxm 姓名, ksmc 科室, ysmc 医生, ghhx 号序, ghrq 挂号时间 from gh_ghdjk where jlzt=0 '; //5-
strsql := strsql + ' and ghrq >= ''' + FormatDateTime('yyyy-mm-dd', DateTimeGhksrq.Date)
+ ''' and ghrq <= ''' + FormatDateTime('yyyy-mm-dd', DateTimeGhjsrq.Date) + '3''';
if CheckBoxCardno.Checked then
strsql := strsql + ' and cardno like ''' + Trim(EditQryCardno.Text) + '%''';
if CheckBoxName.Checked then
strsql := strsql + ' and hzxm like ''%' + Trim(EditQryName.Text) + '%''';
if CheckBoxKs.Checked then
strsql := strsql + ' and ksdm=''' + getval(ComboBoxQryKs, 1) + '''';
if CheckBoxYs.Checked then
strsql := strsql + ' and ysdm=''' + getval(ComboBoxQryYs, 1) + '''';
ADODataSetGhlist.Active := false;
ADODataSetGhlist.CommandText := strsql;
try
ADODataSetGhlist.Active := true;
except
on e:exception do
begin
errmsg:=e.Message;
showmessage(errmsg);
exit;
end;
end;
DBGridGhlist.Columns[0].Visible := false;
DBGridGhlist.Columns[1].Visible := false;
DBGridGhlist.Columns[2].Width := 80;
DBGridGhlist.Columns[3].Width := 80;
DBGridGhlist.Columns[4].Width := 60;
DBGridGhlist.Columns[5].Width := 70;
DBGridGhlist.Columns[6].Width := 80;
DBGridGhlist.Columns[7].Width := 70;
DBGridGhlist.Columns[8].Width := 50;
DBGridGhlist.Columns[9].Width := 130;
StatusGhInfo.Panels[1].Text := '挂号人次:' + IntToStr(ADODataSetGhlist.RecordCount);
end;
procedure TFormMain.InitialComboBox;
var
strsql, errmsg: string;
begin
strsql := 'select ksdm,ksmc from yy_ksdmk ';
ADOQuery1.Active := false;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(strsql);
try
ADOQuery1.Active := true;
except
on e:exception do
begin
errmsg:=e.Message;
showmessage(errmsg);
exit;
end;
end;
ComboBoxKs.Items.Clear;
ComboBoxQryKs.Items.Clear;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
ComboBoxKs.Items.Add(ADOQuery1.FieldByName('ksdm').AsString + '-' + ADOQuery1.FieldByName('ksmc').AsString);
ComboBoxQryKs.Items.Add(ADOQuery1.FieldByName('ksdm').AsString + '-' + ADOQuery1.FieldByName('ksmc').AsString);
ADOQuery1.Next;
end;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, ImgList, ExtCtrls, StdCtrls, Buttons, DB,
DBClient, MConnect, Grids, DBGrids, ADODB, IniFiles;
type
TFormMain = class(TForm)
ImageList1: TImageList;
ToolBar1: TToolBar;
ToolButtonCheckPatInfo: TToolButton;
ToolButton2: TToolButton;
ToolButtonExit: TToolButton;
ToolButton4: TToolButton;
Panel1: TPanel;
EditCardno: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
EditName: TEdit;
EditSex: TEdit;
EditBirth: TEdit;
Label5: TLabel;
ComboBoxKs: TComboBox;
BitBtnGh: TBitBtn;
GroupBox1: TGroupBox;
DBGridGhList: TDBGrid;
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
dsGhlist: TDataSource;
ADODataSetGhlist: TADODataSet;
StatusGhInfo: TStatusBar;
Label6: TLabel;
ComboBoxYs: TComboBox;
RadioGroupklx: TRadioGroup;
Label1: TLabel;
EditPhone: TEdit;
Panel2: TPanel;
EditQryCardno: TEdit;
Label8: TLabel;
DateTimeGhksrq: TDateTimePicker;
DateTimeGhjsrq: TDateTimePicker;
BitBtnQry: TBitBtn;
Label9: TLabel;
BitBtnGhzf: TBitBtn;
ToolButtonTj: TToolButton;
ToolButton3: TToolButton;
CheckBoxCardno: TCheckBox;
CheckBoxName: TCheckBox;
CheckBoxKs: TCheckBox;
CheckBoxYs: TCheckBox;
EditQryName: TEdit;
ComboBoxQryKs: TComboBox;
ComboBoxQryYs: TComboBox;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure EditCardnoKeyPress(Sender: TObject; var Key: Char);
procedure ComboBoxKsKeyPress(Sender: TObject; var Key: Char);
procedure BitBtnGhClick(Sender: TObject);
procedure ToolButtonCheckPatInfoClick(Sender: TObject);
procedure ToolButtonExitClick(Sender: TObject);
procedure ComboBoxYsKeyPress(Sender: TObject; var Key: Char);
procedure BitBtnQryClick(Sender: TObject);
procedure BitBtnGhzfClick(Sender: TObject);
procedure ToolButtonTjClick(Sender: TObject);
procedure EditQryCardnoChange(Sender: TObject);
procedure CheckBoxCardnoClick(Sender: TObject);
procedure CheckBoxNameClick(Sender: TObject);
procedure CheckBoxKsClick(Sender: TObject);
procedure CheckBoxYsClick(Sender: TObject);
private
{ Private declarations }
m_isconnected : boolean;
m_patid : string;
//取数据库配置信息
procedure ConnectDataBase;
//清空数据
procedure ClearControls;
//刷新挂号列表数据
procedure RefreshGhlist;
//初始化下拉列表数据
procedure InitialComboBox;
//通过卡号取病人信息
function CheckCardno(cardno: string; patid: string): Boolean;
function getval(combobox:Tcombobox; valuetype: integer):string;
public
{ Public declarations }
end;
var
FormMain: TFormMain;
implementation
uses
uPatinfo,uWorkStatistic;
{$R *.dfm}
procedure TFormMain.FormCreate(Sender: TObject);
begin
//取数据库配置信息
ConnectDataBase;
end;
procedure TFormMain.FormShow(Sender: TObject);
begin
//取科室、医生信息
InitialComboBox;
DateTimeGhksrq.DateTime := Now;
DateTimeGhjsrq.DateTime := Now;
//取当天已挂号信息
RefreshGhlist;
EditCardno.SetFocus;
end;
procedure TFormMain.ConnectDataBase;
var
MyIniFile :TIniFile;
strServer,strDb,strUsrid,strPsd: string;
errmsg: string;
begin
MyIniFile := TIniFile.Create(extractfilepath(Application.ExeName) + 'ghsettings.ini');
strServer := MyIniFile.ReadString('center', 'server', '');
strDb := MyIniFile.ReadString('center', 'database', '');
strUsrid := MyIniFile.ReadString('center', 'usrid', '');
strPsd := MyIniFile.ReadString('center', 'password', '');
ADOConnection1.Connected := false;
ADOConnection1.ConnectionString := 'Provider=SQLOLEDB.1;Password='+strPsd+';Persist Security Info=True;User ID='+strUsrid+
';Initial Catalog='+strDb+';Data Source='+strServer;
try
ADOConnection1.Connected := True;
except
on e:exception do
begin
errmsg:='连接数据库失败!'+e.Message;
showmessage(errmsg);
exit;
end;
end;
if not ADOConnection1.Connected then
begin
showmessage('连接数据库失败!');
exit;
end;
m_isconnected := true;
end;
function TFormMain.CheckCardno(cardno: string; patid: string): Boolean;
var
strsql : string;
errmsg : string;
begin
Result := false;
strsql := 'select patid,cardno,blh,hzxm,birthday,sex,memo,phone,addr from gh_brxxk(nolock) ';
if cardno <> '' then
strsql := strsql + ' where cardno=''' + cardno + ''' and cardtype = ' + inttostr(RadioGroupklx.ItemIndex)
else
strsql := strsql + ' where patid=' + patid;
ADOQuery1.Active := false;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(strsql);
try
ADOQuery1.Active := true;
except
on e:exception do
begin
errmsg:=e.Message;
showmessage(errmsg);
exit;
end;
end;
if ADOQuery1.RecordCount = 0 then exit;
m_patid := ADOQuery1.FieldByName('patid').AsString;
EditCardno.Text := ADOQuery1.FieldByName('cardno').AsString;
EditName.Text := ADOQuery1.FieldByName('hzxm').AsString;
EditSex.Text := ADOQuery1.FieldByName('sex').AsString;
EditBirth.Text := ADOQuery1.FieldByName('birthday').AsString;
EditPhone.Text := ADOQuery1.FieldByName('phone').AsString;
Result := true;
end;
procedure TFormMain.RefreshGhlist;
var
strsql, errmsg: string;
begin
strsql := ' select xh, patid, blh 病历号, cardno 卡号, case cardtype when 0 then ''自费卡'' when 1 then ''医保卡'' else '''' end 卡类型,'
+ ' hzxm 姓名, ksmc 科室, ysmc 医生, ghhx 号序, ghrq 挂号时间 from gh_ghdjk where jlzt=0 '; //5-
strsql := strsql + ' and ghrq >= ''' + FormatDateTime('yyyy-mm-dd', DateTimeGhksrq.Date)
+ ''' and ghrq <= ''' + FormatDateTime('yyyy-mm-dd', DateTimeGhjsrq.Date) + '3''';
if CheckBoxCardno.Checked then
strsql := strsql + ' and cardno like ''' + Trim(EditQryCardno.Text) + '%''';
if CheckBoxName.Checked then
strsql := strsql + ' and hzxm like ''%' + Trim(EditQryName.Text) + '%''';
if CheckBoxKs.Checked then
strsql := strsql + ' and ksdm=''' + getval(ComboBoxQryKs, 1) + '''';
if CheckBoxYs.Checked then
strsql := strsql + ' and ysdm=''' + getval(ComboBoxQryYs, 1) + '''';
ADODataSetGhlist.Active := false;
ADODataSetGhlist.CommandText := strsql;
try
ADODataSetGhlist.Active := true;
except
on e:exception do
begin
errmsg:=e.Message;
showmessage(errmsg);
exit;
end;
end;
DBGridGhlist.Columns[0].Visible := false;
DBGridGhlist.Columns[1].Visible := false;
DBGridGhlist.Columns[2].Width := 80;
DBGridGhlist.Columns[3].Width := 80;
DBGridGhlist.Columns[4].Width := 60;
DBGridGhlist.Columns[5].Width := 70;
DBGridGhlist.Columns[6].Width := 80;
DBGridGhlist.Columns[7].Width := 70;
DBGridGhlist.Columns[8].Width := 50;
DBGridGhlist.Columns[9].Width := 130;
StatusGhInfo.Panels[1].Text := '挂号人次:' + IntToStr(ADODataSetGhlist.RecordCount);
end;
procedure TFormMain.InitialComboBox;
var
strsql, errmsg: string;
begin
strsql := 'select ksdm,ksmc from yy_ksdmk ';
ADOQuery1.Active := false;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add(strsql);
try
ADOQuery1.Active := true;
except
on e:exception do
begin
errmsg:=e.Message;
showmessage(errmsg);
exit;
end;
end;
ComboBoxKs.Items.Clear;
ComboBoxQryKs.Items.Clear;
ADOQuery1.First;
while not ADOQuery1.Eof do
begin
ComboBoxKs.Items.Add(ADOQuery1.FieldByName('ksdm').AsString + '-' + ADOQuery1.FieldByName('ksmc').AsString);
ComboBoxQryKs.Items.Add(ADOQuery1.FieldByName('ksdm').AsString + '-' + ADOQuery1.FieldByName('ksmc').AsString);
ADOQuery1.Next;
end;