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

📄 findstatframefrm.pas

📁 相关的销售服务管理行业的一个软件
💻 PAS
字号:
unit FindStatFrameFrm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, jpeg, ExtCtrls, ActnList, Buttons, ComCtrls, Grids, DBGridEh,
  Db, ADODB, EHGrids;

type
  TFindStatFrameForm = class(TForm)
    Panel1: TPanel;
    Image1: TImage;
    LTitle: TLabel;
    Panel2: TPanel;
    Panel3: TPanel;
    DBGridEh1: TDBGridEh;
    DTPBegin: TDateTimePicker;
    DTPEnd: TDateTimePicker;
    Label2: TLabel;
    Label3: TLabel;
    BitBtn1: TBitBtn;
    BitBtn3: TBitBtn;
    BitBtn2: TBitBtn;
    ActionList1: TActionList;
    APrint: TAction;
    AClose: TAction;
    AExec: TAction;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    AReview: TAction;
    BitBtn4: TBitBtn;
    procedure DTPBeginChange(Sender: TObject);
    procedure DTPBeginCloseUp(Sender: TObject);
    procedure DTPEndChange(Sender: TObject);
    procedure DTPEndCloseUp(Sender: TObject);
    procedure ACloseExecute(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure AExecExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure DBGridEh1TitleBtnClick(Sender: TObject; ACol: Integer;
      Column: TColumnEh);
    procedure DBGridEh1SortMarkingChanged(Sender: TObject);
  private
    FTitle: string;
    FBeginDate: TDate;
    FEndDate: TDate;
    FIsASCOrder: Boolean;
    FSortString: String;
    procedure SetTitle(const Value: string);
    procedure SetBeginDate(const Value: TDate);
    procedure SetEndDate(const Value: TDate);
    function  BeforeMonthDate(consultDate: TDateTime): TDateTime;
    procedure SetIsASCOrder(const Value: Boolean);
    procedure SetSortString(const Value: String);
  protected
    ColumnIndex: integer;
    ConditionString: string;
    procedure InitInterface; virtual;
    procedure InitCondition; virtual;
    procedure CreateConditionString; virtual;
  public
    { Public declarations }
    property Title: string read FTitle write SetTitle;
    property BeginDate: TDate read FBeginDate write SetBeginDate;
    property EndDate:   TDate read FEndDate   write SetEndDate;
    property IsASCOrder: Boolean read FIsASCOrder write SetIsASCOrder;
    property SortString: String read FSortString write SetSortString;
  end;

var
  FindStatFrameForm: TFindStatFrameForm;

implementation

uses Umain, U_DM;

{$R *.DFM}

{ TFindStatFrameForm }

const QASCInf  = ' %s ASC ';
const QDESCInf = ' %s DESC ';

procedure TFindStatFrameForm.SetBeginDate(const Value: TDate);
begin
  FBeginDate := Value;
  if DTPBegin.Date<>Value then
    DTPBegin.Date := Value;
end;

procedure TFindStatFrameForm.SetEndDate(const Value: TDate);
begin
  FEndDate := Value;
  if DTPEnd.Date<>Value then
    DTPEnd.Date := Value;
end;

procedure TFindStatFrameForm.SetTitle(const Value: string);
begin
  FTitle := Value;
  lTitle.Caption := Value;
  self.Caption := Value;
end;

procedure TFindStatFrameForm.DTPBeginChange(Sender: TObject);
begin
  if DTPBegin.Date>DTPEnd.Date then
    DTPBegin.Color := clsilver
  else
    DTPBegin.Color := clWindow;
  BeginDate := DTPBegin.Date;  
end;

procedure TFindStatFrameForm.DTPBeginCloseUp(Sender: TObject);
begin
  if DTPBegin.Date>DTPEnd.Date then
  begin
    DTPBegin.Color := clWindow;
    DTPBegin.Date := DTPEnd.Date;
  end;
end;

procedure TFindStatFrameForm.DTPEndChange(Sender: TObject);
begin
  if DTPBegin.Date>DTPEnd.Date then
    DTPEnd.Color := clsilver
  else
    DTPEnd.Color := clWindow;
  EndDate := DTPEnd.Date;  
end;

procedure TFindStatFrameForm.DTPEndCloseUp(Sender: TObject);
begin
  if DTPBegin.Date>DTPEnd.Date then
  begin
    DTPEnd.Color := clWindow;
    DTPEnd.Date := DTPBegin.Date;
  end;
end;

procedure TFindStatFrameForm.InitCondition;
begin
  BeginDate := BeforeMonthDate(Date);
  EndDate := Date;
  ColumnIndex := 0;
  IsASCOrder := true;
end;

function TFindStatFrameForm.BeforeMonthDate(consultDate: TDateTime): TDateTime;
var
  year,month,day,year_1,month_1: word;
  days,days1,days2: integer;
begin

  decodeDate(consultDate,year,month,day);
  
  if month <> 1 then
  begin
    month_1 := month-1;
    year_1 := year;
  end
  else
  begin
    month_1 := 12;
    year_1 := year-1;
  end;
  days1 := DateTimeToTimeStamp(encodeDate(year,month,1)).Date;
  days2 := DateTimeToTimeStamp(encodeDate(year_1,month_1,1)).Date;
  days := days1-days2;
  if day < days then
    result := encodeDate(year_1,month_1,day)
  else
    result := encodeDate(year_1,month_1,days);

end;

procedure TFindStatFrameForm.ACloseExecute(Sender: TObject);
begin
  Close;
end;

procedure TFindStatFrameForm.FormActivate(Sender: TObject);
begin
  frmmain.Outlook1.Visible := false;
  frmmain.Panel1.Visible   := false;
  frmmain.Panel2.Visible   := false;
end;

procedure TFindStatFrameForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Frmmain.Outlook1.Visible :=true;
  frmmain.Panel1.Visible:=true;
  Frmmain.Panel2.Visible:=True;
  frmmain.Label1.Caption:='';
  frmmain.LTitle.Caption := '';
  Action := caFree;
end;

procedure TFindStatFrameForm.AExecExecute(Sender: TObject);
begin
  CreateConditionString;
end;

procedure TFindStatFrameForm.InitInterface;
begin
//
end;

procedure TFindStatFrameForm.CreateConditionString;
begin
//set ConditionString
end;

procedure TFindStatFrameForm.FormCreate(Sender: TObject);
begin
  InitInterface;
  InitCondition;
  AExec.OnExecute(nil);
end;

procedure TFindStatFrameForm.SetIsASCOrder(const Value: Boolean);
begin
  FIsASCOrder := Value;
  DBGridEh1.Columns[0].Title.SortMarker := smNoneEh;//?
  if Value and (DBGridEh1.Columns[ColumnIndex].Title.SortMarker<>smUpEh) then
  begin
    DBGridEh1.Columns[ColumnIndex].Title.SortMarker := smUpEh;
    DBGridEh1.OnSortMarkingChanged(nil);
  end;
  if not Value and (DBGridEh1.Columns[ColumnIndex].Title.SortMarker<>smDownEh) then
  begin
    DBGridEh1.Columns[ColumnIndex].Title.SortMarker := smDownEh;
    DBGridEh1.OnSortMarkingChanged(nil);
  end;
end;

procedure TFindStatFrameForm.DBGridEh1TitleBtnClick(Sender: TObject;
  ACol: Integer; Column: TColumnEh);
begin
  ColumnIndex := ACol;
end;

procedure TFindStatFrameForm.DBGridEh1SortMarkingChanged(Sender: TObject);
begin
  if (DBGridEh1.Columns[ColumnIndex].Title.SortMarker = smUpEh) then
    SortString := Format(QASCInf,[DBGridEh1.Columns[ColumnIndex].Title.Caption])
  else
    SortString := Format(QDESCInf,[DBGridEh1.Columns[ColumnIndex].Title.Caption]);
end;

procedure TFindStatFrameForm.SetSortString(const Value: String);
begin
  FSortString := Value;
  if ADOQuery1.Active then
    ADOQuery1.Sort := Value;
end;

end.

⌨️ 快捷键说明

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