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

📄 workstatetjfrm.pas

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

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ImgList, Qrctrls, QuickRpt, QRPrntr, ComCtrls, ToolWin, ExtCtrls,
  StdCtrls, Buttons, RxLookup, TeeProcs, TeEngine, Chart, DBChart, QrTee,
  Series;

type
  TForm_WorkStateTJ = class(TForm)
    Panel1: TPanel;
    SpBtn_Stat: TSpeedButton;
    GroupBox1: TGroupBox;
    CmBox_SelectTJStyle: TComboBox;
    GroupBox2: TGroupBox;
    GroupBox3: TGroupBox;
    Lbl_OnlyMonthselect: TLabel;
    Lbl_to: TLabel;
    DatePicker: TDateTimePicker;
    Edt_OnlyMonthSelect: TEdit;
    UpDown1: TUpDown;
    DatePicker_Start: TDateTimePicker;
    DatePicker_End: TDateTimePicker;
    TimePicker_Start: TDateTimePicker;
    TimePicker_End: TDateTimePicker;
    Splitter1: TSplitter;
    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;
    QRep_IMage: TQuickRep;
    TitleBand1: TQRBand;
    QRImage1: TQRImage;
    QRLabel1: TQRLabel;
    Panel4: TPanel;
    Panel5: TPanel;
    Panel6: TPanel;
    ImageList1: TImageList;
    Timer1: TTimer;
    GroupBox4: TGroupBox;
    RdBtn_Report: TRadioButton;
    RdBtn_Graph1: TRadioButton;
    RxDBLpCb_Agent: TRxDBLookupCombo;
    CkBox_AllAgent: TCheckBox;
    QRep_WTJ: TQuickRep;
    TitleBand2: TQRBand;
    QRShape1: TQRShape;
    QRImage2: TQRImage;
    QRLabel2: TQRLabel;
    QRLabel3: TQRLabel;
    QRShape2: TQRShape;
    QRLabel4: TQRLabel;
    QRLbl_DateRangeWTJ: TQRLabel;
    QRShape4: TQRShape;
    QRLabel5: TQRLabel;
    QRShape5: TQRShape;
    QRLabel6: TQRLabel;
    QRShape6: TQRShape;
    QRLabel7: TQRLabel;
    QRSubDetail1: TQRSubDetail;
    QRShape8: TQRShape;
    QRShape9: TQRShape;
    QRShape10: TQRShape;
    PageFooterBand1: TQRBand;
    QRSysData1: TQRSysData;
    QRLbl_GZ_Foot1: TQRLabel;
    QRLbl_GZ_Foot2: TQRLabel;
    QRShape11: TQRShape;
    QRLbl_GZ_FootDate: TQRLabel;
    QRSysData2: TQRSysData;
    QRShape3: TQRShape;
    QRLabel8: TQRLabel;
    QRShape7: TQRShape;
    QRLabel9: TQRLabel;
    QRShape12: TQRShape;
    QRLabel10: TQRLabel;
    QRShape13: TQRShape;
    QRLabel11: TQRLabel;
    QRShape14: TQRShape;
    QRShape15: TQRShape;
    QRShape16: TQRShape;
    QRShape17: TQRShape;
    QRDBText1: TQRDBText;
    QRDBText2: TQRDBText;
    QRDBText3: TQRDBText;
    QRDBText4: TQRDBText;
    QRDBText5: TQRDBText;
    QRDBText6: TQRDBText;
    QRExpr1: TQRExpr;
    SummaryBand1: TQRBand;
    QRShape18: TQRShape;
    QRLabel12: TQRLabel;
    QRShape20: TQRShape;
    QRShape21: TQRShape;
    QRShape22: TQRShape;
    QRShape23: TQRShape;
    QRShape24: TQRShape;
    QRDBText7: TQRDBText;
    QRDBText8: TQRDBText;
    QRDBText9: TQRDBText;
    QRDBText10: TQRDBText;
    QRLbl_SUM: TQRLabel;
    QRep_CHART1: TQuickRep;
    QRBand1: TQRBand;
    QRShape19: TQRShape;
    QRImage3: TQRImage;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRShape25: TQRShape;
    QRLabel15: TQRLabel;
    QRLbl_DateRange: TQRLabel;
    QRBand2: TQRBand;
    QRSysData3: TQRSysData;
    QRLabel24: TQRLabel;
    QRLabel25: TQRLabel;
    QRShape40: TQRShape;
    QRLabel26: TQRLabel;
    QRSysData4: TQRSysData;
    TitleBand3: TQRBand;
    QRDBChart1: TQRDBChart;
    QRChart1: TQRChart;
    Series1: TBarSeries;
    Series2: TBarSeries;
    Series3: TBarSeries;
    Series4: TBarSeries;
    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 FormDestroy(Sender: TObject);
    procedure CmBox_SelectTJStyleKeyPress(Sender: TObject; var Key: Char);
    procedure Edt_OnlyMonthSelectKeyPress(Sender: TObject; var Key: Char);
    procedure CkBox_AllAgentClick(Sender: TObject);
    procedure SpBtn_StatClick(Sender: TObject);
    procedure QRep_WTJPreview(Sender: TObject);
    procedure QRep_CHART1Preview(Sender: TObject);
    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;
    procedure DoAllAgent_OnlySelectMonth;
    procedure DoAllAgent_OnlySelectDay;
    procedure DoAllAgent_BetweenTowDateTime;
    procedure DoOneAgent_OnlySelectMonth;
    procedure DoOneAgent_OnlySelectDay;
    procedure DoOneAgent_BetweenTowDateTime;
  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_WorkStateTJ: TForm_WorkStateTJ;

