c++-倉(cāng)庫(kù)管理系統(tǒng)_第1頁(yè)
c++-倉(cāng)庫(kù)管理系統(tǒng)_第2頁(yè)
c++-倉(cāng)庫(kù)管理系統(tǒng)_第3頁(yè)
c++-倉(cāng)庫(kù)管理系統(tǒng)_第4頁(yè)
c++-倉(cāng)庫(kù)管理系統(tǒng)_第5頁(yè)
已閱讀5頁(yè),還剩16頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

年5月29日c++倉(cāng)庫(kù)管理系統(tǒng)文檔僅供參考#include<iostream>#include<fstream>usingnamespacestd;constintm=100;//定義常量mclassStore//定義類{private: intnum;//編號(hào) charname[20];//名稱 doubleprice;//價(jià)格 intquantity;//數(shù)量 intamount;//數(shù)目public: voidInput(); intInput_2(); voidDig(); voidChange(); voidSearch_num(); voidSearch_name(); voidShow(); voidShort(); voidDelete();}goods[m];voidStore::Input()//創(chuàng)立表單{ inti,n; cout<<"請(qǐng)輸入貨物總數(shù):"; cin>>amount; cout<<endl; for(i=0;i<amount;i++) { cout<<"這是第"<<(i+1)<<"貨物信息"<<endl; goods[i].num=i+1; cout<<"貨品名:"; cin>>goods[i].name; cout<<"單價(jià):"; cin>>goods[i].price; cout<<"庫(kù)存量:"; cin>>goods[i].quantity; cout<<endl; } cout<<"\n輸入的信息:"<<endl; for(i=0;i<amount;i++) { cout<<"貨號(hào):"<<goods[i].num<<ends; cout<<"貨品名:"<<goods[i].name<<ends; cout<<"單價(jià):"<<goods[i].price<<ends; cout<<"庫(kù)存量:"<<goods[i].quantity<<ends<<endl; } ofstreamos("goods.txt",ios_base::out|ios_base::binary);//創(chuàng)立、打開文件 for(n=0;n<amount;n++) { os.write(reinterpret_cast<char*>(&(goods[n])),sizeof(Store));//導(dǎo)出文件 } os.close();//關(guān)閉文件}intStore::Input_2()//文件讀入{ inti,n; ifstreamis("goods.txt",ios_base::in|ios_base::binary); if(!is) { cout<<"打開失敗"<<endl; return0; } for(i=0;is.read(reinterpret_cast<char*>(goods+i),sizeof(Store));i++) amount=i; cout<<"導(dǎo)入的表單:"<<endl; for(n=0;n<amount;n++) { cout<<"貨號(hào):"<<goods[n].num<<ends; cout<<"貨品名:"<<goods[n].name<<ends; cout<<"單價(jià):"<<goods[n].price<<ends; cout<<"庫(kù)存量:"<<goods[n].quantity<<ends<<endl; } return1;}voidStore::Dig()//插入信息{ inti,n,m; cout<<"請(qǐng)輸入增加的貨物總數(shù):"; cin>>n; cout<<endl; for(i=0;i<n;i++) { cout<<"這是第"<<(i+1)<<"貨物信息"<<endl; goods[amount+i].num=amount+i+1; cout<<"貨品名:"; cin>>goods[amount+i].name; cout<<"單價(jià):"; cin>>goods[amount+i].price; cout<<"庫(kù)存量:"; cin>>goods[amount+i].quantity; } cout<<"\n輸入的信息"<<endl; for(i=0;i<amount+n;i++) { cout<<"貨號(hào):"<<goods[i].num<<ends; cout<<"貨品名:"<<goods[i].name<<ends; cout<<"單價(jià):"<<goods[i].price<<ends; cout<<"庫(kù)存量:"<<goods[i].quantity<<ends<<endl; } amount=amount+n; ofstreamos("goods.txt",ios_base::out|ios_base::binary);//創(chuàng)立、打開文件 for(m=0;m<amount;m++) { os.write(reinterpret_cast<char*>(&(goods[m])),sizeof(Store));//導(dǎo)出文件 } os.close();//關(guān)閉文件};voidStore::Change()//修改信息{ intn,i,m; cout<<"要修改第幾個(gè)貨物的信息(輸入貨號(hào)):"; cin>>n; cout<<endl; cout<<"請(qǐng)輸入修改的信息"<<endl; cout<<"貨品名:"; cin>>goods[n-1].name; cout<<"單價(jià):"; cin>>goods[n-1].price; cout<<"庫(kù)存量:"; cin>>goods[n-1].quantity; cout<<endl; cout<<"修改后的信息:"<<endl; for(i=0;i<amount;i++) { cout<<"貨號(hào):"<<goods[i].num<<ends; cout<<"貨品名:"<<goods[i].name<<ends; cout<<"單價(jià):"<<goods[i].price<<ends; cout<<"庫(kù)存量:"<<goods[i].quantity<<ends<<endl; } ofstreamos("goods.txt",ios_base::out|ios_base::binary);//創(chuàng)立、打開文件 for(m=0;m<amount;m++) { os.write(reinterpret_cast<char*>(&(goods[m])),sizeof(Store));//導(dǎo)出文件 } os.close();//關(guān)閉文件}voidStore::Search_num()//按編號(hào)查{ intn; cout<<"請(qǐng)輸入貨號(hào):"; do { cin>>n; cout<<endl; if(n<=amount) { cout<<"貨號(hào):"<<goods[n-1].num<<ends; cout<<"貨品名:"<<goods[n-1].name<<ends; cout<<"單價(jià):"<<goods[n-1].price<<ends; cout<<"庫(kù)存量:"<<goods[n-1].quantity<<ends<<endl; } elseif(n>amount) { cout<<"輸入錯(cuò)誤,請(qǐng)重新輸入:"<<ends; } }while(n>amount);};voidStore::Search_name()//按名稱查{ intflag=0; inti; charx[20]; cout<<"請(qǐng)輸入貨物名:"; do { cin>>x; cout<<endl; for(i=0;i<amount;i++) { if(strcmp(goods[i].name,x)==0)//strcmp用來(lái)比較字符串.tname和x { flag=1; cout<<"貨號(hào):"<<goods[i].num<<ends; cout<<"貨品名:"<<goods[i].name<<ends; cout<<"單價(jià):"<<goods[i].price<<ends; cout<<"庫(kù)存量:"<<goods[i].quantity<<ends<<endl; } else; } if(flag==0) cout<<"輸入錯(cuò)誤,請(qǐng)重新輸入:"<<ends; }while(flag==0);};voidStore::Show()//顯示信息{ inti; for(i=0;i<amount;i++) { cout<<"貨號(hào):"<<goods[i].num<<ends; cout<<"貨品名:"<<goods[i].name<<ends; cout<<"單價(jià):"<<goods[i].price<<ends; cout<<"庫(kù)存量:"<<goods[i].quantity<<ends<<endl; }};voidStore::Short()//查詢不足貨物{ intflag=0; inti; inty; cout<<"請(qǐng)查詢庫(kù)存量:"; do { cin>>y; cout<<endl; for(i=0;i<amount;i++) { if(goods[i].quantity<=y) { flag=1; cout<<"貨號(hào):"<<goods[i].num<<ends; cout<<"貨品名:"<<goods[i].name<<ends; cout<<"單價(jià):"<<goods[i].price<<ends; cout<<"庫(kù)存量:"<<goods[i].quantity<<ends<<endl; } else; } if(flag==0) cout<<"沒有貨物,請(qǐng)重新輸入:"<<ends; }while(flag==0);};voidStore::Delete()//刪除貨物{ chary[20]; intn,m; cout<<"請(qǐng)輸入要?jiǎng)h除的貨物名:"; cin>>y; for(inti=0;i<amount;i++) { if(strcmp(goods[i].name,y)==0)//strcmp用來(lái)比較字符串.tname和y { for(;i<amount;i++) { goods[i]=goods[i+1]; goods[i].num=i+1; } amount=amount-1;//貨物數(shù)減一 } } cout<<"刪除后貨單:"<<endl; for(m=0;m<amount;m++) { cout<<"貨號(hào):"<<goods[m].num<<ends; cout<<"貨品名:"<<goods[m].name<<ends; cout<<"單價(jià):"<<goods[m].price<<ends; cout<<"庫(kù)存量:"<<goods[m].quantity<<ends<<endl; } ofstreamos("goods.txt",ios_base::out|ios_base::binary);//創(chuàng)立、打開文件 for(n=0;n<amount;n++) { os.write(reinterpret_cast<char*>(&(goods[n])),sizeof(Store));//導(dǎo)出文件 } os.close();//關(guān)閉文件};voidClear()//清屏函數(shù){ chara; a=getchar(); system("cls");}voidmenuPrint()//主菜單{ cout<<"\t*****倉(cāng)庫(kù)管理*****"<<endl; cout<<"\t*1.輸入貨物信息*"<<endl; cout<<"\t*2.查詢貨物信息*"<<endl; cout<<"\t*3.顯示貨物信息*"<<endl; cout<<"\t*4.顯示不足貨物*"<<endl; cout<<"\t*5.刪除貨物信息*"<<endl; cout<<"\t*6.退出系統(tǒng)*"<<endl; cout<<"\t**********************"<<endl; cout<<"請(qǐng)輸入你要進(jìn)行的操作(1~6):"<<endl;}intmain()//主函數(shù){ StoreGoods;//定義對(duì)象 intn; do { menuPrint();//調(diào)用主菜單 cin>>n; cout<<endl; switch(n) { case1://輸入貨物信息 { inta; cout<<"輸入方式"<<endl; cout<<"1.創(chuàng)立表單"<<endl; cout<<"2.從文件導(dǎo)入"<<endl; cout<<"3.插入信息"<<endl; cout<<"4.修改信息"<<endl; cout<<"5.返回主菜單"<<endl; cin>>a; cout<<endl; switch(a) { case1://調(diào)用創(chuàng)立函數(shù) Goods.Input(); break; case2://調(diào)用文件讀入函數(shù) Goods.Input_2(); break; case3://調(diào)用增加函數(shù) Goods.Dig(); break; case4://調(diào)用增加函數(shù) Goods.Change(); break; case5: break; default: cout<<"您的輸入有誤,請(qǐng)重新選擇"<<endl;

溫馨提示

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

評(píng)論

0/150

提交評(píng)論