?? cformcorplist.pas
字號(hào):
{-----------------------------------------------------------------------------
Unit Name: CFormCorpList
Author: hubdog(陳省)
Purpose: 單位列表
BeginDate: 2002-6-28
History:
對(duì)于IWDbGrid來說:
要想標(biāo)出當(dāng)前記錄所在行,要設(shè)定Options的dgIndicator為True
RowLimite限制當(dāng)前Grid顯示的數(shù)據(jù)條數(shù),為0表示無限制,這時(shí)如果
數(shù)據(jù)太多,會(huì)自動(dòng)出現(xiàn)一個(gè)滾動(dòng)條。
翻頁(yè)的實(shí)現(xiàn)是通過數(shù)據(jù)集MoveBy方法來實(shí)現(xiàn)的,但是同時(shí)必須將Grid.FromStart屬性設(shè)定為False
Column.Text和Header屬性不知道是干什么的?
LinkField可以將綁定的字段的值傳給OnClick事件,可以用來定位數(shù)據(jù)集的游標(biāo)
Note:注意Table有序號(hào),但是Query就無法取得RecNo
-----------------------------------------------------------------------------}
unit CFormCorpList;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, CFormBase, CFrameMenu, IWControl, IWCompLabel, IWExtCtrls, jpeg,
IWGrids, IWDBGrids, IWDBStdCtrls, DB, ADODB, IWCompMemo, IWCompButton,
BetterADODataSet, CFormEditCorp;
type
TformCorpList = class(TformBase)
iwgCorp: TIWDBGrid;
iwnCorp: TIWDBNavigator;
iwdmChnInfo: TIWDBMemo;
iwdmEngInfo: TIWDBMemo;
iwbIWLabel1: TIWLabel;
iwbIWLabel2: TIWLabel;
iwbLastPage: TIWButton;
iwbNextPage: TIWButton;
iwbDelete: TIWButton;
procedure iwbLastPageClick(Sender: TObject);
procedure iwbNextPageClick(Sender: TObject);
procedure adotCorpNoGetText(Sender: TField; var Text: String;
DisplayText: Boolean);
procedure iwgCorpColumns1Click(ASender: TObject; const AValue: String);
procedure iwnCorpEdit(Sender: TObject);
procedure IWAppFormCreate(Sender: TObject);
procedure iwnCorpInsert(Sender: TObject);
procedure iwbDeleteClick(Sender: TObject);
private
{ Private declarations }
FEditForm:TformEditCorp;
public
{ Public declarations }
end;
var
formCorpList: TformCorpList;
implementation
uses DatamoduleUnit, IWAppForm, IWInit, IWTypes;
{$R *.dfm}
procedure TformCorpList.iwbLastPageClick(Sender: TObject);
begin
inherited;
//adoqCorp.MoveBy(-iwgCorp.RowLimit);
dmHR.badoCorp.MoveBy(-iwgCorp.RowLimit);
end;
procedure TformCorpList.iwbNextPageClick(Sender: TObject);
begin
inherited;
//adoqCorp.MoveBy(iwgCorp.RowLimit);
dmHR.badoCorp.MoveBy(iwgCorp.RowLimit);
end;
procedure TformCorpList.adotCorpNoGetText(Sender: TField; var Text: String;
DisplayText: Boolean);
begin
inherited;
Text:=IntToStr(Sender.DataSet.RecNo);
end;
procedure TformCorpList.iwgCorpColumns1Click(ASender: TObject;
const AValue: String);
var
Id:Integer;
begin
inherited;
//
Id:=StrToInt(AValue);
dmHR.badoCorp.Locate('CorpId',Id,[]);
end;
procedure TformCorpList.iwnCorpEdit(Sender: TObject);
begin
//inherited;
// 顯示編輯窗體
FEditForm.EditMode:=emEdit;
FEditForm.CorpId:=dmhr.badoCorp.FieldByName('CorpId').AsInteger;
FEditForm.Show;
end;
procedure TformCorpList.IWAppFormCreate(Sender: TObject);
begin
inherited;
FEditForm:=TformEditCorp.Create(RWebApplication);
try
//adoqCorp.Active := True;
dmHR.badoCorp.Active:=True;
except
//Todo:增加錯(cuò)誤反饋信息
end;
end;
procedure TformCorpList.iwnCorpInsert(Sender: TObject);
begin
//inherited;
// 顯示編輯窗體
FEditForm.EditMode:=emInsert;
//FEditForm.CorpId:=dmhr.badoCorp.FieldByName('CorpId').AsInteger;
FEditForm.Show;
end;
procedure TformCorpList.iwbDeleteClick(Sender: TObject);
begin
inherited;
//因?yàn)镮WDBNavigator默認(rèn)情況下是先刪除,然后才調(diào)用我們的事件,因此需要修改這一處理過程
//所以只好是用Button來實(shí)現(xiàn)
with dmHR do
begin
badoQuery.Active:=False;
badoQuery.CommandText:=format('Select count(*) as HumanCount from tblhuman where CorpID=%s', [badoCorp.FieldByName('CorpID').AsString]);
badoQuery.Active:=True;
if badoQuery.FieldByName('HumanCount').AsInteger>0 then
begin
WebApplication.ShowMessage('先刪除該公司下所有的人員信息后才能刪除該公司');
Exit;
end;
//Todo:加事務(wù)處理?
badoCorp.Delete;
end;
end;
end.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -