Beispiel #1
0
pClub oEvent::getClubCreate(int Id, const string &CreateName)
{
  if (Id > 0) {
    //map<int, pClub>::iterator mit=clubIdIndex.find(Id);
    //if (mit!=clubIdIndex.end()) {
    pClub value;
    if (clubIdIndex.lookup(Id, value)) {
      if (!trim(CreateName).empty() && _stricmp(value->getName().c_str(), trim(CreateName).c_str())!=0)
        Id = 0; //Bad, used Id.
      if (trim(CreateName).empty() || Id>0)
        return value;
    }
  }
  if (CreateName.empty()) {
    //Not found. Auto add...
    return getClubCreate(Id, "Klubblös");
  }
  else	{
    oClubList::iterator it;
    string tname = trim(CreateName);

    //Maybe club exist under different ID
    for (it=Clubs.begin(); it != Clubs.end(); ++it)
      if (_stricmp(it->name.c_str(), tname.c_str())==0)
        return &*it;

    //Else, create club.
    return addClub(tname, Id);
  }
}
Beispiel #2
0
void RunnerDB::updateAdd(const oRunner &r, map<int, int> &clubIdMap)
{
  if (r.getExtIdentifier() > 0) {
    RunnerDBEntry *dbe = getRunnerById(int(r.getExtIdentifier()));
    if (dbe) {
      dbe->cardNo = r.CardNo;
      return; // Do not change too much in runner from national database
    }
  }

  const pClub pc = r.Club;
  int localClubId = r.getClubId();

  if (pc) {
    if (clubIdMap.count(localClubId))
      localClubId = clubIdMap[localClubId];

    pClub dbClub = getClub(localClubId);
    bool wrongId = false;
    if (dbClub) {
      if (dbClub->getName() != pc->getName()) {
        dbClub = 0; // Wrong club!
        wrongId = true;
      }
    }

    if (dbClub == 0) {
      dbClub = getClub(r.getClub());
      if (dbClub) {
        localClubId = dbClub->getId();
        clubIdMap[pc->getId()] = localClubId;
      }
    }

    if (dbClub == 0) {
      localClubId = addClub(*pc, wrongId);
      if (wrongId)
        clubIdMap[pc->getId()] = localClubId;
    }
  }

  RunnerDBEntry *dbe = getRunnerByCard(r.getCardNo());

  if (dbe == 0) {
    dbe = addRunner(r.getName().c_str(), 0, localClubId, r.getCardNo());
    if (dbe)
      dbe->birthYear = r.getDCI().getInt("BirthYear");
  }
  else {
    if (dbe->getExtId() == 0) { // Only update entries not in national db.
      dbe->setName(r.getName().c_str());
      dbe->clubNo = localClubId;
      dbe->birthYear = r.getDCI().getInt("BirthYear");
    }
  }
}
Beispiel #3
0
void displayAdminClub(LinkedList<Item> *listOfItems, LinkedList<Club> *listOfClubs, LinkedList<User> *listOfUsers)
{
	int choice = 0;
	string junk;

	clearScreen();
	displayLogo();

	cout << setw(36) << right << "Administrator Club Menu:\n\n\n";
	cout << setw(12) << right << "1.) " << left << "Add Club\n";
	cout << setw(12) << right << "2.) " << left << "Remove Club\n";
	cout << setw(12) << right << "3.) " << left << "Modify Club\n";
	cout << setw(12) << right << "4.) " << left << "Return to Administrator Menu\n";

	cout << setw(28) << right << "Please enter a choice: ";
	cin >> choice;
	getline(cin, junk);

	while ((choice < 1) || (choice > 4))
	{
		cout << setw(28) << right << "Invalid... Enter choice: ";
		cin >> choice;
		getline(cin, junk);
	}

	switch (choice)
	{
	case 1:
		addClub(listOfClubs);
		break;
	case 2:
		removeClub(listOfClubs);
		break;
	case 3:
		modifyClub(listOfClubs);
		break;
	case 4:
		displayAdminMenu(listOfItems, listOfClubs, listOfUsers);
		return;
	}
	pause();
}
Beispiel #4
0
Club *ClubController::createClub()
{
    int clubId = findNextId();
    Club club(clubId, QString("<Club %1>").arg(clubId), QString("<coach %1>").arg(clubId));
    return addClub(club);
}