示例#1
0
        /// <summary>
        /// 判断选择的日期是否可以预约,false为不可预约
        /// </summary>
        /// <param name="set"></param>
        /// <returns></returns>
        private bool dateBespeak(SeatManage.ClassModel.SeatBespeakSet set, DateTime nowDate)
        {
            DateTime selectedDate = DateTime.Parse(date);

            for (int i = 0; i < set.NoBespeakDates.Count; i++)
            {
                try
                {
                    DateTime beginDate = DateTime.Parse(set.NoBespeakDates[i].BeginTime);
                    DateTime endDate   = DateTime.Parse(set.NoBespeakDates[i].EndTime);
                    if (SeatManage.SeatManageComm.DateTimeOperate.DateAccord(beginDate, endDate, selectedDate))
                    {//如果当前时间符合某个不可预约的规则,则直接返回false,不可预约
                        return(false);
                    }
                }
                catch
                {//日期转换遇到异常,则忽略
                }
            }
            //判断当天是否大于选择的日期
            TimeSpan span = selectedDate.Date - nowDate.Date;

            if (span.Days > set.BespeakBeforeDays)
            {
                return(false);
            }
            return(true);
        }
示例#2
0
 /// <summary>
 /// 判断当前时间是否可以预约
 /// </summary>
 /// <param name="set"></param>
 /// <param name="nowDate"></param>
 /// <returns></returns>
 private bool timeCanBespeak(SeatManage.ClassModel.SeatBespeakSet set, DateTime nowDate)
 {
     try
     {
         DateTime beginTime = DateTime.Parse(string.Format("{0} {1}", nowDate.ToShortDateString(), set.CanBespeatTimeSpace.BeginTime));
         DateTime endTime   = DateTime.Parse(string.Format("{0} {1}", nowDate.ToShortDateString(), set.CanBespeatTimeSpace.EndTime));
         if (SeatManage.SeatManageComm.DateTimeOperate.DateAccord(beginTime, endTime, nowDate))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(true);
     }
 }