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

📄 unitreport.pas

📁 一个不错的系统
💻 PAS
字号:
unit UnitReport;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, DBCtrls, Grids, DBGrids, Mask, ADODB,
  ToolWin, ComCtrls, ImgList, DB, Buttons, DBTables, QuickRpt, QRCtrls;

type
  TFrmReport = class(TForm)
    Panel1: TPanel;
    bbtnSearch: TBitBtn;
    bbtnClose: TBitBtn;
    ADOQuery1: TADOQuery;
    QuickRep1: TQuickRep;
    DetailBand1: TQRBand;
    QRDBText1: TQRDBText;
    QRLabel1: TQRLabel;
    QRShape2: TQRShape;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRLabel4: TQRLabel;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRLabel7: TQRLabel;
    QRLabel8: TQRLabel;
    QRLabel9: TQRLabel;
    QRLabel10: TQRLabel;
    QRLabel11: TQRLabel;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    QRDBText4: TQRDBText;
    QRDBText5: TQRDBText;
    QRDBText6: TQRDBText;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRLabel15: TQRLabel;
    QRLabel16: TQRLabel;
    QRLabel17: TQRLabel;
    QRLabel18: TQRLabel;
    QRDBText7: TQRDBText;
    QRDBText8: TQRDBText;
    QRDBText9: TQRDBText;
    QRDBText10: TQRDBText;
    QRLabel19: TQRLabel;
    QRLabel20: TQRLabel;
    QRLabel21: TQRLabel;
    QRDBText12: TQRDBText;
    QRDBText13: TQRDBText;
    QRDBText14: TQRDBText;
    QRDBText15: TQRDBText;
    QRLabel22: TQRLabel;
    QRLabel23: TQRLabel;
    QRLabel24: TQRLabel;
    QRLabel25: TQRLabel;
    QRLabel26: TQRLabel;
    QRLabel27: TQRLabel;
    QRLabel28: TQRLabel;
    QRLabel29: TQRLabel;
    QRLabel30: TQRLabel;
    QRLabel31: TQRLabel;
    QRLabel33: TQRLabel;
    QRLabel34: TQRLabel;
    QRLabel35: TQRLabel;
    QRLabel36: TQRLabel;
    QRLabel37: TQRLabel;
    QRLabel38: TQRLabel;
    QRLabel39: TQRLabel;
    QRLabel40: TQRLabel;
    QRLabel41: TQRLabel;
    QRLabel42: TQRLabel;
    QRLabel43: TQRLabel;
    QRLabel44: TQRLabel;
    QRLabel45: TQRLabel;
    QRLabel46: TQRLabel;
    QRDBText17: TQRDBText;
    QRDBText18: TQRDBText;
    QRDBText19: TQRDBText;
    QRDBText20: TQRDBText;
    QRDBText21: TQRDBText;
    QRDBText22: TQRDBText;
    QRDBText23: TQRDBText;
    QRDBText24: TQRDBText;
    QRDBText25: TQRDBText;
    QRDBText26: TQRDBText;
    QRDBText27: TQRDBText;
    QRDBText28: TQRDBText;
    QRDBText29: TQRDBText;
    QRDBText30: TQRDBText;
    QRDBText31: TQRDBText;
    QRDBText32: TQRDBText;
    QRDBText33: TQRDBText;
    QRDBText34: TQRDBText;
    QRDBText35: TQRDBText;
    QRDBText36: TQRDBText;
    QRDBText37: TQRDBText;
    QRLabel49: TQRLabel;
    PageHeaderBand1: TQRBand;
    QRLabel65: TQRLabel;
    QRLabel67: TQRLabel;
    Label38: TLabel;
    edtTagNO: TEdit;
    Label53: TLabel;
    Edit3: TEdit;
    Label40: TLabel;
    edtName: TEdit;
    Label41: TLabel;
    cmbGender: TComboBox;
    Label43: TLabel;
    cmbRegArea: TComboBox;
    cmbCurArea: TComboBox;
    Label42: TLabel;
    cmbContract: TComboBox;
    Label44: TLabel;
    MaskEdit2: TMaskEdit;
    Label47: TLabel;
    MaskEdit1: TMaskEdit;
    Label39: TLabel;
    Label45: TLabel;
    MaskEdit3: TMaskEdit;
    Label46: TLabel;
    MaskEdit4: TMaskEdit;
    Label59: TLabel;
    ComboBox1: TComboBox;
    Label60: TLabel;
    ComboBox2: TComboBox;
    QRLabel50: TQRLabel;
    QRShape97: TQRShape;
    QRLabel51: TQRLabel;
    QRLabel12: TQRLabel;
    QRDBText11: TQRDBText;
    QRDBText38: TQRDBText;
    QRDBText39: TQRDBText;
    QRDBText40: TQRDBText;
    QRDBText41: TQRDBText;
    QRDBText42: TQRDBText;
    QRDBText43: TQRDBText;
    QRDBText44: TQRDBText;
    QRDBText45: TQRDBText;
    QRDBText46: TQRDBText;
    QRDBText47: TQRDBText;
    QRDBText48: TQRDBText;
    QRDBText49: TQRDBText;
    QRDBText50: TQRDBText;
    QRDBText51: TQRDBText;
    QRDBText52: TQRDBText;
    QRDBText53: TQRDBText;
    QRDBText54: TQRDBText;
    QRLabel32: TQRLabel;
    QRDBText55: TQRDBText;
    QRLabel47: TQRLabel;
    QRLabel48: TQRLabel;
    QRDBRichText1: TQRDBRichText;
    QRLabel52: TQRLabel;
    QRDBText16: TQRDBText;
    QRLabel53: TQRLabel;
    QRLabel54: TQRLabel;
    QRExpr1: TQRExpr;
    QRShape1: TQRShape;
    QRShape3: TQRShape;
    QRShape4: TQRShape;
    QRShape5: TQRShape;
    QRShape6: TQRShape;
    QRShape7: TQRShape;
    QRShape8: TQRShape;
    QRShape9: TQRShape;
    QRShape10: TQRShape;
    QRShape11: TQRShape;
    QRShape12: TQRShape;
    QRShape13: TQRShape;
    QRShape14: TQRShape;
    QRShape15: TQRShape;
    QRShape16: TQRShape;
    QRShape17: TQRShape;
    QRShape18: TQRShape;
    QRShape19: TQRShape;
    QRShape20: TQRShape;
    QRShape21: TQRShape;
    QRShape22: TQRShape;
    QRShape23: TQRShape;
    QRShape24: TQRShape;
    QRShape25: TQRShape;
    QRShape26: TQRShape;
    QRShape27: TQRShape;
    QRShape28: TQRShape;
    QRShape29: TQRShape;
    QRShape30: TQRShape;
    QRShape31: TQRShape;
    QRShape32: TQRShape;
    QRShape33: TQRShape;
    QRShape34: TQRShape;
    QRShape35: TQRShape;
    QRShape36: TQRShape;
    QRShape37: TQRShape;
    QRShape38: TQRShape;
    QRShape39: TQRShape;
    QRShape40: TQRShape;
    QRShape41: TQRShape;
    QRShape42: TQRShape;
    QRShape43: TQRShape;
    QRShape44: TQRShape;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure bbtnCloseClick(Sender: TObject);
    procedure bbtnSearchClick(Sender: TObject);
    procedure DetailBand1BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmReport: TFrmReport;

