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

📄 s2.controller.ts2adapterdatapagescontroller.pas

📁 轉載的程序應用框架
💻 PAS
字号:
unit S2.Controller.TS2AdapterDataPagesController;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  S2.Controller.TS2PagesController, S2.Controller.IS2DataAdapterController,
  S2.Controller.IS2PrintController, S2.Tools.TS2Object, RzTabs, ExtCtrls,
  RzPanel, RzBckgnd, Buttons, RzSpnEdt, S2.Model.TS2Model, S2.Model.IS2DataNavigation,
  S2.View.TS2View, StdCtrls, RzLabel;

type
  TS2AdapterDataPagesController = class(TS2PagesController, IS2DataAdapterController, IS2PrintController)
    _Panel1: TRzPanel;
    _Background1: TRzBackground;
    _Panel2: TRzPanel;
    _Panel3: TRzPanel;
    _AppendButton: TRzRapidFireButton;
    _DeleteButton: TRzRapidFireButton;
    _FirstButton: TRzRapidFireButton;
    _PriorButton: TRzRapidFireButton;
    _NextButton: TRzRapidFireButton;
    _LastButton: TRzRapidFireButton;
    _Panel4: TRzPanel;
    _Label1: TRzLabel;
    _SaveButton: TRzRapidFireButton;
    procedure _PagesChange(Sender: TObject);
    procedure _AppendButtonClick(Sender: TObject);
    procedure _DeleteButtonClick(Sender: TObject);
    procedure _SaveButtonClick(Sender: TObject);
  public  //  S2.Controller.IS2DataAdapterController
    procedure Append(O: TS2Object); virtual;
    procedure Cancel(O: TS2Object); virtual;
    procedure Delete(O: TS2Object); virtual;
    procedure Modify(O: TS2Object); virtual;
    procedure Update(O: TS2Object); virtual;
    procedure First(); virtual;
    procedure Last(); virtual;
    procedure Next(); virtual;
    procedure Prior(); virtual;
  public  //  S2.Controller.IS2PrintController
    procedure PreparePrint(); virtual;
    procedure Preview(); virtual;
    procedure Print(); virtual;
  private
    _ActiveModel: TS2Model;
    _ActiveDataNavigation: IS2DataNavigation;
    _ActiveView: TS2View;
    _ActiveDataAdapterController: IS2DataAdapterController;
    _ActivePrintController: IS2PrintController;
  public
    function GetActiveModel: TS2Model;
    function GetActiveDataNavigation: IS2DataNavigation;
    function GetActiveView: TS2View;
    function GetActiveDataAdapterController: IS2DataAdapterController;
    function GetActivePrintController: IS2PrintController;
  public
    function FindActiveModel: Boolean;
    function FindActiveDataNavigation: Boolean;
    function FindActiveView: Boolean;
    function FindActiveDataAdapterController: Boolean;
    function FindActivePrintController: Boolean;
  end;

implementation

uses
  S2.Model.TS2ClientDataModel, S2.View.TS2AdapterDataItemsView, S2.View.TS2AdapterDataItemView,
  S2.View.TS2PrintView;

{$R *.dfm}

{ TS2AdapterDataPagesController }

procedure TS2AdapterDataPagesController.Append(O: TS2Object);
begin
  if FindActiveView and FindActiveDataAdapterController then
  begin
    _ActiveDataAdapterController.Append(O);
  end;
end;

procedure TS2AdapterDataPagesController.Cancel(O: TS2Object);
begin
  if FindActiveView and FindActiveDataAdapterController then
    _ActiveDataAdapterController.Cancel(O);
end;

procedure TS2AdapterDataPagesController.Delete(O: TS2Object);
begin
  if FindActiveView and FindActiveDataAdapterController then
    _ActiveDataAdapterController.Delete(O);
end;

procedure TS2AdapterDataPagesController.First;
begin
  if FindActiveModel and FindActiveDataNavigation then
    _ActiveDataNavigation.First;
end;

function TS2AdapterDataPagesController.FindActiveModel: Boolean;
begin
  Result := False;
  if GetViewCount < 1 then Exit;
  _ActiveModel := GetActiveView.GetModel;
end;

