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

📄 goodstore.cpp

📁 货物的管理
💻 CPP
📖 第 1 页 / 共 3 页
字号:
			  q=p;
			  p=new LinkNode;
			  strcpy(p->info.num,a);
			  strcpy(p->info.name,b);
			  strcpy(p->info.amount,c);
			  strcpy(p->info.loc,d);
              cout<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
			  first->link=p;
			  p->link=q;
			}
		  else{
			  q=p;
			  p=new LinkNode;
			  strcpy(p->info.num,a);
			  strcpy(p->info.name,b);
			  strcpy(p->info.amount,c);
			  strcpy(p->info.loc,d);
			  k->link=p;
			  p->link=q;
			}
		  i=0;
		  n++;
		  break;
		}
		else{
		    k=p;
            p=p->link;
		}  
		}
    if(i!=0){
		p=first->link;
		q=p;
		p=new LinkNode;
		strcpy(p->info.num,a);
		strcpy(p->info.name,b);
		strcpy(p->info.amount,c);
		strcpy(p->info.loc,d);
        cout<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
		first->link=p;
		p->link=q;
		i=0;
	}
	outfile<<n<<endl;
    p=first->link;
label:while(p!=first){
        outfile<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
		p=p->link;
	  }
    if(i==0)
		return 1;
	else
        return 0;
}

int addbyname(char a[maxSize], char b[maxSize], char c[maxSize], char d[maxSize],
			  char e[maxSize], LinkNode * p, LinkNode * first){
	   //将具有所给定的相应信息且仓库中并不含有的货物放入仓库中,并将它
	//放在有给定name值的仓库管理表格文本中第一个出现的货物的前面
    ofstream outfile("Inventory management forms.txt");
    p=first->link;
	int i;
    LinkNode * k;
    LinkNode * q;
	while(p!=first){
			if(strcmp(p->info.name,b)==0){
				cout<<"wrong!!!"<<endl;
				cout<<"the good of the name is exist!!!"<<endl;
				i=1;
				goto label;
			}
            if(strcmp(p->info.num,a)==0){
				cout<<"wrong!!!"<<endl;
				cout<<"the good of the num is exist!!!"<<endl;
				i=1;
				goto label;
			}
			p=p->link;
	}
    p=first->link;
	while(p!=first){
		if(strcmp(p->info.name,e)==0){
			if(p==first->link){
				q=p;
				p=new LinkNode;
				strcpy(p->info.num,a);
			    strcpy(p->info.name,b);
			    strcpy(p->info.amount,c);
			    strcpy(p->info.loc,d);
                cout<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
				first->link=p;
				p->link=q;
			}
			else{
				q=p;
				p=new LinkNode;
				strcpy(p->info.num,a);
			    strcpy(p->info.name,b);
			    strcpy(p->info.amount,c);
			    strcpy(p->info.loc,d);
				k->link=p;
				p->link=q;
			}
			i=0;
			n++;
			break;
		}
		else{
		    k=p;
            p=p->link;
		}  
		}
    if(i!=0){
		p=first->link;
		q=p;
		p=new LinkNode;
		strcpy(p->info.num,a);
		strcpy(p->info.name,b);
		strcpy(p->info.amount,c);
		strcpy(p->info.loc,d);
        cout<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
		first->link=p;
		p->link=q;
		i=0;
	}
	outfile<<n<<endl;
    p=first->link;
label:while(p!=first){
        outfile<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
		p=p->link;
	  }
    if(i==0)
		return 1;
	else
        return 0;
}