implementation

uses UnitDatabase, UnitCommon;

{$R *.dfm}

procedure TFrmReport.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TFrmReport.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if Key=13 then Perform(WM_NEXTDLGCTL,0,0);
end;

procedure TFrmReport.bbtnCloseClick(Sender: TObject);
begin
  Close;
end;

procedure TFrmReport.bbtnSearchClick(Sender: TObject);
var
  TmpSQL:String;
begin
  TmpSQL:='where MTagNO<>''''';
  if Trim(edtTagNO.Text)<>'' then begin
    if Trim(Edit3.Text)<>'' then begin
      TmpSQL:=TmpSQL+' and MTagNO>='''+Trim(edtTagNO.Text)+''' and MTagNO<='''+Trim(Edit3.Text)+'''';
    end else begin
      TmpSQL:=TmpSQL+' and MTagNO like '''+Trim(edtTagNO.Text)+'''';
    end;
  end;
  if Trim(edtName.Text)<>'' then TmpSQL:=TmpSQL+' and MName like '''+Trim(edtName.Text)+'''';
  if cmbGender.ItemIndex>0 then TmpSQL:=TmpSQL+' and MGender like '''+Trim(cmbGender.Text)+'''';
  if cmbContract.ItemIndex>0 then TmpSQL:=TmpSQL+' and MContract like '''+Trim(cmbContract.Text)+'''';
  if cmbRegArea.ItemIndex>0 then TmpSQL:=TmpSQL+' and MRegArea like '''+Trim(cmbRegArea.Text)+'''';
  if cmbCurArea.ItemIndex>0 then TmpSQL:=TmpSQL+' and MWork like '''+Trim(cmbCurArea.Text)+'''';
  if ComboBox1.ItemIndex>0 then TmpSQL:=TmpSQL+' and MF5 like '''+Trim(ComboBox1.Text)+'''';
  if ComboBox2.ItemIndex>0 then TmpSQL:=TmpSQL+' and MF8 like '''+Trim(ComboBox2.Text)+'''';
  if Trim(MaskEdit1.Text)<>'-  -' then begin
    if Trim(MaskEdit2.Text)<>'-  -' then begin
      TmpSQL:=TmpSQL+' and MBirthday between #'+MaskEdit1.Text+'# and #'+MaskEdit2.Text+'#';
    end else begin
      TmpSQL:=TmpSQL+' and MBirthday>=#'+MaskEdit1.Text+'#';
    end;
  end else begin
    if Trim(MaskEdit2.Text)<>'-  -' then begin
      TmpSQL:=TmpSQL+' and MBirthday<=#'+MaskEdit2.Text+'#';
    end;
  end;
  if Trim(MaskEdit3.Text)<>'-  -' then begin
    if Trim(MaskEdit4.Text)<>'-  -' then begin
      TmpSQL:=TmpSQL+' and MStartWorkDate between #'+MaskEdit3.Text+'# and #'+MaskEdit4.Text+'#';
    end else begin
      TmpSQL:=TmpSQL+' and MStartWorkDate>=#'+MaskEdit3.Text+'#';
    end;
  end else begin
    if Trim(MaskEdit4.Text)<>'-  -' then begin
      TmpSQL:=TmpSQL+' and MStartWorkDate<=#'+MaskEdit4.Text+'#';
    end;
  end;
  ADOQuery1.Close;
  ADOQuery1.SQL.Clear;
  ADOQuery1.SQL.Add('select MID,MTagNO,MName,MGender,MBirthday,MMarrigae,MPolitics,MMember,MEducation,MTitle,MNative,MFolk,MProvince,MCity,MPolice,MIDCardNO,MTel,MRegAdd,MRegPostalcode,MRegArea');
  ADOQuery1.SQL.Add(',MCurAdd,MCurPostalcode,MCurArea,MInDate,MDuty,MJob,MStartWorkDate,MSalary,MWork,MContract,MPWork,MIncome,MMemo,MFName1,MFName2,MFName3,MFName4,MFName5');
  ADOQuery1.SQL.Add(',MFAppellation1,MFAppellation2,MFAppellation3,MFAppellation4,MFAppellation5,MFFactory1,MFFactory2,MFFactory3,MFFactory4,MFFactory5,MF1,MF2,MF3,MF4,MF5,MFType,MF6,MF7,MF8 from Employee ');
  ADOQuery1.SQL.Add(TmpSQL+' order by MTagNO');
  ADOQuery1.Open;
  QuickRep1.Prepare;
  QRLabel54.Caption:='操作员:'+Users.Name;
  QuickRep1.PreviewModal;
end;

procedure TFrmReport.DetailBand1BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
var
  Y1,M1,D1,Y2,M2,D2:Word;
begin
  if (Trim(ADOQuery1.FieldByName('MBirthday').AsString)<>'') and (Trim(ADOQuery1.FieldByName('MGender').AsString)<>'') then begin
    DecodeDate(Date,Y1,M1,D1);
    DecodeDate(ADOQuery1.FieldByName('MBirthday').AsDateTime,Y2,M2,D2);
    if Trim(ADOQuery1.FieldByName('MGender').AsString)='男' then
      D1:=(Y2+60-Y1)*12+M2-M1
    else
      D1:=(Y2+50-Y1)*12+M2-M1;
    QRLabel32.Caption:=IntToStr(D1 div 12)+'年'+IntToStr(D1 mod 12)+'月';
  end else
    QRLabel32.Caption:='';
end;

end.

⌨️ 快捷键说明

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