基于java+mysql的swing+java+mysql餐厅在线点餐系统(管理员、用户)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
后台管理
admin/123456
前台点餐
user1/123456
基于java+mysql的Swing+Java+MySQL餐厅在线点餐系统(管理员、用户)
jb_add)))
.addContainerGap(32, Short.MAX_VALUE)));
layout
.setVerticalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addContainerGap()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(
goodsNameTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)
.addComponent(
imageLinkTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(
priceTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jb_chooser))
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
private javax.swing.JButton jb_add;
private javax.swing.JButton jb_delete;
private javax.swing.JButton jb_ok;
private javax.swing.JTextField totalMoneyTxt;
private javax.swing.JTextField totalNumTxt;
// End of variables declaration//GEN-END:variables
}
/*
* GoodsAddInterFrm.java
*
* Created on __DATE__, __TIME__
*/
/**
*
*/
public class GoodsAddInterFrm extends javax.swing.JInternalFrame {
DbUtil dbUtil = new DbUtil();
GoodsDao goodsDao = new GoodsDao();
/** Creates new form GoodsAddInterFrm */
public GoodsAddInterFrm() {
initComponents();
this.setLocation(200, 80);
public void run() {
new RegisterFrm().setVisible(true);
}
});
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JTextField emailTxt;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JButton jb_register;
private javax.swing.JButton jb_reset;
private javax.swing.JPasswordField passwordConfirmTxt;
private javax.swing.JPasswordField passwordTxt;
private javax.swing.JTextField userNameTxt;
// End of variables declaration//GEN-END:variables
}
/*
* AccountModify.java
*
* Created on __DATE__, __TIME__
*/
/**
*
*/
public class AccountModifyInterFrm extends javax.swing.JInternalFrame {
DbUtil dbUtil = new DbUtil();
UserDao userDao = new UserDao();
this.setLocation(320, 100);
this.userNameTxt.setText(LogOnFrm.s_currentUser.getUserName());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jb_modify = new javax.swing.JButton();
jb_reset = new javax.swing.JButton();
userNameTxt = new javax.swing.JTextField();
oldPasswordTxt = new javax.swing.JPasswordField();
newPasswordTxt = new javax.swing.JPasswordField();
newPasswordConfirmTxt = new javax.swing.JPasswordField();
setClosable(true);
setIconifiable(true);
setTitle("\u8d26\u6237\u4fe1\u606f\u4fee\u6539");
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource(
"/images/userName.png"))); // NOI18N
jLabel1.setText("\u7528\u6237\u540d\uff1a");
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource(
"/images/password.png"))); // NOI18N
jLabel2.setText("\u65e7\u5bc6\u7801\uff1a");
jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource(
"/images/new_password.png"))); // NOI18N
jLabel3.setText("\u65b0\u5bc6\u7801\uff1a");
jLabel4.setText("\u65b0\u5bc6\u7801\u786e\u8ba4\uff1a");
jb_modify.setIcon(new javax.swing.ImageIcon(getClass().getResource(
"/images/edit.png"))); // NOI18N
jb_modify.setText("\u786e\u8ba4\u4fee\u6539");
jb_modify.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
private void jb_okActionPerformed(java.awt.event.ActionEvent evt) {
String userName = LogOnFrm.s_currentUser.getUserName();//
//生成订单号
String orderId = new java.text.SimpleDateFormat("yyyyMMddHHmmss")
.format(new java.util.Date());//将当前时间作为订单号码
float orderTotalMoney = Float.parseFloat(this.totalMoneyTxt.getText());//
int orderNum = Integer.parseInt(this.totalNumTxt.getText());//
int rowNum = cartTable.getRowCount();//计算行数
if (rowNum == 0) {
JOptionPane.showMessageDialog(null, "请添加上商品后再结算!");
return;
}
Connection con = null;
try {
con = dbUtil.getCon();
Order order = new Order(orderId, 0, orderNum, orderTotalMoney,
userName);
int addNum = orderDao.order_infoAdd(con, order);//插入数据到order_info表
if (addNum == 1) {
for (int i = 0; i < rowNum; i++) {
int goodsId = Integer.parseInt((String) cartTable
.getValueAt(i, 0));
String goodsName = (String) cartTable.getValueAt(i, 1);
int goodsNum = Integer.parseInt((String) cartTable
.getValueAt(i, 2));
float goodsPrice = Float.parseFloat((String) cartTable
.getValueAt(i, 3));
float goodsTotalPrice = Float.parseFloat((String) cartTable
.getValueAt(i, 4));
order = new Order(orderId, goodsTotalPrice, goodsId,
goodsPrice, goodsNum, goodsName);
//循环插入数据到order_goods表
addNum += orderDao.order_goodsAdd(con, order);
}
} else {
JOptionPane.showMessageDialog(null, "订单提交失败");
}
if (addNum == (1 + rowNum)) {
int row = cartTable.getSelectedRow();
int goodsId = Integer.parseInt((String) cartTable.getValueAt(row, 0));
Goods goods = new Goods();
goods.setId(goodsId);
Connection con = null;
try {
con = dbUtil.getCon();
ResultSet rs = goodsDao.goodsList(con, goods);
while (rs.next()) {
picturePath = rs.getString("imageLink");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
dbUtil.closeCon(con);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (StringUtil.isNotEmpty(picturePath)) {
Icon icon = new ImageIcon(picturePath);
this.iamgeLb.setIcon(icon);
} else {
this.iamgeLb.setIcon(null);
}
}
//取消订单操作
private void jb_statusActionPerformed(java.awt.event.ActionEvent evt) {
//获取选中的行,如果为选中,row默认为-1
int row = orderTable.getSelectedRow();//
if (row < 0) {
JOptionPane.showMessageDialog(null, "请选择一个订单");
return;
}
//获取订单编号
String orderId = (String) orderTable.getValueAt(row, 0);
Order order = new Order();
order.setOrderId(orderId);
order.setOrderStatus(4);//取消订单
try {
Connection con = dbUtil.getCon();
int modifyNum = orderDao.orderStatusModify(con, order);
if (modifyNum == 1) {
goods.setPrice1(Float.parseFloat(s_price1));
goods.setPrice(Float.parseFloat(s_price2));
}
}
//若都为空则不作为查询条件
goods.setGoodsName(s_goodsName);
this.filltable(goods);
System.out.println(goods.getPrice1());
System.out.println(goods.getPrice());
}
private void resetValues() {
this.goodsNameTxt.setText("");
this.goodsDescTxt.setText("");
this.priceTxt.setText("");
this.imageLinkTxt.setText("");
this.iamgeLb.setIcon(null);
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.JTextArea goodsDescTxt;
private javax.swing.JTextField goodsIdTxt;
private javax.swing.JTextField goodsNameTxt;
private javax.swing.JTable goodsTable;
private javax.swing.JLabel iamgeLb;
private javax.swing.JTextField imageLinkTxt;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
ResultSet rs = orderDao.orderGoodsList(con, order);
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("goodsId"));
v.add(rs.getString("goodsName"));
v.add(rs.getInt("goodsNum"));
v.add(rs.getFloat("goodsPrice"));
v.add(rs.getFloat("goodsTotalPrice"));
dtm.addRow(v);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
dbUtil.closeCon(con);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
//查找显示订单列表
private void jb_searchActionPerformed(java.awt.event.ActionEvent evt) {
fillOrderTable();
}
//GEN-BEGIN:variables
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JTable cartTable;
private javax.swing.JLabel iamgeLb;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel2;
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(
jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
58,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(
userNameTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(
passwordTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37)
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jb_logon)
.addComponent(jb_reset)
.addComponent(
jb_register))
.addContainerGap(55, Short.MAX_VALUE)));
pack();
return false;
}
}
public static boolean isNotEmpty(String str){
if(!"".equals(str)&&str!=null){
return true;
}else{
return false;
}
}
/**
* 验证邮箱地址是否正确
* @param email
* @return
*/
public static boolean checkEmail(String email){
boolean flag = false;
try{
String check = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
Pattern regex = Pattern.compile(check);
Matcher matcher = regex.matcher(email);
flag = matcher.matches();
}catch(Exception e){
flag = false;
}
return flag;
}
/**
* 验证手机号码
* @param mobiles
* @return [0-9]{5,9}
*/
public static boolean isMobileNO(String mobiles){
boolean flag = false;
try{
Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");
Matcher m = p.matcher(mobiles);
flag = m.matches();
}catch(Exception e){
flag = false;
}
return flag;
}
//浮点型判断
public static boolean isNum(String str){
return str.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
}
new Object[][] {
}, new String[] { "套餐编号", "套餐名称", "套餐数量", "套餐单价", "套餐金额" }) {
boolean[] canEdit = new boolean[] { false, false, false, false,
false };
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit[columnIndex];
}
});
cartTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mousePressed(java.awt.event.MouseEvent evt) {
cartTableMousePressed(evt);
}
});
jScrollPane2.setViewportView(cartTable);
jLabel2.setText("\u603b\u6570\u91cf\uff1a");
totalNumTxt.setEditable(false);
totalMoneyTxt.setEditable(false);
jLabel1.setText("\u603b\u91d1\u989d\uff1a");
jLabel3.setText("\u8ba2\u5355\u72b6\u6001\uff1a");
orderStatusTxt.setEditable(false);
jb_status.setText("\u53d6\u6d88\u8ba2\u5355");
jb_status.setFocusPainted(false);
jb_status.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb_statusActionPerformed(evt);
}
});
jLabel4.setText("\u70b9\u9910\u4eba\uff1a");
userNameTxt.setEditable(false);
jLabel5.setText("\u8ba2\u5355\u53f7\uff1a");
jb_search.setIcon(new javax.swing.ImageIcon(getClass().getResource(
.addGroup(
layout
.createSequentialGroup()
.addGap(
47,
47,
47)
.addComponent(
jb_reset))
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(
jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(
jb_chooser)
.addComponent(
imageLinkTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
161,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(
layout
.createSequentialGroup()
.addGap(
56,
56,
56)
.addComponent(
jb_add)))
.addContainerGap(32, Short.MAX_VALUE)));
layout
.setVerticalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addContainerGap()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(
goodsNameTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
jMenuBar1.add(jMenu3);
jMenu4.setIcon(new javax.swing.ImageIcon(getClass().getResource(
"/images/about.png"))); // NOI18N
jMenu4.setText("\u5176\u4ed6");
jmiModify.setIcon(new javax.swing.ImageIcon(getClass().getResource(
"/images/modify.png"))); // NOI18N
jmiModify.setText("\u4fee\u6539\u5bc6\u7801");
jmiModify.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmiModifyActionPerformed(evt);
}
});
jMenu4.add(jmiModify);
jmiExit.setIcon(new javax.swing.ImageIcon(getClass().getResource(
"/images/exit.png"))); // NOI18N
jmiExit.setText("\u9000\u51fa\u7cfb\u7edf");
jmiExit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmiExitActionPerformed(evt);
}
});
jMenu4.add(jmiExit);
jMenuBar1.add(jMenu4);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addComponent(table,
javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE));
layout.setVerticalGroup(layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addComponent(table,
javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE));
pack();
}// </editor-fold>
//GEN-END:initComponents
//订单处理操作
private void jmiDealOrderActionPerformed(java.awt.event.ActionEvent evt) {
DealOrderInterFrm dealOrderInterFrm = new DealOrderInterFrm();
dealOrderInterFrm.setVisible(true);
/**
*
*/
public class AccountModifyInterFrm extends javax.swing.JInternalFrame {
DbUtil dbUtil = new DbUtil();
UserDao userDao = new UserDao();
/** Creates new form AccountModify */
public AccountModifyInterFrm() {
initComponents();
this.setLocation(320, 100);
this.userNameTxt.setText(LogOnFrm.s_currentUser.getUserName());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jb_modify = new javax.swing.JButton();
jb_reset = new javax.swing.JButton();
userNameTxt = new javax.swing.JTextField();
oldPasswordTxt = new javax.swing.JPasswordField();
newPasswordTxt = new javax.swing.JPasswordField();
newPasswordConfirmTxt = new javax.swing.JPasswordField();
setClosable(true);
setIconifiable(true);
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(
35,
35,
35))
.addGroup(
javax.swing.GroupLayout.Alignment.TRAILING,
layout
.createSequentialGroup()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addComponent(
jLabel3)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
orderStatusTxt,
javax.swing.GroupLayout.DEFAULT_SIZE,
177,
Short.MAX_VALUE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
jLabel2)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
totalNumTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
76,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(
layout
.createSequentialGroup()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
jrb_1)
.addComponent(
jrb_3))
.addGap(
12,
12,
12)
76,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED))
.addGroup(
layout
.createSequentialGroup()
.addComponent(
jb_status)
.addGap(
297,
297,
297)))
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(
layout
.createSequentialGroup()
.addComponent(
jLabel1)
.addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(
totalMoneyTxt,
javax.swing.GroupLayout.PREFERRED_SIZE,
81,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(
jPanel2,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(23, Short.MAX_VALUE)));
layout
.setVerticalGroup(layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addGroup(
layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(
layout
.createSequentialGroup()
.addContainerGap()
.addGroup(
layout
.createParallelGroup(
User resultUser = null;
String sql="select *from user where userName=? and password=?";
PreparedStatement pstmt=con.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
pstmt.setString(2, user.getPassword());
ResultSet rs=pstmt.executeQuery();
if(rs.next()){
resultUser = new User();
resultUser.setUserName(rs.getString("userName"));
resultUser.setPassword(rs.getString("password"));
resultUser.setRank(rs.getInt("rank"));
resultUser.setId(rs.getInt("id"));
}
return resultUser;
}
public int userAdd(Connection con,User user) throws Exception{
String sql="insert into `user` values(null,?,?,?,?)";
PreparedStatement pstmt=con.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
pstmt.setString(2, user.getPassword());
pstmt.setString(3, user.getEmail());
pstmt.setInt(4, user.getRank());
return pstmt.executeUpdate();
}
public boolean isUserExist(Connection con,User user) throws Exception{
String sql="select *from user where userName=?";
PreparedStatement pstmt=con.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
ResultSet rs =pstmt.executeQuery();
return rs.next();
}
public int userModify(Connection con,User user) throws Exception{
String sql="update `user` set userName=?,password=?,email=? where id=?";
PreparedStatement pstmt=con.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
pstmt.setString(2, user.getPassword());
pstmt.setString(3, user.getEmail());
pstmt.setInt(4, user.getId());;
return pstmt.executeUpdate();
}
}
}
Connection con = null;
try {
con = dbUtil.getCon();
Order order = new Order(orderId, 0, orderNum, orderTotalMoney,
userName);
int addNum = orderDao.order_infoAdd(con, order);//插入数据到order_info表
if (addNum == 1) {
for (int i = 0; i < rowNum; i++) {
int goodsId = Integer.parseInt((String) cartTable
.getValueAt(i, 0));
String goodsName = (String) cartTable.getValueAt(i, 1);
int goodsNum = Integer.parseInt((String) cartTable
.getValueAt(i, 2));
float goodsPrice = Float.parseFloat((String) cartTable
.getValueAt(i, 3));
float goodsTotalPrice = Float.parseFloat((String) cartTable
.getValueAt(i, 4));
order = new Order(orderId, goodsTotalPrice, goodsId,
goodsPrice, goodsNum, goodsName);
//循环插入数据到order_goods表
addNum += orderDao.order_goodsAdd(con, order);
}
} else {
JOptionPane.showMessageDialog(null, "订单提交失败");
}
if (addNum == (1 + rowNum)) {
JOptionPane.showMessageDialog(null, "订单提交成功,请记住您的定单号:"
+ orderId);
} else {
JOptionPane.showMessageDialog(null, "订单提交失败");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
JOptionPane.showMessageDialog(null, "订单提交失败");
} finally {
try {
dbUtil.closeCon(con);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
DefaultTableModel dtm = (DefaultTableModel) cartTable.getModel();