防止同一日期重复预订 [英] preventing double booking for same date

查看:117
本文介绍了防止同一日期重复预订的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我正在开发一个Web表单,用户可以在其中预订房间,并且我想防止同一天再次进行预订.如何防止别人预订已经预订的房间.

例如,我正在预订5月10日至12日的房间,然后我希望任何用户都不能预订5月12日至5月12日的房间,或者直到12日为止的任何日期,因为它已经预订了10至12日. > 并且我必须在其中输入开始日期和结束日期的文本框中,我想在此处进行检查.

请以JavaScript,SQL或C#编码提供逻辑或代码.

谢谢

Hello

I am developing a web form in which users can book rooms and I want to prevent another booking taking place on the same date. How would I prevent someone else from booking a room that has already been booked.

as a example i am booking a room for 10 may to 12 may then i want that any user can not book that room for 10 may to 12 may or any date upto 12 may becouse it is already booked for 10 to 12.
and i have to text boxes in which start date and and end date are being entered i want to put a check here.

Please provide logic or code in JavaScript, SQL or C# coding.

Thanks

推荐答案

您的问题确实有两部分.第一部分是如何防止用户在打开页面选择可以预订的房间时选择已经预订的房间.如果您知道某个房间已经被预订,那么您的目的是通过直观地指示该房间已被预订,让用户知道他们无法预订.也许通过改变那个时期的颜色.但是,如果用户选择该日期,您也将禁用按钮以保存预订.

问题的第二部分稍微有些微妙,但是却经常被那些忘记了他们正在设计多用户系统的人所忽略.您要在此处阻止的是用户选择在页面打开后已经预订的房间,或者选择与他们试图预订房间同时预订的房间.这有一个简单的技巧-在您的插入语句中,将日期用作插入测试的一部分.您可以使用基于选择的INSERT功能来进行此操作,然后进行测试以查看该日期是否已经预订了房间(此处的重要提示是这是您的选择标准).如果您不能插入记录,那么您就知道该房间已被预订.
There are really a couple of parts to your question. The first part is how to prevent the user from choosing a room that has already been booked when they open up the page to choose the rooms they can book. If you know that a room has been booked, at this point, you would aim to let the user know that they can''t book it by visually indicating that the room has been booked; perhaps by changing colours for that period. But you would also disable the buttons to save the booking if the user chooses that date.

The second part to your question is slightly more subtle, but is one that is often overlooked by people who forget that they are designing a multi-user system. What you are trying to prevent here is the user selecting a room that has been booked after the page has opened, or is being booked at the same time as they attempt to book that room. There''s a simple trick to this - in your insert statement, use the date as part of the an insert test. You do this by using the ability to INSERT based off a selection, and you test to see if the room has been booked for that date (the big hint here is that this is your select criteria). If you can''t insert the record, then you know the room has been booked.


u将创建表室!!! ...插入列状态并保持该状态.默认值是false ...当用户预订时,将其值更改为true....使用此方法,您可以检查并阻止已经预订的房间....仅向用户显示免费的房间...
u would have created the table room !!!...insert the column status and keep the default value as false ...when an user books it change the value to true ....with this u can check and prevent the already booked room ....show the users only the rooms which are free ...


这篇关于防止同一日期重复预订的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