界说一个判断皂班/夜班的办法
priZZZate bool IsNight(DateTime curDt, DateTime dtBeginTime, DateTime dtEndTime) { bool isNight = false; if (dtBeginTime < dtEndTime && curDt >= dtBeginTime && curDt < dtEndTime) { //皂班 isNight = false; } else if { //夜班 isNight = true; } return isNight; }而后,可以通过那种方式挪用
ZZZar curDt = DateTime.Now; DateTime dtBeginTime = DateTime.Parse(String.Format("{0} {1}", curDt.ToString_yyyyMMdd(),"08:30:00")); DateTime dtEndTime = DateTime.Parse(String.Format("{0} {1}", curDt.ToString_yyyyMMdd(),"20:30:00")); ZZZmData.isNight = IsNight(curDt, dtBeginTime, dtEndTime);