不要在两个日期之间插入数据库 [英] Dont Insert in database between two dates
本文介绍了不要在两个日期之间插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
我正在Visual Basic中创建一个项目来管理酒店
在预订部分,当我要进行新的预订时,例如12-在房间3的12-2014到04-01-2015预订,但是当我在房间3进行另一次预订时,例如从2014年12月14日到2015年3月3日,它也进行预订,但我不想要在那些日子预订的程序。
我正在使用mysql数据库
你能帮帮我吗?
谢谢你
Hello
I am making a project in Visual Basic to manage a hotel
In the reservation part when i am going to make a new reservation for example from 12-12-2014 to 04-01-2015 in the room 3 it makes the reservation but when i make another reservation for example from 14-12-2014 to 03-01-2015 in the room 3 it makes the reservation too but i dont want that the program to make the reservation at those days.
And i am using mysql database
Can you help me?
Thanks
推荐答案
hi
i在C#中完成了那个逻辑,我不擅长VB.net
你可以用这个逻辑来工作VB。
hi i have done that logic in C# , i am not good at VB.net
you can use this logic to work in VB.
//12-12-2014 to 04-01-2015
DateTime DbStartdateForRoom3 = new DateTime(2014, 12, 12);
DateTime DbEnddateForRoom3 = new DateTime(2015, 01, 04);
// 14-12-2014 to 03-01-2015
DateTime selectedStartDate = new DateTime(2014, 12, 14);
DateTime selectedEndDate = new DateTime(2015, 01, 03);
List<DateTime> lstDatesEngaged = new List<DateTime>();
int j =0;
for (DateTime i = DbStartdateForRoom3; i <= DbEnddateForRoom3; i = DbStartdateForRoom3.AddDays(j))
{
lstDatesEngaged.Add( i);
j++;
}
bool isBooked = lstDatesEngaged.Any(k => k == selectedStartDate || k == selectedEndDate);
if (isBooked)
{
// show error message [Its already booked]
}
这篇关于不要在两个日期之间插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文