// 查詢該員工資料並將資料填進UI中 private void SetAllEmplDataToUI() { _employeeController = new EmployeeController(_employeePresentationModel); _employeePresentationModel = _employeeController.SearchDataByEmplID(); try { _newEmplIDTB.Text = _employeePresentationModel.GetEmplID(); _newEmplBirthDP.Value = _employeePresentationModel.GetBirth(); _newEmplMarriedStatCB.SelectedItem = _employeePresentationModel.GetMarriedStatus(); // 1 為未婚 // 0 為已婚 if (_newEmplMarriedStatCB.SelectedIndex == 1) { _newEmplSpouseTB.Text = _employeePresentationModel.GetSpouse(); } else if (_newEmplMarriedStatCB.SelectedIndex == 0) { _newEmplSpouseTB.ReadOnly = true; _newEmplSpouseTB.Text = null; } _newEmplJobStatCB.SelectedItem = _employeePresentationModel.GetJobStatus(); _newEmplMilitaryStatCB.SelectedItem = _employeePresentationModel.GetMilitaryStatus(); _newEmplBloodCB.SelectedItem = _employeePresentationModel.GetBlood(); _newEmplSexCB.SelectedItem = _employeePresentationModel.GetSex(); _newEmplNameTB.Text = _employeePresentationModel.GetName(); _newEmpllSsnTB.Text = _employeePresentationModel.GetSsn(); ; _newEmplAddrTB.Text = _employeePresentationModel.GetAddress(); _newEmplEmerPersonTB.Text = _employeePresentationModel.GetEmerPerson(); _newEmplEmerPhoneTB.Text = _employeePresentationModel.GetEmerPhone(); _newEmplBasicSalaryTB.Text = _employeePresentationModel.GetBasicSalary().ToString(); _newEmplPhoneTB.Text = _employeePresentationModel.GetPhone(); _newEmplDeptCB.SelectedValue = _employeePresentationModel.GetDeptID(); _newEmplPositionCB.SelectedValue = _employeePresentationModel.GetPositionID(); _addEmplLoginPWTB.Text = _employeePresentationModel.GetEmplLoginPassword(); } catch(Exception ex) { Console.WriteLine(ex.Message); MessageBox.Show("系統發生錯誤, 請稍後再嘗試!"); } }
// 建構子 public EmployeeController(EmployeePresentationModel employeePresentationModel) { this._employeeModel.SetEmplID(employeePresentationModel.GetEmplID()); this._employeeModel.SetName(employeePresentationModel.GetName()); this._employeeModel.SetSsn(employeePresentationModel.GetSsn()); this._employeeModel.SetSex(employeePresentationModel.GetSex()); this._employeeModel.SetPhone(employeePresentationModel.GetPhone()); this._employeeModel.SetAddress(employeePresentationModel.GetAddress()); this._employeeModel.SetBlood(employeePresentationModel.GetBlood()); this._employeeModel.SetBirth(employeePresentationModel.GetBirth()); this._employeeModel.SetEmerPerson(employeePresentationModel.GetEmerPerson()); this._employeeModel.SetEmerPhone(employeePresentationModel.GetEmerPhone()); this._employeeModel.SetMilitaryStatus(employeePresentationModel.GetMilitaryStatus()); this._employeeModel.SetJobStatus(employeePresentationModel.GetJobStatus()); this._employeeModel.SetMarriedStatus(employeePresentationModel.GetMarriedStatus()); this._employeeModel.SetSpouse(employeePresentationModel.GetSpouse()); this._employeeModel.SetDeptID(employeePresentationModel.GetDeptID()); this._employeeModel.SetPositoinID(employeePresentationModel.GetPositionID()); this._employeeModel.SetBasicSalary(employeePresentationModel.GetBasicSalary()); this._employeeModel.SetEmplLoginPassword(employeePresentationModel.GetEmplLoginPassword()); }