當前位置:偏方大全网 - 藥品查詢 - 求java求倉庫管理系統的源碼或者詳細設計。

求java求倉庫管理系統的源碼或者詳細設計。

導入Java . util . *;

導入Java . awt . event . *;

導入Java . awt . *;

導入javax . swing . *;

導入Java . io . *;

分類商品擴展面板

{字符串代碼名稱;Int庫存;浮動單價;

商品(字符串代碼、字符串名稱、int庫存、浮動單價)

{這個。code =代碼;這個。Name =名稱;這個。庫存=存貨;這個。單價=單價;

}

}

類ShowWin擴展JFrame實現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顯示區域=新JTextArea(25,10);

ShowWin()

{super("倉庫管理窗口");

Hashtable = new Hashtable();

container con = getContentPane();

Jscrollpane = new jscrollpane(顯示區域);

展示區。set editable(false);

JPanel save = new JPanel();

save.setLayout(new GridLayout(8,2));

Save.add(新標簽("輸入碼:")));

Save.add(代碼文本框);

Save.add(新標簽("輸入姓名:")));

Save.add(名稱文本框);

Save.add(新標簽("輸入庫存:")));

Save.add(庫存文本框);

Save.add(新標簽("輸入單價:")));

Save.add(單價文本框);

Save.add(新標簽("點擊添加:")));

save . add(b _ add);

Save.add(新標簽("點擊修改:")));

save . add(b _ xiu);

Save.add(新標簽("輸入查詢代碼:")));

Save.add(查詢文本框);

Save.add(新標簽("點擊查詢:")));

save . add(b _ Xun);

JPanel del = new JPanel();

del.setLayout(new GridLayout(2,2));

Del.add(new Label("輸入要刪除的代碼:"));

Del.add(刪除文本框);

Del.add(新標簽("點擊刪除:")));

del . add(b _ del);

JPanel show = new JPanel();

show . set layout(new BorderLayout());

show.add(pane,BorderLayout。中心);

show.add(b_show,BorderLayout。南);

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。中心);

JPanel Xun = new JPanel();

Xun.add(新標簽("獲取信息:")));

Xun.add(查詢信息文本框);

xun.setLayout(new GridLayout(2,1));

con.add(荀,BorderLayout。南);

b _ add . addactionlistener(this);

b_del.addActionListener(這個);

b _ Xun . addactionlistener(this);

b _ xiu . addactionlistener(this);

b_show.addActionListener(這個);

}

公共無效操作已執行(操作事件e)

{if(e.getSource()==b_add)

{String daihao=null,mingcheng = nullint ku Cun = 0;浮動賈丹= 0.0f

代號=代碼文本框。getText();明城=名稱文本框。getText();

Kucun=Integer.parseInt(庫存文本框。getText());

賈丹=Float.valueOf(單價文本框。getText())。float value();

商品=新貨(代豪、明城、庫存、賈丹);

hashtable.put(代豪,商品);

try { file output stream file = new file output stream(" goods . txt ");

object output stream out = new object output stream(file);

out . writeobject(hashtable);out . close();

}

catch(IOException事件){}

}

else if(e.getSource()==b_del)

{String daihao1=刪除文本框。getText();

try { file inputstream come _ in = new file inputstream(" goods . txt ");

ObjectInputStream in = new ObjectInputStream(come _ in);

Hashtable =(Hashtable)in . read object();//////

in . close();

}

catch(ClassNotFoundException事件){}

catch(IOException事件){}

commodity temp =(commodity)hashtable . get(daihao 1);

{ hashtable . remove(daihao 1);}

try { file output stream file = new file output stream(" goods . txt ");

object output stream out = new object output stream(file);

out . writeobject(hashtable);//

out . close();

}

catch(IOException事件){}

}

//

else if(e.getSource()==b_xun)

{字符串aa;

Aa=查詢文本框。getText();

查詢信息文本框。setText(空);

try { file inputstream come _ in = new file inputstream(" goods . txt ");

ObjectInputStream in = new ObjectInputStream(come _ in);

Hashtable =(Hashtable)in . read object();////

in . close();

}

catch(ClassNotFoundException事件){}

catch(IOException事件){}

商品a=(商品)hashtable . get(aa);

查詢信息文本框。setText(" code:"+A . code+" name:"+a . name+"存貨:"+A. inventory+"單價:"+a .單價);

}

//

else if(e.getSource()==b_xiu)

{字符串bb;

Bb=代碼文本框。getText();

try { file inputstream come _ in = new file inputstream(" goods . txt ");

ObjectInputStream in = new ObjectInputStream(come _ in);

Hashtable =(Hashtable)in . read object();//////

in . close();

}

catch(ClassNotFoundException事件){}

catch(IOException事件){}

商品temp=(商品)hashtable . get(bb);

{ hashtable . remove(bb);}

try { file output stream file = new file output stream(" goods . txt ");

object output stream out = new object output stream(file);

out . writeobject(hashtable);//

out . close();

}

catch(IOException事件){}

String daihao1=null,mingcheng 1 = null;int kucun 1 = 0;float danjia 1 = 0.0f;

Daihao1=代碼文本框。getText();Mingcheng1=名稱文本框。getText();

kucun 1 = integer . parse int(inventory getText box . getText());

Danjia1=Float.valueOf(單價文本框。getText())。float value();

goods 1 =新貨(代號1,明城1,庫存1,賈丹1);

hashtable.put(daihao1,goods 1);

try { file output stream file = new file output stream(" goods . txt ");

object output stream out = new object output stream(file);

out . writeobject(hashtable);out . close();

}

catch(IOException事件){}

}

//

else if(e.getSource()==b_show)

{顯示區域。setText(空);

try { file inputstream come _ in = new file inputstream(" goods . txt ");

ObjectInputStream in = new ObjectInputStream(come _ in);

Hashtable =(Hashtable)in . read object();////

}

catch(ClassNotFoundException事件){}

catch(IOException事件){}

enumeration enum = hashtable . elements();

while(enum.hasMoreElements())

{ commodity te =(commodity)enum . nextelement();

展示區。append("商品代碼:"+te。code+" ");

展示區。append("產品名稱:"+te。姓名+" ");

展示區。追加("商品庫存:"+te。庫存+" ");

展示區。追加("商品單價:"+te。單價+" ");

展示區。追加(" \ n ");

}

}

}

}

公共類鏈表四

{ public static void main(String args[])

{ show win win = new show win();

win.setSize(400,350);

win . set visible(true);

win.addWindowListener(新WindowAdapter()

{公共void窗口關閉(WindowEvent e)

{ system . exit(0);}});

}

}

  • 上一篇:田七營養價值?
  • 下一篇:為什麽壹些大品牌的化妝品這麽便宜?
  • copyright 2024偏方大全网