// 用員工ID查詢該員工所有獎金, 並判斷日期與期別是否在輸入範圍內, 回傳所有在範圍內的獎金總合 private float ComputeEmplBonus(String emplID) { float totalBonus = 0; BonusModel bonusModel = new BonusModel(); bonusModel.SetEmplID(emplID); BonusService bonusService = new BonusService(bonusModel); List <BonusModel> emplTotalBonus = bonusService.searchBonusByEmplID(); List <BonusModel> emplBonusInDate = new List <BonusModel>(); int emplTotalBonusCount = emplTotalBonus.Count; // 取出所有符合日期與期別的獎金資料 for (int i = 0; i < emplTotalBonusCount; i++) { DateTime bonusDate = emplTotalBonus[i].GetBonusDate(); String bonusT = emplTotalBonus[i].GetBonusT(); if (bonusDate.CompareTo(this._startDate) == 1 && bonusDate.CompareTo(this._endDate) == -1 && bonusT == this._salaryT) { emplBonusInDate.Add(emplTotalBonus[i]); } } // 計算符合日期與期別之獎金總額 BonusDefModel bonusDefModel; BonusDefService bonusDefService; int totalBonusInDateCount = emplBonusInDate.Count; for (int i = 0; i < totalBonusInDateCount; i++) { bonusDefModel = new BonusDefModel(); bonusDefModel.SetBonusDefID(emplBonusInDate[i].GetBonusDefID()); bonusDefService = new BonusDefService(bonusDefModel); bonusDefModel = bonusDefService.SearchBonusDefByBonusDefID(); totalBonus += bonusDefModel.GetBonusDefAmount(); } return(totalBonus); }
public void TestAmount() { _bonusDef.SetBonusDefAmount(81000.00F); Assert.AreEqual(81000.00F, _bonusDef.GetBonusDefAmount()); }