⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 monthreport.pas

📁 小管理程序主要管理的小咖啡厅我是从网上下的经测试可用
💻 PAS
字号:
unit monthreport;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, Buttons, DB, ADODB, FR_DSet, FR_DBSet,
  FR_Class;

type
  TFrmmonthreport = class(TForm)
    GroupBox1: TGroupBox;
    mydate1: TDateTimePicker;
    mydate2: TDateTimePicker;
    Label1: TLabel;
    Label2: TLabel;
    SpeedButton1: TSpeedButton;
    frReport1: TfrReport;
    frDBDataSet1: TfrDBDataSet;
    ADOQuery1: TADOQuery;
    procedure SpeedButton1Click(Sender: TObject);
    procedure createreport(dataset:Tdataset;sumdate1,sumdate2:Tdatetime);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Frmmonthreport: TFrmmonthreport;

implementation
   uses dbmodule;
{$R *.dfm}
procedure TFrmmonthreport.createreport(dataset:Tdataset;sumdate1,sumdate2:Tdatetime);
var
  v: TfrView;
  b: TfrBandView;
  Page: TfrPage;
  fieldcount:integer;
  datamemo:string;
begin
  frReport1.Pages.Clear;
  frReport1.Pages.Add;              // create page
  Page := frReport1.Pages[0];
  page.pgMargins.Top:=36;
  b := TfrBandView(frCreateObject(gtBand, ''));  // create ReportHeader band
  b.SetBounds(0,36,757,76);
  b.BandType := btpageheader;
  Page.Objects.Add(b);
  v := TfrMemoView.Create;             // create memo
  v.SetBounds(216,48, 304, 32);
  v.BandAlign := baWidth;
  v.Prop['Alignment'] := frtaCenter;   // another way to access properties
  v.Prop['Font.Style'] := 2;
  v.Prop['Font.Name']:='宋体';
  v.Prop['Font.Size']:=16;
  v.Memo.Add('上岛咖啡营业明细日报表');
  Page.Objects.Add(v);
  v := TfrMemoView.Create;             // create memo
  v.SetBounds(452,88,260,20);
  //v.BandAlign := baWidth;
  //v.Prop['Alignment'] := frtaRight;   // another way to access properties
  v.Prop['Font.Style'] := 2;
  v.Prop['Font.Name']:='宋体';
  v.Prop['Font.Size']:=10;
  v.Memo.Add('统计日期:'+datetostr(sumdate1)+'--至--'+datetostr(sumdate2));
  Page.Objects.Add(v);
  b := TfrBandView(frCreateObject(gtBand, ''));  // create MasterHeader band
  b.SetBounds(0,112,757,36);
  b.BandType := btMasterheader;
  Page.Objects.Add(b);
  for Fieldcount:=0 to DataSet.FieldCount-1 do    //create masterheadermemo
    begin
      v := TfrMemoView.Create;
      v.SetBounds(64+(Fieldcount*96),128, 96, 20);
      v.Prop['Alignment'] :=frtaMiddle+frtaCenter;
      v.Prop['Font.Style'] := 2;
      v.Prop['Font.Name']:='宋体';
      v.Prop['Font.Size']:=10;
      v.Prop['FrameTyp']:=15;
      v.Memo.Add(DataSet.Fields[Fieldcount].FieldName);
      Page.Objects.Add(v);
    end;
  b := TfrBandView(frCreateObject(gtBand, ''));  // create MasterData band
  b.SetBounds(0,158,757, 20);
  b.BandType := btMasterData;
  b.Dataset := 'frDBDataSet1';         // band's dataset
  Page.Objects.Add(b);
  for Fieldcount:=0 to DataSet.FieldCount-1 do    //create MasterDataMemo
    begin
      v := TfrMemoView.Create;
      v.SetBounds(64+(Fieldcount*96),158,96, 20);
      v.Prop['Alignment'] :=frtaMiddle+frtaCenter;
      v.Prop['Font.Style'] := 1;
      v.Prop['Font.Name']:='宋体';
      v.Prop['Font.Size']:=10;
      v.Prop['FrameTyp']:=15;
      if DataSet.Fields[Fieldcount].DataType in [ftFloat, ftCurrency, ftBCD] then
        begin
          datamemo:='['+dataset.Name+'.'+DataSet.Fields[Fieldcount].FieldName+' #9.2]';
        end
      else
         datamemo:='['+dataset.Name+'.'+DataSet.Fields[Fieldcount].FieldName+']';
      v.Memo.Add(datamemo);
      Page.Objects.Add(v);
    end;
  b := TfrBandView(frCreateObject(gtBand, ''));  // create Reportfooter band
  b.SetBounds(0,256,757,34);
  b.BandType := btpagefooter;
  Page.Objects.Add(b);
  v := TfrMemoView.Create;             // create memo
  v.SetBounds(330,256,96,20);
  v.BandAlign := baWidth;
  v.Prop['Alignment'] := frtaCenter;   // another way to access properties
  v.Prop['Font.Style'] := 2;
  v.Prop['Font.Name']:='宋体';
  v.Prop['Font.Size']:=10;
  v.Memo.Add('[page#]');
  Page.Objects.Add(v);
  frReport1.ShowReport;
end;
procedure TFrmmonthreport.SpeedButton1Click(Sender: TObject);
begin
 if adoquery1.Active then
    adoquery1.Close;
  adoquery1.SQL.Clear;
  adoquery1.SQL.Add('TRANSFORM sum(Q_customertemp.caipincount*Q_customertemp.caipinprice) AS heji');
  adoquery1.SQL.Add(' SELECT Q_customertemp.chuanbiaohao as 传票号码,Q_customertemp.fangtaiid as 房台编号');
  adoquery1.SQL.Add(' FROM ((Q_caipin INNER JOIN Q_childclass ON Q_caipin.chclassid=Q_childclass.chclassid) INNER JOIN Q_customertemp ON Q_caipin.Caipinid=Q_customertemp.Caipinid) INNER JOIN Q_masterclass ON Q_childclass.Mclassid=Q_masterclass.mclassid');
  adoquery1.SQL.Add(' WHERE  Q_customertemp.opratedate between #'+datetostr(mydate1.Date)+' 00:00:00# and #'+datetostr(mydate2.Date)+' 23:59:59#');
  adoquery1.SQL.Add(' GROUP BY Q_customertemp.chuanbiaohao,Q_customertemp.fangtaiid');
  adoquery1.SQL.Add(' PIVOT Q_masterclass.Mclass_name');
  adoquery1.Open;
  if not adoquery1.Eof then
    createreport(adoquery1,mydate1.Date,mydate2.Date)
  else
    application.MessageBox('没有要查询的数据。','提示',mb_ok);
  adoquery1.Close;
end;

procedure TFrmmonthreport.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  if adoquery1.Active then
    adoquery1.Close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -