bool CWizIndexBase::modifyUserEx(const WIZBIZUSER& user) { qDebug() << "modify user, alias: " << user.alias; Q_ASSERT(!user.bizGUID.isEmpty() && !user.userGUID.isEmpty()); // save old user info WIZBIZUSER userOld; userFromGUID(user.bizGUID, user.userGUID, userOld); CString strWhere = "BIZ_GUID=%s AND USER_GUID=%s"; strWhere = strWhere.arg(STR2SQL(user.bizGUID)).arg(STR2SQL(user.userGUID)); CString strFormat = FormatUpdateSQLByWhere(TABLE_NAME_WIZ_USER, FIELD_LIST_WIZ_USER_MODIFY, strWhere); CString strSQL; strSQL.Format(strFormat, STR2SQL(user.alias).utf16(), STR2SQL(user.pinyin).utf16() ); if (!ExecSQL(strSQL)) return false; // read new user info WIZBIZUSER userNew; userFromGUID(user.bizGUID, user.userGUID, userNew); if (!m_bUpdating) { emit userModified(userOld, userNew); } return true; }
bool CWizDatabase::updateBizUser(const WIZBIZUSER& user) { bool bRet = false; WIZBIZUSER userTemp; if (userFromGUID(user.bizGUID, user.userGUID, userTemp)) { // only modify user when alias changed if (userTemp.alias != user.alias) { bRet = modifyUserEx(user); } else { bRet = true; } } else { bRet = createUserEx(user); } if (!bRet) { Q_EMIT updateError("Failed to update user: " + user.alias); } return bRet; }