예제 #1
0
        //呼叫service 利用bonus def ID查詢bonus資料
        public BonusDefPresentationModel SearchDataByBonusDefID()
        {
            BonusDefPresentationModel bonusDefPresentationModel = new BonusDefPresentationModel();

            if (this._bonusDefModel.GetBonusDefID() == null || this._bonusDefModel.GetBonusDefID() == "")
                MessageBox.Show("請輸入獎金ID");
            else
            {
                this._bonusDefService = new BonusDefService(this._bonusDefModel);
                this._bonusDefModel = _bonusDefService.SearchBonusDefByBonusDefID();

                bonusDefPresentationModel.SetBonusDefID(this._bonusDefModel.GetBonusDefID());
                bonusDefPresentationModel.SetBonusDefName(this._bonusDefModel.GetBonusDefName());
                bonusDefPresentationModel.SetBonusDefDesc(this._bonusDefModel.GetBonusDefDesc());
                bonusDefPresentationModel.SetBonusDefCreateDate(this._bonusDefModel.GetBonusDefCreateDate());
                bonusDefPresentationModel.SetBonusDefEffiDate(this._bonusDefModel.GetBonusDefEffiDate());
                bonusDefPresentationModel.SetBonusDefAmount(this._bonusDefModel.GetBonusDefAmount());

                if (bonusDefPresentationModel.GetBonusDefName() == null || bonusDefPresentationModel.GetBonusDefName() == "")
                {
                    MessageBox.Show("此獎金ID不存在!");
                    bonusDefPresentationModel.SetBonusDefID(null);
                }
            }
            return bonusDefPresentationModel;
        }
예제 #2
0
        // 判斷員工獎金新增日期是否在獎金資料建立之後或在有效日期之後
        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;
        }
        // 用員工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;
        }
예제 #4
0
 public void Initialize()
 {
     _bonusDef = new BonusDefModel();
     _target = new PrivateObject(_bonusDef);
 }
예제 #5
0
 public BonusDefService(BonusDefModel bonusDefModel)
 {
     this._bonusDefModel = bonusDefModel;
 }