如何检查周期是否重叠 [英] How do I Check if Periods Overlap

查看:86
本文介绍了如何检查周期是否重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经获得了一个项目来创建预订dbase的房间,并希望在我保存之前搜索当前记录以验证预订。


我的预订记录包含以下信息: -

tblBooking

日期StartTime EndTime RoomNo

10/10/2011 9 AM 1PM 7

10/10/2011下午1点4点7

10/10/2011 9AM 2PM 1

10/10/2011 3PM 5PM 1

12/10/2011下午5点1


frmBooking

如果我预订房间1(比如)10/10/2011下午2点到下午4点(比如说)我需要看看在tblBooking中检查房间在这个日期和时间是免费的。


任何人都可以就此提出建议。

解决方案

在My Humble Opinion中,这将是MS Access日历应用程序的完美候选者,它在Bytes中如此受欢迎。对于任何给定的日期,此日历将为您提供关于特定房间是否可用于指定日期和时间间隔的视觉提示。如果你感兴趣的话,它太过于复杂地解释了这是怎么做的,但我已经为你创建了一个简单的Demo。

  1. 下载附件。
  2. 单击任何特定日期以展开表单底部的列表框,该列表框将显示其他扩展信息。数据按日期,房间号和开始时间排序,并应明确指示是否可以进行预订。
  3. 月/年导航可以通过多个控件轻松完成。
  4. 您可以填充tblBookings,然后在表单上显示预约。
  5. 您甚至可以添加允许您直接通过Calendar GUI添加预订的功能。
  6. 有任何问题,请随时询问。

附加文件
Bookings.zip (55.0 KB,236 views)


感谢ADZel(再次)


我是upda记录到Outlook并启动了一些逻辑来检查是否有任何重叠,如下所示: -

展开 | 选择 | Wrap | 行号


正如我所见,关于新预订,您必须检查4个条件,即:日期,房间号,开始时间,结束时间。如果日期相同,并且房间号相同,并且开始时间在开始和结束时间范围之间,或者结束时间在数据库中的任何记录的开始和结束时间范围之间,那么预约无效。由于下午3点,以下预订将失败2011年10月10日#7房间的开始时间。从下午1:00起的时间间隔内,此日期(10/10/2011)和房间(7)已存在现有预约。下午4点,1小时重叠。当您执行此代码时,您将获得预订无效,但如果您将开始时间更改为下午5:00,则一切都在世界各地。

展开 | 选择 | Wrap | 行号

I have been given a project to create a room booking dbase and wish to search current records to validate a booking before I save it.

My booking records contains info like:-
tblBooking
Date StartTime EndTime RoomNo
10/10/2011 9AM 1PM 7
10/10/2011 1PM 4PM 7
10/10/2011 9AM 2PM 1
10/10/2011 3PM 5PM 1
12/10/2011 5PM 6PM 1

frmBooking
If I make a booking for Room 1 for (say) 10/10/2011 for 2PM to 4PM (say) I need to look in the tblBooking to check that the room is free on this date and time.

Would anyone be able to advise on this please.

解决方案

In My Humble Opinion, this would be a perfect candidate for the MS Access Calendar App that is so popular here at Bytes. For any given Date, this Calendar will give you a visual cue as to whether or not a specific Room would be available for a specified Date and Time Interval. It is too involved to explain exactly how this is done, but I have created a simple Demo for you if you are interested.

  1. Download the Attachment.
  2. Click on any specific Date to expand a Listbox at the bottom of the Form that will display additional, expanded information. The Data is sorted by Date, Room Number, and Start Time and should give a clear indication as to whether or not a Reservation can occur.
  3. Month/Year Navigation can easily be accomplished via several Controls.
  4. You can Populate tblBookings, then have the Reservation display on the Form.
  5. You can even add functionality that will allow you to add Reservations through the Calendar GUI directly.
  6. Any questions, feel free to ask.

Attached Files
Bookings.zip (55.0 KB, 236 views)


Thanks ADZel (again)

I am updateing records to Outlook and have started some logic to check for any overlap as follows:-

Expand|Select|Wrap|Line Numbers


As I see it, there are 4 conditions that you must check for regarding a New Reservation, namely: Date, Room Number, Start Time, End Time. If the Date is the same, AND the Room Number is the same, AND the Start Time is between the Start and End Time Range, OR the End Time is between the Start and End Time Range for any Record in the Database, then the Reservation is NOT Valid. The following Reservation will fail because of the 3:00 P.M. Start Time for Room #7 on 10/10/2011. An existing Reservation already exists for this Date (10/10/2011) and Room (7) from the Time Interval from 1:00 P.M. to 4:00 P.M., a 1 Hour Overlap. When you execute this Code, you will get a Reservation NOT Valid, but if you change the Start Time to 5:00 P.M., all is well in the world.

Expand|Select|Wrap|Line Numbers


这篇关于如何检查周期是否重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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