C語言--倉庫管理系統(tǒng)004培訓(xùn)講學(xué)_第1頁
C語言--倉庫管理系統(tǒng)004培訓(xùn)講學(xué)_第2頁
C語言--倉庫管理系統(tǒng)004培訓(xùn)講學(xué)_第3頁
C語言--倉庫管理系統(tǒng)004培訓(xùn)講學(xué)_第4頁
C語言--倉庫管理系統(tǒng)004培訓(xùn)講學(xué)_第5頁
已閱讀5頁,還剩48頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、Good is good, but better carries it.精益求精,善益求善。C語言-倉庫管理系統(tǒng)004-/*倉庫管理系統(tǒng)*/*頭文件(.h)*/#includestdio.h#includebios.h#includedos.h#includeconio.h#includestdlib.h#includestring.h#includemem.h#includectype.h#includealloc.htypedefstructz1charnum11;charname15;floatprice;intamount;structz1*prior;structz1*next;DA

2、TA;structz1*First;structz1*Last;/*函數(shù)原型*/voidinit();voidcreate();voiddelete();voidsearch();voidsave();voidload();voidappend();voidcopy();voidsort();voidindex();voidlist();voidabout();voidkey();intmenu_select();/*主函數(shù)開始*/main()key();for(;)switch(menu_select()case0:init();break;case1:create();break;case

3、2:list();break;case3:search();break;case4:delete();break;case5:append();break;case6:save();break;case7:load();break;case8:copy();break;case9:sort();break;case10:index();break;case11:about();break;case12:exit(0);menu_select()char*f=*Cang*MENU*KU*,0.initlist,1.Enterlist,2.Listalln,3.Searchrecordonname

4、,4.Deletearecord,5.Appendrecordtofile,6.Savedatatothefile,7.Loaddatafromthefile,8.Copythefiletonewfile,9.Sortonprice,10.Indexonnumber,11.Aboutwriter,12.Quit;chars80;inti;intkey=0;intc=0;gotoxy(65,25);printf(ByYoungshook);gotoxy(1,25);printf(pressanykeyEntermenu.);getch();clrscr();gotoxy(65,25);print

5、f(ByYoungshook);textcolor(YELLOW);textbackground(BLUE);gotoxy(10,2);putch(0 xda);for(i=1;i44;i+)putch(0 xc4);putch(0 xbf);for(i=3;i22;i+)gotoxy(10,i);putch(0 xb3);gotoxy(54,i);putch(0 xb3);gotoxy(10,22);putch(0 xc0);for(i=1;i44;i+)putch(0 xc4);putch(0 xd9);window(11,3,53,21);clrscr();for(i=0;i8;goto

6、xy(10,i+1);textbackground(BLUE);cprintf(%s,fi);if(key=72)i=i=1?13:i-1;if(key=80)i=i=13?1:i+1;gotoxy(10,i+1);textbackground(LIGHTGREEN);cprintf(%s,fi);c=i-1;textbackground(BLACK);window(1,1,80,25);returnc;voidkey()FILE*fp;intm,j,i,z=3;intf,d,s;charpassword17=0;charpassword27=0;charpassword7=0;charkey

7、7=y,o,u,n,k,s,0;textcolor(0);textbackground(3);clrscr();gotoxy(25,8);printf(*n);gotoxy(25,9);printf(*n);gotoxy(25,10);printf(*n);gotoxy(25,11);printf(*system*n);gotoxy(25,12);printf(*n);gotoxy(25,13);printf(*n);gotoxy(25,14);printf(*n);getch();clrscr();gotoxy(65,25);printf(ByYoungshook);if(fp=fopen(

8、key.dat,r)=NULL)gotoxy(18,5);printf(Welcometousewarehousesystemfirst!);fclose(fp);gotokkk;elsefclose(fp);gotolll;kkk:gotoxy(23,10);/*設(shè)置初始密碼*/printf(Pleasesettheinitialpassword_1!);gotoxy(41,12);printf();gotoxy(23,12);printf(password_1:);for(j=0;j6;j+)scanf(%c,&password1j);password1j=0;getchar();clrs

9、cr();gotoxy(18,10);printf(Pleasesettheinitialpassword_2!Again!);gotoxy(36,12);printf();gotoxy(18,12);printf(password_2:);for(f=0;f6;f+)scanf(%c,&password2f);password2f=0;getchar();clrscr();if(strcmp(password1,password2)!=0)/*驗證設(shè)置的密碼是否一樣*/gotoxy(20,10);printf(Passworddoesnotmatch!n);getch();clrscr();

10、gotokkk;else/*對密碼進(jìn)行加密和保存*/for(m=0;m6;m+)password2m=keym;if(fp=fopen(key.dat,wb+)!=NULL)fwrite(password2,sizeof(char),7,fp);elseprintf(error!);exit(0);fclose(fp);gotoxy(18,10);printf(setsucceed!pleasecomeincangkusystem!n);getch();gotoooo;clrscr();/*驗證身份*/lll:gotoxy(28,10);printf(Pleaseinputpassword!n

11、);gotoxy(44,12);printf();gotoxy(28,12);printf(password:);for(s=0;s6;s+)scanf(%c,&passwords);passwords=0;getchar();if(fp=fopen(key.dat,rb)=NULL)getch();exit(1);fread(password2,sizeof(char),7,fp);fclose(fp);for(d=0;dnext=NULL;info-prior=NULL;gotoxy(1,8+x);printf(|);gotoxy(17,8+x);printf(|);gotoxy(34,8

12、+x);printf(|);gotoxy(44,8+x);printf(|);gotoxy(55,8+x);printf(|);gotoxy(2,8+x);inputs(info-num,10);if(info-num0=!)flag=1;break;gotoxy(18,8+x);inputs(info-name,14);gotoxy(35,8+x);scanf(%f,&temp);info-price=temp;gotoxy(45,8+x);scanf(%d,&kkkk);info-amount=kkkk;if(p=NULL)First=Last=info;First-prior=NULL;

13、Last-next=NULL;elseinfo-next=p;info-prior=p-prior;p-prior=info;p=info;First=info;x+=2;gotoxy(1,8+x);i+;if(i%9=0)break;gotoxy(1,8+x);printf(|-|-|-|-|);inputs(char*s,intcount)charp255;doscanf(%s,p);if(strlen(p)count)printf(ntoolong!n);while(strlen(p)count);strcpy(s,p);voidlist()inti=0,n;DATA*p;clrscr(

14、);gotoxy(65,25);printf(ByYoungshook);p=First;while(i%10=0&p!=NULL)i=0;clrscr();gotoxy(65,25);printf(ByYoungshook);printf(nnn);printf(*DATA*n);printf(|Num|Name|Price|Amount|n);printf(|-|-|-|-|n);while(p!=NULL)printf(|%-10s|%-15s|%9.2f|%10d|n,p-num,p-name,p-price,p-amount);p=p-next;i+;if(i%10=0)break;

15、printf(*end*n);printf(Pressanykeycongtinue.n);getch();voidprint(DATA*p)if(p)clrscr();gotoxy(65,25);printf(ByYoungshook);printf(nnn);printf(*DATA*n);printf(|Num|Name|Price|Amount|n);printf(|-|-|-|-|n);printf(|%-11s|%-15s|%10.2f|%9d|n,p-num,p-name,p-price,p-amount);printf(*end*n);DATA*find(char*num)DA

16、TA*p;p=First;while(p)if(!strcmp(num,p-num)returnp;p=p-next;printf(notfoundn);returnNULL;voiddelete()DATA*p;chars11;clrscr();gotoxy(65,24);printf(ByYoungshook);gotoxy(1,25);printf(pleasedeletednumn);scanf(%s,s);if(p=find(s)!=NULL)if(First=p)First=p-next;if(First)First-prior=NULL;elseLast=NULL;elsep-p

17、rior-next=p-next;if(p!=Last)p-next-prior=p-prior;elseLast=p-prior;free(p);printf(nhavedeleted%sDATAn,s);printf(Dontforgetsaven);voidsearch()DATA*p;chars15;clrscr();printf(pleaseenternameforsearchn);scanf(%s,s);p=First;while(strcmp(p-name,s)&p!=NULL)p=p-next;if(p=NULL)printf(nlistno%sDATAn,s);elsepri

18、ntf(nn);print(p);/*保存文件*/voidsave()FILE*fp;DATA*p;charoutfile10;clrscr();gotoxy(65,24);printf(ByYoungshook);gotoxy(1,25);printf(Enteroutfilename,forexamplec:f1te.txt:n);scanf(%s,outfile);if(fp=fopen(outfile,wb)=NULL)printf(cannotopenfilen);return;printf(nSavingfile.n);p=First;while(p!=NULL)fwrite(p,

19、sizeof(DATA),1,fp);p=p-next;fclose(fp);printf(-savesuccess!-n);voidload()DATA*p,*q=NULL;FILE*fp;charinfile10;clrscr();gotoxy(65,24);printf(ByYoungshook);gotoxy(1,25);printf(Enterinfilename,forexamplec:f1te.txt:n);scanf(%s,infile);if(fp=fopen(infile,rb)=NULL)printf(cannotopenfilen);return;while(First

20、)p=First;First=First-next;free(p);printf(n-Loadingfile!-n);First=(DATA*)malloc(sizeof(DATA);if(!First)printf(outofmemory!n);return;p=First;while(!feof(fp)if(1!=fread(p,sizeof(DATA),1,fp)break;p-next=(DATA*)malloc(sizeof(DATA);if(!p-next)printf(outofmemory!n);return;p-prior=q;q=p;p=p-next;q-next=NULL

21、;Last=q;First-prior=NULL;fclose(fp);printf(-Youhavesuccessreaddatafromfile!-n);voidappend()FILE*fp;intkk;DATA*info;charinfile10;floattemp;clrscr();gotoxy(65,25);printf(ByYoungshook);gotoxy(1,3);printf(*CK_append*);gotoxy(1,5);printf(|-|);gotoxy(1,6);printf(|Num|Name|Price|Amount|);gotoxy(1,7);printf

22、(|-|-|-|-|);info=(DATA*)malloc(sizeof(DATA);if(!info)printf(notofmemory);exit(0);info-next=NULL;info-prior=NULL;gotoxy(1,8);printf(|);gotoxy(13,8);printf(|);gotoxy(30,8);printf(|);gotoxy(40,8);printf(|);gotoxy(51,8);printf(|);gotoxy(2,8);inputs(info-num,10);gotoxy(14,8);inputs(info-name,14);gotoxy(3

23、1,8);scanf(%f,&temp);info-price=temp;gotoxy(41,8);scanf(%d,kk);info-amount=kk;printf(|-|-|-|-|);printf(nnnEnterinfilename,forexamplec:f1te.txt:n);scanf(%s,infile);if(fp=fopen(infile,ab)=NULL)printf(cannotopenfilen);return;printf(n-Appendingrecord!-n);if(1!=fwrite(info,sizeof(DATA),1,fp)printf(-filew

24、riteerror!-n);return;printf(-appendsucess!-n);fclose(fp);voidcopy()charoutfile10,infile10;FILE*sfp,*tfp;DATA*p=NULL;clrscr();gotoxy(65,24);printf(ByYoungshook);gotoxy(1,25);printf(Enterinfilename,forexamplec:f1te.txt:n);scanf(%s,infile);if(sfp=fopen(infile,rb)=NULL)printf(cannotopeninputfilen);retur

25、n;printf(Enteroutfilename,forexamplec:f1te.txt:n);scanf(%s,outfile);if(tfp=fopen(outfile,wb)=NULL)printf(cannotopenoutputfilen);return;while(!feof(sfp)if(1!=fread(p,sizeof(DATA),1,sfp)break;fwrite(p,sizeof(DATA),1,tfp);fclose(sfp);fclose(tfp);printf(youhavesuccesscopyfile!n);voidsort()DATA*p0,*p00,*p1,*p11,*p2;inti=1;clrscr();gotoxy(65,25);printf(ByYoungshook);printf(nnstartsort.n);p1=p11=p2=First;while(p1!=NULL)p0=p1;p2=p1;while(p2-next!=NULL)if(p0-pricep2-next-price)p00=p2;p0=p2-next;p2=p2-next;Last=p0;if(p1!=p0)p00-next=p0-next;p0-next-

溫馨提示

  • 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

提交評論