?? spbsbb.pas
字號:
unit spbsbb;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, RpDefine, RpBase, RpSystem, ComCtrls, StdCtrls, Grids,
DBGrids, Buttons, ExtCtrls,Main;
type
Tf_spbsbb = class(TForm)
Label1: TLabel;
Panel2: TPanel;
dy: TBitBtn;
yl: TBitBtn;
BitBtn2: TBitBtn;
cx: TBitBtn;
Grid1: TDBGrid;
Panel1: TPanel;
Label2: TLabel;
Check1: TCheckBox;
zd: TComboBox;
zhi: TComboBox;
Check2: TCheckBox;
qssj: TDateTimePicker;
zzsj: TDateTimePicker;
Rprinter: TRvSystem;
DataSource1: TDataSource;
procedure zdChange(Sender: TObject);virtual;
procedure FormCreate(Sender: TObject);virtual;
procedure RprinterPrint(Sender: TObject);virtual;
procedure dyClick(Sender: TObject);
procedure ylClick(Sender: TObject);virtual;
procedure cxClick(Sender: TObject);virtual;
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_spbsbb: Tf_spbsbb;
TempField: String ='';
Sumzdkd: real=0.0;// 字段總寬度
Rowzdkd: Real=0.0;//每行字段總寬度
zbj: real=0.0; //正文左邊距
Content: RContent;
AZdmc: Array[0..7]of String=('報損票號','庫存名稱','商品代碼','商品名稱','數量','成本價','金額','保質期');
AZdkd : Array[0..7]of Real=(1,1,1,1,1,1,1,1); //數組中的元素對應表格中相應字段的寬度
TitleFont,BtFont,BgtitleFont,BgFont: RFont;//讀取或設置標題,表頭,表格字體,表格標題字體
zds : integer = 8;//表格字段數
Cols: integer = 5;//每行列數
bbtitle: String = '';//報表標題
implementation
uses DataModal, spbsdysz;
{$R *.dfm}
procedure Tf_spbsbb.zdChange(Sender: TObject);
begin
if Trim(zd.Text)<>'' then
begin
zhi.Clear;
Case zd.ItemIndex of
0: TempField := 'bsph';
1: TempField := 'spdm';
2: TempField := 'spmc';
3: TempField := 'kcmc';
end;
if TempField<>'spmc' then
begin
with Data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select distinct '+ TempField + ' From t_bsmx');
Open;
end;
end
else
begin
with Data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select distinct '+ TempField + ' From t_spjcxx');
Open;
end;
end;
while Not Data.Query1.Eof do
begin
zhi.Items.Add(Trim(Data.Query1.Fields[0].AsString));
Data.Query1.Next;
end;
end;
end;
procedure Tf_spbsbb.FormCreate(Sender: TObject);
var
i: Integer;
begin
qssj.DateTime := Now;
zzsj.DateTime := Now;
bbtitle := '商品報損報表';
zds := 8;
cols := 5;
Sumzdkd := 0;
For i := 0 to zds-1 do
begin
Azdkd[i]:= 1;
sumzdkd := Sumzdkd+ Azdkd[i];
end;
Rowzdkd := Cols*(Sumzdkd/8);
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_spbsbb.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);//在折行時,第一個字段的寬度等于每行的列數*行號(第一行行號為0)
if i <>n-1 then //不是最后一行
if Cols = 1 then
tab(-2,-2,-2,-2,10)
else
tab(-2,Na,-2,-2,10)
else
begin
if m<>0 then
begin
if (Cols = 1) then //每行只有一列
tab(-2,-2,-2,-2,10)
else if m=1 then
tab(-2,-2,-2,-2,10)
else
tab(-2,na,-2,-2,10);
end
else
begin
if Cols = 1 then
tab(-2,-2,-2,-2,10)
else
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -