⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5_2.cpp

📁 物品存放的管理C++源程序 用于管理物品的小软件 适合课程设计
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}

void IE::show()
{
	int n;
	system("cls");
	ifstream file( "IES.DAT" ,ios::in); 
	if(!file)  
	{
		if(lgwg==1) cout<<"Error Could Not Open File.\n\nPress Enter to continue.";
		else cout<<"错误!无法打开文件。\n\n按回车继续";
		cin.ignore();cin.get(pause);
		exit(1);
	}
	IE t1;
	file.read(reinterpret_cast<char *>(&t1),sizeof(IE));
	cout.setf(ios::left);
	if(lgwg==1) 
	{
		cout<<"How Many Data Would You Like to Show In A Time: ";
		cin>>n;
		cin.ignore();
		system("cls");
		cout<<setw(16)<<"DATE"<<setw(16)<<"ITEM NAME"<<setw(16)<<"ITEM CODE"<<setw(16)<<"QUANTITY"<<setw(16)<<"CONDITION"<<endl;
	}
	else
	{
		cout<<"每次显示几组数据: ";
		cin>>n;
		cin.ignore();
		system("cls");
		cout<<setw(16)<<"日期"<<setw(16)<<"物品名称"<<setw(16)<<"物品编号"<<setw(16)<<"物品数量"<<setw(16)<<"状态"<<endl;
	}
	for(i=1;!file.eof();i++)
	{
		t1.showdata();  
		file.read(reinterpret_cast<char *> (&t1),sizeof(IE)); 
		if(i%n==0) cin.get(pause);
	}
	if(lgwg==1) cout<<"\n\nPress Enter to continue.";
	else cout<<"\n\n按回车继续";
	cin.get(pause);
	i=0;
}

void IE::search()
{
node5:
	while(1)
	{	
		char year[6]={'\0','\0','\0','\0','\0','\0'};
		char month[6]={'\0','\0','\0','\0','\0','\0'};
		char day[6]={'\0','\0','\0','\0','\0','\0'};
		int a1=0,a2=0;
		int option;
		fstream file( "IES.DAT" ,ios::in);  
		if(!file) 
		{
			if(lgwg==1) cout<<"Error Could Not Open File.\n\nPress Enter to continue.";
			else cout<<"错误!无法打开文件。\n\n按回车继续";
			cin.ignore();cin.get(pause);
			exit(1);
		}
		system("cls");
		if(lgwg==1) cout<<"\n(1)Strict to Year\n(2)Strict to Month\n(3)Strict to Day\n(4)Back  ";
		else cout<<"\n(1)精确到年\n(2)精确到月\n(3)精确到日\n(4)返回   ";
		cin>>option;
		cin.ignore();
		switch(option)
		{
		case 1: break;
		case 2: a1=1; break;
		case 3: a1=1,a2=1; break;
		case 4: system("cls");	return;
		default: goto node5;
		}
		char flag='a';  
		IE t1;
		file.read(reinterpret_cast<char *>(&t1),sizeof(IE));	
		if(lgwg==1) 
		{
			cout<<"Please Enter The Data:\n";
			cout<<"Year: ";
			cin.getline(year,6);
			strcpy(day,t1.date_day);
			strcpy(month,t1.date_month);
			if(a1)
			{
				cout<<"Month: ";
				cin.getline(month,6);
			}
			if(a2)
			{
				cout<<"Day: ";
				cin.getline(day,6);
			}
		}
		else
		{
			cout<<"请输入日期:\n";
			cout<<"年: ";
			cin.getline(year,6);
			strcpy(month,t1.date_month);
			strcpy(day,t1.date_day);
			if(a1)
			{
				cout<<"月: ";
				cin.getline(month,6);
			}
			if(a2)
			{	
				cout<<"日: ";
				cin.getline(day,6);
			}
		}	
		while(!file.eof())
		{
			if((strcmp(t1.date_year,year)==0)&&(strcmp(t1.date_month,month)==0)&&(strcmp(t1.date_day,day)==0))
			{
				t1.showdata();
				if(lgwg==1) cout<<"\n\nPress Enter to continue.";
				else cout<<"\n\n按回车继续";
 				cin.get(pause);
				flag='z'; 
			}
			file.read(reinterpret_cast<char *> (&t1),sizeof(IE));
			if(!a1) strcpy(month,t1.date_month);
			if(!a2) strcpy(day,t1.date_day);
		}
		if(flag !='z') 
		{
			if(lgwg==1) cout<<"Data Not Found.\n\nPress Enter to continue.";
			else cout<<"未找到匹配档案。\n\n按回车继续";
			cin.get(pause);
		}
	}
}

void IE::IEport(Item p,int t)
{
	char iore[10];
	if(lgwg==1) 
	{
		if(t==1) strcpy(iore,"Import");
		else strcpy(iore,"Export");
		cout<<"Please Enter The "<<iore<<"Data:\n";
		cout<<"Year: ";
		cin.ignore();cin.getline(date_year,6);
		cout<<"Month: ";
		cin.getline(date_month,6);
		cout<<"Day: ";
		cin.getline(date_day,6);
	}
	else
	{
		if(t==1) strcpy(iore,"进口");
		else strcpy(iore,"出口");
		cout<<"请输入"<<iore<<"日期:\n";
		cout<<"年: ";
		cin.ignore();cin.getline(date_year,6);
		cout<<"月: ";
		cin.getline(date_month,6);
		cout<<"日: ";
		cin.getline(date_day,6);
	}
	condition=t;
	strcpy(item_name,p.rtnname());
	item_code=p.rtncode();
	item_quantity=p.rtnqtt();
}

void tgs()
{
	system("cls");
	switch(lgwg)
	{
	case 1:
		cout<<"\t\t*************************************************\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*     Welcome to The Guest System (TGS) Ver.1   *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*            Projected by: Fan Jingyu           *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*          Class:03042101 Code:03304578         *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*************************************************\n\n";
		break;
	case 2:
		cout<<"\t\t*************************************************\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*          欢迎使用客户管理程序  第一版         *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*                 设计者: 樊劲宇               *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*          班级:03042101  学号:03304578         *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*************************************************\n\n";
	}
	if(lgwg==1) cout<<"\n\n\t\t\tPress Enter to continue.";
	else cout<<"\n\n\t\t\t\t按回车继续";
	cin.ignore();cin.get(pause);
	Guest n;
	int choice;
	while(1)
	{
		system("cls");
		if(lgwg==1)
		{
			cout<<"\n\n(1)Add Guest\n\n(2)Show All The Guest\n\n(3)Search Guest\n\n(4)Remove Guest\n\n(5)Back";
			cout<<"\n\nEnter Choice ";
		}
		else
		{
			cout<<"\n\n(1)增加客户\n\n(2)显示所有客户\n\n(3)查找客户\n\n(4)清除客户\n\n(5)返回";
			cout<<"\n\n请输入选择项: ";
		}
		cin>>choice;
		switch(choice)
		{
		case 1:
			n.add();
			break;
		case 2:
			n.showag();
			break;
		case 3:
           	n.search();
			break;
		case 4:
			n.remove();
			break;
		case 5:
			welcome();
			break;
		default:
			{
				if(lgwg==1) cout<<"Bad Command.Please Choice Again.\n";
				else cout<<"无效!情重新输入\n";
			}
		}
	}
}

void tis()
{
	system("cls");
	switch(lgwg)
	{
	case 1:
		cout<<"\t\t*************************************************\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*  Welcome to The Inventory System (TIS) Ver.1  *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*            Projected by: Fan Jingyu           *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*          Class:03042101 Code:03304578         *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*************************************************\n\n";
		break;
	case 2:
		cout<<"\t\t*************************************************\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*         欢迎使用物品库存管理程序 第一版       *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*                 设计者: 樊劲宇               *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*          班级:03042101  学号:03304578         *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*************************************************\n\n";
	}
	if(lgwg==1) cout<<"\n\n\t\t\tPress Enter to continue.";
	else cout<<"\n\n\t\t\t\t按回车继续";
	cin.ignore();cin.get(pause);
	Item m;
	int choice;
	while(1)
	{
		//clrscr();
		system("cls");
		if(lgwg==1)
		{
			cout<<"\n\n(1)Add Item\n\n(2)Show All Data\n\n(3)Search Item\n\n(4)Remove Item\n\n(5)Back";
			cout<<"\n\nEnter Choice ";
		}
		else
		{
			cout<<"\n\n(1)添加物品\n\n(2)显示所有数据\n\n(3)搜索物品\n\n(4)删除物品\n\n(5)返回";
			cout<<"\n\n请输入选择项: ";
		}
		cin>>choice;
		switch(choice)
		{
		case 1:
			m.add();
			break;
		case 2:
			m.showab();
			break;
		case 3:
           	m.search();
			break;
		case 4:
			m.remove();
			break;
		case 5:
			welcome();
			break;
		default:
			{
				if(lgwg==1) cout<<"Bad Command.Please Choice Again.\n";
				else cout<<"无效!情重新输入\n";
			}
		}
	}
}

