当前位置:网站首页>About XXX management system (version C)

About XXX management system (version C)

2022-06-26 05:29:00 Elliot_ Alderson

Because a lot of people didi I said only C++ and C# The management system is too cumbersome , I think so myself , So I put a C Of , No line is C++ Code , Probably for The loop will be there and C++ It's kind of the same , The rest are not .

#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#define MAXN 1000// The maximum number of management objects can be stored 

int Count = 0;

struct Tem
{
	char department[30];
	char lab_name[30];
	char lab_admin_name[30];
	char lab_admin_phonenumber[30];
	char order_name[30];
	char order_phonenumber[30];
	char order_course[30];
	char order_subject[30];
	int order_id;
	int lab_id;
	int order_weektime;
	int order_daytime;
	int status;// Status flag ,0 For there is no such thing , Nonzero is negative 
}tem[MAXN];

void insert(int index)// Input function 
{
	printf(" Please enter the Department :\n");
	scanf("%s", &tem[index].department);
	printf(" Please enter the laboratory name :\n");
	scanf("%s", &tem[index].lab_name);
	printf(" Please enter the administrator name :\n");
	scanf("%s", &tem[index].lab_admin_name);
	printf(" Please enter the administrator phone number :\n");
	scanf("%s", &tem[index].lab_admin_phonenumber);
	printf(" Please enter the name of the subscriber :\n");
	scanf("%s", &tem[index].order_name);
	printf(" Please enter the telephone number of the person making the appointment :\n");
	scanf("%s", &tem[index].order_phonenumber);
	printf(" Please enter a course appointment :\n");
	scanf("%s", &tem[index].order_course);
	printf(" Please enter the appointment major :\n");
	scanf("%s", &tem[index].order_subject);
	printf(" Please enter the appointment number :\n");
	scanf("%d", &tem[index].order_id);
	printf(" Please enter the lab number :\n");
	scanf("%d", &tem[index].lab_id);
	printf(" Please enter the appointment week :\n");
	scanf("%d", &tem[index].order_weektime);
	printf(" Please enter the appointment section :\n");
	scanf("%d", &tem[index].order_daytime);
}

void output(int index)// Output function 
{
	printf(" departments :%s\n", tem[index].department);
	printf(" Laboratory name :%s\n", tem[index].lab_name);
	printf(" Administrator name :%s\n", tem[index].lab_admin_name);
	printf(" Administrator phone :%s\n", tem[index].lab_admin_phonenumber);
	printf(" Name of the person making the appointment :%s\n", tem[index].order_name);
	printf(" Telephone number of the person making the appointment :%s\n", tem[index].order_phonenumber);
	printf(" Book a course :%s\n", tem[index].order_course);
	printf(" Make an appointment for a major :%s\n", tem[index].order_subject);
	printf(" Appointment number :%d\n", tem[index].order_id);
	printf(" Lab No :%d\n", tem[index].lab_id);
	printf(" Appointment weeks :%d\n", tem[index].order_weektime);
	printf(" Appointment session :%d\n", tem[index].order_daytime);
}

void insert_function()// Add function 
{
	insert(Count);
	tem[Count].status = 1;
	Count++;
}

void find_function()// Lookup function 
{
	int flag = 0;
	int id;
	printf(" Please enter the appointment number :\n");
	scanf("%d", &id);
	for (int i = 0; i < Count; i++)
	{
		if (tem[i].order_id == id)
		{
			flag = 1;
			output(i);
			break;
		}
	}
	if (!flag)
	{
		printf(" There is no such item \n");
	}
}

void del_function()// Delete function 
{
	int flag = 0;
	int id;
	printf(" Please enter the appointment number :\n");
	scanf("%d", &id);
	for (int i = 0; i < Count; i++)
	{
		if (tem[i].order_id == id)
		{
			flag = 1;
			output(i);
			tem[i].status = 0;
			printf(" deleted \n");
			break;
		}
	}
	if (!flag)
	{
		printf(" There is no such item \n");
	}
}

void change_function()// Modify the function 
{
	int flag = 0;
	char Name[30];
	printf(" Please enter the Department :\n");
	scanf("%s", &Name);
	for (int i = 0; i < Count; i++)
	{
		if (strcmp(Name, tem[i].department) == 0 && tem[i].status)
		{
			flag = 1;
			output(i);
			insert(i);
			break;
		}
	}
	if (!flag)
	{
		printf(" There is no such item \n");
	}
}

void save_function()// Save file functions 
{
	FILE* fp = fopen("save.txt", "w+");
	for (int i = 0; i < Count; i++)
	{
		if (tem[i].status)
		{
			fwrite(&tem[i], sizeof(struct Tem), 1, fp);
		}
	}
	fclose(fp);
}

void show_function()// Display all appointment information 
{
	for (int i = 0; i < MAXN; i++)
	{
		if (tem[i].status)
		{
			printf("-----------------------\n");
			output(i);
			printf("-----------------------\n");
		}
	}
}

void statistics_function()
{
	printf(" Please enter what information you want to make statistics based on .\n");
	printf("1、 Professional name \n");
	printf("2、 school \n");
	int i;
	scanf("%d", &i);
	printf(" Please enter name \n");
	char name[20];
	scanf("%s", name);
	int flag = 0;
	int result = 0;
	for (int i = 0; i < Count; i++)
	{
		if (strcmp(i == 1 ? tem[i].order_course : tem[i].department, name) == 0)
		{
			flag = 1;
			result++;
		}
	}
	if (!flag)
	{
		printf(" No such item found \n");
	}
	else
	{
		printf(" The total number of people in this project is :%d\n", result);
	}
}

int main()
{
	while (1)
	{
		printf("\t\t\t\t Open laboratory information management system \n");
		printf("\t\t\t\t 1. Add laboratory information \n");
		printf("\t\t\t\t 2. Delete Lab Information \n");
		printf("\t\t\t\t 3. Modify laboratory information \n");
		printf("\t\t\t\t 4. Query laboratory information \n");
		printf("\t\t\t\t 5. Statistical laboratory information \n");
		printf("\t\t\t\t 6. Display Lab Information \n");
		printf("\t\t\t\t  0. Exit the system \n");
		printf(" Please select :\n");
		int i;
		scanf("%d", &i);
		switch (i)
		{
		case 1:
			system("cls");
			insert_function();
			system("pause");
			system("cls");
			break;
		case 2:
			system("cls");
			del_function();
			system("pause");
			system("cls");
			break;
		case 3:
			system("cls");
			change_function();
			system("pause");
			system("cls");
			break;
		case 4:
			system("cls");
			find_function();
			system("pause");
			system("cls");
			break;
		case 5:
			system("cls");
			statistics_function();
			system("pause");
			system("cls");
			break;
		case 6:
			system("cls");
			show_function();
			system("pause");
			system("cls");
			break;
		default:
			save_function();
			exit(0);
			break;
		}
	}
	return 0;
}

 

原网站

版权声明
本文为[Elliot_ Alderson]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180506068898.html