【delphi开源代码栏目提醒】:网学会员为广大网友收集整理了,csyfkbb.pas,希望对大家有所帮助!
unit csyfkbb;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, RpDefine, RpBase, RpSystem, ComCtrls, StdCtrls, Grids,
DBGrids, Buttons, ExtCtrls,main;
type
Tf_csyfkbb = class(TForm)
Label1: TLabel;
Panel2: TPanel;
dy: TBitBtn;
yl: TBitBtn;
BitBtn2: TBitBtn;
cx: TBitBtn;
Grid1: TDBGrid;
Panel1: TPanel;
Label3: TLabel;
Check1: TCheckBox;
zd: TComboBox;
Check2: TCheckBox;
qssj: TDateTimePicker;
zzsj: TDateTimePicker;
Rprinter: TRvSystem;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
procedure cxClick(Sender: TObject);
procedure RprinterPrint(Sender: TObject);
procedure dyClick(Sender: TObject);
procedure ylClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
RFont = Record //设置字体
RFontName: String;
RFontSize: Integer;
RFontColor: Integer;
RFontStyle: TFontStyles;
End;
RContent = ReCord //设置正文
TitleHeight: Real; //标题高度
BtHeight: Real;//表头与标题的间距
Bgjj: Real;//表格与表头的间距
Czyjj: real;//操作员与其标签的水平距离
sjjj: real;//时间与其标签的水平距离
Bgdqfs: integer;//表格内容的对齐方式 0居左,1居右,2居中
end;
var
f_csyfkbb: Tf_csyfkbb;
TempField: String ='';
Sumzdkd: real=0.0;// 字段总宽度
Rowzdkd: Real=0.0;//每行字段总宽度
zbj: real=0.0; //正文左边距
Content: RContent;
AZdmc: Array[0..5]of String=('付款票号','厂商名称','付款形态','付款金额','付款人','时间');
AZdkd : Array[0..5]of Real=(1,1,1,1,1,1); //数组中的元素对应表格中相应字段的宽度
TitleFont,BtFont,BgtitleFont,BgFont: RFont;//读取或设置标题,表头,表格字体,表格标题字体
zds : integer = 6;//表格字段数
Cols: integer = 6;//每行列数
bbtitle: String = '';//报表标题
implementation
uses DataModal,csyfkdysz;
{$R *.dfm}
procedure Tf_csyfkbb.FormCreate(Sender: TObject);
var
i: Integer;
begin
zd.Clear;
with Data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select csmc from t_cszl');
Open;
end;
while Not Data.Query1.Eof do
begin
zd.Items.Add(Trim(Data.Query1.Fields[0].AsString));
Data.Query1.Next;
end;
qssj.DateTime := Now;
zzsj.DateTime := Now;
bbtitle := '厂商预付款报表';
zds := 6;
cols := 6;
Sumzdkd := 0;
For i := 0 to zds-1 do
begin
Azdkd[i]:= 1;
sumzdkd := Sumzdkd+ Azdkd[i];
end;
Rowzdkd := Cols*(Sumzdkd/zds);
with TitleFont do
begin
RFontName := '宋体';
RFontSize := 18;
RFontColor := clRed;
RFontStyle := [];
end;
with BtFont do
begin
RFontName := '宋体';
RFontSize := 10;
RFontColor := clBlue;
RFontStyle := [];
end;
with BgFont do
begin
RFontName := '宋体';
RFontSize := 10;
RFontColor := clBlue;
RFontStyle := [];
end;
with BgtitleFont do
begin
RFontName := '宋体';
RFontSize := 12;
RFontColor := clBlue;
RFontStyle := [fsBold];
end;
with Content do
begin
TitleHeight := 0.8;
BtHeight := 0.4;
Bgjj := 0.4;
Czyjj := 0.8;
sjjj := 0.8;
Bgdqfs := 0;//表格居左对齐
end;
end;
procedure Tf_csyfkbb.cxClick(Sender: TObject);
begin
if check1.Checked = True then
begin
if Trim(zd.Text)<>'' then
begin
if check2.Checked = False then
begin
with Data.Query2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from t_csyfkjl where csmc = :a');
ParamByName('a').AsString := Trim(zd.Text);
Open;
end;
if Data.Query2.RecordCount>0 then
begin
DataSource1.DataSet := Data.Query2;
dy.Enabled := True;
end
else
begin
DataSource1.DataSet := Nil;
dy.Enabled := False;
Application.MessageBox('没有符合条件的记录.','提示',64);
end;
end
else
begin
if zzsj.DateTime<qssj.DateTime then
begin
Application.MessageBox('起始时间不能大于终止时间.','提示',64);
Exit;
end;
with Data.Query2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from t_csyfkjl where csmc = :aa and (sj >= :bb and sj <:cc)');
ParamByName('aa').AsString := Trim(zd.Text);
ParamByName('bb').AsDate := Trunc(qssj.DateTime);
ParamByName('cc').AsDate := Trunc(zzsj.DateTime)+1;
Open;
end;
if Data.Query2.RecordCount>0 then
begin
DataSource1.DataSet := Data.Query2;
dy.Enabled := True;
end
else
begin
DataSource1.DataSet := Nil;
dy.Enabled := False;
Application.MessageBox('没有符合条件的记录.','提示',64);
end;
end;
end;
end
else if check2.Checked = True then
begin
if zzsj.DateTime<qssj.DateTime then
begin
Application.MessageBox('起始时间不能大于终止时间.','提示',64);
Exit;
end;
with Data.Query2 do
begin
Close;
SQL.Clear;
SQL.Add('select * from t_csyfkjl where sj>= :b and sj <:c');
ParamByName('b').AsDate := Trunc(qssj.DateTime);
ParamByName('c').AsDate := Trunc(zzsj.DateTime)+1;
Open;
end;
if Data.Query2.RecordCount>0 then
begin
DataSource1.DataSet := Data.Query2;
dy.Enabled := True;
end
else
begin
DataSource1.DataSet := Nil;
dy.Enabled := False;
Application.MessageBox('没有符合条件的记录.','提示',64);
end;
end
else
Application.MessageBox('请设置查询条件.','提示',64);
end;
procedure Tf_csyfkbb.RprinterPrint(Sender: TObject);
var
justify: TPrintJustify;
i,m,n,l: integer;
begin
with Sender as TBaseRePort do
begin
justify := pjleft;
zbj := (PageWidth-Rowzdkd)/2;
SetFont(TitleFont.RFontName,TitleFont.RFontSize);
FontColor := TitleFont.RFontColor;
if (fsBold in TitleFont.RFontStyle) then
Bold := True
else
Bold := False;
if (fsUnderline in TitleFont.RFontStyle) then
underline := True
else
underline := False;
if (fsItalic in TitleFont.RFontStyle) then
Italic := True
else
Italic := False;
if (fsStrikeOut in TitleFont.RFontStyle) then
Strikeout := True
else
Strikeout := False;
ypos := Content.TitleHeight;
PrintCenter(bbtitle,PageWidth/2);
setFont(BtFont.RFontName,BtFont.RFontSize);
FontColor := BtFont.RFontColor;
if (fsBold in BtFont.RFontStyle) then
Bold := True
else
Bold := False;
if (fsUnderline in BtFont.RFontStyle) then
underline := True
else
underline := False;
if (fsItalic in BtFont.RFontStyle) then
Italic := True
else
Italic := False;
if (fsStrikeOut in BtFont.RFontStyle) then
Strikeout := True
else
Strikeout := False;
ypos := ypos+Content.BtHeight ;
printLeft('操作员:',zbj);
printleft(Trim(czyxx.czymc),Content.Czyjj+zbj);
PrintRight(FormatDateTime('yyyy-mm-dd',Now),zbj+Rowzdkd);
printRight('时间:',zbj+Rowzdkd-Content.sjjj);
ypos := ypos+Content.Bgjj;
m:= zds mod Cols;
n:= zds div Cols;
if m<>0 then
n:=n+1;//n记录需要折几行
For i:=0 to n-1 do
begin
Cleartabs;
setFont(BgtitleFont.RFontName,BgtitleFont.RFontSize);
FontColor := BgtitleFont.RFontColor;
if (fsBold in BgTitleFont.RFontStyle) then
Bold := True
else
Bold := False;
if (fsUnderline in BgTitleFont.RFontStyle) then
underline := True
else
underline := False;
if (fsItalic in BgTitleFont.RFontStyle) then
Italic := True
else
Italic := False;
if (fsStrikeOut in BgTitleFont.RFontStyle) then
Strikeout := True
else
Strikeout := False;
setpen(clblack,pssolid,1,pmcopy);
settab(zbj,pjcenter,Azdkd[Cols*i],0,boxlineall,0);//在折行时,第一个字段的宽度等于每行的列数*行号
上一篇:
frmdisplay.frm
下一篇:
百公里油耗仅6.45L,哈弗F7智能节油赛燃“擎”登陆石家庄