#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
struct BOOK
{
int id,usr[10],total,store,days[10];
char name[31],author[21];
}books[100];
/*上面是结构体的定义,用于存放书籍及借书的信息。*/
void page_title(char *menu_item)
{
clrscr();
printf(">>> 图 书 管 理 系 统 <<<\n\n- %s -\n\n",menu_item);
}
/*上面是打印页眉的函数,同时通过参数menu_item,可以显示当前的状态。*/
void return_confirm(void)
{
printf("\n按任意键返回……\n");
getch();
}
/*上面是返回前请求确认的函数,以便在返回前观察结果*/
int search_book(void)
{
int n,i;
printf("请输入图书序号:");
scanf("%d",&i);
for(n=0;n<100;n++)
{
if(books[n].id==i)
{
printf("书名:%s\n",books[n].name);
printf("作者:%s\n",books[n].author);
printf("存数:%d of ",books[n].store);
printf("%d\n",books[n].total);
return n;
}
}
printf("\n输入错误或无效图书序号.\n");
return -1;
}
/*上面的函数是在数组中找到图书号匹配的记录,显示其信息并返
回数组下标,如果找不到相应记录则提示错误并返回-1。*/
void book_out(void)
{
int n,s,l,d;
page_title("借阅图书");
if((n=search_book())!=-1&&books[n].store>0)
{
printf("请输入借书证序号:");
scanf("%d",&s);
printf("请输入可借天数:");
scanf("%d",&d);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==0)
{
books[n].usr[l]=s;
books[n].days[l]=d;
break;
}
}
books[n].store--;
}
if(n!=-1&&books[n].store==0) printf("此书已经全部借出.\n");
return_confirm();
}
/*上面是借书的函数,首先调用找书函数*/
void book_in(void)
{
int n,s,l;
page_title("归还图书");
if((n=search_book())!=-1&&books[n].store<books[n].total)
{
printf("借阅者图书证列表:\n");
for(l=0;l<10;l++)
if (books[n].usr[l]!=0)
printf("[%d] - %d天\n",books[n].usr[l],books[n].days[l]);
printf("请输入借书证序号:");
scanf("%d",&s);
for(l=0;l<10;l++)
{
if(books[n].usr[l]==s)
{
books[n].usr[l]=0;
books[n].days[l]=0;
break;
}
}
books[n].store++;
}
if(n!=-1&&books[n].store==books[n].total)
printf("全部入藏.\n");
return_confirm();
}
void book_add(void)
{
int n;
page_title("注册新书");
for(n=0;n<100;n++)
if(books[n].id==0) break;
printf("序号:");
scanf("%d",&books[n].id);
『贰』 C语言仓库管理系统
仓库管理系统C语言C++数据结构链表课程设计
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <conio.h>
#define MAX 64
typedef struct node{ /* 定义结构体类型dnode */ int number; /* 货物编号 */ char name[MAX]; /* 货物名称 */ int counter; /* 货物数量 */ struct node *prior,*next; /* 前驱和后继指针 */}dnode;
dnode* head = NULL;
void output_one(dnode* n) /* 输出一条记录 */{ printf("%d\t%s\t%d\n", n->number, n->name, n->counter);}
void output() /* 输出所有记录 */{ dnode* pos = head; if(head == NULL) { return; } while (pos) { output_one(pos); /* 循环调用output_one */ pos = pos->next; }}
int insert() /* 插入一条数据 */{ dnode* pos = head; dnode* n = malloc(sizeof(dnode)); n->prior = NULL; n->next = NULL; printf("请输入货物编号:"); scanf("%d", &n->number); printf("请输入货物名称:"); scanf("%s", n->name); printf("请输入货物数量:"); scanf("%d", &n->counter); if(head==NULL) /* 如果还没有头节点,就作为头节点 */ { head = n; return 1; } while (pos) { if(pos->number > n->number) /* 按顺序查找,如果找到比自己大的,就插在它前面 */ { if(pos->prior) pos->prior->next = n; n->prior = pos->prior; pos->prior = n; if(pos->next) pos->next->prior = n; n->next = pos; return 1; } else if(pos->number == n->number) { free(n); return 0; /* 有重复数据,插入不成功 */ } if (!pos->next) /* 如果已经到链表尾部,插入到后面 */ { pos->next = n; n->prior = pos; return 1; } pos = pos->next;
} return 1;}
void init(){ while (1) /* 初始化,循环插入 */ { insert(); printf("按任意键继续输入,按Esc停止输入\n"); if(getch()==27) break; }}
int delete() /* 删除一条记录 */{ int num; dnode* pos = head; printf("请输入要删除的编号:"); scanf("%d", &num);
if(head == NULL) { return 0; } while (pos) { if(pos->number == num) /* 找到匹配的项 */ { if(pos->prior) pos->prior->next = pos->next; if(pos->next) pos->next->prior = pos->prior; free(pos); return 1; } pos = pos->next; } return 0; // 没找到}
int amend() /* 修改数量 */{ int num, count; dnode* pos = head; printf("请输入要修改的编号:"); scanf("%d", &num); printf("请输入要修改的数量:"); scanf("%d", &count); if(head == NULL) { return 0; } while (pos) { if(pos->number == num) { if (count == 0) /* 如果数量是0,就删除 */ { if(pos->prior) pos->prior->next = pos->next; if(pos->next) pos->next->prior = pos->prior; free(pos); return 1; } pos->counter = count; return 1; } pos = pos->next; } return 0; }
void search() /* 按编号查找 */{ int num; dnode* pos = head;
printf("请输入要查找的编号:"); scanf("%d", &num);
if(head == NULL) { return; } while (pos) { if(pos->number == num) { output_one(pos); /* 找到就打印 */ return; } pos = pos->next; }}
void search_by_name() /* 按名称查找 */{ char name[MAX]; dnode* pos = head; printf("请输入要查找的名称:"); scanf("%s", name);
if(head == NULL) { return; } while (pos) { if(!strcmp(pos->name, name)) output_one(pos); pos = pos->next; }}
int main(){ init(); while (1) { char ch; system("cls"); printf("\t\t\t\ti 增加新货物\n"); printf("\t\t\t\td 删除某种货物\n"); printf("\t\t\t\ta 修改某种货物的数量\n"); printf("\t\t\t\ts 查找指定的货物\n"); printf("\t\t\t\to 输出存货信息\n"); printf("\t\t\t\tq 退出程序\n"); ch = getch(); switch (ch) { case 'i': case 'I': insert(); break;
case 'd': case 'D': delete(); break;
case 'a': case 'A': amend(); break;
case 's': case 'S': printf("1. 按编号查找\n2. 按名称查找\n"); ch = getch(); if(ch == '1') { search(); } else if(ch == '2') { search_by_name(); } break;
case 'o': case 'O': output(); break;
case 'q': case 'Q': return 0; break; } printf("按任意键继续...\n"); getch(); } return 0;}
『叁』 求java编写的仓库管理系统源代码或详细设计
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;
class 商品 extends Panel
{String 代号,名称;int 库存;float 单价;
商品(String 代号,String 名称,int 库存,float 单价)
{this.代号=代号;this.名称=名称;this.库存=库存;this.单价=单价;
}
}
class ShowWin extends JFrame implements ActionListener
{ Hashtable hashtable=null;
JTextField 代号文本框=new JTextField(),
名称文本框=new JTextField(),
库存文本框=new JTextField(),
单价文本框=new JTextField(),
查询文本框=new JTextField(),
查询信息文本框=new JTextField(),
删除文本框=new JTextField();
JButton b_add=new JButton("添加商品"),
b_del=new JButton("删除商品"),
b_xun=new JButton("查询商品"),
b_xiu=new JButton("修改商品"),
b_show=new JButton("显示商品清单");
JTextArea 显示区=new JTextArea(25,10);
ShowWin()
{super("仓库管理窗口");
hashtable=new Hashtable();
Container con=getContentPane();
JScrollPane pane=new JScrollPane(显示区);
显示区.setEditable(false);
JPanel save=new JPanel();
save.setLayout(new GridLayout(8,2));
save.add(new Label("输入代号:"));
save.add(代号文本框);
save.add(new Label("输入名称:"));
save.add(名称文本框);
save.add(new Label("输入库存:"));
save.add(库存文本框);
save.add(new Label("输入单价:"));
save.add(单价文本框);
save.add(new Label("单击添加:"));
save.add(b_add);
save.add(new Label("单击修改:"));
save.add(b_xiu);
save.add(new Label("输入查询代号:"));
save.add(查询文本框);
save.add(new Label("单击查询:"));
save.add(b_xun);
JPanel del=new JPanel();
del.setLayout(new GridLayout(2,2));
del.add(new Label("输入删除的代号:"));
del.add(删除文本框);
del.add(new Label("单击删除:"));
del.add(b_del);
JPanel show=new JPanel();
show.setLayout(new BorderLayout());
show.add(pane,BorderLayout.CENTER);
show.add(b_show,BorderLayout.SOUTH);
JSplitPane split_one,split_two;
split_one=new JSplitPane(JSplitPane.VERTICAL_SPLIT,save,del);
split_two=new
JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,split_one,show);
con.add(split_two,BorderLayout.CENTER);
JPanel xun=new JPanel();
xun.add(new Label("所得信息:"));
xun.add(查询信息文本框);
xun.setLayout(new GridLayout(2,1));
con.add(xun,BorderLayout.SOUTH);
b_add.addActionListener(this);
b_del.addActionListener(this);
b_xun.addActionListener(this);
b_xiu.addActionListener(this);
b_show.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==b_add)
{String daihao=null,mingcheng=null;int kucun=0;float danjia=0.0f;
daihao=代号文本框.getText();mingcheng=名称文本框.getText();
kucun=Integer.parseInt(库存文本框.getText());
danjia=Float.valueOf(单价文本框.getText()).floatValue();
商品 goods=new 商品(daihao,mingcheng,kucun,danjia);
hashtable.put(daihao,goods);
try{FileOutputStream file=new FileOutputStream("goods.txt");
ObjectOutputStream out=new ObjectOutputStream(file);
out.writeObject(hashtable); out.close();
}
catch(IOException event){}
}
else if(e.getSource()==b_del)
{String daihao1=删除文本框.getText();
try{FileInputStream come_in=new FileInputStream("goods.txt");
ObjectInputStream in=new ObjectInputStream(come_in);
hashtable=(Hashtable)in.readObject(); //////
in.close();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 temp=(商品)hashtable.get(daihao1);
{hashtable.remove(daihao1);}
try{FileOutputStream file=new FileOutputStream("goods.txt");
ObjectOutputStream out =new ObjectOutputStream(file);
out.writeObject(hashtable);//
out.close();
}
catch(IOException event){}
}
//
else if(e.getSource()==b_xun)
{ String aa;
aa=查询文本框.getText();
查询信息文本框.setText(null);
try{FileInputStream come_in=new FileInputStream("goods.txt");
ObjectInputStream in =new ObjectInputStream(come_in);
hashtable=(Hashtable)in.readObject(); ////
in.close();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 a=(商品)hashtable.get(aa);
查询信息文本框.setText(" 代号:"+a.代号+" 名称:"+a.名称+" 库存:"+a.库存+" 单价:"+a.单价);
}
//
else if(e.getSource()==b_xiu)
{ String bb;
bb=代号文本框.getText();
try{FileInputStream come_in=new FileInputStream("goods.txt");
ObjectInputStream in=new ObjectInputStream(come_in);
hashtable=(Hashtable)in.readObject(); //////
in.close();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 temp=(商品)hashtable.get(bb);
{hashtable.remove(bb);}
try{FileOutputStream file=new FileOutputStream("goods.txt");
ObjectOutputStream out =new ObjectOutputStream(file);
out.writeObject(hashtable);//
out.close();
}
catch(IOException event){}
String daihao1=null,mingcheng1=null;int kucun1=0;float danjia1=0.0f;
daihao1=代号文本框.getText();mingcheng1=名称文本框.getText();
kucun1=Integer.parseInt(库存文本框.getText());
danjia1=Float.valueOf(单价文本框.getText()).floatValue();
商品 goods1=new 商品(daihao1,mingcheng1,kucun1,danjia1);
hashtable.put(daihao1,goods1);
try{FileOutputStream file=new FileOutputStream("goods.txt");
ObjectOutputStream out=new ObjectOutputStream(file);
out.writeObject(hashtable); out.close();
}
catch(IOException event){}
}
//
else if(e.getSource()==b_show)
{ 显示区.setText(null);
try{FileInputStream come_in=new FileInputStream("goods.txt");
ObjectInputStream in =new ObjectInputStream(come_in);
hashtable=(Hashtable)in.readObject(); ////
}
catch(ClassNotFoundException event){}
catch(IOException event){}
Enumeration enum=hashtable.elements();
while(enum.hasMoreElements())
{ 商品 te=(商品)enum.nextElement();
显示区.append("商品代号:"+te.代号+" ");
显示区.append("商品名称:"+te.名称+" ");
显示区.append("商品库存:"+te.库存+" ");
显示区.append("商品单价:"+te.单价+" ");
显示区.append("\n ");
}
}
}
}
public class LinkListFour
{public static void main(String args[])
{ ShowWin win=new ShowWin();
win.setSize(400,350);
win.setVisible(true);
win.addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{ System.exit(0);}});
}
}
『肆』 C语言写一个仓库管理系统
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<malloc.h>#define max 32int ifempty=0;//标志,判断链表是无否为空typedef struct dnode /* 定义双向链表结构体 */ {int number; /* 货物编号 */char name[max]; /* 货物名称 */ int counter; /* 货物数量 */struct dnode *prior, *next;/* 定义两指针,分别指向其前驱和后继 */}dlnode; dlnode *create(dlnode *L);dlnode *input(dlnode *L);dlnode *output(dlnode *L);dlnode * outnum(dlnode *L);dlnode * outname(dlnode *L);dlnode *current(dlnode *L);void search(dlnode *L);void print(dlnode *L);void searchnum(dlnode *L);void searchname(dlnode *L);void display(dlnode *L) ;void main(){int x;dlnode *L;if(!(L=(dlnode *)malloc(sizeof(dlnode)))) //分配空间{printf("\n");exit(1);}create(L);///调用函数,创建头节点while(1){////////////////////////主菜单///////////////////////////printf(" ============================\n");printf(" 1. 货物出库和入库\n");printf(" 2. 查找货物表\n"); printf(" 3. 显示仓库货物表\n");printf(" 4. 输出到文件\n");printf(" 0. 退出\n");printf(" =============================\n");printf(" 选择0--3:");scanf("%d",&x);switch(x){case 2:search(L);break;//调用查找函数case 1:current(L);break;//调用入库出库函数case 3:display(L);break;//调用显示输出函数case 4:print(L);break;//调用打印函数case 0:printf("\n bye!see you!\n");getchar();getchar();exit(0);//退出程序default:printf("\n Enter erreor!please input 0--4!"); getchar();getchar();}}}dlnode *create(dlnode *L)//创建链表头节点{printf(" 欢迎使用我的仓库管理系统");getchar(); ifempty=0;///////初始化头节点的值////////L->next=NULL;L->prior=NULL;L->number=L->counter=0;strcpy(L->name," "); return L;}void search(dlnode *L) ///查找的主要菜单{int y;if(ifempty==0){printf("没有输入货物!\n");getchar();getchar();return;}else{while(1){printf("=====================\n");printf("1.按编号查询\n");printf("2.按货物名称查询\n");printf("0.返回上一层\n");printf("====================\n");printf("选择0--2:");scanf("%d",&y);switch(y){case 1:searchnum(L);break;//调用按编号查找的函数case 2:searchname(L);break;//调用按名称查找的函数case 0:return;//返回default:printf("enter error!Please input 0--2!\n\n");getchar();getchar();printf("\n\n");}}}}void searchnum(dlnode *L)///按编号查找的函数{int num,flag=0;//flag为是否找到的标志dlnode *head=L;if(ifempty==0){printf("没有货物被输入\n");getchar();getchar();return;}printf("输入你要查找的货物编号:\n");scanf("%d",&num);while((L=L->next)!=head){if(L->number==num){ flag=1;//flag为1时表示找到printf("找到指定编号货物 \n"); printf("\n编号:%d\n",L->number);printf("名称:%s\n",L->name) ;printf("数量:%d\n\n",L->counter); } }if(flag==0)//flag为0时表示没有找到printf("没有找到指定编号货物,请查看是否还有货物。\n");getchar();getchar();}void searchname(dlnode *L)//按名称查找的函数{int flag=0;//flag为是否找到的标志char na[32];dlnode *head=L;if(ifempty==0){printf("没有货物被输入\n");getchar();getchar();return;}printf("输入你要查找的货物名称\n");scanf("%s",&na);while((L=L->next)!=head){if(strcmp(L->name,na)==0){ flag=1;//flag为1时表示找到printf("找到指定名称货物 \n"); printf("\n编号:%d\n",L->number);printf("名称:%s\n",L->name) ;printf("数量:%d\n\n",L->counter); } }if(flag==0)//flag为0时表示没有找到printf("没有找到指定编号货物,请查看是否还有货物。\n\n");getchar();getchar();}dlnode *current(dlnode *L)//货物出库入库函数{int y;while(1){printf("========================\n");printf(" 1.货物入库\n");printf(" 2.货物出库\n");printf(" 0.返回上一层\n");printf("========================\n");printf(" 选择0--2:");scanf("%d",&y);switch(y){case 1:input(L);break;//调用入库函数case 2:output(L);break;//调用出库函数case 0:return(L);//返回上一层default:printf("enter error!Please input 0--2!");getchar();getchar();printf("\n\n");}}}dlnode *input(dlnode *L)//定义入库函数{dlnode *in,*head;head=in=(dlnode *)malloc(sizeof(dlnode));//分配空间head=L;printf("\n请输入货物数据:\n");printf("编号:");scanf("%d",&in->number);printf("名称:");scanf("%s",&in->name);printf("数量:");scanf("%d",&in->counter);if(L->next==NULL) //如果只有头节点,{ //把刚输入的in节点L->next=in; //跟在头节点后面L->prior=in; //in->next=L; //in->prior=L; //ifempty++; //ifempty加1}else{//如果当前L的下一个节点不是头节点while((L=L->next)!=head){//如果输入的数大于L->number,则插到L的前面if(L->number<in->number){in->next=L;in->prior=L->prior; L->prior->next=in;L->prior=in;ifempty++; //ifempty加1return(head);} }//输入的编号比其它编号都小,则插到最后个节点,并首尾相连head->prior->next=in;in->prior=head->prior;head->prior=in;in->next=head;ifempty++; //ifempty加1} return head;}dlnode *output(dlnode *L)//出库的函数{int y;dlnode *head=L;if(ifempty==0)//检测是否有货物输入{printf("没有货物输入系统\n");getchar();getchar();return(head);} while(1){printf("=============\n");printf("1.按编号出库\n");printf("2.按名称出库\n");printf("0.返回上一层\n");printf("==============\n");printf("选择0--2:");scanf("%d",&y);switch(y){case 1:outnum(L);break;//调用按编号出库函数case 2:outname(L);break;//调用按名称出库函数case 0:return(L);default:printf("enter error!Please input 0--2!");getchar();getchar();printf("\n\n");}}} dlnode *outnum(dlnode *L)//按编号出库函数{ int num;dlnode *head=L;printf("请输入出库货物的编号:");scanf("%d",&num);while((L=L->next)!=head){//如果找到就删除节点if(L->number==num){L->prior->next=L->next;L->next->prior=L->prior;ifempty--; //ifempty减1 printf("编号为%d的货物成功出库",num); getchar();getchar();return head; } }printf("没有此编号的货物,请查看是否还有货物。\n\n");getchar();getchar();return (head);}dlnode *outname(dlnode *L)//按名称出库函数{char na[32];dlnode *head=L;printf("请输入出库货物的名称:");scanf("%s",&na);while((L=L->next)!=head){//如果找到就删除节点if(strcmp(L->name,na)==0){L->prior->next=L->next;L->next->prior=L->prior;ifempty--; //ifempty减1 printf("名称为%s的货物成功出库",na);getchar();getchar();return (head);}}printf("没有此名称的货物,请查看是否还有货物。\n\n");getchar();getchar();return(head);} void display(dlnode *L)//显示货物清单{dlnode *head=L;if(ifempty==0){printf("没有货物可显示\n");getchar();getchar();return;}L=L->next;do{ printf("\n编号:%d\n",L->number);printf("名称:%s\n",L->name) ;printf("数量:%d\n\n",L->counter);}while((L=L->next)!=head);getchar();getchar(); }void print(dlnode *L){dlnode *head=L;L=L->next;char filename[max];FILE *out;if(ifempty==0){printf("没有货物可输出\n");getchar();getchar();return;}printf("请输入文件名称:");scanf("%s",filename);if((out=fopen(filename,"w"))==NULL){printf("打开文件失败!\n");getchar();getchar();return;}do{ fprintf(out,"编号:%d\n名称:%s\n数量:%d\n\n",L->number,L->name,L->counter);}while((L=L->next)!=head);printf("输出成功\n");getchar();getchar();fclose(out);}
『伍』 仓库管理系统源代码
你要什么语言的?我有vb的