------------------------------------------------
first table :
------------------------------------------------
IDBooking (P.K) Type Guest Hotel Address
------------------------------------------------
1
2
3
4
------------------------------------------------
Second Table
------------------------------------------------
ID(P.K) IdBooking (F.K) Number Night Number Rooms
------------------------------------------------
1 1
2 1
3 1
4 2
5 2
6 2
7 2
8 3
------------------------------------------------
When you delete the IDBooking(ID = 1) from
first table
, you should two any of the following.
0) Check the ID exists in the
second table
, if exists then show alert like you have mentioned in your question.
You must delete all Booking in the Second table
that related with this Client.
Sample query to find existence of records
SELECT * FROM second-table WHERE IdBooking=@ID
Check this article to show alerts
Use & Call RegisterStartUpScript, RegisterClientScript and Client-Side Script[
^]
1) Delete the matching record[IDBooking(ID = 1)] from
second table
, then delete the record from
first table
. And display message to end user.
Sample query to delete records
DELETE FROM second-table WHERE IdBooking=@ID
DELETE FROM first-table WHERE IdBooking=@ID
But it depends on requirement.