?? untschoolset.pas
字號:
unit UntSchoolSet;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, untBaseMDEdit, DB, ADODB, StdCtrls, Buttons, ExtCtrls, Grids,
DBGrids, jpeg, untGlobalVar, Mask, DBCtrls, fcButton, fcImgBtn;
type
TfrmSchoolSet = class(TfrmBaseMDEdit)
Label1: TLabel;
DBEdit1: TDBEdit;
Label4: TLabel;
adsDetailiAutoID: TAutoIncField;
adsDetailSchoolID: TIntegerField;
adsDetailClassYear: TStringField;
adsDetailName: TStringField;
private
{ Private declarations }
protected
procedure CheckAvoild; override;
procedure DoBeforePost; override;
procedure AfterFormShow; override;
public
{ Public declarations }
end;
function SetSchool(ADataSet: TADODataSet; AOpMode: TOperatorMode): Boolean;
implementation
uses untGlobalFun, untDM;
function SetSchool(ADataSet: TADODataSet; AOpMode: TOperatorMode): Boolean;
begin
with TfrmSchoolSet.Create(Application) do
try
DataSet := ADataSet;
Title := '學校資料';
OpMode := AOpMode;
ContinueAppend := true;
Result := ShowModal=mrOK;
finally
Free;
end;
end;
{$R *.dfm}
{ TfrmSchoolSet }
procedure TfrmSchoolSet.AfterFormShow;
var
ID: Integer;
begin
inherited;
with adsDetail do begin
if Active then Active := false;
Connection := DataSet.Connection;
if DataSet.FieldByName('iAutoID').IsNull then ID := -1
else ID := DataSet.FieldByName('iAutoID').AsInteger;
CommandText := ' select * from tClass '
+' where SchoolID='+IntToStr(ID);
Active := true;
end;
end;
procedure TfrmSchoolSet.CheckAvoild;
var
strSQL: string;
begin
inherited;
if OpMode = omNew then begin
strSQL := 'select count(*) from tSchool '
+' where Name='+QuotedStr(Trim(DBEdit1.Text));
if GetDBValue(DataSet.Connection, strSQL) > 0 then
begin
if DBEdit1.CanFocus then DBEdit1.SetFocus;
raise Exception.Create('學校名稱重復,請重輸!');
end;
end;
end;
procedure TfrmSchoolSet.DoBeforePost;
var
ABookStr: TBookmarkStr;
ID: Integer;
begin
inherited;
with adsDetail do begin
if State in [dsInsert, dsEdit] then Post;
DisableControls;
ABookStr := Bookmark;
First;
if OpMode=omNew then
ID := GetMaxID(DataSet.Connection, 'tSchool', 'iAutoID')
else
ID := DataSet.FieldByName('iAutoID').Value;
while not Eof do begin
Edit;
if adsDetailSchoolID.Value <> ID then
adsDetailSchoolID.Value := ID;
Post;
Next;
end;
EnableControls;
end;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -