求java编写的仓库管理系统源代码或详细设计

求java编写的仓库管理系统源代码或详细设计,第1张

import javautil;
import javaawtevent;
import javaawt;
import javaxswing;
import javaio;
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();
savesetLayout(new GridLayout(8,2));
saveadd(new Label("输入代号:"));
saveadd(代号文本框);
saveadd(new Label("输入名称:"));
saveadd(名称文本框);
saveadd(new Label("输入库存:"));
saveadd(库存文本框);
saveadd(new Label("输入单价:"));
saveadd(单价文本框);
saveadd(new Label("单击添加:"));
saveadd(b_add);
saveadd(new Label("单击修改:"));
saveadd(b_xiu);
saveadd(new Label("输入查询代号:"));
saveadd(查询文本框);
saveadd(new Label("单击查询:"));
saveadd(b_xun);
JPanel del=new JPanel();
delsetLayout(new GridLayout(2,2));
deladd(new Label("输入删除的代号:"));
deladd(删除文本框);
deladd(new Label("单击删除:"));
deladd(b_del);
JPanel show=new JPanel();
showsetLayout(new BorderLayout());
showadd(pane,BorderLayoutCENTER);
showadd(b_show,BorderLayoutSOUTH);
JSplitPane split_one,split_two;
split_one=new JSplitPane(JSplitPaneVERTICAL_SPLIT,save,del);
split_two=new
JSplitPane(JSplitPaneHORIZONTAL_SPLIT,true,split_one,show);
conadd(split_two,BorderLayoutCENTER);
JPanel xun=new JPanel();
xunadd(new Label("所得信息:"));
xunadd(查询信息文本框);
xunsetLayout(new GridLayout(2,1));
conadd(xun,BorderLayoutSOUTH);
b_addaddActionListener(this);
b_deladdActionListener(this);
b_xunaddActionListener(this);
b_xiuaddActionListener(this);
b_showaddActionListener(this);
}
public void actionPerformed(ActionEvent e)
{if(egetSource()==b_add)
{String daihao=null,mingcheng=null;int kucun=0;float danjia=00f;
daihao=代号文本框getText();mingcheng=名称文本框getText();
kucun=IntegerparseInt(库存文本框getText());
danjia=FloatvalueOf(单价文本框getText())floatValue();
商品 goods=new 商品(daihao,mingcheng,kucun,danjia);
hashtableput(daihao,goods);
try{FileOutputStream file=new FileOutputStream("goodstxt");
ObjectOutputStream out=new ObjectOutputStream(file);
outwriteObject(hashtable); outclose();
}
catch(IOException event){}
}
else if(egetSource()==b_del)
{String daihao1=删除文本框getText();
try{FileInputStream come_in=new FileInputStream("goodstxt");
ObjectInputStream in=new ObjectInputStream(come_in);
hashtable=(Hashtable)inreadObject(); //////
inclose();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 temp=(商品)hashtableget(daihao1);
{hashtableremove(daihao1);}
try{FileOutputStream file=new FileOutputStream("goodstxt");
ObjectOutputStream out =new ObjectOutputStream(file);
outwriteObject(hashtable);//
outclose();
}
catch(IOException event){}
}
//
else if(egetSource()==b_xun)
{ String aa;
aa=查询文本框getText();
查询信息文本框setText(null);
try{FileInputStream come_in=new FileInputStream("goodstxt");
ObjectInputStream in =new ObjectInputStream(come_in);
hashtable=(Hashtable)inreadObject(); ////
inclose();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 a=(商品)hashtableget(aa);
查询信息文本框setText(" 代号:"+a代号+" 名称:"+a名称+" 库存:"+a库存+" 单价:"+a单价);
}
//
else if(egetSource()==b_xiu)
{ String bb;
bb=代号文本框getText();
try{FileInputStream come_in=new FileInputStream("goodstxt");
ObjectInputStream in=new ObjectInputStream(come_in);
hashtable=(Hashtable)inreadObject(); //////
inclose();
}
catch(ClassNotFoundException event){}
catch(IOException event){}
商品 temp=(商品)hashtableget(bb);
{hashtableremove(bb);}
try{FileOutputStream file=new FileOutputStream("goodstxt");
ObjectOutputStream out =new ObjectOutputStream(file);
outwriteObject(hashtable);//
outclose();
}
catch(IOException event){}
String daihao1=null,mingcheng1=null;int kucun1=0;float danjia1=00f;
daihao1=代号文本框getText();mingcheng1=名称文本框getText();
kucun1=IntegerparseInt(库存文本框getText());
danjia1=FloatvalueOf(单价文本框getText())floatValue();
商品 goods1=new 商品(daihao1,mingcheng1,kucun1,danjia1);
hashtableput(daihao1,goods1);
try{FileOutputStream file=new FileOutputStream("goodstxt");
ObjectOutputStream out=new ObjectOutputStream(file);
outwriteObject(hashtable); outclose();
}
catch(IOException event){}
}
//
else if(egetSource()==b_show)
{ 显示区setText(null);
try{FileInputStream come_in=new FileInputStream("goodstxt");
ObjectInputStream in =new ObjectInputStream(come_in);
hashtable=(Hashtable)inreadObject(); ////
}
catch(ClassNotFoundException event){}
catch(IOException event){}
Enumeration enum=hashtableelements();
while(enumhasMoreElements())
{ 商品 te=(商品)enumnextElement();
显示区append("商品代号:"+te代号+" ");
显示区append("商品名称:"+te名称+" ");
显示区append("商品库存:"+te库存+" ");
显示区append("商品单价:"+te单价+" ");
显示区append("\n ");
}
}
}
}
public class LinkListFour
{public static void main(String args[])
{ ShowWin win=new ShowWin();
winsetSize(400,350);
winsetVisible(true);
winaddWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{ Systemexit(0);}});
}
}

首先 java网站是基于jdk运行的。你得先装jdk。去官网下载一个jdk安装。然后你得编译你的项目,打包到容器(tomcat,weblogic,jboss等)中运行即可。再提醒一下就是,看看你的源代码有木有用到数据库或者其他类型的服务。如果有的话,你得装数据库或服务,并且初始化数据。再启动你的你的容器。

首先,如果有别人项目的开发文档,是必须先阅读的东西;
其次,最好借助于开发工具,比如导入eclipse,比如代码中按下ctrl+T就会显示当前类型的关联关系,还可以进行class搜索等。
第三,通过运行代码,跟踪进去,用debug模式查看一些关心的变量和方法是如何被调用和执行的。
MVC项目,可以从下往上看,就是从数据库 *** 作,然后封装dao, service,到Action,再到页面。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/dianzi/13177090.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-06-16
下一篇 2023-06-16

发表评论

登录后才能评论

评论列表(0条)

保存