小型書店進銷存管理系統_第1頁
小型書店進銷存管理系統_第2頁
小型書店進銷存管理系統_第3頁
小型書店進銷存管理系統_第4頁
小型書店進銷存管理系統_第5頁
已閱讀5頁,還剩16頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、本科學生設計性實驗報告工程組長 學號 0103845成 員 專 業軟件工程 班級 10軟件 1 班實驗工程名稱小型書店進銷存管理系統 指導教師及職稱趙曉平 講師 開課學期 11 至12 學年一學期上課時間 2021 年 8 月 29 日 一、實驗設計方案實驗名稱:小型書店進銷存管理實驗時間:11.30(三) 567節、12.7(三) 567節12.14(三) 567節、12.21(三) 567節小組合作: 是 否小組成員: 1、實驗目的:通過本程序的設計開發,使學生熟悉和掌握C+程序開發,訓練自己分析實際問題和解決問題以及編程的能力;掌握C+程序設計的方法,訓練自己分析實際問題和解決問題以及編

2、程的能力,為學生創造分析問題、獨立思考的條件,培養學生分析解決實際問題和編程等實際動手能力,為后續課程的學習打下扎實的編程根底。實驗要求:1實現圖書進銷存的根本管理,包括圖書的增加、刪除、查詢、按某種屬性例如價格、銷售量等的排序輸出。圖書的屬性包括:編號、書名、作者、價格、購進數量、銷售量、折扣等等。2編制窗體界面美觀,輸入方式靈活和簡便。3程序邏輯清晰,格式標準。個人獨立完成并提交一份實驗報告。要求能熟悉地運用C+語言編寫代碼實現圖書進銷存的根本管理;要求輸入方式靈活和簡便,程序邏輯清晰,格式標準。2、實驗場地及儀器、設備和材料:軟件工程管理實驗室W102、計算機、SQL Server200

3、0、VC6.0、Office等軟件、打印機、打印紙等。3、實驗思路實驗內容、數據處理方法及實驗步驟等:一、實驗內容:學生寫明實驗的內容做什么,文字,準備實現的功能 /*結果顯示:選擇所要進行的操作: 先對書店書進行盤點,確定是否要進購書: 進購書本: 銷售書本: 庫存缺乏查詢: 再次進行盤點同時添加書本: 更新記錄將序號1的書本改為序號5,進價改為25,售價改為30: 查詢記錄: 查詢序號為1的書查詢失敗,因為序號已被改為5: 查詢序號為5的書: 財務統計所輸入的書本序號應為5: 如果輸入的序號為1: 輸入的序號為5: 重組文件后退出。*/二、數據處理方法 Microsoft Visual S

