示例#1
0
// function for deleting(deleted=1) a person from the list
void deleteMember() {
	char deleteName[64];

	printf("Enter the name of the person you want to delete from the list\n");
	scanf("%s", deleteName);
	int	   found		 = searchMember(deleteName);
	Tree * currentPerson = pivot;

	// if the person is on the list, find it and remove it(deleted =1)
	if (found == 1) {
		while (strcmp(deleteName, currentPerson->name) != 0) {
			// if the deleteName is larger, move to right side
			if (strcmp(deleteName, currentPerson->name) > 0) {
				currentPerson = currentPerson->nextPerson;
				// else move to the left side
			} else if (strcmp(deleteName, currentPerson->name) < 0) {
				currentPerson = currentPerson->previousPerson;
			}
		}

		currentPerson->deleted = 1;
		printf("%s is removed from the list\n", deleteName);
	} else {
		printf("%s was not on the list\n", deleteName);
	}

	options();
}
void mainPage(Member *list)
{
	char input;


	while (1)
	{
		system("cls");
		printf("\n\n\n\n\n\n\n\n");
		printf("               ================================================\n");
		printf("                                 1.회원보기\n");
		printf("                                 2.회원등록\n");
		printf("                                 3.회원수정\n");
		printf("                                 4.회원삭제\n");
		printf("                                 5.회원검색\n");
		printf("                                 6.변경사항 저장\n");
		printf("                                 7.종료\n");
		printf("               ================================================\n");
		input = _getch();
		if (48 < input && 56 > input) // 문자'1'의 아스키코드는 49
		{
			switch (input)
			{
			case 49:
				printPersonalInformation(list);
				break;
			case 50:
				addMember(list);
				break;
			case 51:
				editMember(list);
				break;
			case 52:
				deleteMember(list);
				break;
			case 53:
				searchMember(list);
				break;
			case 54:;
				saveMember(list);
				break;
			case 55:;
				return;
			}
		}
		else printf("\a"); // 1~7 이외의 값 입력시 beep음 출력
	}

	return;
}
示例#3
0
// function for searching a member from the list
void searchMemberCall() {
	char searchName[64];

	printf("Enter the name of the person you want to search for\n");
	scanf("%s", searchName);
	int found = searchMember(searchName);

	if (found == 1) {
		printf("%s is on the list\n", searchName);
	} else {
		printf("%s is not on the list\n", searchName);
	}

	options();
}
void searchWithID(Member* list)
{
	int i, j;
	int count = 0;
	char buf[10];
	char input;
	system("cls");
	printf("================================================================================");
	printf("                              회원 정보 검색 메뉴\n");
	printf("================================================================================\n");
	printf("\n\n\n\n\n     검색 방법 선택 :   1. ID Number로 검색     2. 이름으로 검색\n");

	printf("\n     검색할 회원 ID Number : ");
	gets(buf);
	printf("\n");
	for (i = 0; i < MAX; i++)
	{
		if (list[i].ID == atoi(buf) && atoi(buf) != 0)
		{
			printf("        %d", list[i].ID);
			printf("       %-6s", list[i].Name);
			printf("      %-23s", list[i].Adress);
			printf("    %s\n", list[i].Phone);
			count++; // if문을 몇 번 통과했는지 체크
		}
	}
	if (count == 0)
	{
		printf("\n\n\n\n\n\n\n\n\n\n                           error : 검색된 회원이 없습니다.\n");
		printf("                     메인페이지로 이동 ( H )   다시 검색 ( S )");
		while (1)
		{
			input = _getch();
			if (input == 'H' || input == 'h' || input == 'ㅗ')
				return;
			else if (input == 'S' || input == 's' || input == 'ㄴ')
			{
				searchMember(list);
				break;
			}
			else printf("\a");
		}
	}
	else
	{
		for (j = 0; j < 11 - count; j++)
			printf("\n");

		printf("                    메인페이지로 이동 ( H )   다시 검색 ( S )");
		while (1)
		{
			input = _getch();
			if (input == 'H' || input == 'h' || input == 'ㅗ')
				return;
			else if (input == 'S' || input == 's' || input == 'ㄴ')
			{
				searchMember(list);
				break;
			}
			else printf("\a");
		}
	}
	return;

}