A simple question for Hotel Rezervation sytem..

I have 2 columns first column for fromDate secont column is toDate. A hotel rezervation system have 3 tables. and 3 form. First table is costumerTable, second Table is RoomTable and 3rd table is relations tables.

I want this ""if I register a room to people between fromDate to ToDate second rezervation can not be between fromDate to ToDate for same room. I just need this code for utcdatetime grid methods on RezervationForm or just only descrition for how can I do that. Thanks you from Now.

I statrted to learn ax for 1 month. I need to much help. Thanks from Now.

Hi Adil Balkiz,

Welcome to dynamicsuser.net!!!

Please validate the date range in the form datasource’s validatewrite method.

Please use the below code

public boolean validateWrite()

{

ReservationTable checkReservationTable;

boolean ret;

ret = super();

if(ret)

{

select * from checkReservationTable

where checkReservationTable.Room == ReservationTable.Room

&& ((ReservationTable.FromDate >= checkReservationTable.FromDate && ReservationTable.FromDate <= checkReservationTable.ToDate)

|| (ReservationTable.ToDate >= checkReservationTable.FromDate && ReservationTable.ToDate <= checkReservationTable.ToDate))

&& checkReservationTable.RecId != ReservationTable.RecId;

if(checkReservationTable.RecId)

{

error(‘Error message’);

ret = false;

}

}

return ret;

}

Thanks,

Hari

Thank you Teacher Hari. :slight_smile:

You are welcome.

Please verify if the solution is correct.

this code block is true but if I chose a room and then create new rezervation for same room on form. new rezarvation dont be for another dates for same room. for exaple costumer: Adil: RoomNumber: 12 fromDate: 12.12.2014 to date: 01.12.2015

costumer: Hari roomNumber: 12 fromdate: 02.04.2015 to date : 05.05.2015

if I want like this system is not register. System ERROR said to me : this record before create you can not do that. so future rezervation is not try. :frowning:

this code block is true but if I chose a room and then create new rezervation for same room on form. new rezarvation dont be for another dates for same room. for exaple costumer: Adil: RoomNumber: 12 fromDate: 12.12.2014 to date: 01.12.2015

costumer: Hari roomNumber: 12 fromdate: 02.04.2015 to date : 05.05.2015

if I want like this system is not register. System ERROR said to me : this record before create you can not do that. so future rezervation is not try. :frowning:

this code block is true but if I chose a room and then create new rezervation for same room on form. new rezarvation dont be for another dates for same room. for exaple costumer: Adil: RoomNumber: 12 fromDate: 12.12.2014 to date: 01.12.2015

costumer: Hari roomNumber: 12 fromdate: 02.04.2015 to date : 05.05.2015

if I want like this system is not register. System ERROR said to me : this record before create you can not do that. so future rezervation is not try. :frowning:

Hi,

Yes. I think, when you try to insert there is no recid so, it is not allowing to insert. Please use this code

if(ReservationTable.RecId)

{

select * from checkReservationTable

where checkReservationTable.Room == ReservationTable.Room

&& ((ReservationTable.FromDate >= checkReservationTable.FromDate && ReservationTable.FromDate <= checkReservationTable.ToDate)

|| (ReservationTable.ToDate >= checkReservationTable.FromDate && ReservationTable.ToDate <= checkReservationTable.ToDate))

&& checkReservationTable.RecId != ReservationTable.RecId;

}

else

{

select * from checkReservationTable

where checkReservationTable.Room == ReservationTable.Room

&& ((ReservationTable.FromDate >= checkReservationTable.FromDate && ReservationTable.FromDate <= checkReservationTable.ToDate)

|| (ReservationTable.ToDate >= checkReservationTable.FromDate && ReservationTable.ToDate <= checkReservationTable.ToDate));

}

Thanks,

Hari

Thank you brother Hari I willl try new Code. Have nice time.

I think your new code like true…