——此文章摘自《Delphi开发经验技巧宝典》定价
¥
特价
¥
购买>>http://track
linktech
cn/?m_id=dangdang&a_id=A
&l=
&l_type
=
width=
height=
border=
nosave>
本例是在窗体关闭前判断是否有未保存的数据如果有则给予提示并自动保存数据主要代码如下
procedure TFrmSaveFormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if ADODataSetState in [dsInsert dsEdit] then
begin
if MessageBox( 发现未保存的数据需要保存吗? MB_YESNO +
MB_ICONQUESTION) = IDYES then
begin
SaveData;
end;
end;
end;
{保存数据}
procedure TFrmSaveSaveData;
begin
with ADODataSet do
begin
Edit;
FieldByName(Number)AsString := Trim(EDNumberText);
FieldByName(Name)AsString := Trim(EDNameText);
FieldByName(Old)AsInteger := StrToIntDef(Trim(EdOldText) );
if CBxSexText = 男 then
FieldByName(Sex)AsInteger :=
else
FieldByName(Sex)AsInteger := ;
FieldByName(TelePhone)AsString := Trim(EdTelePhoneText);
FieldByName(DepartMent)AsString := Trim(CBXdePartMentText);
FieldByName(JoinDate)AsDateTime := DTPJoinDateDate;
Post;
end;
end;