// 取得所有員工資料 private List<EmployeeModel> GetAllEmplDate() { List<EmployeeModel> emplList = new List<EmployeeModel>(); EmployeeModel emplModel = new EmployeeModel(); EmployeeService emplService = new EmployeeService(emplModel); emplList = emplService.GetAllEmplData(); return emplList; }
// 判斷員工ID是否存在 private Boolean JudgeEmplIDIsExist() { String emplID = this._workAttendanceModel.GetWAEmplID(); EmployeeModel emplModel = new EmployeeModel(); emplModel.SetEmplID(emplID); EmployeeService emplService = new EmployeeService(emplModel); emplModel = emplService.searchByEmplID(); if (emplModel.GetName() == null || emplModel.GetName() == "") return false; return true; }
// 呼叫service, 將資料新增至資料庫 public void AddEmployee() { this._employeeService = new EmployeeService(this._employeeModel); AccountService accountService = new AccountService(this._employeeModel.GetEmplID(), this._employeeModel.GetEmplLoginPassword()); int errorFlag = 0; errorFlag = JudgeEmplDataFormat(); if (errorFlag == 1) return; // 新增員工資料與帳號資訊 if (_employeeService.AddEmployee() && accountService.AddAccount()) MessageBox.Show("新增成功!"); else MessageBox.Show("新增失敗!"); }
// 呼叫service 利用員工ID查詢員工資料 public EmployeePresentationModel SearchDataByEmplID() { EmployeePresentationModel emplPresentationModel = new EmployeePresentationModel(); if (this._employeeModel.GetEmplID() == null || this._employeeModel.GetEmplID() == "") MessageBox.Show("請輸入員工ID"); else { _employeeService = new EmployeeService(this._employeeModel); _employeeModel = _employeeService.searchByEmplID(); emplPresentationModel.SetEmplID(_employeeModel.GetEmplID()); emplPresentationModel.SetName(_employeeModel.GetName()); emplPresentationModel.SetSsn(_employeeModel.GetSsn()); emplPresentationModel.SetSex(_employeeModel.GetSex()); emplPresentationModel.SetPhone(_employeeModel.GetPhone()); emplPresentationModel.SetAddress(_employeeModel.GetAddress()); emplPresentationModel.SetBlood(_employeeModel.GetBlood()); emplPresentationModel.SetBirth(_employeeModel.GetBirth()); emplPresentationModel.SetEmerPerson(_employeeModel.GetEmerPerson()); emplPresentationModel.SetEmerPhone(_employeeModel.GetEmerPhone()); emplPresentationModel.SetMilitaryStatus(_employeeModel.GetMilitaryStatus()); emplPresentationModel.SetJobStatus(_employeeModel.GetJobStatus()); emplPresentationModel.SetMarriedStatus(_employeeModel.GetMarriedStatus()); emplPresentationModel.SetSpouse(_employeeModel.GetSpouse()); emplPresentationModel.SetDeptID(_employeeModel.GetDeptID()); emplPresentationModel.SetPositoinID(_employeeModel.GetPositionID()); emplPresentationModel.SetBasicSalary(_employeeModel.GetBasicSalary()); if (_employeeModel.GetName() == null || _employeeModel.GetName() == "") { MessageBox.Show("此員工ID不存在!"); emplPresentationModel.SetEmplID(null); } } return emplPresentationModel; }
// 呼叫service, 將資料更新制資料庫(edit) public Boolean EditEmployee() { this._employeeService = new EmployeeService(this._employeeModel); int errorFlag = 0; errorFlag = JudgeEmplDataFormat(); if (errorFlag == 1) return false; if (_employeeService.EditEmployee()) MessageBox.Show("修改成功!"); else { MessageBox.Show("修改失敗!"); return false; } return true; }