implementation

uses WorkStateTJDM, SystemPH;

{$R *.DFM}

procedure TForm_WorkStateTJ.DoAllAgent_OnlySelectMonth;
begin
   With DM_WorkStateTJ.Qr_WorkStateTJ do
        begin

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

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

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

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


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

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

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

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

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

          close; sql.Clear;
          sql.Text:='create view GZBX_Num as  select count(slr) GZBX_Num,Slr from ClientElecOut where  year(zzflsj)='''+inttostr(CurYear)+''' and Month(zzflsj)='''+Edt_OnlyMonthSelect.Text+''' Group By Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view YKZX_Num as  select count(slr) YKZX_Num,Slr from YkGcZx where  year(SlTime)='''+inttostr(CurYear)+''' and Month(SlTime)='''+Edt_OnlyMonthSelect.Text+''' Group By Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view YHTS_Num as  select count(slr) YHTS_Num,Slr from ClientComp where  year(Slsj)='''+inttostr(CurYear)+''' and Month(Slsj)='''+Edt_OnlyMonthSelect.Text+''' Group By Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view YHZX_Num as  select count(slr) YHZX_Num,Slr from ClientAsk where  year(Slsj)='''+inttostr(CurYear)+''' and Month(Slsj)='''+Edt_OnlyMonthSelect.Text+''' Group By Slr';
          ExecSQL;


          close; sql.Clear;
          sql.Text:='create view Temp1 as  select a.WorkId,a.WorkName,b.GZBX_Num from SysLogin a Left Join GZBX_Num b on a.WorkId=b.Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view Temp2 as  select a.WorkId,a.WorkName,a.GZBX_Num,b.YKZX_Num from Temp1 a Left Join YKZX_Num b on a.WorkId=b.Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view Temp3 as  select a.WorkId,a.WorkName,a.GZBX_Num,a.YKZX_Num,b.YHTS_Num from Temp2 a Left Join YHTS_Num b on a.WorkId=b.Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view Temp4 as  select a.WorkId,a.WorkName,a.GZBX_Num,a.YKZX_Num,a.YHTS_Num,b.YHZX_Num from Temp3 a Left Join YHZX_Num b on a.WorkId=b.Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view Total as  select Sum(GZBX_Num) GZBX_Total,Sum(YKZX_Num) YKZX_Total,Sum(YHTS_Num) YHTS_Total,Sum(YHZX_Num) YHZX_Total from Temp4';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='select * from Temp4';
          Open;

        end;
end;

procedure TForm_WorkStateTJ.DoAllAgent_OnlySelectDay;
var
  Uyear,Umonth,Uday:word;
begin
    DecodeDate(DatePicker.DateTime,Uyear,Umonth,Uday);
    With DM_WorkStateTJ.Qr_WorkStateTJ do
        begin

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

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

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

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


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

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

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

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

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

          close; sql.Clear;
          sql.Text:='create view GZBX_Num as  select count(slr) GZBX_Num,Slr from ClientElecOut where  year(zzflsj)='''+inttostr(UYear)+''' and Month(zzflsj)='''+inttostr(UMonth)+''' and Day(zzflsj)='''+IntToStr(Uday)+''' Group By Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view YKZX_Num as  select count(slr) YKZX_Num,Slr from YkGcZx where  year(SlTime)='''+inttostr(CurYear)+''' and Month(SlTime)='''+inttostr(UMonth)+''' and Day(Sltime)='''+IntToStr(UDay)+''' Group By Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view YHTS_Num as  select count(slr) YHTS_Num,Slr from ClientComp where  year(Slsj)='''+inttostr(CurYear)+''' and Month(Slsj)='''+inttostr(UMonth)+''' and Day(Slsj)='''+IntToStr(UDay)+''' Group By Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view YHZX_Num as  select count(slr) YHZX_Num,Slr from ClientAsk where  year(Slsj)='''+inttostr(CurYear)+''' and Month(Slsj)='''+inttostr(UMonth)+''' and Day(Slsj)='''+IntToStr(UDay)+''' Group By Slr';
          ExecSQL;


          close; sql.Clear;
          sql.Text:='create view Temp1 as  select a.WorkId,a.WorkName,b.GZBX_Num from SysLogin a Left Join GZBX_Num b on a.WorkId=b.Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view Temp2 as  select a.WorkId,a.WorkName,a.GZBX_Num,b.YKZX_Num from Temp1 a Left Join YKZX_Num b on a.WorkId=b.Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view Temp3 as  select a.WorkId,a.WorkName,a.GZBX_Num,a.YKZX_Num,b.YHTS_Num from Temp2 a Left Join YHTS_Num b on a.WorkId=b.Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view Temp4 as  select a.WorkId,a.WorkName,a.GZBX_Num,a.YKZX_Num,a.YHTS_Num,b.YHZX_Num from Temp3 a Left Join YHZX_Num b on a.WorkId=b.Slr';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='create view Total as  select Sum(GZBX_Num) GZBX_Total,Sum(YKZX_Num) YKZX_Total,Sum(YHTS_Num) YHTS_Total,Sum(YHZX_Num) YHZX_Total from Temp4';
          ExecSQL;

          close; sql.Clear;
          sql.Text:='select * from Temp4';
          Open;

        end;
end;

procedure TForm_WorkStateTJ.DoAllAgent_BetweenTowDateTime;
var
  StartTime,EndTime:TDateTime;
begin
  StartTime:=DatePicker_Start.Date;
  EndTime:=DatePicker_End.Date;

  ReplaceTime(StartTime,TimePicker_Start.time);

⌨️ 快捷键说明

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