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

📄 dealstatetjfrm.pas

📁 一个电力企业的后台管理程序
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit DealStateTJFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Qrctrls, QuickRpt, QRPrntr, ComCtrls, ToolWin, ImgList, ExtCtrls,
  Buttons, StdCtrls;

type
  TForm_DealStateTJ = class(TForm)
    ImageList1: TImageList;
    Splitter1: TSplitter;
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    ToolBar1: TToolBar;
    ToolButton2: TToolButton;
    ToolButton4: TToolButton;
    ToolButton3: TToolButton;
    ToolButton10: TToolButton;
    ToolButton7: TToolButton;
    ToolButton6: TToolButton;
    ToolButton8: TToolButton;
    ToolButton9: TToolButton;
    ToolButton1: TToolButton;
    ToolButton11: TToolButton;
    ToolButton13: TToolButton;
    ToolButton5: TToolButton;
    ToolButton14: TToolButton;
    QRPreview1: TQRPreview;
    Panel4: TPanel;
    Panel5: TPanel;
    Panel6: TPanel;
    Timer1: TTimer;
    GroupBox1: TGroupBox;
    CmBox_SelectTJStyle: TComboBox;
    GroupBox2: TGroupBox;
    RdBtn_GZBX: TRadioButton;
    RdBtn_YKZX: TRadioButton;
    RdBtn_YHTS: TRadioButton;
    RdBtn_YHZX: TRadioButton;
    SpeedButton1: TSpeedButton;
    GroupBox3: TGroupBox;
    DatePicker: TDateTimePicker;
    Edt_OnlyMonthSelect: TEdit;
    UpDown1: TUpDown;
    Lbl_OnlyMonthselect: TLabel;
    DatePicker_Start: TDateTimePicker;
    Lbl_to: TLabel;
    DatePicker_End: TDateTimePicker;
    QRep_GZCX: TQuickRep;
    TitleBand2: TQRBand;
    QRShape1: TQRShape;
    QRImage2: TQRImage;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRShape2: TQRShape;
    QRLabel4: TQRLabel;
    QRLbl_DateRangeGZBX: TQRLabel;
    QRShape4: TQRShape;
    QRLabel5: TQRLabel;
    QRShape5: TQRShape;
    QRLabel6: TQRLabel;
    QRShape6: TQRShape;
    QRLabel7: TQRLabel;
    QRSubDetail1: TQRSubDetail;
    QRShape8: TQRShape;
    QRShape9: TQRShape;
    QRShape10: TQRShape;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    QRExpr1: TQRExpr;
    PageFooterBand1: TQRBand;
    QRSysData1: TQRSysData;
    QRLbl_GZ_Foot1: TQRLabel;
    QRLbl_GZ_Foot2: TQRLabel;
    QRShape11: TQRShape;
    QRLbl_GZ_FootDate: TQRLabel;
    QRSysData2: TQRSysData;
    TimePicker_Start: TDateTimePicker;
    TimePicker_End: TDateTimePicker;
    QRep_YKZX: TQuickRep;
    QRBand1: TQRBand;
    QRShape3: TQRShape;
    QRImage3: TQRImage;
    QRLabel8: TQRLabel;
    QRLabel9: TQRLabel;
    QRShape7: TQRShape;
    QRLabel10: TQRLabel;
    QRLbl_DateRangeYKZX: TQRLabel;
    QRShape12: TQRShape;
    QRLabel12: TQRLabel;
    QRShape13: TQRShape;
    QRLabel13: TQRLabel;
    QRShape14: TQRShape;
    QRLabel14: TQRLabel;
    QRSubDetail2: TQRSubDetail;
    QRShape15: TQRShape;
    QRShape16: TQRShape;
    QRShape17: TQRShape;
    QRDBText1: TQRDBText;
    QRDBText4: TQRDBText;
    QRExpr2: TQRExpr;
    QRBand2: TQRBand;
    QRSysData3: TQRSysData;
    QRLabel15: TQRLabel;
    QRLabel16: TQRLabel;
    QRShape18: TQRShape;
    QRLabel17: TQRLabel;
    QRSysData4: TQRSysData;
    QRep_YHTS: TQuickRep;
    QRBand3: TQRBand;
    QRShape19: TQRShape;
    QRImage4: TQRImage;
    QRLabel11: TQRLabel;
    QRLabel18: TQRLabel;
    QRShape20: TQRShape;
    QRLabel19: TQRLabel;
    QRLbl_DateRangeYHTS: TQRLabel;
    QRShape21: TQRShape;
    QRLabel21: TQRLabel;
    QRShape22: TQRShape;
    QRLabel22: TQRLabel;
    QRShape23: TQRShape;
    QRLabel23: TQRLabel;
    QRSubDetail3: TQRSubDetail;
    QRShape24: TQRShape;
    QRShape25: TQRShape;
    QRShape26: TQRShape;
    QRDBText5: TQRDBText;
    QRDBText6: TQRDBText;
    QRExpr3: TQRExpr;
    QRBand4: TQRBand;
    QRSysData5: TQRSysData;
    QRLabel24: TQRLabel;
    QRLabel25: TQRLabel;
    QRShape27: TQRShape;
    QRLabel26: TQRLabel;
    QRSysData6: TQRSysData;
    QRep_YHZX: TQuickRep;
    QRBand5: TQRBand;
    QRShape28: TQRShape;
    QRImage5: TQRImage;
    QRLabel20: TQRLabel;
    QRLabel27: TQRLabel;
    QRShape29: TQRShape;
    QRLabel28: TQRLabel;
    QRLbl_DateRangeYHZX: TQRLabel;
    QRShape30: TQRShape;
    QRLabel30: TQRLabel;
    QRShape31: TQRShape;
    QRLabel31: TQRLabel;
    QRShape32: TQRShape;
    QRLabel32: TQRLabel;
    QRSubDetail4: TQRSubDetail;
    QRShape33: TQRShape;
    QRShape34: TQRShape;
    QRShape35: TQRShape;
    QRDBText7: TQRDBText;
    QRDBText8: TQRDBText;
    QRExpr4: TQRExpr;
    QRBand6: TQRBand;
    QRSysData7: TQRSysData;
    QRLabel33: TQRLabel;
    QRLabel34: TQRLabel;
    QRShape36: TQRShape;
    QRLabel35: TQRLabel;
    QRSysData8: TQRSysData;
    QRep_IMage: TQuickRep;
    TitleBand1: TQRBand;
    QRImage1: TQRImage;
    QRLabel1: TQRLabel;
    procedure ToolButton2Click(Sender: TObject);
    procedure ToolButton4Click(Sender: TObject);
    procedure ToolButton3Click(Sender: TObject);
    procedure ToolButton7Click(Sender: TObject);
    procedure ToolButton6Click(Sender: TObject);
    procedure ToolButton8Click(Sender: TObject);
    procedure ToolButton9Click(Sender: TObject);
    procedure ToolButton11Click(Sender: TObject);
    procedure ToolButton13Click(Sender: TObject);
    procedure ToolButton14Click(Sender: TObject);
    procedure QRPreview1PageAvailable(Sender: TObject; PageNum: Integer);
    procedure QRep_IMagePreview(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure CmBox_SelectTJStyleChange(Sender: TObject);
    procedure UpDown1Click(Sender: TObject; Button: TUDBtnType);
    procedure QRep_GZCXPreview(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure CmBox_SelectTJStyleKeyPress(Sender: TObject; var Key: Char);
    procedure Edt_OnlyMonthSelectKeyPress(Sender: TObject; var Key: Char);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    FPageCount : integer; // 生成报表的总页数
    Fyear,
    FMonth,
    FDay:word;
    procedure SetFyear(Value:word);
    procedure SetFMonth(Value:word);
    procedure SetFDay(Value:word);
    procedure UpdatePanelShow;
  public
    { Public declarations }
    CurRep : TQuickRep; // 所预览的报表
    property CurYear:word read  Fyear write SetFyear;
    property CurMonth:word read  FMonth write SetFMonth;
    property CurDay:word read  FDay write SetFDay;
  end;

var
  Form_DealStateTJ: TForm_DealStateTJ;

implementation

uses DealStateTJDM, SystemPH;

{$R *.DFM}

procedure TForm_DealStateTJ.ToolButton2Click(Sender: TObject);
begin
  QRPreview1.ZoomToFit;
end;

procedure TForm_DealStateTJ.ToolButton4Click(Sender: TObject);
begin
  QRPreview1.ZoomToWidth;
end;

procedure TForm_DealStateTJ.ToolButton3Click(Sender: TObject);
begin
  QRPreview1.Zoom:=100;
end;

procedure TForm_DealStateTJ.ToolButton7Click(Sender: TObject);
begin
QRPreview1.PageNumber := QRPreview1.PageNumber-1;
if QRPreview1.PageNumber =0 then
QRPreview1.PageNumber:=1;
UpdatePanelShow;
end;

procedure TForm_DealStateTJ.ToolButton6Click(Sender: TObject);
begin
  QRPreview1.PageNumber := 1;
  UpdatePanelShow;
end;

procedure TForm_DealStateTJ.ToolButton8Click(Sender: TObject);
begin
 QRPreview1.PageNumber := QRPreview1.PageNumber+1;
 UpdatePanelShow;
end;

procedure TForm_DealStateTJ.ToolButton9Click(Sender: TObject);
begin
 QRPreview1.PageNumber := QRPreview1.PageNumber+1;
 UpdatePanelShow;
end;

procedure TForm_DealStateTJ.ToolButton11Click(Sender: TObject);
begin
 try
 QRPreview1.QRPrinter.PrintSetup;
 except
  showmessage('请安装打印机');
 end;
end;

procedure TForm_DealStateTJ.ToolButton13Click(Sender: TObject);
begin
try
 QRPreview1.QRPrinter.Print;
except
 showmessage('请检查打印机');
end;
end;

procedure TForm_DealStateTJ.ToolButton14Click(Sender: TObject);
begin
  QRPreview1.Hide;
  Close;
end;

procedure TForm_DealStateTJ.UpdatePanelShow;
begin
  Panel5.Caption :=' 第'+inttostr(QRPreview1.PageNumber)+' 页 总'+inttostr(FPageCount)+' 页  ';
end;

procedure TForm_DealStateTJ.QRPreview1PageAvailable(Sender: TObject;
  PageNum: Integer);
begin
// QRPreview1.Zoom:=100;
 FPageCount := PageNum ;
 UpdatePanelShow;
end;

procedure TForm_DealStateTJ.QRep_IMagePreview(Sender: TObject);
begin
  QRPreview1.QRPrinter := TQRPrinter(Sender);
    CurRep := self.QRep_Image;
  Show;
end;

procedure TForm_DealStateTJ.Timer1Timer(Sender: TObject);
begin
 Timer1.Enabled:=false;
 QRPreview1.Show;
 ToolButton14.Enabled:=true;
 QRep_Image.PreviewModeless;
// QRep_Image.Hide;

end;

procedure TForm_DealStateTJ.FormShow(Sender: TObject);
var
  yy,mm,dd:word;
begin
 DecodeDate(date,yy,mm,dd);
 CurYear:=yy;
 CurMonth:=mm;
 CurDay:=dd;

 ToolButton14.Enabled:=False;
 timer1.Enabled:=true;

 Edt_OnlyMonthSelect.Text:=IntTostr(mm);
 DatePicker.Date:=Date;
 DatePicker_Start.Date:=Date-1;
 DatePicker_End.Date:=Date;
 TimePicker_Start.Time:=Time-0.5;
 TimePicker_End.Time:=Time;
 UpDown1.position:=StrToInt(Edt_OnlyMonthSelect.Text);
end;

procedure TForm_DealStateTJ.CmBox_SelectTJStyleChange(Sender: TObject);
begin
 if CmBox_SelectTJStyle.Text='按月统计' then
 begin
   Edt_OnlyMonthSelect.Visible:=True;
   Lbl_OnlyMonthSelect.Visible:=True;
   UpDown1.Visible:=True;
   DatePicker_Start.Visible:=False;
   DatePicker_End.Visible:=False;
   TimePicker_Start.Visible:=False;
   TimePicker_End.Visible:=False;
   Lbl_to.Visible:=False;
   DatePicker.Visible:=False;
 end;
 if CmBox_SelectTJStyle.Text='按日统计' then
 begin
   Edt_OnlyMonthSelect.Visible:=False;
   Lbl_OnlyMonthSelect.Visible:=False;
   UpDown1.Visible:=False;
   DatePicker_Start.Visible:=False;
   DatePicker_End.Visible:=False;
   TimePicker_Start.Visible:=False;
   TimePicker_End.Visible:=False;
   Lbl_to.Visible:=False;
   DatePicker.Visible:=True;
 end;
 if CmBox_SelectTJStyle.Text='按任意时间统计' then
 begin
   Edt_OnlyMonthSelect.Visible:=False;
   Lbl_OnlyMonthSelect.Visible:=False;
   UpDown1.Visible:=False;
   DatePicker_Start.Visible:=True;
   DatePicker_End.Visible:=True;
   TimePicker_Start.Visible:=True;
   TimePicker_End.Visible:=True;
   Lbl_to.Visible:=True;
   DatePicker.Visible:=False;
 end;
end;

procedure TForm_DealStateTJ.SetFDay(Value: word);
begin
  if FDay<>Value then FDay:=Value;
end;

procedure TForm_DealStateTJ.SetFMonth(Value: word);
begin
  if FMonth<>Value then FMonth:=Value;
end;

procedure TForm_DealStateTJ.SetFyear(Value: word);
begin
  if FYear<>Value then FYear:=Value;
end;

procedure TForm_DealStateTJ.UpDown1Click(Sender: TObject;
  Button: TUDBtnType);
begin
  if Button=BtNext then
  begin
       Edt_OnlyMonthSelect.Text:=IntToStr(UpDown1.position);
  end  else
  begin
       Edt_OnlyMonthSelect.Text:=IntToStr(UpDown1.position);
  end;
end;

procedure TForm_DealStateTJ.QRep_GZCXPreview(Sender: TObject);
begin
 QRPreview1.QRPrinter := TQRPrinter(Sender);
 CurRep := self.QRep_GZCX;
 Show;
end;

procedure TForm_DealStateTJ.SpeedButton1Click(Sender: TObject);
var
  Uyear,Umonth,Uday:word;
  StartTime,EndTime:TDateTime;
begin
//故障报修统计
 if RdBtn_GZBX.Checked=True then
 begin
   if CmBox_SelectTJStyle.Text='按月统计' then
   begin
      QRLbl_DateRangeGZBX.Caption:=IntToStr(CurYear)+'年'+Edt_OnlyMonthSelect.Text+'月';

      with DM_DealStateTJ.Qr_DealStateTj do
      begin
       close; sql.Clear;
       sql.Text:='drop view NotDealGZ';
       try
        ExecSQL;
       except
       end;


       close; sql.Clear;
       sql.Text:='drop view DealedGZ';
       try
        ExecSQL;
       except
       end;

       close; sql.Clear;
       sql.Text:='create view NotDealGZ as  select count(*) NotDealNum from ClientElecOut where state<>2 and state<>7 and year(zzflsj)='''+inttostr(CurYear)+''' and Month(zzflsj)='''+Edt_OnlyMonthSelect.Text+'''';
       ExecSQL;


       close; sql.Clear;
       sql.Text:='create view DealedGZ as  select count(*) DealedNum from ClientElecOut where (state=2 or state=7) and year(zzflsj)='''+inttostr(CurYear)+''' and Month(zzflsj)='''+Edt_OnlyMonthSelect.Text+'''';
       ExecSQL;

       close; sql.Clear;
       sql.Text:='select a.NotDealNum,b.DealedNum from NotDealGZ a,DealedGZ b ';
       Open;


     end;
   end;

   if CmBox_SelectTJStyle.Text='按日统计' then
   begin
     QRLbl_DateRangeGZBX.Caption:=FormatDateTime('yyyy"年"mm"月"dd"日"',DatePicker.date);

     DecodeDate(DatePicker.DateTime,Uyear,Umonth,Uday);

     with DM_DealStateTJ.Qr_DealStateTj do
      begin
       close; sql.Clear;
       sql.Text:='drop view NotDealGZ';
       try
        ExecSQL;
       except
       end;


       close; sql.Clear;
       sql.Text:='drop view DealedGZ';
       try
        ExecSQL;
       except
       end;

       close; sql.Clear;
       sql.Text:='create view NotDealGZ as  select count(*) NotDealNum from ClientElecOut where state<>2 and state<>7 and year(zzflsj)='''+IntToStr(Uyear)+''' and month(zzflsj)='''+IntToStr(Umonth)+''' and Day(zzflsj)='''+IntToStr(Uday)+'''';
       ExecSQL;


       close; sql.Clear;
       sql.Text:='create view DealedGZ as  select count(*) DealedNum from ClientElecOut where (state=2 or state=7) and year(zzflsj)='''+IntToStr(Uyear)+''' and month(zzflsj)='''+IntToStr(Umonth)+''' and Day(zzflsj)='''+IntToStr(Uday)+'''';

⌨️ 快捷键说明

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