unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxGraphics, ComCtrls, StdCtrls, cxControls, cxContainer, cxEdit,
cxTextEdit, cxMaskEdit, cxDropDownEdit;
type
TForm8 = class(TForm)
Label1: TLabel;
cxComboBox1: TcxComboBox;
Button1: TButton;
pg: TProgressBar;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
var tc1,tc2,tc3:tclientdataset; dc:string;
begin
if cxcombobox1.text='' then exit;
dc:=vartostr(getsqldata('select code from doctor where name = "'+cxcombobox1.text+'"'));
tc1:=tclientdataset.create(nil);
tc2:=tclientdataset.create(nil);
tc3:=tclientdataset.create(nil);
tc1.data:=hosxp_getdataset('select code from doctor where name <> "'+cxcombobox1.text+'"');
tc2.data:=hosxp_getdataset('select * from pe_template where doctor = "'+dc+'"');
pg.min:=0;
pg.max:=tc2.recordcount;
pg.position:=0;
while not tc2.eof do
begin
pg.position:=pg.position+1;
tc1.first;
while not tc1.eof do
begin
tc3.data:=hosxp_getdataset('select * from pe_template where doctor="'+
tc1.fieldbyname('code').asstring+'" and pe_name="'+tc2.fieldbyname('pe_name').asstring+'"');
if tc3.recordcount=0 then
begin
tc3.append;
tc3.fieldbyname('pe_temp_id').asinteger:=
getserialnumber('pe_temp_id');
end else
begin
tc3.edit;
end;
tc3.fieldbyname('doctor').asstring:=tc1.fieldbyname('code').asstring;
tc3.fieldbyname('pe_name').asstring:=tc2.fieldbyname('pe_name').asstring;
tc3.fieldbyname('pe_text').asstring:=tc2.fieldbyname('pe_text').asstring;
// tc3.fieldbyname('icd_order').asinteger:=tc2.fieldbyname('icd_order').asinteger;
tc3.post;
if tc3.changecount>0 then hosxp_updatedelta(tc3.delta,'select * from pe_template where doctor="'+
tc1.fieldbyname('code').asstring+'" and pe_name="'+tc2.fieldbyname('pe_name').asstring+'"');
tc1.next;
end;
tc2.next;
end;
end;
procedure TForm8.FormShow(Sender: TObject);
var tc:tclientdataset;
begin
tc:=tclientdataset.create(nil);
tc.data:=hosxp_getdataset('select name from doctor order by name');
while not tc.eof do
begin
cxcombobox1.properties.items.add(tc.fieldbyname('name').asstring);
tc.next;
end;
tc.free;
end;
end.