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

📄 menu2.cpp

📁 连接到数据库(sql和access)
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s(例如:1990-01):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 flag=1;
			 }while(strlen(temp[1])!=7 || !(IsDate(temp[1],0)));
		 }
		 //限制人数
		 if(i==4)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s(0-1000):",row_txt[table][i]);
				 grade=Force();
				 flag=1;
			 }while(grade<0 ||grade>1000);
			 //将整型转换为字符型
			 itoa(grade,temp[1],10);
		 }
        //院系号限制
		if(i==5)
		{
			do
			{
				printf("请输入%s(2位):",row_txt[table][i]);
				scanf("%s",temp[1]);
				Find[1]=5;
				if(find(Find,temp[1],temp[1],all).departmenthead==NULL)
				{
					printf("\n该院系号不存在,请重新输入!\n\n");
					continue;
				}
				if(strlen(temp[1])!=2)
				{
					printf("\n院系号位数错误,请重新输入!\n\n");
					continue;
				}
				break;
			}while(1);
		}

	 }
	 //插入院系表
	 if(table==5)
	 {
		 //限制院系编号
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(2位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 if(n[2]==1&&find(Find,temp[1],temp[1],all).departmenthead!=NULL)
				 {
					 printf("\n该院系号已存在,请重新输入!\n\n");
					 continue;
				 }
				 if(n[2]==2&&find(Find,temp[1],temp[1],all).departmenthead==NULL)
				 {
					 printf("\n该院系号不存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[1])!=2)
				 {
					 printf("\n院系号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
		 //院系名
		 if(i==2)
		 {
			 printf("请输入%s:",row_txt[table][i]);
			 scanf("%s",temp[1]);
		 }
		 //限制创办年份
		 if(i==3)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s(例如:1990-01):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 flag=1;
			 }while(strlen(temp[1])!=7 || !(IsDate(temp[1],0)));
		 }
		 //系主任
		 if(i==4)
		 {
			 printf("请输入%s:",row_txt[table][i]);
			 scanf("%s",temp[1]);
		 }
		 //系办公室地点
		 if(i==5)
		 {
			 printf("请输入%s:",row_txt[table][i]);
			 scanf("%s",temp[1]);
		 }
		 //电话
		 if(i==6)
		 {				
			 printf("请输入%s:",row_txt[table][i]);
			 scanf("%s",temp[1]);
		 }
	 }
	 //插入班级表
	 if(table==6)
	 {
		 //限制班级编号
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(10位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 if(n[2]==1&&find(Find,temp[1],temp[1],all).classhead!=NULL)
				 {
					 printf("\n该班级号已存在,请重新输入!\n\n");
					 continue;
				 }
				 if(n[2]==2&&find(Find,temp[1],temp[1],all).classhead==NULL)
				 {
					 printf("\n该班级号不存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[1])!=10)
				 {
					 printf("\n班级号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
		 //班级名
		 if(i==2)
		 {
			 printf("请输入%s:",row_txt[table][i]);
			 scanf("%s",temp[1]);
		 }
		 //限制创办年份
		 if(i==3)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s(例如:1990-01):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 flag=1;
			 }while(strlen(temp[1])!=7 || !(IsDate(temp[1],0)));
		 }
		 //自修教室
		 if(i==4)
		 {
			 printf("请输入%s:",row_txt[table][i]);
			 scanf("%s",temp[1]);
		 }
		 //限制人数
		 if(i==5)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s(0-40):",row_txt[table][i]);
				 grade=Force();
				 flag=1;
			 }while(grade<0 ||grade>40);
			 //将整型转换为字符型
			 itoa(grade,temp[1],10);
		 }
		 //班主任教师号限制
		 if(i==6)
		 {
			 do
			 {
				 printf("请输入%s(10位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 Find[1]=2;
				 if(find(Find,temp[1],temp[1],all).teacherhead==NULL)
				 {		
					 printf("\n该教师号不存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[1])!=10)
				 {
					 printf("\n教师号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
        //院系号限制
		if(i==7)
		{
			do
			{
				printf("请输入%s(2位):",row_txt[table][i]);
				scanf("%s",temp[1]);
				Find[1]=5;
				if(find(Find,temp[1],temp[1],all).departmenthead==NULL)
				{
					printf("\n该院系号不存在,请重新输入!\n\n");
					continue;
				}
				if(strlen(temp[1])!=2)
				{
					printf("\n院系号位数错误,请重新输入!\n\n");
					continue;
				}
				break;
			}while(1);
		}

	 }
	 //插入教学计划表
	 if(table==7)
	 {
		 //专业号限制
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(2位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 Find[1]=4;
				 if(find(Find,temp[1],temp[1],all).specialityhead==NULL)
				 {
					 printf("\n该专业号不存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[1])!=2)
				 {
					 printf("\n专业号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
		 //同时限制课程号,专业号
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(10位):",row_txt[table][2]);
				 scanf("%s",temp[2]);
				 Find[1]=3;
				 if(find(Find,temp[2],temp[2],all).coursehead==NULL)
				 {
					 printf("\n该课程号不存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[2])!=10)
				 {
					 printf("\n课程号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 Find[1]=7;
				 if(n[2]==1&&find(Find,temp[1],temp[2],all).projecthead!=NULL)
				 {
					 printf("\n该教学计划已存在,请重新输入!\n\n");
					 continue;
				 }
				 if(n[2]==2&&find(Find,temp[1],temp[2],all).projecthead==NULL)
				 {
					 printf("\n该教学计划不存在,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }

		 //限制课程属性
		 if(i==3)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s(选修课/必修课):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 flag=1;
			 }while(strlen(temp[1])!=6 || (strcmp("选修课",temp[1])!=0&&strcmp("必修课",temp[1])!=0));
		 }
	 }
	 //插入入校报到表
	 if(table==8)
	 {
		 //限制入校报到编号
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(5位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 if(strlen(temp[1])!=5)
				 {
					 printf("\n入学报到号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 if(n[2]==1&&find(Find,temp[1],temp[1],all).registerhead!=NULL)
				 {
					 printf("\n该入学报到号已存在,请重新输入!\n\n");
					 continue;
				 }
				 if(n[2]==2&&find(Find,temp[1],temp[1],all).registerhead==NULL)
				 {
					 printf("\n该入学报到号不存在,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
		 //院系号限制
		 if(i==2)
		 {
			 do
			 {
				 printf("请输入%s(2位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 Find[1]=5;
				 if(find(Find,temp[1],temp[1],all).departmenthead==NULL)
				 {
					 printf("\n该入学报到号已存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[1])!=2)
				 {
					 printf("\n入学报到号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
		 //限制学费
		 if(i==3)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s:",row_txt[table][i]);
				 grade=Force();
				 flag=1;
			 }while(grade<0 ||grade>20000);
			 //将整型转换为字符型
			 itoa(grade,temp[1],10);
		 }
	 }
	 //插入选修表
	 if(table==9)
	 {
		 //学号限制
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(10位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 Find[1]=1;
				 if(find(Find,temp[1],temp[1],all).studenthead==NULL)
				 {
					 printf("\n该学号不存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[1])!=10)
				 {
					 printf("\n学号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
		 //同时限制学号、课程号
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(10位):",row_txt[table][2]);
				 scanf("%s",temp[2]);
				 Find[1]=3;
				 if(find(Find,temp[2],temp[2],all).coursehead==NULL)
				 {
					 printf("\n该课程号不存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[2])!=10)
				 {
					 printf("\n课程号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 Find[1]=9;
				 if(n[2]==1&&find(Find,temp[1],temp[2],all).schead!=NULL)
				 {
					 printf("\n该选修记录已存在,请重新输入!\n\n");
					 continue;
				 }
				 if(n[2]==2&&find(Find,temp[1],temp[2],all).schead==NULL)
				 {
					 printf("\n该选修记录不存在,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);

		 }
		 //考试类别
		 if(i==3)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s(考试课/考查课):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 flag=1;
			 }while(strlen(temp[1])!=6 || (strcmp("考试课",temp[1])!=0&&strcmp("考查课",temp[1])!=0));
		 }
		 //限制成绩
		 if(i==4)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }
				 printf("请输入%s:",row_txt[table][i]);
				 grade=Force();
				 flag=1;
			 }while(grade<0 ||grade>150);
			 //将整型转换为字符型
			 itoa(grade,temp[1],10);
		 }
		 //教师号限制
		 if(i==5)
		 {
			 do
			 {
				 printf("请输入%s(10位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 if(strlen(temp[1])!=10)
				 {
					 printf("\n教师号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 Find[1]=2;
				 if(find(Find,temp[1],temp[1],all).teacherhead==NULL)
				 {
					 printf("\n该教师号不存在,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }

		 //限制选修年份
		 if(i==6)
		 {
			 do
			 {
				 if(flag==1)
				 {
					 printf("\n输入错误,请重新输入!\n\n");
				 }					
				 printf("请输入%s(例如:1990-01):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 flag=1;
			 }while(strlen(temp[1])!=7 || !(IsDate(temp[1],0)));
		 }
	 }
	 //插入讲授表
	 if(table==10)
	 {
		 //教师号限制
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(10位):",row_txt[table][i]);
				 scanf("%s",temp[1]);
				 if(strlen(temp[1])!=10)
				 {
					 printf("\n教师号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 Find[1]=2;
				 if(find(Find,temp[1],temp[1],all).teacherhead==NULL)
				 {
					 printf("\n该教师号不存在,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
        //同时限制课程号、教师号
		 if(i==1)
		 {
			 do
			 {
				 printf("请输入%s(10位):",row_txt[table][2]);
				 scanf("%s",temp[2]);
				 Find[1]=3;
				 if(find(Find,temp[2],temp[2],all).coursehead==NULL)
				 {
					 printf("\n该课程号不存在,请重新输入!\n\n");
					 continue;
				 }
				 if(strlen(temp[2])!=10)
				 {
					 printf("\n课程号位数错误,请重新输入!\n\n");
					 continue;
				 }
				 Find[1]=10;
				 if(n[2]==1&&find(Find,temp[1],temp[2],all).tchead!=NULL)
				 {
					 printf("\n该讲授记录已存在,请重新输入!\n\n");
					 continue;
				 }
				 if(n[2]==2&&find(Find,temp[1],temp[2],all).tchead==NULL)
				 {
					 printf("\n该讲授记录不存在,请重新输入!\n\n");
					 continue;
				 }
				 break;
			 }while(1);
		 }
		 //授课时间
		 if(i==3)
		 {
			 printf("请输入%s:",row_txt[table][i]);

⌨️ 快捷键说明

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