IntraWeb »P (¤U )
Write By
v P
D
¦b v P o ÒD e A n F  IntraWeb ¤O p o d ÒA IntraWeb ¬O p g b L F A o b IntraWeb ¦
p B C  -A g u d A S O g O A o
o i B A o b IntraWeb ¤F o u A
o O p F O o u O  o D A
W IntraWeb ±O T  IntraWeb ¬O p o
e d b O O  O Session ªA O o  b o
DataModule ³i Session ªh F A o O C Session A C Session °DataModule ªA M  ÒC
M Session ªi ÒTimeout ®A DataMoudle
s A Session ±Ò
A m DataModule
W TDatabase¡B TTable ªL A M S O o O
F C  ³o k n a A u I O A j i O o s b A P o
a A A
b g Window s  µDataModule ¤Table¡C  Ãa
B O  O F A Database Connection ¤DataSet ³O n I O A b h
O t Òy t i p C  ¸M o D k h A
O Database Connection u
n A u n A n o I A o e b O T A
i F
o G :
(µ) unit IWformEmployeeGrid;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IWformEmployee, DB, IWFramMenu, IWDBStdCtrls, IWCompEdit,
IWControl, IWCompLabel, IWGrids, IWDBGrids, IWCompButton,ServerController;
type
TLastEvent=(stGridClick,stNavEdit,stNavInsert);
TformEmployeeGrid = class(TformEmployee)
IWDBGrid1: TIWDBGrid;
btnPrev: TIWButton;
btnNext: TIWButton;
procedure btnNextClick(Sender: TObject);
procedure btnPrevClick(Sender: TObject);
procedure IWDBGrid1Columns0Click(ASender: TObject;
const A Value: String);
procedure IWAppFormRender(Sender: TObject);
procedure IWAppFormAfterRender(Sender: TObject);
procedure IWDBNavigator1Edit(Sender: TObject);
procedure IWDBNavigator1First(Sender: TObject);
procedure IWDBNavigator1Insert(Sender: TObject);
private
function IsEOF:Boolean;
function IsBOF:Boolean;
procedure MaintainPage;
procedure InitData;
procedure ReloadState;
procedure SaveState(LastEvent:TLastEvent=stGridClick);
{ Private declarations }
public
procedure ExecuteForm;override;
{ Public declarations }
end;
var
formEmployeeGrid: TformEmployeeGrid;
implementation
uses IWData;
{$R *.dfm}
procedure TformEmployeeGrid.ExecuteForm;
begin
ReloadState;
inherited;
end;
procedure TformEmployeeGrid.InitData;
begin
MainDM.Database1.Connected:=True;
MainDM.tbEmployee.Open;
end;session下载
procedure TformEmployeeGrid.ReloadState;
begin
InitData;
if HiddenParams.IndexOfName('DB_STA TE') <> -1 then
begin
MainDM.tbEmployee.Locate('EmpNo',HiddenParams.Values['DB_KEY'],[]);
case TLastEvent(StrToInt(HiddenParams.Values['DB_STATE'])) of
stNavEdit:
MainDM.tbEmployee.Edit;
stNavInsert:
MainDM.tbEmployee.Insert;
end;
end;
end;
procedure TformEmployeeGrid.SaveState(LastEvent:TLastEvent=stGridClick);
begin
HiddenParams.Values['DB_KEY']:=MainDM.tbEmployee.FieldByName('EmpNo').AsString;  HiddenParams.Values['DB_STATE']:=IntToStr(Ord(LastEvent));
end;
procedure TformEmployeeGrid.MaintainPage;
begin
if IsBOF then btnPrev.Enabled:=False
else btnPrev.Enabled:=True;
if IsEOF then btnNext.Enabled:=False
else btnNext.Enabled:=True;
end;
function TformEmployeeGrid.IsEOF:Boolean;
var
vBookmark:TBookmark;
begin
Result:=False;
vBookmark:=MainDM.tbEmployee.GetBookmark;
try
MainDM.tbEmployee.MoveBy(10);
if MainDM.tbEmployee.EOF then
Result:=True;
finally
MainDM.tbEmployee.GotoBookmark(vBookmark);
MainDM.tbEmployee.FreeBookmark(vBookmark);
end;
end;
function TformEmployeeGrid.IsBOF:Boolean;
begin
Result:=UserSession.CurrentPage = 0;
end;
procedure TformEmployeeGrid.btnNextClick(Sender: TObject); begin
inherited;
MainDM.tbEmployee.First;
Inc(UserSession.CurrentPage);
MainDM.tbEmployee.MoveBy(UserSession.CurrentPage*10);  SaveState;
MaintainPage;
end;
procedure TformEmployeeGrid.btnPrevClick(Sender: TObject); begin
inherited;
MainDM.tbEmployee.First;
Dec(UserSession.CurrentPage);
MainDM.tbEmployee.MoveBy(UserSession.CurrentPage*10);
SaveState;
MaintainPage;
end;
procedure TformEmployeeGrid.IWDBGrid1Columns0Click(ASender: TObject;  const A Value: String);
begin
inherited;
MainDM.tbEmployee.Locate('EmpNo',A Value,[]);
SaveState(stGridClick);
end;
procedure TformEmployeeGrid.IWAppFormRender(Sender: TObject);
begin
inherited;
if not MainDM.tbEmployee.Active then
begin
InitData;
if (MainDM.tbEmployee.State <> dsInsert) and
(MainDM.tbEmployee.State <> dsEdit) then
MaintainPage;
ReloadState;
end;
end;
procedure TformEmployeeGrid.IWAppFormAfterRender(Sender: TObject); begin
inherited;
MainDM.tbEmployee.Close;
MainDM.Database1.Connected:=False;
end;
procedure TformEmployeeGrid.IWDBNavigator1Edit(Sender: TObject); begin

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。