// 呼叫service利用departmentID查詢dept資料 public DepartmentPresentationModel SearchDepartmentByID() { DepartmentPresentationModel deptPresentModel = new DepartmentPresentationModel(); if (this._deptModel.GetDepartmentID() == null || _deptModel.GetDepartmentID() == "") MessageBox.Show("請輸入部門ID"); else { _deptService = new DepartmentService(this._deptModel); _deptModel = _deptService.searchByDeptID(); deptPresentModel.setDepartmentID(_deptModel.GetDepartmentID()); deptPresentModel.setDepartmentName(_deptModel.GetDepartmentName()); deptPresentModel.setDepartmentStartTime(_deptModel.GetDepartmentStartTime()); deptPresentModel.setDepartmentEndTime(_deptModel.GetDepartmentEndTime()); deptPresentModel.setDepartmentManager(_deptModel.GetDepartmentManager()); if(_deptModel.GetDepartmentName() == null || _deptModel.GetDepartmentName() == "") { MessageBox.Show("此部門ID不存在!"); deptPresentModel.setDepartmentID(null); } } return deptPresentModel; }
//建構子 public DepartmentController(DepartmentPresentationModel deptPresentationModel) { _deptModel.SetDepartmentID(deptPresentationModel.getDepartmentID()); _deptModel.SetDepartmentName(deptPresentationModel.getDepartmentName()); _deptModel.SetDepartmentStartTime(deptPresentationModel.getDepartmentStartTime()); _deptModel.SetDepartmentEndTime(deptPresentationModel.getDepartmentEndTime()); _deptModel.SetDepartmentManager(deptPresentationModel.getDepartmentManager()); }
private void ClickSearchDeptButton(object sender, EventArgs e) { String deptID = _editDeptIDTB.Text; _deptPresentationModel.setDepartmentID(deptID); _deptController = new DepartmentController(_deptPresentationModel); _deptPresentationModel = _deptController.SearchDepartmentByID(); if (_deptPresentationModel.getDepartmentID() == null || _deptPresentationModel.getDepartmentID() == "") return; this.SetAllDeptEditToEnable(); this.ResetSearchEditDeptUI(); }