int addbyamount(char a[maxSize], char b[maxSize], char c[maxSize], char d[maxSize], 
				char e[maxSize], LinkNode * p, LinkNode * first){
	   //将具有所给定的相应信息且仓库中并不含有的货物放入仓库中,并将它
	//放在有给定amount值的仓库管理表格文本中第一个出现的货物的前面
    ofstream outfile("Inventory management forms.txt");
    p=first->link;
	int i;
    LinkNode * k;
    LinkNode * q;
	while(p!=first){
			if(strcmp(p->info.name,b)==0){
				cout<<"wrong!!!"<<endl;
				cout<<"the good of the name is exist!!!"<<endl;
				i=1;
				goto label;
			}
            if(strcmp(p->info.num,a)==0){
				cout<<"wrong!!!"<<endl;
				cout<<"the good of the num is exist!!!"<<endl;
				i=1;
				goto label;
			}
			p=p->link;
	}
    p=first->link;
	while(p!=first){
		if(strcmp(p->info.amount,e)==0){
			if(p==first->link){
				q=p;
				p=new LinkNode;
				strcpy(p->info.num,a);
			    strcpy(p->info.name,b);
			    strcpy(p->info.amount,c);
			    strcpy(p->info.loc,d);
                cout<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
				first->link=p;
				p->link=q;
			}
			else{
				q=p;
				p=new LinkNode;
				strcpy(p->info.num,a);
			    strcpy(p->info.name,b);
			    strcpy(p->info.amount,c);
			    strcpy(p->info.loc,d);
				k->link=p;
				p->link=q;
			}
			i=0;
			n++;
			break;
		}
		else{
		    k=p;
            p=p->link;
		}  
		}
    if(i!=0){
		p=first->link;
		q=p;
		p=new LinkNode;
		strcpy(p->info.num,a);
		strcpy(p->info.name,b);
		strcpy(p->info.amount,c);
		strcpy(p->info.loc,d);
        cout<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
		first->link=p;
		p->link=q;
		i=0;
	}
	outfile<<n<<endl;
    p=first->link;
label:	while(p!=first){
        outfile<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
		p=p->link;
	}
	if(i==0)
	    return 1;
	else
		return 0;
}

int addbyloc(char a[maxSize], char b[maxSize], char c[maxSize], char d[maxSize], 
			 char e[maxSize], LinkNode * p, LinkNode * first){
	   //将具有所给定的相应信息且仓库中并不含有的货物放入仓库中,并将它
	//放在有给定loc值的仓库管理表格文本中第一个出现的货物的前面
    ofstream outfile("Inventory management forms.txt");
    p=first->link;
	int i;
    LinkNode * k;
    LinkNode * q;
	while(p!=first){
			if(strcmp(p->info.name,b)==0){
				cout<<"wrong!!!"<<endl;
				cout<<"the good of the name is exist!!!"<<endl;
				i=1;
				goto label;
			}
            if(strcmp(p->info.num,a)==0){
				cout<<"wrong!!!"<<endl;
				cout<<"the good of the num is exist!!!"<<endl;
				i=1;
				goto label;
			}
			p=p->link;
	}
    p=first->link;
	while(p!=first){
		if(strcmp(p->info.loc,e)==0){
			if(p==first->link){
				q=p;
				p=new LinkNode;
				strcpy(p->info.num,a);
			    strcpy(p->info.name,b);
			    strcpy(p->info.amount,c);
			    strcpy(p->info.loc,d);
                cout<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
				first->link=p;
				p->link=q;
			}
			else{
				q=p;
				p=new LinkNode;
				strcpy(p->info.num,a);
			    strcpy(p->info.name,b);
			    strcpy(p->info.amount,c);
			    strcpy(p->info.loc,d);
				k->link=p;
				p->link=q;
			}
			i=0;
			n++;
			break;
		}
		else{
		    k=p;
            p=p->link;
		}  
		}
    if(i!=0){
		p=first->link;
		q=p;
		p=new LinkNode;
		strcpy(p->info.num,a);
		strcpy(p->info.name,b);
		strcpy(p->info.amount,c);
		strcpy(p->info.loc,d);
        cout<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
		first->link=p;
		p->link=q;
		i=0;
	}
	outfile<<n<<endl;
    p=first->link;
label:	while(p!=first){
        outfile<<p->info.num<<" "<<p->info.name<<" "<<p->info.amount<<" "<<p->info.loc<<endl;
		p=p->link;
	}
	if(i==0)
	    return 1;
	else
		return 0;
}