function TS2AdapterDataPagesController.FindActiveView: Boolean;
begin
  Result := False;
  if GetViewCount < 1 then Exit;
  _ActiveView := inherited GetActiveView;
  Result := True;
end;

function TS2AdapterDataPagesController.FindactiveDataNavigation: Boolean;
begin
  Result := True;
  if _ActiveModel is TS2ClientDataModel then
    _ActiveDataNavigation := _ActiveModel as TS2ClientDataModel
  else
    Result := False;
end;

procedure TS2AdapterDataPagesController.Last;
begin
  if FindActiveModel and FindActiveDataNavigation then
    _ActiveDataNavigation.Last;
end;

procedure TS2AdapterDataPagesController.Modify(O: TS2Object);
begin
  if FindActiveView and FindActiveDataAdapterController then
    _ActiveDataAdapterController.Modify(O);
end;

procedure TS2AdapterDataPagesController.Next;
begin
  if FindActiveModel and FindActiveDataNavigation then
    _ActiveDataNavigation.Next;
end;

procedure TS2AdapterDataPagesController.PreparePrint;
begin
  if FindActiveView and FindActivePrintController then
    _ActivePrintController.PreparePrint;
end;

procedure TS2AdapterDataPagesController.Preview;
begin
  if FindActiveView and FindActivePrintController then
  begin
    _ActivePrintController.PreparePrint;
    _ActivePrintController.Preview;
  end;
end;

procedure TS2AdapterDataPagesController.Print;
begin
  if FindActiveView and FindActivePrintController then
  begin
    _ActivePrintController.PreparePrint;
    _ActivePrintController.Print;
  end;
end;

procedure TS2AdapterDataPagesController.Prior;
begin
  if FindActiveModel and FindActiveDataNavigation then
    _ActiveDataNavigation.Prior;
end;

procedure TS2AdapterDataPagesController.Update(O: TS2Object);
begin
  if FindActiveView and FindActiveDataAdapterController then
    _ActiveDataAdapterController.Update(O);
end;

function TS2AdapterDataPagesController.FindActiveDataAdapterController: Boolean;
begin
  Result := True;
  if (_ActiveView is TS2AdapterDataItemsView) then _ActiveDataAdapterController := _ActiveView as TS2AdapterDataItemsView
  else if (_ActiveView is TS2AdapterDataItemView) then _ActiveDataAdapterController := _ActiveView as TS2AdapterDataItemView
  else Result := False;
end;

function TS2AdapterDataPagesController.FindActivePrintController: Boolean;
begin
  Result := True;
  if (_ActiveView is TS2PrintView) then _ActivePrintController := _ActiveView as TS2PrintView
  else Result := False;
end;

function TS2AdapterDataPagesController.GetActiveDataAdapterController: IS2DataAdapterController;
begin
  FindActiveDataAdapterController;
  Result := _ActiveDataAdapterController;
end;

function TS2AdapterDataPagesController.GetActiveDataNavigation: IS2DataNavigation;
begin
  FindActiveDataNavigation;
  Result := _ActiveDataNavigation;
end;

function TS2AdapterDataPagesController.GetActiveModel: TS2Model;
begin
  FindActiveModel;
  Result := _ActiveModel;
end;

function TS2AdapterDataPagesController.GetActivePrintController: IS2PrintController;
begin
  FindActivePrintController;
  Result := _ActivePrintController;
end;

function TS2AdapterDataPagesController.GetActiveView: TS2View;
begin
  FindActiveView;
  Result := _ActiveView;
end;

procedure TS2AdapterDataPagesController._PagesChange(Sender: TObject);
var
  View: TS2View;
begin
  inherited;
  _Label1.Caption := '当前页面 ' + GetActiveView.GetCaption;
end;

procedure TS2AdapterDataPagesController._AppendButtonClick(
  Sender: TObject);
begin
  inherited;
  Append(nil);
end;

procedure TS2AdapterDataPagesController._DeleteButtonClick(
  Sender: TObject);
begin
  inherited;
  Delete(nil);
end;

procedure TS2AdapterDataPagesController._SaveButtonClick(Sender: TObject);
begin
  inherited;
  Update(nil);
end;

end.

⌨️ 快捷键说明

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