我有一个epson-300k的针式打印机程序.医院的
给你
procedure Tw_xs_cf.PrintBill;
var
position:array[0..2,0..2] of integer;
Lhigh,Rhigh,Lwidth,Rwidth : integer ;
X,Y : integer ;
Flag :integer ;
begin
if printer.Printers.Count = 0 then
begin
showmessage('请接入打印机之后按确定键!');
exit;
end;
position[0,0] := 260 ;//宽;
position[0,1] := 140 ;
position[1,0] := 880 ;//宽;
position[1,1] := 150 ;
position[2,0] := 1358 ;//宽;
position[2,1] := 99 ;
Lhigh := 45 ;
Lwidth := 330 ;
Rhigh := 30 ;
Rwidth := 100 ;
//设置流水号和初始位置;
if printer.Canvas.Font.Size<>9 then
printer.Canvas.Font.Size := 9;
printer.Canvas.Font.Name:= '宋体';
printer.Canvas.Font.Charset := GB2312_CHARSET;
{ DecodeDate(date,year,month,day);
monthstr:=FloatToStr(month);
daystr:=FloatToStr(day);
if length(monthstr)=1 then
monthstr := '0'+monthstr ;
if length(daystr)=1 then
daystr := '0'+daystr ;
LSH := FloatToStr(year)+monthstr+daystr;
if LSHnum=0 then
begin
if adqBill.Active then
adqBill.Close ;
SQLSTR:='select count(*) as NUM from Tselm150 '
+' where (CWCBJ='+inttostr(1)+' or CWCBJ='+inttostr(2)
+') and to_char(DHJRQ) = '
+ QuotedStr(PublicFunction.GetStrDate(FloatToStr(year)+'-'+monthstr+'-'+daystr));
adqBill.SQL.Clear ;
adqBill.SQL.Add(SQLSTR);
adqBill.Open ;
if adqBill.FieldByName('NUM').asinteger >0 then
LSHnum := adqBill.FieldByName('NUM').asinteger - 1 ;
end;
LSHnum := LSHnum +1 ;
if length(inttostr(LSHnum))=1 then
LSH := LSH +'00'+inttostr(LSHnum) ;
if length(inttostr(LSHnum))=2 then
LSH := LSH +'0'+inttostr(LSHnum) ;
if length(inttostr(LSHnum))=3 then
LSH := LSH +inttostr(LSHnum) ;
if (length(inttostr(LSHnum))>3) or (length(inttostr(LSHnum))<1) then
begin
showmessage('打印的门诊收据数量太大,请与管理员联系!');
Exit ;
end;
}
X := position[0,0] ;
Y := position[0,1] ;
///////////////////////////////////////////////////////////////////////
//打印;
///////////////////////////////////////////////////////////////////////
adsMasterData.DisableControls ;
adsClientData.DisableControls ;
printer.begin
Doc ;
// 1)打印主表内容;
with printer.Canvasdo
begin
TextOut(X,Y,adsMasterData.FieldByName('SXM').asstring) ;
X := X + Lwidth ;
TextOut(X,Y,adsMasterData.FieldByName('CCFBH').asstring);
X := X - Lwidth ;
Y := Y + Lhigh ;
TextOut(X,Y,adsMasterData.FieldByName('CKHBM').asstring);
Y := Y + Lhigh ;
TextOut(X,Y,adsMasterData.FieldByName('NXYF').asstring);
X := X + Lwidth ;
TextOut(X,Y,adsMasterData.FieldByName('NZLF').asstring);
X := X - Lwidth ;
Y := Y + Lhigh ;
TextOut(X,Y,adsMasterData.FieldByName('NZYF').asstring);
X := X + Lwidth ;
TextOut(X,Y,adsMasterData.FieldByName('NSSF').asstring);
X := X - Lwidth ;
Y := Y + Lhigh ;
TextOut(X,Y,adsMasterData.FieldByName('NJCF').asstring);
X := X + Lwidth ;
TextOut(X,Y,adsMasterData.FieldByName('NCLF').asstring);
X := X - Lwidth ;
Y := Y + Lhigh ;
TextOut(X,Y,adsMasterData.FieldByName('NFSF').asstring);
X := X + Lwidth ;
TextOut(X,Y,adsMasterData.FieldByName('NZCF').asstring);
X := X - Lwidth ;
Y := Y + Lhigh ;
TextOut(X,Y,adsMasterData.FieldByName('NHYF').asstring);
X := X + Lwidth ;
TextOut(X,Y,adsMasterData.FieldByName('NQTF').asstring);
X := X - Lwidth ;
Y := Y + Lhigh ;
TextOut(X,Y,adsmasterData.FieldByName('NCFZE').asstring);
Y := Y + Lhigh ;
TextOut(X,Y,adsMasterData.FieldByName('NSFZE').asstring);
Y := Y + Lhigh ;
TextOut(X,Y,adsMasterData.FieldByName('SBZ').asstring);
Y := Y + Lhigh ;
TextOut(X-54,Y+7,dateToStr(date));
X := X + Lwidth ;
TextOut(X-54,Y+7,Login.LoginForm.ps_UserNa);
end;
//2)打印收费明细单;
X := position[1,0] ;
Y := position[1,1] ;
printer.Canvas.TextOut(X+60,Y-57,adsMasterdata.FieldByName('SXM').asstring);
printer.Canvas.TextOut(X,Y,'药品名称');
printer.Canvas.TextOut(X+180,Y,'数量');
printer.Canvas.TextOut(X+250,Y,'金额');
with adsClientData do
begin
first ;
while not eofdo
begin
with printer.Canvasdo
begin
Y := Y +30 ;
TextOut(X,Y,FieldByName('SWLMC').asstring);
TextOut(X+180,Y,FieldByName('NSL').asstring);
TextOut(X+250,Y,Trim(format('%8.2f',[FieldByName('NSL').asFloat*FieldByName('NXSJG').asFloat])));
end;
if Y > printer.PageHeight-120 then
begin
printer.NewPage ;
X := position[1,0] ;
Y := position[1,1] ;
printer.Canvas.TextOut(X+50,Y-65,adsMasterdata.FieldByName('SXM').asstring);
printer.Canvas.TextOut(X,Y,'药品名称');
printer.Canvas.TextOut(X+180,Y,'数量');
printer.Canvas.TextOut(X+250,Y,'金额');
end;
Next ;
end;
end;
//3)打印内部核算联;
X := position[2,0] ;
Y := position[2,1] ;
flag := 0 ;
with adsClientDatado
begin
first ;
while not eofdo
begin
if FieldByName('CXNJ').asstring = 'Y' then
begin
inc(flag);
if ((Flag mod 2)<>0) and (Flag <> 1) then
begin
printer.NewPage ;
X := position[2,0] ;
Y := position[2,1]+13 ;
end;
if (Flag mod 2) = 0 then
Y := Y + 147 ;//两页间隔;
with printer.Canvasdo
begin
TextOut(X,Y,adsMasterData.FieldByName('SXM').asstring);
Y :=Y + 46 ;
TextOut(X,Y,FieldByName('SWLMC').asstring);
Y :=Y + 46 ;
TextOut(X,Y,Trim(format('%8.2f',[FieldByName('NSL').asFloat*FieldByName('NXSJG').asFloat])));
Y :=Y + 46 ;
TextOut(X,Y,Login.LoginForm.ps_UserNa);
Y :=Y + 46 ;
TextOut(X,Y,DateToStr(Date));
end;
end ;
Next ;
end;
end;
//4)输入到打印机;
printer.EndDoc ;
adsMasterData.EnableControls ;
adsClientData.EnableControls ;
printer.begin
Doc ;
printer.NewPage ;
printer.EndDoc ;
if not(adsMasterData.State in [dsEdit,dsInsert]) then
adsMasterData.Edit ;
adsMasterData.FieldByName('CDY').asstring := 'Y' ;
adsMasterData.Post;
end;