E
e518
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFrmHotelRoomType.BtnAddClick(Sender: TObject);
var
s:string;
begin
if sender=BtnAdd then begin
s:='insert into Hotel.RoomType (rRoomType,rRoomPriceDay,rRoomPriceHour)'+
' values ('+
quotedstr(RoomType.tType)+','+
quotedstr(floattostr(RoomType.tPriceDay))+','+
quotedstr(floattostr(RoomType.tPriceHour))+')';
end
else begin
s:='update RoomType set'+
' rRoomType='+quotedstr(RoomType.tType)+','+
' rRoomPriceDay='+quotedstr(floattostr(RoomType.tPriceDay))+','+
' rRoomPriceHour='+quotedstr(floattostr(RoomType.tPriceHour))+
' where rRoomType='+quotedstr(ADORoomType.FieldValues['rRoomType']);
end;
HotelDM.ADOLink.BeginTrans;
with HotelDM.CommitSQL do begin
Close;
SQL.Clear;
SQL.Add(s);
ExecSQL; //这一行,我见有些资料是放于TRY语句之后,CommitTrans之前,不知怎样的才对
//请各位大虾指正。
try
//ExecSQL; //这一行。。。。。
HotelDM.ADOLink.CommitTrans;
except
HotelDM.ADOLink.RollbackTrans;
s:='房间类型:“'+RoomType.tType+'”已存在,请重输新值。';
MessBox(s);
end;
end;
end;
var
s:string;
begin
if sender=BtnAdd then begin
s:='insert into Hotel.RoomType (rRoomType,rRoomPriceDay,rRoomPriceHour)'+
' values ('+
quotedstr(RoomType.tType)+','+
quotedstr(floattostr(RoomType.tPriceDay))+','+
quotedstr(floattostr(RoomType.tPriceHour))+')';
end
else begin
s:='update RoomType set'+
' rRoomType='+quotedstr(RoomType.tType)+','+
' rRoomPriceDay='+quotedstr(floattostr(RoomType.tPriceDay))+','+
' rRoomPriceHour='+quotedstr(floattostr(RoomType.tPriceHour))+
' where rRoomType='+quotedstr(ADORoomType.FieldValues['rRoomType']);
end;
HotelDM.ADOLink.BeginTrans;
with HotelDM.CommitSQL do begin
Close;
SQL.Clear;
SQL.Add(s);
ExecSQL; //这一行,我见有些资料是放于TRY语句之后,CommitTrans之前,不知怎样的才对
//请各位大虾指正。
try
//ExecSQL; //这一行。。。。。
HotelDM.ADOLink.CommitTrans;
except
HotelDM.ADOLink.RollbackTrans;
s:='房间类型:“'+RoomType.tType+'”已存在,请重输新值。';
MessBox(s);
end;
end;
end;