【文章內(nèi)容簡(jiǎn)介】
y key\n,DataFile)。 perror(Write file fail )。 華科學(xué)院數(shù)據(jù)庫(kù)課程設(shè)計(jì) 21 getch()。 exit(1)。 } count++。 } /*如果輸入的數(shù)據(jù)量超過(guò)最大允許的范圍,則提示數(shù)據(jù)不能錄入 */ if (countSIZE) printf(\nsorry,number of data can not exceed%d\n,SIZE)。 fclose(fp)。 /*====在屏幕上顯示文件內(nèi)容 ====*/ printf(The data you input is store successful %s in file.\n,DataFile)。 printf(Content as follow:\n)。 fp=fopen(DataFile,rb)。 if (fp == NULL) { printf(\nOpen file%sfail!End with any key \n,DataFile)。 perror(Open file fail)。 getch()。 exit(1)。 } printf(\nNumber\t\tName\tps\tpower\n)。 while(fread(amp。Show,sizeof(user),1,fp) != (int)NULL) { printf(\n%ld\t%s\t%s\t%d\n,)。 } fclose(fp)。 } /*:管理員功能選擇界面,根據(jù)客戶選項(xiàng)調(diào)用相應(yīng)函數(shù)實(shí)現(xiàn)系統(tǒng)功能 */ include include include include include include include include void Admin() { int choice = 0。 /*存放客戶選項(xiàng)的變量 */ /*====功能及操作的界面提示 ====*/ while(1) { 華科學(xué)院數(shù)據(jù)庫(kù)課程設(shè)計(jì) 22 printf(\n)。 printf(| |\n)。 printf(| Wele to Product Management System |\n)。 printf(| |\n)。 printf(||\n)。 printf(| 1. Init Product Information File |\n)。 printf(| 2. AddProduct() |\n)。 printf(| 3. DelProduct() |\n)。 printf(| 4. QueryByProductName() |\n)。 printf(| 5. QueryByProductNum() |\n)。 printf(| 6. ModifyByProductNumber() |\n)。 printf(| 7. SortByMemberPrice() |\n)。 printf(++++++++++++++++++++++++++++++++++++++++++++++++++++\n)。 printf(| System User Management |\n)。 printf(| () |\n)。 printf(| () |\n)。 printf(| () |\n)。 printf(| () |\n)。 printf(| () |\n)。 printf(++++++++++++++++++++++++++++++++++++++++++++++++++++\n)。 printf(| 0. Exit System |\n)。 printf(\n)。 printf( Please Input Your Choose \n)。 printf( number 1~7 to Manage the Product Information \n)。 printf( number 11,12,13,14,15 to Manage the System User \n)。 printf( number 0 to Exit the System \n)。 printf(\n)。 scanf(%d,amp。choice)。 getchar()。 /*根據(jù)客戶選項(xiàng)調(diào)用相應(yīng)函數(shù) */ switch(choice) { case 1: CreatFile()。 break。 case 2: AddRecord()。 break。 case 3: DelRecord()。 break。 case 4: 華科學(xué)院數(shù)據(jù)庫(kù)課程設(shè)計(jì) 23 QueryByName()。 break。 case 5: QueryBySeatNum()。 break。 case 6: ModifyByNumber()。 break。 case 7: SortByMemberPrice()。 break。 case 11: CreatUser()。 break。 case 12: AddUser()。 break。 case 13: DelUser()。 break。 case 14: ModifyByUserNumber()。 break。 case 15: SortByUserNum()。 break。 case 0: exit(0)。 default: break。 } } } /*:用于創(chuàng)建商品信息文件 */ include /*函數(shù) CreatFile*/ void CreatFile() { FILE *fp = NULL。 /*定義指向文件的指針 */ product TmpS。 /*定義進(jìn)行操作時(shí)存放結(jié)構(gòu)體變量的 */ char DataFile[40] = 。/*存儲(chǔ)商品信息的文件名 */ int count = 1。 /*計(jì)算可輸入數(shù)據(jù)的最大范圍 */ 華科學(xué)院數(shù)據(jù)庫(kù)課程設(shè)計(jì) 24