4、tudio 2021 旗艦版三、實驗步驟第一步:,定義書店結構booktype,構建類manage1類manage中定義功能函數void Addbook(); /進書void Additional(); /追加void Updatebook(); /更新void Sellbook(); /銷售void Tell(); /庫存缺乏void count(); /財務統計void Searchbook(); /查詢void Pack(); /刪除2編寫代碼實現各類功能函數3編寫程序實行函數Run 第二步:定義Main函數Manage obj;if(obj.file.fail() throw(&quo

5、t;翻開文件失敗¨!");if(!obj.file.fail()obj.Run();return 0;第三步:修改代碼以及運行程序指導老師對實驗設計方案的意見: 指導老師簽名: 年 月 日 二、實驗結果與分析1、實驗目的、場地及儀器、設備和材料、實驗思路等見實驗設計方案2、實驗現象、數據及結果#include<iostream>#include<fstream>#include<iomanip>using namespace std;struct booktype /書店結構 bool delTag; /刪除標志 unsigned int

6、 seat; /序號 char name16; /書名 char author16; /作者 float enter_price; /進價 float sale_price; /售價 int sale; /銷售量 int day; /銷售日號 static float day_sum; /當日銷售額統計 static float month_sum; /當月銷售額統計 static float day_Profit; /當日銷售盈利 static double discount; /優惠折扣 int quantity; /書的數量;class Manage private: void Addb

7、ook(); /進書 void Additional(); /追加 void Updatebook(); /更新數據 void Sellbook(); /銷售 void Tell(); /庫存缺乏提示 void count(); /財務統計 void Searchbook(); /查詢 void Pack(); /刪除作有刪除記錄標記的記錄 public: Manage(); /無參構造函數 virtual Manage() file.close(); /析構函數 void Run(); /處理 fstream file; /書店文件 ;Manage:Manage() /無參構造函數ifstr

8、eam iFile("M.dat"); /建立輸入文件if(iFile.fail() /翻開文件失敗ofstream oFile("M.dat"); /建立輸入出文件if(oFile.fail() throw("翻開文件失敗!"); /拋出異常oFile.close(); /關閉文件else iFile.close(); /文件存在,關閉文件file.open("M.dat",ios:in|ios:out|ios:binary); /以讀寫方式翻開文件if(file.fail() throw("翻開文件失

9、敗!"); /拋出異常/進書void Manage:Addbook()booktype M; M.delTag=false; /正常,未作刪除標志char tag='Y' while(tag='Y') cout<<"*輸入進購書本的信息*"<<endl; cout<<" 輸入要進購書的序號: " cin>>M.seat; cout<<" 輸入該書的書名: " cin>>M.name; cout<<"

10、輸入該書的作者名: " cin>>M.author; cout<<" 輸入要進購的數量: " cin>>M.quantity; cout<<" 輸入該書的進價: " cin>>M.enter_price; cout<<" 輸入該書的售價: " cin>>M.sale_price; file.write(char*)&M,sizeof(booktype); /寫入文件 cout<<"是否繼續進購?是Y,否N: &q

11、uot; cin>>tag; cout<<endl;/追加(添加書本,顯示進貨前和進貨后的記錄)void Manage:Additional()booktype M;unsigned int seat; /序號int amount; /進購的數量cout<<"輸入要追加書本的序號:"cin>>seat;file.seekg(0);/定位file.read(char*)&M,sizeof(booktype);/讀記錄while(!file.eof()/文件末結束 if(M.seat=seat&&!M.de

12、lTag) break; /序號相同,記錄正常,未作刪除標志 file.read(char*)&M,sizeof(booktype);/讀記錄if(!file.eof() cout<<"*輸出添加前的數據*"<<endl; cout<<" 該書的序號: "<<M.seat<<endl; cout<<" 該書的書名: "<<M.name<<endl; cout<<" 該書的作者名: "<<M

13、.author<<endl; cout<<" 該書的現存數量: "<<M.quantity<<endl; cout<<" 該書的進價: "<<M.enter_price<<endl; cout<<" 該書的售價: "<<M.sale_price<<endl; /輸出記錄 cout<<endl; cout<<" 輸入該書還需添加的數量: " cin>>amount

14、; M.quantity=M.quantity+amount; cout<<"*輸出添加后的數據*"<<endl; cout<<" 該書的序號: "<<M.seat<<endl; cout<<" 該書的書名: "<<M.name<<endl; cout<<" 該書的作者名: "<<M.author<<endl; cout<<" 該書的現存數量: "<

15、;<M.quantity<<endl; cout<<" 該書的進價: "<<M.enter_price<<endl; cout<<" 該書的售價: "<<M.sale_price<<endl; /輸出記錄 file.seekg(-sizeof(booktype),ios:cur);/定位 file.write(char*)&M,sizeof(booktype);/寫入記錄else cout<<"=本書店沒有此書的記錄,需要進購該書!=&

16、quot;<<endl; file.clear();/更新記錄(對書本信息記錄進行更新,本實驗對序號為1的書本進行了更新將信號更新為5,進價更新為25,售價更新為30void Manage:Updatebook() booktype M; unsigned int seat; /序號 cout<<" 輸入要更新書的序號:" cin>>seat; file.seekg(0); /定位 file.read(char*)&M,sizeof(booktype);/讀記錄 while(!file.eof()/文件末結束 if(M.seat=

17、seat&&!M.delTag) break; /序號相同,記錄正常,未作刪除標志file.read(char*)&M,sizeof(booktype);/讀記錄 if(!file.eof() /查詢成功 cout<<"*輸出更新前的數據*"<<endl; cout<<" 該書的序號: "<<M.seat<<endl; cout<<" 該書的書名: "<<M.name<<endl; cout<<"

18、; 該書的作者名: "<<M.author<<endl; cout<<" 該書的現存數量: "<<M.quantity<<endl; cout<<" 該書的進價: "<<M.enter_price<<endl; cout<<" 該書的售價: "<<M.sale_price<<endl; /輸出記錄 cout<<"*輸入書本更新的數據*"<<endl;

19、cout<<" 輸入該書的序號: " cin>>M.seat; cout<<" 輸入書名: " cin>>M.name; cout<<" 輸入該書的作者名: " cin>>M.author; cout<<" 輸入現存的數量: " cin>>M.quantity; cout<<" 輸入該書的進價: " cin>>M.enter_price; cout<<"

20、輸入該書的售價: " cin>>M.sale_price; file.seekg(-sizeof(booktype),ios:cur);/定位 file.write(char*)&M,sizeof(booktype);/寫入記錄 else cout<<"=本書店沒有此書的記錄,請添加該書的記錄!="<<endl;file.clear(); /銷售(支持折扣優惠促銷,這里將其設置為對一次購5本以上者,可以享受8.5折優惠)float booktype:day_sum=0; /當日銷售額統計float booktype:mo

21、nth_sum=0; /當月銷售額統計 float booktype:day_Profit=0; /當日盈利統計double booktype:discount=0.15; /優惠折扣void Manage:Sellbook() booktype M; unsigned int seat; /序號 cout<<" 輸入書的序號: " cin>>seat; file.seekg(0); /定位 file.read(char*)&M,sizeof(booktype);/讀記錄 while(!file.eof()/文件末結束 if(M.seat=s

22、eat&&!M.delTag) break; /序號相同,記錄正常,未作刪除標志 file.read(char*)&M,sizeof(booktype);/讀記錄 if(!file.eof() /查詢成功 cout<<"*輸出要被售出的書本信息*"<<endl; cout<<" 該書的序號: "<<M.seat<<endl; cout<<" 該書的書名: "<<M.name<<endl; cout<<&q

23、uot; 該書的作者名: "<<M.author<<endl; cout<<" 該書的現存數量: "<<M.quantity<<endl; cout<<" 該書的進價: "<<M.enter_price<<endl; cout<<" 該書的售價: "<<M.sale_price<<endl; /輸出記錄 cout<<" 輸入賣出的數量: " cin>>

24、M.sale; cout<<" 輸入該書銷售的日號: " cin>>M.day; if(M.sale<=M.quantity) float n=1.0; M.day_sum=M.day_sum+n*(1-M.discount)*M.sale*M.sale_price; /該書當日銷售額統計 M.day_Profit=M.day_Profit+n*(1-M.discount)*M.sale*(M.sale_price-M.enter_price); /該書當日盈利統計 M.quantity=M.quantity-M.sale; file.seek

25、g(-sizeof(booktype),ios:cur);/定位 file.write(char*)&M,sizeof(booktype);/寫入記錄 cout<<"=銷售成功!="<<endl; else if(M.sale>M.quantity) cout<<"=庫存缺乏,需要進購該書!="<<endl; else cout<<"=本書店沒有此書的記錄!="<<endl; file.clear(); /去除文件結束標志 /庫存缺乏提示(這里設置當

26、書本數量小于10時,庫存缺乏)void Manage:Tell() booktype M; unsigned int seat; /序號 cout<<" 輸入書的序號: " cin>>seat; file.seekg(0); /定位 file.read(char*)&M,sizeof(booktype);/讀記錄 while(!file.eof()/文件末結束 if(M.seat=seat&&!M.delTag) break; /序號相同,記錄正常,未作刪除標志 file.read(char*)&M,sizeof(bo

27、oktype);/讀記錄 if(!file.eof() /查詢成功 cout<<" 該書的序號: "<<M.seat<<endl; cout<<" 該書現有的數量: "<<M.quantity<<endl; if(M.quantity>=10) cout<<"=無庫存缺乏現象,暫不需進購新書!="<<endl; else cout<<"=該書庫存缺乏,需立即進購!="<<endl; file

28、.seekg(-sizeof(booktype),ios:cur);/定位 file.write(char*)&M,sizeof(booktype);/寫入記錄 else cout<<"=本書店沒有此書的記錄!="<<endl; file.clear(); /去除文件結束標志 /財務統計(統計該書店當日某書的銷售額及其盈利)void Manage:count() booktype M; unsigned int seat; /序號 cout<<" 輸入書的序號: " cin>>seat; file.

29、seekg(0); /定位 file.read(char*)&M,sizeof(booktype);/讀記錄 while(!file.eof()/文件末結束 if(M.seat=seat&&!M.delTag) break; /序號相同,記錄正常,未作刪除標志 file.read(char*)&M,sizeof(booktype);/讀記錄 if(!file.eof() /查詢成功 cout<<"*對售出書本進行財務統計*"<<endl; cout<<" 該書的序號: "<<

30、M.seat<<endl; cout<<" 該書的書名: "<<M.name<<endl; cout<<" 該書的作者名: "<<M.author<<endl; cout<<" 該書售出的數量: "<<M.sale<<endl; cout<<" 該書售出的日號: "<<M.day<<endl; cout<<" 輸出該書當日銷售額為: &qu

31、ot;<<M.day_sum<<endl; cout<<" 輸出該書當日銷售盈利: "<<M.day_Profit<<endl; file.seekg(-sizeof(booktype),ios:cur);/定位 file.write(char*)&M,sizeof(booktype);/寫入記錄 else cout<<"=本書店沒有此書的記錄!="<<endl; file.clear(); /去除文件結束標志 /查詢書店書本的信息:查詢序號為1的書查詢失敗,應為

32、序號已被改為5;查詢序號為5的書查詢成功。void Manage:Searchbook() booktype M; unsigned int seat; /序號 cout<<"輸入要查詢的書序號: " cin>>seat; file.seekg(0); /定位 file.read(char*)&M,sizeof(booktype); /讀記錄 while(!file.eof()/文件末結束 if(M.seat=seat&&!M.delTag) break; /序號相同,記錄正常,未作刪除標志 file.read(char*)&

33、amp;M,sizeof(booktype); /讀記錄 if(!file.eof() /查詢成功 cout<<"*輸出查詢的記錄*"<<endl;cout<<" 該書的序號: "<<M.seat<<endl;cout<<" 該書的書名: "<<M.name<<endl;cout<<" 該書的作者名: "<<M.author<<endl; cout<<" 該書的現

34、存數量: "<<M.quantity<<endl; cout<<" 該書的進價: "<<M.enter_price<<endl; cout<<" 該書的售價: "<<M.sale_price<<endl; /輸出記錄 cout<<"=查詢成功!="<<endl; else /查詢失敗 cout<<setw(10)<<"=查詢失敗,本書店沒有此書!="<<

35、;endl; file.clear(); /去除文件結束標志 void Manage:Pack() / 在物理上刪除作有刪除標志的記錄 ofstream outFile("tem.dat",ios:app|ios:binary); /建立輸出文件對象 booktype M; file.seekg(0); /定位 file.read(char*)&M,sizeof(booktype); /讀記錄 while(!file.eof()/文件末結束 if(!M.delTag) /記錄正常,未作刪除標志 outFile.write(char*)&M,sizeof(bo

36、oktype); /寫入記錄 file.read(char*)&M,sizeof(booktype); /繼續讀記錄 file.close(); /關閉文件 outFile.close(); /關閉文件 remove("M.dat"); /刪除文件 rename("tem.dat","M.dat"); /更改文件名 file.open("M.dat",ios:in|ios:out|ios:binary); /重新翻開文件/處理void Manage:Run() int select; Manage t; d

37、o cout<<"*"<<endl; cout<<"請選擇操作:"<<endl; cout<<" 1.進購書本"<<endl; cout<<" 2.追加書本"<<endl; cout<<" 3.銷售書本"<<endl; cout<<" 4.庫存查詢"<<endl; cout<<" 5.更新記錄"<

38、<endl; cout<<" 6.查詢書本信息"<<endl; cout<<" 7.財務統計"<<endl; cout<<" 8.重置文件"<<endl; cout<<" 9.退出系統"<<endl; cout<<"*"<<endl; cout<<"選擇的操作為: " cin>>select; /輸入選擇 while(cin.get()!='n'); /跳過當前行后面的字符 switch(select) case 1: t.Addbook(); /進購書本 break; case 2:

溫馨提示

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

評論

0/150

提交評論