package com.hodo.frame;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import com.hodo.model.Cls;
import com.hodo.model.Good;
import com.hodo.service.ClsService;
import com.hodo.service.GoodService;
import com.hodo.util.NumUtils;
public class GoodEditFrame extends JFrame {
private GoodService ls=new GoodService();
private ClsService cs=new ClsService();
private JPanel contentPane;
private Integer goodNO;
public static GoodEditFrame frame;
private JTextField nm;
private JTextField inPrice;
private JTextField outPrice;
private JTextField num;
private JComboBox<String> cls;
/**
* Launch the application.
*/
public static void main(Integer[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
GoodEditFrame frame = new GoodEditFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public GoodEditFrame() {
setTitle("商品基本信息");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 351, 357);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
nm = new JTextField();
nm.setColumns(10);
nm.setBounds(141, 27, 167, 21);
contentPane.add(nm);
JLabel label = new JLabel("商品名称:");
label.setBounds(36, 30, 74, 15);
contentPane.add(label);
JButton button = new JButton("提交");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
update();
}
});
button.setBounds(133, 275, 93, 23);
contentPane.add(button);
JLabel label_1 = new JLabel("商品类别:");
label_1.setBounds(36, 75, 74, 15);
contentPane.add(label_1);
JLabel label_2 = new JLabel("进货价格:");
label_2.setBounds(36, 117, 74, 15);
contentPane.add(label_2);
inPrice = new JTextField();
inPrice.setColumns(10);
inPrice.setBounds(141, 114, 167, 21);
contentPane.add(inPrice);
JLabel label_3 = new JLabel("零售价格:");
label_3.setBounds(36, 155, 74, 15);
contentPane.add(label_3);
outPrice = new JTextField();
outPrice.setColumns(10);
outPrice.setBounds(141, 152, 167, 21);
contentPane.add(outPrice);
JLabel label_4 = new JLabel("库存数量:");
label_4.setBounds(36, 197, 74, 15);
contentPane.add(label_4);
num = new JTextField();
num.setColumns(10);
num.setBounds(141, 194, 167, 21);
contentPane.add(num);
cls = new JComboBox<String>();
cls.setBounds(141, 72, 167, 21);
List<Cls> aList=cs.queryAll();
for (Cls c : aList) {
cls.addItem(c.getId()+":"+c.getNm());
}
contentPane.add(cls);
}
//修改
private void update() {
Good a;
int i = -1;
if(check()){
if(this.getGoodNO()!=null && this.getGoodNO()!=0){
a=ls.queryOne(this.getGoodNO());
a.setNm(nm.getText());
a.setInPrice(Float.parseFloat(inPrice.getText()));
a.setOutPrice(Float.parseFloat(outPrice.getText()));
a.setNum(Integer.parseInt(num.getText()));
String clsIdString=cls.getSelectedItem().toString();
int index=clsIdString.indexOf(":");
String clsIdString2=clsIdString.substring(0, index);
Integer aId=Integer.parseInt(clsIdString2);
a.setCls(aId);
i = ls.update(a);
} else {
a = new Good();
a.setNm(nm.getText());
a.setInPrice(Float.parseFloat(inPrice.getText()));
a.setOutPrice(Float.parseFloat(outPrice.getText()));
a.setNum(Integer.parseInt(num.getText()));
String clsIdString=cls.getSelectedItem().toString();
int index=clsIdString.indexOf(":");
String clsIdString2=clsIdString.substring(0, index);
Integer aId=Integer.parseInt(clsIdString2);
a.setCls(aId);
i=ls.insert(a);
}
if(i==0) {
JOptionPane.showMessageDialog(null, "操作成功");
GoodFrame.frame.quaryAll();
dispose();
return;
}else {
JOptionPane.showMessageDialog(null, "操作失败");
}
}
}
public boolean check() {
boolean b=true;
String c=cls.getSelectedItem().toString();
String n=nm.getText();
String ip=inPrice.getText();
String op=outPrice.getText();
String i=num.getText();
if(c==null || "".equals(c)){JOptionPane.showMessageDialog(null, "请选择商品类别!");return false;}
if(n==null || "".equals(n)){JOptionPane.showMessageDialog(null, "商品名称不能为空!");return false;}
if(ip==null || "".equals(ip)){JOptionPane.showMessageDialog(null, "进货价格不能为空!");return false;}
if(op==null || "".equals(op)){JOptionPane.showMessageDialog(null, "零售价格不能为空!");return false;}
if(i==null || "".equals(i)){JOptionPane.showMessageDialog(null, "库存数量不能为空!");return false;}
if(!NumUtils.checkPrice(ip)){
JOptionPane.showMessageDialog(null, "进货价格不正确!");
inPrice.setText("");
return false;
}
if(!NumUtils.checkPrice(op)){
JOptionPane.showMessageDialog(null, "零售价格不正确!");
outPrice.setText("");
return false;
}
if(!NumUtils.isNum(i)){
JOptionPane.showMessageDialog(null, "库存数量必须为数字!");
num.setText("");
return false;
}
return b;
}
public Integer getGoodNO() {
return goodNO;
}
public void setGoodNO(Integer goodNO) {
this.goodNO = goodNO;
}
public JTextField getNm() {
return nm;
}
public void setNm(JTextField nm) {
this.nm = nm;
}
public JTextField getInPrice() {
return inPrice;
}
public void setInPrice(JTextField inPrice) {
this.inPrice = inPrice;
}
public JTextField getOutPrice() {
return outPrice;
}
public void setOutPrice(JTextField outPrice) {
this.outPrice = outPrice;
}
public JTextField getNum() {
return num;
}
public void setNum(JTextField num) {
this.num = num;
}
public JComboBox<String> getCls() {
return cls;
}
public void setCls(JComboBox<String> cls) {
this.cls = cls;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
java编程超市商品管理系统,图形界面完成。连接My SQL 要求: 1)商品类别管理,商品类别主要包括文具,小零食,日常生活用品,肉类,蔬菜类等类别,可以添加新的类别,请编程实现这些信息的增、删、改、查操作。 2)商品基本信息管理,商品基本信息主要包括商品编号,商品类别,商品名称,进货价格,零售价格,库存数量等,其中商品类别需要是一中所指的各种类别。 3)商品出售管理,对于商品库存数量大于1的商品,可以出售,出售后其库存数量减1。 4)商品进货管理,每次进货后,需要根据进货商品的种类,数量,修改对应商品的库存数量。
资源推荐
资源详情
资源评论
收起资源包目录
超市商品管理系统.zip (118个子文件)
GoodEditFrame.class 8KB
GoodEditFrame.class 7KB
GoodFrame.class 7KB
GoodFrame.class 7KB
GoodOutFrame.class 7KB
GoodInFrame.class 7KB
GoodOutFrame.class 7KB
GoodInFrame.class 7KB
GoodDao.class 6KB
GoodDao.class 6KB
ClsFrame.class 5KB
ClsFrame.class 5KB
ClsDao.class 4KB
ClsDao.class 4KB
ClsEditFrame.class 3KB
ClsEditFrame.class 3KB
DateUtil.class 3KB
DateUtil.class 3KB
GoodService.class 2KB
GoodService.class 2KB
GoodOutFrame$3.class 2KB
GoodOutFrame$3.class 2KB
GoodInFrame$3.class 2KB
GoodInFrame$3.class 2KB
Util.class 2KB
Util.class 2KB
mainFrame.class 2KB
mainFrame.class 2KB
ClsService.class 2KB
ClsService.class 2KB
JdbcUtil.class 2KB
Good.class 2KB
Good.class 2KB
JdbcUtil.class 1KB
NumUtils.class 1KB
NumUtils.class 1KB
mainFrame$5.class 825B
mainFrame$5.class 825B
mainFrame$4.class 823B
mainFrame$4.class 823B
mainFrame$3.class 819B
mainFrame$3.class 819B
mainFrame$2.class 817B
mainFrame$2.class 817B
GoodFrame$3.class 801B
GoodFrame$3.class 801B
ClsFrame$4.class 793B
ClsFrame$4.class 793B
GoodEditFrame$1.class 773B
GoodEditFrame$1.class 773B
GoodOutFrame$1.class 771B
GoodOutFrame$1.class 771B
ClsEditFrame$1.class 768B
ClsEditFrame$1.class 768B
GoodInFrame$1.class 766B
GoodInFrame$1.class 766B
GoodFrame$1.class 756B
GoodFrame$1.class 756B
Cls.class 755B
Cls.class 755B
mainFrame$1.class 752B
mainFrame$1.class 752B
ClsFrame$1.class 751B
ClsFrame$1.class 751B
GoodFrame$5.class 727B
GoodFrame$4.class 727B
GoodFrame$5.class 727B
GoodFrame$4.class 727B
ClsFrame$6.class 721B
ClsFrame$5.class 721B
ClsFrame$6.class 721B
ClsFrame$5.class 721B
GoodOutFrame$2.class 720B
GoodOutFrame$2.class 720B
GoodEditFrame$2.class 719B
GoodEditFrame$2.class 719B
GoodInFrame$2.class 714B
GoodInFrame$2.class 714B
ClsEditFrame$2.class 713B
ClsEditFrame$2.class 713B
GoodFrame$2.class 702B
GoodFrame$2.class 702B
ClsFrame$2.class 690B
ClsFrame$2.class 690B
ClsFrame$3.class 689B
ClsFrame$3.class 689B
.classpath 480B
.classpath 425B
.classpath 226B
.classpath 226B
jdbcinfo.config 110B
errors.config 39B
mysql-connector-java-5.1.38-bin.jar 961KB
c3p0-0.9.1.2.jar 596KB
junit-4.4.jar 158KB
GoodEditFrame.java 6KB
GoodOutFrame.java 6KB
GoodInFrame.java 6KB
GoodFrame.java 6KB
GoodDao.java 5KB
共 118 条
- 1
- 2
资源评论
- weixin_540320242021-06-22??????你这不是JAVA,怎么是网页h5啊?你这是骗人啊
十分放心的
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功