package 商品信息管理系统;
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import 商品信息管理系统.Purchase;
class SetGoods extends JFrame implements ActionListener {
JLabel JL = new JLabel("请用以下任意一种方式查询您想要的东西", JLabel.CENTER);
JLabel number = new JLabel("商品编号");
JTextField Number = new JTextField();
JLabel JClass=new JLabel("类别");
String str[]={"无","食品","化妆品","日用品","饮料"};
JComboBox jcb=new JComboBox(str);
JLabel name = new JLabel("商品名称");
JTextField Name = new JTextField();
JLabel price=new JLabel("商品价格");
JTextField Price = new JTextField();
JLabel brand= new JLabel("品牌");
JTextField Brand = new JTextField();
JLabel vender = new JLabel("生产厂家");
JTextField Vender = new JTextField();
JTextField jt=new JTextField(10);
JButton Set = new JButton("查询");
JButton purchase = new JButton("购买");
JButton Reset = new JButton("重置");
JButton Exit = new JButton("退出");
String sql = "";
public SetGoods(){
this.setTitle("顾客管理系统");
this.setLayout(null);
JL.setBounds(100, 50,250, 20);
this.add(JL);
number.setBounds(100,100,100,20);
this.add(number);
Number.setBounds(200,100,100,20);
this.add(Number);
JClass.setBounds(100,150,100,20);
this.add(JClass);
jcb.setBounds(200,150,100,20);
this.add(jcb);
name.setBounds(100,200,100,20);
this.add(name);
Name.setBounds(200,200,100,20);
this.add(Name);
price.setBounds(100,250,100,20);
this.add(price);
Price.setBounds(200,250,100,20);
this.add(Price);
brand.setBounds(100,300,100,20);
this.add(brand);
Brand.setBounds(200,300,100,20);
this.add(Brand);
vender.setBounds(100,350,100,20);
this.add(vender);
Vender.setBounds(200,350,100,20);
this.add(Vender);
Set.setBounds(100,400,60,20);
this.add(Set);
Set.addActionListener(this);
purchase .setBounds(160,400,60,20);
this.add(purchase );
purchase .addActionListener(this);
Reset.setBounds(220,400,60,20);
this.add(Reset);
Reset.addActionListener(this);
Exit.setBounds(280, 400,60, 20);
this.add(Exit);
Exit.addActionListener(this);
this.setVisible(true);
this.setBounds(10,10,450,540);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new SetGoods();
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == Set) {
Statement stm=null;
Connection cot;
try{
cot=ConnectionFactory.getConnection();
stm=cot.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE ,ResultSet.CONCUR_UPDATABLE );
if(Number.getText()!=null)
sql="select * from goods where number='"+Number.getText()+"'";
else if(Name.getText()!=null)
sql="select * from goods where name='"+Name.getText()+"'";
else if(Price.getText()!=null)
sql="select * from goods where price='"+Price.getText()+"'";
else if(Brand.getText()!=null)
sql="select * from goods where brand='"+Brand.getText()+"'";
else if(Vender.getText()!=null)
sql="select * from goods where vender='"+Vender.getText()+"'";
ResultSet rs=stm.executeQuery(sql);
while(rs.next()) {
System.out.println("商品编号: "+Number.getText());
int s=jcb.getSelectedIndex();
if(s==0)
JOptionPane.showMessageDialog( null, "请选择商品类别!" );
else if(s==1)
System.out.println("商品类别: 食品");
else if(s==2)
System.out.println("商品类别: 化妆品");
else if(s==3)
System.out.println("商品类别: 日用品");
else if(s==4)
System.out.println("商品类别: 饮料");
System.out.println("商品名称: "+rs.getString("name"));
System.out.println("价格: "+rs.getString("price"));
System.out.println("库存量: "+rs.getString("storage"));
System.out.println("品牌: "+rs.getString("brand"));
System.out.println("生产厂家: "+rs.getString("vender"));
}
}catch(Exception ee){
JOptionPane.showMessageDialog( null, "该商品不存在!" );
ee.printStackTrace();
}
}
else if(e.getSource()==purchase){
new Purchase();
}
else if(e.getSource()==Reset){
Number.setText(null);
Name.setText(null);
Vender.setText(null);
Price.setText(null);
Brand.setText(null);
}
else if(e.getSource()==Exit) {
this.setVisible(false);
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
这是本人在做课程设计的时候写的用Java实现商品信息管理系统的代码,具体信息请看本人博客,博客地址https://blog.csdn.net/vegetable_haker/article/details/102556311,其中MySQL数据库需要根据本地配置做些修改 (本人菜鸟一枚,代码是几年前课设时写的,现在学的知识都交还给老师了,所以有什么问题的话,不要问我,我也不知道~ . ~,仅供学交流使用,有诸多不完善的地方,介意请谨慎下载)
资源推荐
资源详情
资源评论
收起资源包目录
商品信息管理系统.rar (11个子文件)
商品信息管理系统
seller_Manage.java 2KB
database.properties 93B
ConnectionFactory.java 1KB
custom_Manage.java 3KB
DeleteGoods.java 2KB
info_Manage.java 2KB
GetGoods.java 2KB
Purchase.java 961B
AddGoods.java 4KB
SetGoods.java 4KB
UsingExit.java 933B
共 11 条
- 1
资源评论
- weixin_523430422020-11-09已经下好了,数据库怎么搞啊
- Double-_-one_2021-12-21代码用不了啊,一片红
_egg_
- 粉丝: 215
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功