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);
推荐阅读
- 网络社交游戏,游戏社交玩法
- 怎么取消手机快速解锁设置,怎么取消手机快速解锁设置oppo
- js为元素加点击事件,js定义点击事件
- 德国禁用chatgpt,德国禁用燃油车
- go语言数组有哪些 golang数组
- html5大文本框,html 文本框大小
- 神偷奶爸单机游戏,神偷奶爸游戏官方
- 直播有回放代表什么生肖,直播回放有什么用途
- python定义数组函数 python数组如何定义