public void updateToken(TokenDTO tokenObj) { string beginDateTimeInString = commonMethods.convertDateTimeInDbFormatString(tokenObj.getBegin()); string validateDateTimeInString = commonMethods.convertDateTimeInDbFormatString(tokenObj.getValidate()); try { db.connect(); string sql = "UPDATE token SET token = '" + tokenObj.getToken() + "', begin = '" + beginDateTimeInString + "', validate = '" + validateDateTimeInString + "' WHERE token_employee_id = " + tokenObj.getTokenId() + ";"; db.executeSql(sql); } catch (Exception ex) { MessageBox.Show("Erro ao tentar atualizar o token: " + ex.Message.ToString()); } }
public void insertToken(TokenDTO tokenObj) { string beginDateTimeInString = commonMethods.convertDateTimeInDbFormatString(tokenObj.getBegin()); string validateDateTimeInString = commonMethods.convertDateTimeInDbFormatString(tokenObj.getValidate()); try { db.connect(); string sql = "INSERT INTO token (token_id, token_employee_id, token, begin, validate) VALUES (NULL, '" + tokenObj.getTokenEmployeeId() + "', '" + tokenObj.getToken() + "', '" + beginDateTimeInString + "', '" + validateDateTimeInString + "');"; db.executeSql(sql); } catch (Exception ex) { MessageBox.Show("Erro ao tentar inserir o token: " + ex.Message.ToString()); } }