void ies()
{
	system("cls");
	switch(lgwg)
	{
	case 1:
		cout<<"\t\t*************************************************\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*  Welcome to Import Export System (IES) Ver.1  *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*            Projected by: Fan Jingyu           *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*          Class:03042101 Code:03304578         *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*************************************************\n\n";
		break;
	case 2:
		cout<<"\t\t*************************************************\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*         欢迎使用进出货统计程序  第一版        *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*                 设计者: 樊劲宇               *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*          班级:03042101  学号:03304578         *\n";
		cout<<"\t\t*                                               *\n";
		cout<<"\t\t*************************************************\n\n";
	}
	if(lgwg==1) cout<<"\n\n\t\t\tPress Enter to continue.";
	else cout<<"\n\n\t\t\t\t按回车继续";
	cin.ignore();cin.get(pause);
	IE l;
	int choice;
	while(1)
	{
		//clrscr();
		system("cls");
		if(lgwg==1)
		{
			cout<<"\n\n(1)Show All The Data\n\n(2)Search Data\n\n(3)Clear All The Data\n\n(4)Back";
			cout<<"\n\nEnter Choice ";
		}
		else
		{
			cout<<"\n\n(1)输出所有数据\n\n(2)查找数据\n\n(3)清空记录\n\n(4)返回";
			cout<<"\n\n请输入选择项: ";
		}
		cin>>choice;
		switch(choice)
		{
		case 1:
			l.show();
			break;
		case 2:
			l.search();
			break;
		case 3:
			char dlt;
			if(lgwg==1) cout<<"Really Clear All The Data ?\tYes(y)/No(n)";
			else cout<<"确定清空所有记录 ?\t是(y)/否(n)";
			cin.ignore();cin>>dlt;
			if(dlt=='y') clear("IES.DAT");
			break;
		case 4:
			welcome();
			break;
		default:
			{
				if(lgwg==1) cout<<"Bad Command.Please Choice Again.\n";
				else cout<<"无效!情重新输入\n";
			}
		}
	}
}

void welcome()
{
	int choice;
	if(flag)
	{
		system("cls");
		cout<<"\n\n\n\t\t     Please Choice The Language(请选择语言):\n\t\t     (1)English(英文)\t (2)Chinese(中文)\n\t\t\t\t\t";
		cin>>lgwg;
		while(lgwg!=1&&lgwg!=2)
		{
			cout<<"\t\tBad Command.Please Choice Again.(无效!情重新输入)\n\t\t\t\t\t";
			cin>>lgwg;
		}
		flag=0;
	}
	while(1)
	{
		system("cls");
		if(lgwg==1)
		{
			cout<<"\n\nPlease Choice The Program:\n(1)The Inventory System (TIS) Ver.1\n(2)The Guest System (TGS) Ver.1\n(3)Import Export System (IES) Ver.1\n(4)Choice Language\n(5)Exit Program\t\t";
			cin>>choice;
		}
		else
		{
			cout<<"\n\n请选择程序:\n(1)物品库存管理程序 第一版\n(2)客户管理程序 第一版\n(3)进出货统计程序 第一版\n(4)语言选择\n(5)退出程序\t\t";
			cin>>choice;
		}
		switch(choice)
		{
		case 1: tis();break;
		case 2: tgs();break;
		case 3: ies();break;
		case 4: flag=1;welcome();break;
		case 5: exit(1);
		}
	}
}

void main()
{
	welcome();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -