예제 #1
0
파일: SQN.c 프로젝트: franc015/storequest
int main(void)
{
	char* d_filename = "department.in";
	char* p_filename = "product.in";
	int department_count = file_length(d_filename);
	int product_count = file_length(p_filename);
	char search_d[9];	//d = deprartment
	char search_p[9];	//p = product
	char command[9];	//p = product
	int j;
	int foundIndex;

	instructions();

	department departments[department_count];
	scan_department(departments, d_filename);
	product products[product_count];
	scan_product(products, p_filename);

	printf("Scanning departments and products now.\n");
	printf("We scanned %d departments\n", department_count);

	printf("Enter Command: ");
	scanf("%s", command);

	while(strcmp(command, "Q") != 0 && strcmp(command, "q") != 0){
		if(strcmp(command, "D") == 0 || strcmp(command, "d") == 0){
			printf("The departments are:\n");
			for (j = 0; j < department_count; j++)
			{
				printf("\t%s - index: %d\n",departments[j].department_name, departments[j].d_index);
			}

			printf("Enter Department: ");
			scanf("%s", search_d);


			foundIndex = d_cmp(search_d, departments, department_count);
			if (foundIndex != 17)
			{
				printf("The index number found is %d\n\n",foundIndex);
				printf("Products:\n");
				show_products(foundIndex, product_count, products);
				printf("Enter Product: ");
				scanf("%s", search_p);
				show_individual_product(search_p, product_count, products);

			}
			else
			{
				printf("The department you entered is not found.\n\n");
			}
		}
		else if(strcmp(command, "H") == 0 || strcmp(command, "h") == 0){
			help();
		}
		printf("Enter Command: ");
		scanf("%s", command);
	};

	return(0);
}
예제 #2
0
파일: interface.c 프로젝트: Tenza/Warehouse
void menu_search(const warehouse *warehouses)
{
	boolean loop = TRUE;
	char *data = NULL;
	int option;

	while(loop)
	{
		show_menu(2);
		int_input(&option, 3);

		switch(option)
		{
			case 1:
				{
					data = show_tree(warehouses);								
					break;
				}
			case 2:
				{
					data = show_products(warehouses);
					break;
				}
			case 3:
				{
					data = show_products_by_hallway(warehouses, choose_hallway(warehouses));
					break;
				}
			case 4:
				{
					int hallway_number = choose_hallway(warehouses);
					int storage_number = choose_storage(warehouses, &hallway_number);

					data = show_products_by_storage(warehouses, hallway_number, storage_number);
					break;
				}
			case 5:
				{					
					printf("Numero do produto: ");
					int_input(&option, 9);

					if(option > 0)
					{
						data = show_products_by_type(warehouses, option);
					}			
					else
					{
						printf("Numero invalido\n\n");
					}
					break;
				}
			case 6:
				{
					printf("Stock do produto: ");
					int_input(&option, 9);

					if(option > 0)
					{
						data = show_products_by_stock(warehouses, option);
					}			
					else
					{
						printf("Numero invalido\n\n");
					}
					break;
				}
			case 7:
				{
					data = show_sold_products(warehouses, FALSE);
					break;
				}
			case 9:
				{
					loop = FALSE;
					break;
				}
			default:
				{
					printf("Essa opcao nao existe.\n\n");
					break;
				}
		}

		if (data != NULL)
		{
			printf("%s\n", data);
			print_file(data);
			free(data);
			data = NULL;
		}
	}
}