|
; CHBNAME[I].Alignment:=taCenter; CHBNAME[I].Caption:=Query.Fields[I].DisplayName;//取字段作为列名 CHBNAME[I].BringToFront;
DBShape[I]:=TQRShape.Create(DB); //建立细节带区线条控件 DBShape[I].Parent:=DB; DBShape[I].Top:=-1; DBShape[I].Left:=CHBlf; DBShape[I].Width:=ObWidth+1; DBShape[I].Height:=17;
DBNAME[I]:=TQRDBText.Create(DB); //建立细节带区控件 DBNAME[I].Parent:=DB; DBNAME[I].ParentReport:=QuickRep; DBNAME[I].Top:=2; DBNAME[I].Left:=CHBlf+2; DBNAME[I].AutoSize:=False; DBNAME[I].Width:=ObWidth-3; DBNAME[I].Height:=13; DBNAME[I].Alignment:=Dj; DBNAME[I].DataSet:=Query; DBNAME[I].DataField:=Query.Fields[I].FieldName; DBNAME[I].BringToFront;
if Tj1.Checked then begin //是否建立页脚带区? FBShape[I]:=TQRShape.Create(FB); //建立页脚带区线条控件 FBShape[I].Parent:=FB; FBShape[I].Top:=0; FBShape[I].Left:=CHBlf; FBShape[I].Width:=ObWidth+1; FBShape[I].Height:=17;
if (Query.Fields[I].DataType=ftFloat) or (Query.Fields[I].DataType=ftCurrency) or (I<2) then begin //如果字段类型为数值类型则建立 FBNAME[I]:=TQRExpr.Create(FB); //建立页脚带区控件 FBNAME[I].Parent:=FB; FBNAME[I].ParentReport:=QuickRep; FBNAME[I].Top:=3; FBNAME[I].Left:=CHBlf+2; FBNAME[I].AutoSize:=False; FBNAME[I].Width:=ObWidth-3; FBNAME[I].Height:=13; FBNAME[I].Alignment:=taCenter; FBNAME[I].Expression:=''''SUM(QUERY.''''+Query.Fields[I].FieldName+'''')''''; FBNAME[I].BringToFront; end; end;
if Tj2.Checked then begin //是否建立总和带区? SumShape[I]:=TQRShape.Create(SB); //建立总和带区线条控件 SumShape[I].Parent:=SB; SumShape[I].Top:=0; SumShape[I].Left:=CHBlf; SumShape[I].Width:=ObWidth+1; SumShape[I].Height:=17;
if (Query.Fields[I].DataType=ftFloat) or (Query.Fields[I].DataType=ftCurrency) or (I<2) then begin //如果字段类型为数值类型则建立 SumNAME[I]:=TQRExpr.Create(SB); //建立总和带区控件 SumNAME[I].Parent:=SB; SumNAME[I].ParentReport:=QuickRep; SumNAME[I].Top:=3; SumNAME[I].Left:=CHBlf+2; SumNAME[I].AutoSize:=False; SumNAME[I].Width:=ObWidth-3; SumNAME[I].Height:=13; SumNAME[I].Alignment:=taCenter; SumNAME[I].Expression:=''''SUM(QUERY.''''+Query.Fields[I].FieldName+'''')''''; SumNAME[I].BringToFront; end; end; CHBlf:=CHBlf+ObWidth;//当前字段处理完成,往右一个字段宽度 end; end; end; CrtRep.Enabled:=False;//禁上生成按钮 BtnPrint.Enabled:=not CrtRep.Enabled;允许打印铵钮 BtnPrview.Enabled:=BtnPrint.Enabled;允许预览按钮 if Tj1.Checked then begin //如果建立了页脚带区,则将页脚带区中前两列更改 FBNAME[0].Expression:=''''''''''''页合计''''''''''''; FBNAME[1].Expression:=''''COUNT+''''''''行''''''''''''; end; if Tj1.Checked then begin //如果建立了总和带区,则将总和带区中前两列更改 SumNAME[0].Expression:=''''''''''''总计''''''''''''; SumNAME[1].Expression:=''''COUNT+''''''''行''''''''''''; end; //调整列标头带区中的日期及页码打印位置 QRE2.Left:=HB.Width-Qre2.Width; QRSQL.Left:=QRE1.Width+10; QRSQL.Width:= QRE2.Left-10-QRSQL.Left; QuickRep.DataSet:=Query; //为QuickRep指定数据集,该句一定不能少 Screen.Cursor:=crDefault; end;
procedure TPrintForm.ClearRep();//清除生成报表格式时建立的控件 Var I:Byte; begin For I:=0 to Query.FieldCount-1 do begin if Assigned(CHBShape[I]) then begin CHBShape[I].Free;CHBShape[I]:=nil;end; if Assigned(CHBNAME[I]) then begin CHBNAME[I].Free;CHBNAME[I]:=nil;end; if Assigned(DBShape[I]) then begin DBShape[I].Free;DBShape[I]:=nil;end; if Assigned(DBNAME[I]) then begin DBNAME[I].Free;DBNAME[I]:=nil;end; if Assigned(FBShape[I]) then begin FBShape[I].Free;FBShape[I]:=nil;end; if Assigned(FBNAME[I]) then begin FBNAME[I].Free;FBNAME[I]:=nil;end; if Assigned(SumShape[I]) then begin SumShape[I].Free;SumShape[I]:=nil;end; if Assigned(SumNAME[I]) then begin SumNAME[I].Free;SumNAME[I]:=nil;end; end; end;
procedure TPrintForm.SRClick(Sender: TObject); begin if Sr.Checked then QrSQL.Caption:=CXTJ else QRSQL.Caption:=''''''''; end;
procedure TPrintForm.FormShow(Sender: TObject); //窗体显示事件 begin Query.Active:=True;//打印SQL TT.Text:=Bt; QuickRep.ReportTitle:=Bt;//设置标题 //控件名数组分配空间 SetLength(CHBNAME,Query.FieldCount); SetLength(CHBShape,Query.FieldCount); SetLength(DBNAME,Query.FieldCount); SetLength(DBShape,Query.FieldCount); SetLength(FBNAME,Query.FieldCount); SetLength(FBShape,Query.FieldCount); SetLength(SumNAME,Query.FieldCount); SetLength(SumShape,Query.FieldCount); end;
procedure TPrintForm.PaperSizeChg(Sender: TObject); begin CrtRep.Enabled:=True; BtnPrint.Enabled:=not CrtRep.Enabled; BtnPrview.Enabled:=BtnPrint.Enabled; end;
procedure TPrintForm.DJChage(Sender: TObject);//对齐方式改变事件处理 var Chg:Byte; begin if Djauto.Checked then Chg:=0 else if DjCenter.Checked then Chg:=1 else Chg:=2; if Chg<>Rd1 then begin PaperSizeChg(nil);Rd1:=Chg;end; end;
procedure TPrintForm.WdChage(Sender: TObject);//宽度改变事件处理 var Chg:Byte; begin if Wdauto.Checked then Chg:=0 else if Wdall.Checked then begin Chg:=1; if ColWd.Text='''''''' then ColWd.Text:=''''100'''';   上一页 [1] [2] [3] [4] 下一页 没有相关教程
|