// 以輸入員工ID搜尋支付資料 public SalaryModel searchByEmplID() { if (this.connectToDB()) { try { DataTable dataSet = new DataTable(); String searchString = String.Format("SELECT * FROM salary WHERE emplID = '" + this._salaryModel.getEmplID() + "'"); MySqlCommand searchCommand = new MySqlCommand(searchString, myConnection); searchCommand.ExecuteNonQuery(); MySqlDataAdapter adapter = new MySqlDataAdapter(searchCommand); adapter.Fill(dataSet); foreach (DataRow searchDr in dataSet.Rows) { _salaryModel.setPayway(searchDr["salaryPayWay"].ToString()); _salaryModel.setAccountData(searchDr["accountData"].ToString()); } } catch (MySqlException ex) { Console.WriteLine("Error " + ex.Number + " : " + ex.Message); } } this.closeConnection(); return(this._salaryModel); }
// 建構子 public SalaryController(SalaryPresentationModel salaryPresentationModel) { _salaryModel.setSalaryDate(salaryPresentationModel.getSalaryDate()); _salaryModel.setSalaryT(salaryPresentationModel.getSalaryT()); _salaryModel.setEmplID(salaryPresentationModel.getEmplID()); _salaryModel.setPayway(salaryPresentationModel.getPayway()); _salaryModel.setAccountData(salaryPresentationModel.getAccountData()); }