哥哥让我帮他写个足彩投注单打印程序。数据源是文本文件,每行一个单注
3101030300310
3333111100003
3333333333333
1111111111111
0000000000000
......
生成的投注单不是直接打印文本,而是根据文本打印图形。投注单是这样的:每单有5栏,每栏有13行3列共39个打印位置。投注单纵向送入打印机,打印机根据每注的13场的结果而涂黑相应位置,就像标准化答题卡那样。每页打印5注。
我的实现方法是这样的:在QReport报表加入39个QRShape控件,分布位置见下图。把投注文本导入ADOQuery1中,然后打印ADOQuery1中的数据。需要涂黑的位置用类似这样的代码实现涂黑:QRShape1.Pen.Color:=clBlack;
实际的投注单的涂黑位置是像标准化答题卡那样细长形的,所以只能用图形形式打印,而不能用我下面给出的示例那样用全角字符■□来表示。实际打印时只需要打印涂黑位置即可,我为了说明问题而加注的1-13,1-3得数字和第X栏的文字不用打印。-----------------------------
13121110 9 8 7 6 5 4 3 2 1 QReport报表控件摆放位置示意图
□□■□□■□■□□□□■ 3 QRShape13 QRShape12 ... QRShape1
□■□□□□□□□■□■□ 1 第一栏 QRShape26 QRShape25 ... QRShape14
■□□■■□■□■□■□□ 0 QRShape39 QRShape38 ... QRShape27
-----------------------------
13121110 9 8 7 6 5 4 3 2 1
■□□□□□□□□■■■■ 3
□□□□□■■■■□□□□ 1 第二栏
□■■■■□□□□□□□□ 0
-----------------------------
13121110 9 8 7 6 5 4 3 2 1
■■■■■■■■■■■■■ 3
□□□□□□□□□□□□□ 1 第三栏
□□□□□□□□□□□□□ 0
-----------------------------
13121110 9 8 7 6 5 4 3 2 1
□□□□□□□□□□□□□ 3
■■■■■■■■■■■■■ 1 第四栏
□□□□□□□□□□□□□ 0
-----------------------------
13121110 9 8 7 6 5 4 3 2 1
□□□□□□□□□□□□□ 3
□□□□□□□□□□□□□ 1 第五栏
■■■■■■■■■■■■■ 0
-----------------------------
3101030300310
3333111100003
3333333333333
1111111111111
0000000000000
......
生成的投注单不是直接打印文本,而是根据文本打印图形。投注单是这样的:每单有5栏,每栏有13行3列共39个打印位置。投注单纵向送入打印机,打印机根据每注的13场的结果而涂黑相应位置,就像标准化答题卡那样。每页打印5注。
我的实现方法是这样的:在QReport报表加入39个QRShape控件,分布位置见下图。把投注文本导入ADOQuery1中,然后打印ADOQuery1中的数据。需要涂黑的位置用类似这样的代码实现涂黑:QRShape1.Pen.Color:=clBlack;
实际的投注单的涂黑位置是像标准化答题卡那样细长形的,所以只能用图形形式打印,而不能用我下面给出的示例那样用全角字符■□来表示。实际打印时只需要打印涂黑位置即可,我为了说明问题而加注的1-13,1-3得数字和第X栏的文字不用打印。-----------------------------
13121110 9 8 7 6 5 4 3 2 1 QReport报表控件摆放位置示意图
□□■□□■□■□□□□■ 3 QRShape13 QRShape12 ... QRShape1
□■□□□□□□□■□■□ 1 第一栏 QRShape26 QRShape25 ... QRShape14
■□□■■□■□■□■□□ 0 QRShape39 QRShape38 ... QRShape27
-----------------------------
13121110 9 8 7 6 5 4 3 2 1
■□□□□□□□□■■■■ 3
□□□□□■■■■□□□□ 1 第二栏
□■■■■□□□□□□□□ 0
-----------------------------
13121110 9 8 7 6 5 4 3 2 1
■■■■■■■■■■■■■ 3
□□□□□□□□□□□□□ 1 第三栏
□□□□□□□□□□□□□ 0
-----------------------------
13121110 9 8 7 6 5 4 3 2 1
□□□□□□□□□□□□□ 3
■■■■■■■■■■■■■ 1 第四栏
□□□□□□□□□□□□□ 0
-----------------------------
13121110 9 8 7 6 5 4 3 2 1
□□□□□□□□□□□□□ 3
□□□□□□□□□□□□□ 1 第五栏
■■■■■■■■■■■■■ 0
-----------------------------
解决方案 »
- 怎样做不同服务器上数据库查询出的数据集的差集?
- 如何删除DBGridEh当前纪录??? 50分
- 在delphi中怎么实现对SQL的数据库中视图进行插入新的数据
- 怎么通过摄像头,数码相机,扫描仪采集图象并实时显示在Delphi的一个空白Form上并存如数据库? 分不够再加
- 多线程的问题,帮忙
- 我的project做好后发现目录下有很多文件:dfm,ddp,pas等各种窗体文件,但为什么别人的软件就很简单?
- 请问如何将MEMO的背景设置为图片??
- 关于DBGRIDE?
- 用sql语句怎样求出某一个字段值为null值的记录个数?
- 调用dll里模式窗体的问题,高手帮忙
- 请教,我编写的多线程的Sock程序,运行后CPU占用100%。
- 有没有这样的软件??
所以大家可以先到大富翁的以下同样内容的帖子看看。这里的待有人回复后,我在陆续把余下代码贴出来。
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2007621
程序存在一个重大错误:打印出来的投注单每注都是数据集中的最后一注。请问代码错在哪?unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, DB, ADODB;type
TForm1 = class(TForm)
Button1: TButton;
RichEdit1: TRichEdit;
ADOQuery1: TADOQuery;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation
uses Unit2;
{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
SL1:TStringList;
i:integer;
txtline:string;
begin
SL1:=TStringList.Create;
SL1.Add('3101030300310');
SL1.Add('3333111100003');
SL1.Add('3333333333333');
SL1.Add('1111111111111');
SL1.Add('0000000000000');
with ADOQuery1 do
begin
ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+ExtractFilePath(Application.ExeName)+'printset.mdb';
SQL.Clear;
SQL.Add('delete from touzhu');
ExecSQL;
close;
SQL.Clear;
SQL.Add('select line from touzhu');
open;
end; for i:=0 to SL1.Count-1 do
begin
ADOQuery1.Append;
ADOQuery1.Fields[0].Value:=SL1[i];
ADOQuery1.Post;
end; with ADOQuery1.Recordset do
begin
while not Eof do
begin
txtline:=Fields[0].Value;
//第1场
if txtline[1]='3' then
begin
Form2.QRShape1.Pen.Color:=clBlack;
Form2.QRShape14.Pen.Color:=clWhite;
Form2.QRShape27.Pen.Color:=clWhite;
end
else if txtline[1]='1' then
begin
Form2.QRShape14.Pen.Color:=clBlack;
Form2.QRShape1.Pen.Color:=clWhite;
Form2.QRShape27.Pen.Color:=clWhite;
end
else if txtline[1]='0' then
begin
Form2.QRShape27.Pen.Color:=clBlack;
Form2.QRShape1.Pen.Color:=clWhite;
Form2.QRShape14.Pen.Color:=clWhite;
end; //第2场
if txtline[2]='3' then
begin
Form2.QRShape2.Pen.Color:=clBlack;
Form2.QRShape15.Pen.Color:=clWhite;
Form2.QRShape28.Pen.Color:=clWhite;
end
else if txtline[2]='1' then
begin
Form2.QRShape15.Pen.Color:=clBlack;
Form2.QRShape2.Pen.Color:=clWhite;
Form2.QRShape28.Pen.Color:=clWhite;
end
else if txtline[2]='0' then
begin
Form2.QRShape28.Pen.Color:=clBlack;
Form2.QRShape2.Pen.Color:=clWhite;
Form2.QRShape15.Pen.Color:=clWhite;
end; //第3场
if txtline[3]='3' then
begin
Form2.QRShape3.Pen.Color:=clBlack;
Form2.QRShape16.Pen.Color:=clWhite;
Form2.QRShape29.Pen.Color:=clWhite;
end
else if txtline[3]='1' then
begin
Form2.QRShape16.Pen.Color:=clBlack;
Form2.QRShape3.Pen.Color:=clWhite;
Form2.QRShape29.Pen.Color:=clWhite;
end
else if txtline[3]='0' then
begin
Form2.QRShape29.Pen.Color:=clBlack;
Form2.QRShape3.Pen.Color:=clWhite;
Form2.QRShape16.Pen.Color:=clWhite;
end; //第4场
if txtline[4]='3' then
begin
Form2.QRShape4.Pen.Color:=clBlack;
Form2.QRShape17.Pen.Color:=clWhite;
Form2.QRShape30.Pen.Color:=clWhite;
end
else if txtline[4]='1' then
begin
Form2.QRShape17.Pen.Color:=clBlack;
Form2.QRShape4.Pen.Color:=clWhite;
Form2.QRShape30.Pen.Color:=clWhite;
end
else if txtline[4]='0' then
begin
Form2.QRShape30.Pen.Color:=clBlack;
Form2.QRShape4.Pen.Color:=clWhite;
Form2.QRShape17.Pen.Color:=clWhite;
end; //第5场
if txtline[5]='3' then
begin
Form2.QRShape5.Pen.Color:=clBlack;
Form2.QRShape18.Pen.Color:=clWhite;
Form2.QRShape31.Pen.Color:=clWhite;
end
else if txtline[5]='1' then
begin
Form2.QRShape18.Pen.Color:=clBlack;
Form2.QRShape5.Pen.Color:=clWhite;
Form2.QRShape31.Pen.Color:=clWhite;
end
else if txtline[5]='0' then
begin
Form2.QRShape31.Pen.Color:=clBlack;
Form2.QRShape5.Pen.Color:=clWhite;
Form2.QRShape18.Pen.Color:=clWhite;
end; //第6场
if txtline[6]='3' then
begin
Form2.QRShape6.Pen.Color:=clBlack;
Form2.QRShape19.Pen.Color:=clWhite;
Form2.QRShape32.Pen.Color:=clWhite;
end
else if txtline[6]='1' then
begin
Form2.QRShape19.Pen.Color:=clBlack;
Form2.QRShape6.Pen.Color:=clWhite;
Form2.QRShape32.Pen.Color:=clWhite;
end
else if txtline[6]='0' then
begin
Form2.QRShape32.Pen.Color:=clBlack;
Form2.QRShape6.Pen.Color:=clWhite;
Form2.QRShape19.Pen.Color:=clWhite;
end;
if txtline[7]='3' then
begin
Form2.QRShape7.Pen.Color:=clBlack;
Form2.QRShape20.Pen.Color:=clWhite;
Form2.QRShape33.Pen.Color:=clWhite;
end
else if txtline[7]='1' then
begin
Form2.QRShape20.Pen.Color:=clBlack;
Form2.QRShape7.Pen.Color:=clWhite;
Form2.QRShape33.Pen.Color:=clWhite;
end
else if txtline[7]='0' then
begin
Form2.QRShape33.Pen.Color:=clBlack;
Form2.QRShape7.Pen.Color:=clWhite;
Form2.QRShape20.Pen.Color:=clWhite;
end; //第8场
if txtline[8]='3' then
begin
Form2.QRShape8.Pen.Color:=clBlack;
Form2.QRShape21.Pen.Color:=clWhite;
Form2.QRShape34.Pen.Color:=clWhite;
end
else if txtline[8]='1' then
begin
Form2.QRShape21.Pen.Color:=clBlack;
Form2.QRShape8.Pen.Color:=clWhite;
Form2.QRShape34.Pen.Color:=clWhite;
end
else if txtline[8]='0' then
begin
Form2.QRShape34.Pen.Color:=clBlack;
Form2.QRShape8.Pen.Color:=clWhite;
Form2.QRShape21.Pen.Color:=clWhite;
end; //第9场
if txtline[9]='3' then
begin
Form2.QRShape9.Pen.Color:=clBlack;
Form2.QRShape22.Pen.Color:=clWhite;
Form2.QRShape35.Pen.Color:=clWhite;
end
else if txtline[9]='1' then
begin
Form2.QRShape22.Pen.Color:=clBlack;
Form2.QRShape9.Pen.Color:=clWhite;
Form2.QRShape35.Pen.Color:=clWhite;
end
else if txtline[9]='0' then
begin
Form2.QRShape35.Pen.Color:=clBlack;
Form2.QRShape9.Pen.Color:=clWhite;
Form2.QRShape22.Pen.Color:=clWhite;
end; //第10场
if txtline[10]='3' then
begin
Form2.QRShape10.Pen.Color:=clBlack;
Form2.QRShape23.Pen.Color:=clWhite;
Form2.QRShape36.Pen.Color:=clWhite;
end
else if txtline[10]='1' then
begin
Form2.QRShape23.Pen.Color:=clBlack;
Form2.QRShape10.Pen.Color:=clWhite;
Form2.QRShape36.Pen.Color:=clWhite;
end
else if txtline[10]='0' then
begin
Form2.QRShape36.Pen.Color:=clBlack;
Form2.QRShape10.Pen.Color:=clWhite;
Form2.QRShape23.Pen.Color:=clWhite;
end; //第11场
if txtline[11]='3' then
begin
Form2.QRShape11.Pen.Color:=clBlack;
Form2.QRShape24.Pen.Color:=clWhite;
Form2.QRShape37.Pen.Color:=clWhite;
end
else if txtline[11]='1' then
begin
Form2.QRShape24.Pen.Color:=clBlack;
Form2.QRShape11.Pen.Color:=clWhite;
Form2.QRShape37.Pen.Color:=clWhite;
end
else if txtline[11]='0' then
begin
Form2.QRShape37.Pen.Color:=clBlack;
Form2.QRShape11.Pen.Color:=clWhite;
Form2.QRShape24.Pen.Color:=clWhite;
end; //第12场
if txtline[12]='3' then
begin
Form2.QRShape12.Pen.Color:=clBlack;
Form2.QRShape25.Pen.Color:=clWhite;
Form2.QRShape38.Pen.Color:=clWhite;
end
else if txtline[12]='1' then
begin
Form2.QRShape25.Pen.Color:=clBlack;
Form2.QRShape12.Pen.Color:=clWhite;
Form2.QRShape38.Pen.Color:=clWhite;
end
else if txtline[12]='0' then
begin
Form2.QRShape38.Pen.Color:=clBlack;
Form2.QRShape12.Pen.Color:=clWhite;
Form2.QRShape25.Pen.Color:=clWhite;
end; //第13场
if txtline[13]='3' then
begin
Form2.QRShape13.Pen.Color:=clBlack;
Form2.QRShape26.Pen.Color:=clWhite;
Form2.QRShape39.Pen.Color:=clWhite;
end
else if txtline[13]='1' then
begin
Form2.QRShape26.Pen.Color:=clBlack;
Form2.QRShape13.Pen.Color:=clWhite;
Form2.QRShape39.Pen.Color:=clWhite;
end
else if txtline[13]='0' then
begin
Form2.QRShape39.Pen.Color:=clBlack;
Form2.QRShape13.Pen.Color:=clWhite;
Form2.QRShape26.Pen.Color:=clWhite;
end;
MoveNext;
end;
end;