//呼叫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; }
// 建構子 public BonusDefController(BonusDefPresentationModel bonusDefPresentationModel) { this._bonusDefModel.SetBonusDefID(bonusDefPresentationModel.GetBonusDefID()); this._bonusDefModel.SetBonusDefName(bonusDefPresentationModel.GetBonusDefName()); this._bonusDefModel.SetBonusDefDesc(bonusDefPresentationModel.GetBonusDefDesc()); this._bonusDefModel.SetBonusDefCreateDate(bonusDefPresentationModel.GetBonusDefCreateDate()); this._bonusDefModel.SetBonusDefEffiDate(bonusDefPresentationModel.GetBonusDefEffiDate()); this._bonusDefModel.SetBonusDefAmount(bonusDefPresentationModel.GetBonusDefAmount()); }
// 按下搜尋bonus def button private void ClickSearchBonusDefButton(object sender, EventArgs e) { String bonusDefID = _editBonusDefIDTB.Text; this._bonusDefPresentationModel.SetBonusDefID(bonusDefID); this._bonusDefController = new BonusDefController(this._bonusDefPresentationModel); this._bonusDefPresentationModel = this._bonusDefController.SearchDataByBonusDefID(); if (this._bonusDefPresentationModel.GetBonusDefID() != null) { this.ResetAllEditUIToEnable(); this.SetAllEditBonusDefVariableFormPM(); } }