// 判斷員工獎金新增日期是否在獎金資料建立之後或在有效日期之後 private String JudgeBonusDateIsValid() { String message = ""; BonusDefModel bonusDefModel = new BonusDefModel(); bonusDefModel.SetBonusDefID(this._bonusModel.GetBonusDefID()); BonusDefService bonusDefService = new BonusDefService(bonusDefModel); bonusDefModel = bonusDefService.SearchBonusDefByBonusDefID(); DateTime bonusDefCreateDate = bonusDefModel.GetBonusDefCreateDate(); DateTime bonusDefEffiDate = bonusDefModel.GetBonusDefEffiDate(); DateTime bonusDate = this._bonusModel.GetBonusDate(); if (bonusDate.CompareTo(bonusDefCreateDate) == -1) { message = "新增員工獎金日期在獎金資料建立之前!"; } if (bonusDate.CompareTo(bonusDefEffiDate) == 1) { message = "新增員工獎金日期在獎金有效日期建立之後!"; } return(message); }
public void TestEffiTime() { DateTime dateTime; dateTime = new DateTime(2016, 6, 21); _bonusDef.SetBonusDefEffiDate(dateTime); Assert.AreEqual(dateTime, _bonusDef.GetBonusDefEffiDate()); }