void main(){
	int m;
	int j;
	Good good;
	char str1[maxSize];
	char str2[maxSize];
	char str3[maxSize];
	char str4[maxSize];
	char str5[maxSize];
    LinkNode * c;
    infile.open("Inventory management forms.txt");
	infile>>n;
    first=new LinkNode;
	if(first==NULL)
		cout<<"Wrong!!!"<<endl;
	else
		p=first;
	for(m=0;m<n;m++){
		c=new LinkNode;
		if(c==NULL)
			cout<<"Wrong!!!"<<endl;
		else{
			p->link=c;
			p=c;
			infile>>good.num>>good.name>>good.amount>>good.loc;
			strcpy(p->info.num,good.num);
			strcpy(p->info.name,good.name);
			strcpy(p->info.amount,good.amount);
			strcpy(p->info.loc,good.loc);
		}
	}
	p->link=first;                 //建立存放仓库管理表格文本文档中货物的信息的链表
    int opt1;    
    int opt2;
	int opt3;
	int opt4;
	int opt5;
	int opt6;
	enum Opt{y,n};
	char t;
menu1:cout<<"***********************************************************"<<endl;
   	cout<<"*............................menu.........................*"<<endl;
	cout<<"*     1.Change the location of the goods stored;          *"<<endl;
	cout<<"*     2.find the information of the good(s) you want;     *"<<endl;
	cout<<"*     3.delete the of the good(s) you want;               *"<<endl;
	cout<<"*     4.add a new good;                                   *"<<endl;
	cout<<"*     5.quit;                                             *"<<endl;
	cout<<"***********************************************************"<<endl;       //第一级菜单
	cout<<"please choose the option:"<<endl;
	cin>>opt1;
    switch(opt1){
	  case 1: cout<<"***********************************************************"<<endl;
		      cout<<"*............................menu.........................*"<<endl;
		      cout<<"*            1.Change based on goodsnum;                  *"<<endl;
			  cout<<"*            2.Change based on goodsname;                 *"<<endl;
			  cout<<"*            3.Change based on goodsamount;               *"<<endl;
			  cout<<"*            4.Change based on goodsloc;                  *"<<endl;
			  cout<<"*            5.quit;                                      *"<<endl;
			  cout<<"***********************************************************"<<endl;         //第二级菜单
	          cout<<"please choose the option:"<<endl;
	          cin>>opt2;
              switch(opt2){
	             case 1: cout<<"Please cin the num of the good you want to change its' location:"<<endl;
		                 cin>>str1;
			             cout<<"Please cin the location you want it to move to:"<<endl;
			             cin>>str2;
                         j=movebynum(str1,str2,p,first);
                         if(j==1)
			                 cout<<"Success!!!"<<endl;
			             else
				             cout<<"fail!!!"<<endl;
						 cout<<"Do you want to do any other operation(y/n)?"<<endl;
						 cin>>t;
						 if(t=='y')
							 opt6=1;
						 if(t=='n')
							 opt6=2;
                         switch(opt6){
						   case 1: goto menu1; 
							       break;
						   case 2: break;
						 }
						 break;
	            case 2: cout<<"Please cin the name of the good you want to change its' location:"<<endl;
                        cin>>str1;
                        cout<<"Please cin the location you want it to move to:"<<endl;
			            cin>>str2;
                        j=movebyname(str1,str2,p,first);
			            if(j==1)
			                 cout<<"Success!!!"<<endl;
			            else
				             cout<<"fail!!!"<<endl;
						 cout<<"Do you want to do any other operation(y/n)?"<<endl;
						 cin>>t;
						 if(t=='y')
							 opt6=1;
						 if(t=='n')
							 opt6=2;
						 switch(opt6){
						   case 1: goto menu1; 
							       break;
						   case 2: break;
						 }
						 break;
                case 3: cout<<"Please cin the amount of the good you want to change its' location:"<<endl;
                        cin>>str1;

⌨️ 快捷键说明

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