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

📄 main.~pas

📁 TQuickRep组件的功能使用 报表的输出设计很详细的介绍
💻 ~PAS
字号:
unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, QuickRpt, StdCtrls, Buttons, QRCtrls, DB, ADODB;

type
  TForm1 = class(TForm)
    QuickRep1: TQuickRep;
    GroupBox2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    BitBtn2: TBitBtn;
    BitBtn1: TBitBtn;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    QRBand4: TQRBand;
    QRBand3: TQRBand;
    QRLabel19: TQRLabel;
    QRSysData3: TQRSysData;
    QRLabel20: TQRLabel;
    QRLabel22: TQRLabel;
    QRLabel18: TQRLabel;
    QRSysData1: TQRSysData;
    QRBand2: TQRBand;
    QRLabel8: TQRLabel;
    ADOConnection1: TADOConnection;
    ADOTable1: TADOTable;
    ADOQuery1: TADOQuery;
    QRDBText1: TQRDBText;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    QRDBText4: TQRDBText;
    QRDBText5: TQRDBText;
    QRDBText6: TQRDBText;
    QRDBText7: TQRDBText;
    QRDBText8: TQRDBText;
    QRDBText9: TQRDBText;
    QRLabel9: TQRLabel;
    QRLabel10: TQRLabel;
    QRLabel11: TQRLabel;
    QRLabel12: TQRLabel;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRLabel15: TQRLabel;
    QRLabel16: TQRLabel;
    QRLabel17: TQRLabel;
    QRExpr1: TQRExpr;
    QRExpr2: TQRExpr;
    QRExpr3: TQRExpr;
    QRBand1: TQRBand;
    QRLabel1: TQRLabel;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRLabel7: TQRLabel;
    QRBand5: TQRBand;
    QRLabel31: TQRLabel;
    QRExpr4: TQRExpr;
    QRExpr5: TQRExpr;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure ComboBox1Select(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

//设置报表显示信息
procedure TForm1.FormShow(Sender: TObject);
begin
   ComboBox1.Text:=ComboBox1.Items[0];
   QRLabel3.Caption:='旭阳软件技术公司';
   QRLabel4.Caption:=FormatDateTime('yyyy-mm',now);
   QRLabel8.Caption:='李小阳';
end;
                                         
//按查询条件输出报表
procedure TForm1.BitBtn1Click(Sender: TObject);
var
   stemp:string;
begin
   if Trim(ComboBox1.Text)='' then
   begin
      MessageDlg(' 请输入------查询条件!',mtInformation,[mbYes],0);
      ComboBox1.SetFocus;
      Exit;
   end;
   if Trim(ComboBox2.Text)='' then
   begin
      MessageDlg(' 请输入------查询结果!',mtInformation,[mbYes],0);
      ComboBox2.SetFocus;
      Exit;
   end;
   //操作数据表(userlogin)
   if ComboBox1.Text='全部' then
      stemp:='select * from userlogin'
   else if ComboBox1.Text='用户名称' then
      stemp:='select * from userlogin where username='''+Trim(ComboBox2.text)+''''
   else if ComboBox1.Text='登陆日期' then
      stemp:='select * from userlogin where logindate='''+Trim(ComboBox2.text)+''''
   else if ComboBox1.Text='登陆时间' then
      stemp:='select * from userlogin where logintime='''+Trim(ComboBox2.text)+''''
   else if ComboBox1.Text='退出时间' then
      stemp:='select * from userlogin where quittime='''+Trim(ComboBox2.text)+'''';
   //模糊查询
   with ADOQuery1 do
   begin
      Close;
      SQL.Clear;
      SQL.Add(stemp);
      Open;
   end;
   if ADOQuery1.RecordCount=0 then
   begin
      MessageDlg('数据库没有你要查询的数据记录!',mtInformation,[mbYes],0);
      ComboBox2.SetFocus;
      Exit;
   end;
   QuickRep1.Preview;
end;

//设置列表选项
procedure TForm1.ComboBox1Select(Sender: TObject);
begin
   if ComboBox1.Text='全部' then ComboBox2.Text:='全部';
end;

//退出
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
   Close;
end;

end.

⌨️ 快捷键说明

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