珠寶銷售管理信息系統(tǒng)課程設(shè)計_第1頁
珠寶銷售管理信息系統(tǒng)課程設(shè)計_第2頁
珠寶銷售管理信息系統(tǒng)課程設(shè)計_第3頁
珠寶銷售管理信息系統(tǒng)課程設(shè)計_第4頁
珠寶銷售管理信息系統(tǒng)課程設(shè)計_第5頁
已閱讀5頁,還剩32頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、 華科學(xué)院數(shù)據(jù)庫課程設(shè)計第一章 需求分析1。1 系統(tǒng)開發(fā)背景、目的及意義隨著電子計算機(jī)和通信技術(shù)的發(fā)展,人類已經(jīng)逐漸地進(jìn)入信息化社會。信息和材料、能源一樣成為一種社會的基本生產(chǎn)資料,在人類的社會生產(chǎn)活動中發(fā)揮著重要的作用。同時人們對信息和數(shù)據(jù)的利用與處理也已進(jìn)入自動化、網(wǎng)絡(luò)化和社會化的階段,因此,開發(fā)相關(guān)的管理信息系統(tǒng)已經(jīng)成為各行各業(yè)的必要和必需了,管理信息系統(tǒng)作為一門邊緣學(xué)科,集管理科學(xué)、信息科學(xué)、系統(tǒng)科學(xué)、現(xiàn)代通信技術(shù)和電子計算機(jī)技術(shù)于一體,可以解決企業(yè)或組織所面臨的問題,對內(nèi)來看,可以提高工作效率;對外來看,獲得競爭優(yōu)勢。在使用計算機(jī)系統(tǒng)之前珠寶的管理都是手工操作。手續(xù)繁雜,還不便管理,

2、不能保證數(shù)據(jù)的準(zhǔn)確性和及時性,而且浪費(fèi)人力和大量的時間,手工操作可能造成數(shù)據(jù)錄入的錯誤,若不及時發(fā)現(xiàn)會在造成不必要的麻煩。庫房進(jìn)出珠寶記錄冗長,復(fù)雜,查找工作不能及時直觀的顯示出來以供查閱,影響工作的效率。對珠寶的各種費(fèi)用的管理更是繁瑣,出錯率高。隨著計算機(jī)的普及以及相關(guān)技術(shù)的發(fā)展 ,開發(fā)一個珠寶銷售管理系統(tǒng)的時機(jī)已經(jīng)成熟.高效率、無差錯的珠寶銷售管理系統(tǒng)的開發(fā)解決了這個問題,本系統(tǒng)的主要目的是告別原始的手工操作,安全快捷的保存數(shù)據(jù)信息,節(jié)省時間,提高了速度和準(zhǔn)確性 .珠寶銷售管理系統(tǒng)可以避免珠寶店珠寶管理的隨意性,使得管理工作規(guī)范化、系統(tǒng)化、程序化,提高信息處理的速度和準(zhǔn)確性,對于減輕工作人

3、員的勞動量、提高勞動熱情和服務(wù)質(zhì)量,具有重要的現(xiàn)實(shí)意義.1.2 用戶需求珠寶銷售管理系統(tǒng)是一款用于珠寶首飾銷售企業(yè)的管理系統(tǒng),實(shí)現(xiàn)了對產(chǎn)品的實(shí)際情況的準(zhǔn)確掌握,不同時間段店鋪產(chǎn)品的庫存情況、不同階段的產(chǎn)品的銷售情況,都可以進(jìn)行詳細(xì)的分析,為采購新的系列產(chǎn)品提供充分的銷售依據(jù)。本系統(tǒng)還具有員工信0 華科學(xué)院數(shù)據(jù)庫課程設(shè)計息管理與供應(yīng)商信息管理、利潤統(tǒng)計、客戶管理、會員管理 ,是廣大珠寶銷售店鋪快速提高管理能力的好幫手。該系統(tǒng)在功能上主要包括基本信息(職員信息、產(chǎn)品信息、供應(yīng)商信息、客戶信息);采購進(jìn)貨(進(jìn)貨登記、退貨登記、付款登記、欠供商統(tǒng)計);預(yù)訂管理(產(chǎn)品預(yù)訂,預(yù)訂報表);產(chǎn)品銷售(產(chǎn)品銷售

4、、銷售報表、客戶退貨、退貨報表);庫存管理(庫存明細(xì)、庫存報表、庫存預(yù)警);會員管理(會員信息、會員報表、到期提醒);客戶管理(客戶信息、客戶報表)其它費(fèi)用(其它收入、收入報表、其它支出、支出報表);信息統(tǒng)計查詢(期間收入查詢、期間利潤查詢、期間進(jìn)).1.3 功能模型系庫統(tǒng)商客產(chǎn)會系費(fèi)系以下為客戶信息管理,會員信息管理、采購進(jìn)貨的功能模型(如圖131、1-32、1存管理計模塊品銷售員管理統(tǒng)維護(hù)統(tǒng)維護(hù)33 所示)庫存庫存庫存預(yù)警珠會圖 1.3。3 采購進(jìn)貨用例圖會會客客戶修改客戶刪除客寶添加員修改員刪除員查詢戶添加戶查詢1。4 數(shù)據(jù)流程圖明細(xì)報表圖 1。4.1 客戶信息數(shù)據(jù)流圖圖 1.4。2 會

5、員信息數(shù)據(jù)流圖圖 1。4。3 采購進(jìn)貨數(shù)據(jù)流圖1.5 業(yè)務(wù)流程圖圖 1.5。1 客戶信息業(yè)務(wù)流程圖登陸圖 1.5。2 會員信息業(yè)務(wù)流程圖登陸客戶信息洽 談 新 供 應(yīng)查詢1會員信息修改刪除添加 華科學(xué)院數(shù)據(jù)庫課程設(shè)計圖 1.5。3 采購進(jìn)貨業(yè)務(wù)流程圖1。6 系統(tǒng)流程圖管理員登是系統(tǒng)管理否是基本信息管理否是客戶管理否刪除客戶信息確定刪除圖 1。6。1 客戶信息管理系統(tǒng)流程圖2 華科學(xué)院數(shù)據(jù)庫課程設(shè)計管理員是是是會 員 管添加會員信息否刪除會員信息確定刪除圖 1.6.2 會員信息管理系統(tǒng)流程圖事庫存信息文查詢結(jié)果進(jìn)貨操作訂 貨 報3 華科學(xué)院數(shù)據(jù)庫課程設(shè)計圖 1.6.2 采購進(jìn)貨管理系統(tǒng)流程圖第二

6、章 概要設(shè)計2。1 硬件環(huán)境硬件環(huán)境:CPU Celeron 1G, Memory 64MB2。2 軟件環(huán)境1、為運(yùn)行本系統(tǒng),計算機(jī)硬件應(yīng)滿足如下要求486DX/66MHz 或更高的處理器(推薦 Pentium 或更高的處理器),或運(yùn)行于Microsoft Windows NT Workstation 的 Alapha 處理器。Microsoft Windows 支持的 VGA 或分辨率更高的監(jiān)視器,16 MB 內(nèi)存以上鼠標(biāo)或其他定點(diǎn)設(shè)備2、軟件環(huán)境應(yīng)滿足如下要求本系統(tǒng)在 Windows 98 下開發(fā),應(yīng)用 Microsoft Access 作后臺服務(wù)器,如果本系統(tǒng)應(yīng)用于比較大的珠寶公司,建議

7、應(yīng)用 SQL Serers 2000 或 Oracle 等大型的數(shù)據(jù)庫作后臺.推薦桌面顯示方式為 1024768 像素3、軟件安裝:直接安裝即可。2。3 軟件特點(diǎn)軟件特點(diǎn)如下:1、界面設(shè)計簡潔,美觀,操作流程人性化,普通用戶亦可很快上手;2、每條出進(jìn)貨記錄均可添加多項出進(jìn)貨物品,滿足實(shí)際需要;3、短缺產(chǎn)品和會員卡到期是系統(tǒng)自動提醒;4、完善的二次開發(fā)功能,用戶可自行或聯(lián)系我們添加所需要的新功能4 華科學(xué)院數(shù)據(jù)庫課程設(shè)計2。4 概念數(shù)據(jù)模型圖2。4 概念數(shù)據(jù)模型第三章 詳細(xì)設(shè)計3。1 功能闡述珠寶銷售管理系統(tǒng)實(shí)現(xiàn)了對產(chǎn)品的實(shí)際情況的準(zhǔn)確掌握 ,不同時間段店鋪產(chǎn)品的銷售情況、不同階段的產(chǎn)品的庫存情

8、況,都可以進(jìn)行詳細(xì)的分析,為采購新的系列產(chǎn)品提供充分的銷售依據(jù)。本系統(tǒng)還具有客戶信息管理與會員信息管理等功能 ,是廣大珠寶銷售店鋪快速提高管理能力的好幫手。本實(shí)例的主要功能如下:1、采購進(jìn)貨(進(jìn)貨登記、退貨登記、付款登記、欠供商統(tǒng)計);2、客戶信息(客戶姓名、地址、聯(lián)系方式、消費(fèi)金額);3、會員信息(會員姓名、地址、聯(lián)系方式、累計積分);軟件特點(diǎn)如下:1、界面設(shè)計簡潔,美觀,操作流程人性化,普通用戶不需培訓(xùn)也能很快上手;2、每條出進(jìn)貨記錄均可添加多項出進(jìn)貨物品,滿足實(shí)際需要;3、短缺產(chǎn)品和會員卡到期是系統(tǒng)自動提醒;4、完善的二次開發(fā)功能,用戶可自行或聯(lián)系我們添加所需要的新功能.3.2 功能界面

9、模型客戶信息管理客戶信息管理是珠寶首飾銷售管理系統(tǒng)的功能之一主要包括添加客戶信息、查詢客戶信息、修改客戶信息以及刪除客戶信息等基本操作。圖 321 客戶添加圖 3-2-2 客戶查詢/修改/刪除客戶信息管理客戶信息管理是珠寶首飾銷售管理系統(tǒng)的功能之一主要包括添加客戶信息、查詢客戶信息、修改客戶信息以及刪除客戶信息等基本操作.圖 3-23 會員添加5 華科學(xué)院數(shù)據(jù)庫課程設(shè)計圖 332-4 會員查詢/修改/刪除采購進(jìn)貨管理是珠寶首飾銷售管理系統(tǒng)的功能之一主要包括進(jìn)貨登記、進(jìn)貨查詢等基本操作.圖 3-25 進(jìn)貨登記3。3 程序流程圖開始重試否是失敗用戶登錄失敗超過 3 次成功用戶管理模塊管理自己的用戶

10、信息圖 33-1 珠寶銷售管理系統(tǒng)程序流程圖6 華科學(xué)院數(shù)據(jù)庫課程設(shè)計3。4 主要代碼/*add.c:添加珠寶信息記錄*/include ”stdio。h”void AddRecord()FILE *fp = NULL;product TmpS;/定義指向文件的指針/*定義進(jìn)行操作時的臨時結(jié)構(gòu)體變量/char DataFile40 = ”; /存儲珠寶信息的文件名/int count = 1; /*計算可輸入數(shù)據(jù)的最大范圍*/=輸入要添加商品信息的文件名=*/printf(n please input the product information file name to add recor

11、d:”);printf(n Notice:Name of file cant exceed 8 characters。suffix cant exceed 3 characters,part ofexceed will be discarded.n”);gets(DataFile);/如顧客沒有輸入,則循環(huán)提示顧客輸入*/while(*DataFile = (0))printf(n please input new file name to store data,end with enter。);printf(n Notice:Name of file cant exceed 8 charac

12、ters,suffix cant exceed 3 characters。part ofexceed will be discarded。n”);gets(DataFile);fp = fopen(DataFile,a+”);/a+:當(dāng)文件存在時,追加,當(dāng)文件不存在時,創(chuàng)建/*如果當(dāng)前文件不存在,提示打開文件失敗/if (fp = NULL)printf(n Open file %s fail!End with any key。n,DataFile);perror(Open file fail”);getch();exit(1);/如果成功打開或創(chuàng)建文件,則提示輸入商品序號、名稱、價格要素等相

13、關(guān)信息/printf(”input number,name and salary.number is 0 means input is end.n”);printf(”Number is not exceed 9 fig ures,Name is not exceed 20 characters,range of grade :0。001000。00n);/循環(huán)從鍵盤上讀取顧客輸入的序號、名稱、價格要素等相關(guān)信息*/while(count = SIZE)/輸入序號,如為 0 則停止輸入*/printf(n input number =0 means end input。n);7 華科學(xué)院數(shù)據(jù)庫

14、課程設(shè)計printf(”number=);scanf(”ld”,&TmpS。Number);if (TmpS。Number = 0 )break;/提示輸入商品名稱*/printf(”name=”);scanf(”%s,TmpS.Name);/*提示輸入商品價格/printf(price=”);scanf(f,TmpS.price);/提示輸入商品折扣*/printf(”discount=”);scanf(”%f”,TmpS。discount);/用公式自動計算商品會員價*/TmpS.memberprice=TmpS。price*TmpS。discount;printf(n”);/如遇無法寫入

15、文件的異常,則加以提示/if(fwrite(TmpS,sizeof(product),1,fp)!=1)printf(nwrite file s fail!End with any keyn”,DataFile);perror(Write file fail ”);getch();exit(1);count+;/如果輸入的數(shù)據(jù)量超過最大允許的范圍,則提示數(shù)據(jù)不能錄入*/if (countSIZE)printf(”nsorry,number of data can not exceeddn,SIZE);fclose(fp);/*=在屏幕上顯示文件內(nèi)容=*/ clrscr();*/printf(”

16、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(”O(jiān)pen file fail”);getch();exit(1);8 華科學(xué)院數(shù)據(jù)庫課程設(shè)計printf(”nNumbertNametpricetdiscountmemberpricen”);while(fread(

17、&TmpS,sizeof(product),1,fp) != (int)NULL)printf(”nldtst%4。1ft%4。1ft%4。1fn,TmpS。Number,TmpS.Name,TmpS。price,TmpS。discount,TmpS。memberprice);fclose(fp);/* adduser。c 增加用戶信息記錄#include ”stdio。h”void AddUser()/FILE *fp = NULL;user Show;user TmpS;char DataFile40 = ”yonghu”;/*存儲用戶信息文件名*/int count = 1; /計算可輸

18、入數(shù)據(jù)的最大范圍*/fp = fopen(DataFile,”ab+”);/a+:當(dāng)文件存在時,追加,當(dāng)文件不存在時,創(chuàng)建/如果當(dāng)前文件不存在,提示打開文件失敗/if (fp = NULL)printf(”n Open file s fail!End with any key。n,DataFile);perror(”O(jiān)pen file fail”);getch();exit(1);/如果成功打開文件,則提示輸入用戶相關(guān)信息*/printf(”input number,name and salary。number is 0 means input is end.n”);print(f ”Numb

19、er is not exceed 9 figures,Name is not exceed 20 characters,range of grade:0。001000。00n);/循環(huán)從鍵盤上讀取用戶輸入的用戶相關(guān)信息/while(count = SIZE)printf(”n input number =0 means end input.n”);printf(”number=);scanf(”%ld”,&TmpS。Number);if (TmpS。Number = 0 )break;printf(”name=”);scanf(s”,TmpS.Name)getchar();printf(ps=

20、”);scanf(”s”,TmpS.ps);9 華科學(xué)院數(shù)據(jù)庫課程設(shè)計printf(”power=);scanf(”d,TmpS.power);printf(”n);/如遇無法寫入文件的異常,則加以提示/if(fwrite(TmpS,sizeof(user),1,fp)!=1)printf(nwrite file %s fail!End with any keyn”,DataFile);perror(”Write file fail ” );getch();exit(1);count+;/*如果輸入的數(shù)據(jù)量超過最大允許的范圍,則提示數(shù)據(jù)不能錄入*/if (countSIZE)printf(”n

21、sorry,number of data can not exceeddn,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);prin

22、tf(”nNumberttNametpstpowern”);while(fread(&Show,sizeof(user),1,fp) != (int)NULL)printf(”nldtst%st%dn”,Show.Number,Show。Name,Show.ps,Show。power);fclose(fp);/*admin.c:管理員功能選擇界面,根據(jù)客戶選項調(diào)用相應(yīng)函數(shù)實(shí)現(xiàn)系統(tǒng)功能*/#include ”shead。h”include ”creat。c”#include ”add。c”include delete。c”#include ”modnum.c”include ”qname。c”1

23、0 華科學(xué)院數(shù)據(jù)庫課程設(shè)計include ”qseatnum.c”include smprice。c”void Admin()int choice = 0; /*存放客戶選項的變量/=功能及操作的界面提示=/while(1)printf(”-n);printf(”printf(”printf(printf(n);|n”);|n);Welcome to Product Management System-n);printf(”printf(|1。 Init Product Information File2. AddProduct()|n”);|n”);|n);n”);|n”);n”);prin

24、tf(printf(”printf(|3。 DelProduct()4。 QueryByProductName()5. QueryByProductNum()6. ModifyByProductNumber()7. SortByMemberPrice()printf(printf(” n” ) ;printf(”+n”);printf(System User Management11。CreatNewUserFile()12。AddUser()n);|n);n”);|n”);printf(printf(”printf(printf(”|13.DelUser()14。ModifyUser()15

25、.SortByUserNum()n”);|n);printf(”printf(”+n”);printf(”|0. Exit Systemn”);printf(-n”);printf(” Please Input Your Choosen);n”);printf(”# number 17 to Manage the Product Informationprintf(”# number 11,12,13,14,15 to Manage the System User n”);printf(” number 0 to Exit the Systemn”);printf(-n);scanf(”d,&

26、choice);getchar();11 華科學(xué)院數(shù)據(jù)庫課程設(shè)計/*根據(jù)客戶選項調(diào)用相應(yīng)函數(shù)*/switch(choice)case 1:CreatFile();break;case 2:AddRecord();break;case 3:DelRecord();break;case 4:QueryByName();break;case 5:QueryBySeatNum();break;case 6:ModifyByNumber( );break;case 7:SortByMemberPrice();break;case 11:CreatUser( );break;case 12:AddUser

27、();break;case 13:DelUser();break;case 14:ModifyByUserNumber();break;case 15:SortByUserNum( );break;case 0:exit(0);default:12 華科學(xué)院數(shù)據(jù)庫課程設(shè)計break;/creat。c:用于創(chuàng)建商品信息文件*/#include ”stdio.h”/函數(shù) CreatFile/void CreatFile()FILE fp = NULL;product TmpS;/定義指向文件的指針/定義進(jìn)行操作時存放結(jié)構(gòu)體變量的/char DataFile40 = ”;/存儲商品信息的文件名/in

28、t count = 1; /計算可輸入數(shù)據(jù)的最大范圍/=輸入存放商品信息的文件名=/printf(n please input new file name of product information?!保籶rintf(”n Notice:Name of file cant exceed 8 characters.suffix cant exceed 3 characters,part ofexceed will be discarded.n”);gets(DataFile);/*如顧客沒有輸入,則循環(huán)提示顧客輸入*/while(*DataFile = (0))printf(”n pleas

29、e input new file name to store data,end with enter。);printf(”n Notice:Name of file cant exceed 8 characters,suffix cant exceed 3 characters。partof exceed will be discarded。n);gets(DataFile);/用二進(jìn)制寫的方式打開文件,即創(chuàng)建文件*/fp = fopen(DataFile,”wb+);/*如果當(dāng)前文件不存在,提示打開文件失敗*/if (fp = NULL)printf(”n Open file s fail!

30、End with any key.n,DataFile);perror(”O(jiān)pen file fail”);getch();exit(1);/如果成功打開或創(chuàng)建文件,則提示輸入商品序號、名稱、價格要素等相關(guān)信息/printf(input product infotmation record.number is 0 means input is end.n”);printf(Number is not exceed 9 figures ,Name is not exceed 20 characters,range of grade :0.001000。00n”);/循環(huán)從鍵盤上讀取顧客輸入的序號

31、、名稱、價格要素等相關(guān)信息/while(count = SIZE)13 華科學(xué)院數(shù)據(jù)庫課程設(shè)計/*輸入序號,如為 0 則停止輸入/printf(n input number =0 means end input。n);printf(”number=”);scanf(”ld”,&TmpS.Number);if (TmpS。Number = 0 )break;/提示輸入商品名稱/printf(name=”);scanf(s”,TmpS.Name);/*提示輸入商品商品價格/printf(”price=);scanf(”%f”,TmpS。price);/提示輸入商品折扣/printf(discoun

32、t=”);scanf(”f”,TmpS。discount);/*用公式自動計算會員價/TmpS。memberprice=TmpS。priceTmpS.discount;printf(”n”);/如遇無法寫入文件的異常,則加以提示*/if(fwrite(TmpS,sizeof(product),1,fp)!=1)printf(”nwrite file s fail!End with any keyn”,DataFile);perror(Write file fail ”);getch();exit(1);count+;/如果輸入的數(shù)據(jù)量超過最大允許的范圍,則提示數(shù)據(jù)不能錄入/if (countS

33、IZE)printf(nsorry,number of data can not exceed%dn,SIZE);fclose(fp);/=在屏幕上顯示文件內(nèi)容=/ clrscr();/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 filesfail!End with any key n”,DataFile);perror(”O(jiān)pen fil

34、e fail);14 華科學(xué)院數(shù)據(jù)庫課程設(shè)計getch();exit(1);printf(”nNumbertNametpricetdiscounttmemberpricen);while(fread(&TmpS,sizeof(product),1,fp) != (int)NULL)、printf(n%ldtst%4。2ft4.2ftt%4.2fn”,TmpS.Number,TmpS。Name,TmpS.price,TmpS。discount,TmpS.memberprice);fclose(fp);/ cuser。c 創(chuàng)建用戶信息文件/#include ”stdio.hvoid CreatUs

35、er()FILE fp = NULL;user Show;user TmpS;char DataFile40 = ”yonghu;/存儲顧客信息的文件名*/int count = 1;/計算可輸入數(shù)據(jù)的最大范圍/fp = fopen(DataFile,”wb+”);/*如果當(dāng)前文件不存在,提示打開文件失敗/if (fp = NULL)printf(n Open file s fail!End with any key。n”,DataFile);perror(”O(jiān)pen file fail);getch();exit(1);/*如果成功打開文件,則提示輸入序號、用戶名、密碼、權(quán)限等相關(guān)信息/pr

36、intf(”input number,name and password.number is 0 means input is end.n”);printf(”Number is not exceed 9 figures,Name is not exceed 20 characters,range of grade:0。001000.00n);/循環(huán)從鍵盤上讀取用戶輸入的用戶相關(guān)信息*/while(count = SIZE)printf(n input number =0 means end input.n);printf(number=”);scanf(”%ld”,&TmpS。Number)

37、;if (TmpS.Number = 0 )break;printf(name=);15 華科學(xué)院數(shù)據(jù)庫課程設(shè)計scanf(”s”,TmpS.Name);printf(password=”);scanf(”s,TmpS.ps);printf(”power=);scanf(”d”,TmpS。power);printf(”n”);/*如遇無法寫入文件的異常,則加以提示*/if(fwrite(&TmpS,sizeof(user),1,fp)!=1)printf(nwrite file %s fail!End with any keyn”,DataFile);perror(”Write file fa

38、il ”);getch();exit(1);count+;/如果輸入的數(shù)據(jù)量超過最大允許的范圍,則提示數(shù)據(jù)不能錄入*/if (countSIZE)printf(”nsorry,number of data can not exceed%dn”,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(”nOp

39、en filesfail!End with any key n,DataFile);perror(”O(jiān)pen file fail”);getch();exit(1);printf(”nNumbertNametpstpowern”);while(fread(&Show,sizeof(user),1,fp) != (int)NULL)、print(f ”n%ldtststdn,Show。Number,Show。Name,Show。ps,Show。power/printf(”n%ldt%st%5.2ft%5。2ft%5.2ft%5。2ft5.2fn”,Show。Number,Show.Name,Sh

40、ow。gongzi,Show。jiangjin,Show。baoxian.Show。shuijin,Show。heji); */fclose(fp);/ delete。c:刪除商品信息記錄/include stdio。hvoid DelRecord()16 華科學(xué)院數(shù)據(jù)庫課程設(shè)計int i,j,k;long delnum;product TmpS;/存放顧客輸入的要刪除商品序號/*定義進(jìn)行操作時的臨時結(jié)構(gòu)體變量/product sSIZE;/SIZE,在 shead。h 頭文件中定義的常量,值為 100 */int recNumber; /原文件中的記錄數(shù)*/char DataFile40 =

41、 ”,next;/DataFile 存儲商品信息的文件名,next 為是否進(jìn)行下一次刪除操作的選項*/FILE *fp;/=fp 指針指向存儲數(shù)據(jù)的文件名=/printf(nplease input the name of production information file。n”);gets(DataFile);/*提示顧客輸入要進(jìn)行刪除紀(jì)錄的文件名*/while(DataFile = (0)printf(”nplease input the name of production information file.n”);gets(DataFile);begin:/*以二進(jìn)制讀的方式打開文

42、件/fp=fopen(DataFile,rb”);if (fp = NULL)printf(”nOpen file s fail!End with any keyn,DataFile);perror(Open file fail”);getch();exit(1);/輸入要刪除的商品序號*/printf(please input the Products seatnum which you will delete:”);scanf(%ld”,delnum);printf(”the product you will delete is:ldn,delnum);/*將文件中信息存入結(jié)構(gòu)體數(shù)組/與要

43、刪除的商品序號相匹配的項不寫入數(shù)組,循環(huán)后數(shù)組中即為去掉了要刪除記錄后的剩余記錄/recNumber=0;while((fread(TmpS,sizeof(product),1,fp) != (int)NULL)if(TmpS。Number!=delnum)srecNumber。Number = TmpS.Number;strcpy(srecNumber.Name, TmpS。Name);srecNumber。price = TmpS.price;17 華科學(xué)院數(shù)據(jù)庫課程設(shè)計srecNumber。discount = TmpS。discount;srecNumber。memberprice =

44、 TmpS。memberprice;recNumber+;fclose(fp);/*=將刪除后的剩余結(jié)構(gòu)體記錄寫入文件=/fp=fopen(DataFile,wb+);if (fp = NULL)printf(”nSet up file sfail !end with anykey。n”,DataFile);perror(”Set up fail”);getch();exit(1);for(i=0; irecNumber; i+)if(fwrite(si,sizeof(product),1,fp)!=1)printf(nWrite file %s fail!end with anykey。n”

45、,DataFile);perror(Write file fail!”);getch();exit(1);fclose(fp);/=顯示刪除后的文件=/fp=fopen(DataFile,”rb);if (fp = NULL)printf(nOpen filesfail!End with any key n,DataFile);perror(”O(jiān)pen file fail);getch();exit(1);printf(”the file after delete is:n);printf(nNumber ttNametpricetdiscounttmemberpricen”);while(f

46、read(TmpS,sizeof(product),1,fp) != (int)NULL)if(TmpS。Number!=0) printf(nldt%st%4。1ft4.1ft4.1fn”,TmpS。Number,TmpS。Name,TmpS.price,TmpS.discount,TmpS.memberprice);18 華科學(xué)院數(shù)據(jù)庫課程設(shè)計fclose(fp);/*詢問顧客是否繼續(xù)刪除*/printf(nGo on ?(y/n)”);next=getche();putchar(n);if ( next =y | next =Y) goto begin;/ deluser。c 刪除用戶信

47、息include stdio。hvoid DelUser()/int i,j,k;long delnum;user TmpS;user sSIZE;/SIZE,在 user。h 頭文件中定義的常量,值為 100 /int recNumber;char DataFile40 = ”yonghu,next;FILE *fp;/=fp 指針指向存儲數(shù)據(jù)的文件名=/begin:fp=fopen(DataFile,”rb”);if (fp = NULL)printf(”nOpen file s fail!End with any keyn,DataFile);perror(Open file fail”

48、);getch();exit(1);printf(please input the userseatnum which you will delete:);scanf(ld,delnum);printf(”the user you will delete is:ldn,delnum);recNumber=0;while((fread(&TmpS,sizeof(user),1,fp)) != (int)NULL)if(TmpS.Number!=delnum)srecNumber。Number = TmpS.Number;strcpy(srecNumber。Name, TmpS。Name);str

49、cpy(srecNumber。ps,TmpS.ps);srecNumber。power = TmpS。power;recNumber+;19 華科學(xué)院數(shù)據(jù)庫課程設(shè)計printf(”end shuzu while);fclose(fp);/=將刪除后的結(jié)構(gòu)體記錄寫入文件=/fp=fopen(DataFile,”wb+”);if (fp = NULL)printf(”nSet up file %sfail !end with anykey。n”,DataFile);perror(Set up fail”);getch();exit(1);for(i=0; irecNumber; i+)if(fwr

50、ite(&si,sizeof(user),1,fp)!=1)printf(nWrite file s fail!end with anykey.n”,DataFile);perror(”Write file fail!”);getch();exit(1);fclose(fp);/*=顯示刪除后的文件=/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(”the file a

51、fter delete is:n”);printf(”nNumber ttNametpstpowern”);while(fread(&TmpS,sizeof(user),1,fp) != (int)NULL)if(TmpS.Number!=0)print(f nldtst st %dn,TmpS。Number,TmpS.Name,TmpS。ps,TmpS。power);fclose(fp);printf(nGo on ?(y/n)”);next=getche();20 華科學(xué)院數(shù)據(jù)庫課程設(shè)計putchar(n);if ( next =y next =Y) goto begin;/guest.c

52、:普通用戶功能選擇界面,根據(jù)用戶選項調(diào)用相應(yīng)函數(shù)/void Guest()int choice = 0;while(1)printf(-n”);printf(”|n”);printf(”| Welcome to Product Management System |n”);printf(n”);printf(”|-n);printf(”printf(”printf(printf(printf(”printf(”|printfn”);n);1。 QueryByName()2。 QueryBySeatNum()3。 SortByMemberPrice()0。 Program end|n”);n);

53、|n);n”);(-n”);printf(”n Please input your choose, (1,2,3,0)?n);scanf(”d,&choice);getchar();switch(choice)case 1:QueryByName();break;case 2:QueryBySeatNum();break;case 3:SortByMemberPrice();break;case 0:exit(0);default:break;21 華科學(xué)院數(shù)據(jù)庫課程設(shè)計/login。c:顧客登錄,判斷顧客登錄名、密碼、權(quán)限,根據(jù)權(quán)限調(diào)用相應(yīng)功能選擇界面/*包含顧客信息頭文件包含創(chuàng)建顧客信息、

54、增加、刪除、修改、排序的顧客處理程序包含管理員、普通顧客的功能選擇界面處理程序*/include ”user。hinclude ”cuser。c”#include ”admin。cinclude ”guest.c”include adduser。c”include deluser。c”#include ”sunum。cinclude ”munum。c”int main()FILE fp = NULL;user Show;user TmpS;/臨時存放顧客信息的結(jié)構(gòu)體變量/char DataFile40 = ”yonghu”;/存放顧客信息的文件名為 yonghu/int i;char relo

55、gin;/是否重新登錄的標(biāo)志*/登錄成功的標(biāo)志/int success=0;/*CreatUser();/printf(=n”);printf(”# Welcome to the Product Management System! n”);printf(”=n”);again:/*輸入登錄名/printf(”please enter the user name:);scanf(%s”,TmpS。Name);/*輸入密碼,用不帶回顯的方式保證安全性/printf(”password=);for(i=0;i6;i+)TmpS。psi=getch();TmpS.ps6=0;/打開 yonghu 文

56、件,用來驗證登錄名和密碼*/fp=fopen(DataFile,rb);if (fp = NULL)22 華科學(xué)院數(shù)據(jù)庫課程設(shè)計printf(”nOpen file%sfail!End with any key n,DataFile);perror(”O(jiān)pen file fail);getch();exit(1);/循環(huán)讀取文件校驗登錄名和密碼是否正確*/while(fread(&Show,sizeof(user),1,fp) != (int)NULL)/*如果通過驗證,則將 success 成功登錄標(biāo)記設(shè)為 1/if((strcmp(TmpS.Name,Show。Name)=0)(strcm

57、p(TmpS。ps,Show。ps)=0)printf(”nlogin successful!n”);success=1;/*判斷權(quán)限,如 power 的值為 1,則是管理員,并調(diào)用管理員功能選擇界面*/if(Show。power=1)printf(”nyour power is administrator!n);Admin();/調(diào)用管理員系統(tǒng)主控平臺/判斷權(quán)限,如 power 的值為 0,則是普通顧客,并調(diào)用普通顧客功能選擇界面/if(Show.power=0)printf(”nyour power is user!n);Guest();/調(diào)用普通客戶系統(tǒng)主控平臺/如未能成功登錄,讓顧客選

58、擇重新登錄或退出/if(success=0)getchar();printf(”nerror user name or password!input again?(y/n)”);scanf(c”,relogin);if(relogin=Y)|(relogin=y))printf(”you choose input again:n);goto again;else23 華科學(xué)院數(shù)據(jù)庫課程設(shè)計printf(”end program”);getch();exit(0);/*/ modnum。c :修改商品信息記錄 */*/#include ”stdio。h”void ModifyByNumber()

59、int i,j,k;long modnum;/存儲顧客輸入的要修改的商品序號/輸入各項修改后信息*/long Number;char Name20;float price;float discount;float memberprice;product TmpS; /*定義進(jìn)行操作時的臨時結(jié)構(gòu)體變量/product sSIZE;/SIZE,在 shead。h 頭文件中定義的常量,值為 100 */int recNumber;char DataFile40 = ”,next;/DataFile 存儲商品信息的文件名,next 為是否進(jìn)行下一次刪除操作的選項/FILE fp;/*=fp 指針指向存

60、儲數(shù)據(jù)的文件名=*/*提示顧客輸入要進(jìn)行修改記錄的文件名/printf(nplease input the name of file where data is stored,end with enter key。n);gets(DataFile);/*提示顧客輸入要進(jìn)行修改記錄的文件名*/while(DataFile = (0)printf(”nplease input the name of file where data is stored,end with enter key.n”);gets(DataFile);begin:/*以讀的方式打開文件,如文件不存在,提示錯誤/fp=fop

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論