You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.0 KiB
113 lines
3.0 KiB
package view;
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.FlowLayout;
|
|
import java.awt.Font;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
|
|
import javax.swing.JButton;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JScrollPane;
|
|
import javax.swing.JTable;
|
|
import javax.swing.table.TableModel;
|
|
|
|
import dao.OrdersDAOtyj;
|
|
|
|
import dao.impl.OrdersDaoImpltyj;
|
|
|
|
|
|
import domain.Orderstyj;
|
|
|
|
|
|
public class JiedanFramembz extends MyFrame {
|
|
//表格
|
|
private JTable table;
|
|
//表格数据
|
|
private Object[][] data=null;
|
|
//商品DAO
|
|
private OrdersDAOtyj dao=new OrdersDaoImpltyj();
|
|
//购物车数据
|
|
private Map<Long,Integer> cart;
|
|
//ProductListFrame窗口
|
|
private OrderListFramembz orderListFrame;
|
|
public JiedanFramembz(Map<Long,Integer> cart,OrderListFramembz orderListFrame) {
|
|
super("接单列表", 1000, 700);
|
|
// TODO 自动生成的构造函数存根
|
|
this.tubiao();
|
|
this.cart=cart;
|
|
this.orderListFrame=orderListFrame;
|
|
|
|
JPanel topPanel=new JPanel();
|
|
FlowLayout fl_toppanel=(FlowLayout) topPanel.getLayout();
|
|
fl_toppanel.setVgap(10);
|
|
fl_toppanel.setHgap(20);
|
|
getContentPane().add(topPanel, BorderLayout.NORTH);
|
|
|
|
JButton btnReturn = new JButton("返回订单列表");
|
|
btnReturn.setFont(new Font("微软雅黑",Font.PLAIN,15));
|
|
topPanel.add(btnReturn);
|
|
|
|
JButton btnSubmit = new JButton("确认订单");
|
|
btnReturn.setFont(new Font("微软雅黑",Font.PLAIN,15));
|
|
topPanel.add(btnSubmit);
|
|
|
|
JScrollPane scrollPane = new JScrollPane();
|
|
getContentPane().add(scrollPane, BorderLayout.CENTER);
|
|
scrollPane.setViewportView(getTable());
|
|
|
|
btnSubmit.addActionListener(e->{
|
|
//生成订单
|
|
JLabel label = new JLabel("订单已生成,是否接单出发");
|
|
label.setFont(new Font("微软雅黑",Font.PLAIN,15));
|
|
if(JOptionPane.showConfirmDialog(this, label, "信息", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION) {
|
|
System.exit(0);
|
|
}else {
|
|
System.exit(0);
|
|
}
|
|
});
|
|
|
|
}
|
|
private JTable getTable() {
|
|
// TODO 自动生成的方法存根
|
|
data = new Object[cart.size()][4];
|
|
Set<Long> keys = this.cart.keySet();
|
|
int indx=0;
|
|
for(Long orderid : keys) {
|
|
Orderstyj o = dao.findById(orderid);
|
|
data[indx][0]=o.getOrderid();
|
|
data[indx][1]=o.getUserid();
|
|
data[indx][2]=o.getOrderdate();
|
|
indx++;
|
|
}
|
|
|
|
TableModel model=new JiedanTableModelmbz(data);
|
|
|
|
if (table == null) {
|
|
// 创建表
|
|
table = new JTable(model);
|
|
// 设置表中内容字体
|
|
table.setFont(new Font("微软雅黑", Font.PLAIN, 16));
|
|
// 设置表列标题字体
|
|
table.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 16));
|
|
// 设置表行高
|
|
table.setRowHeight(51);
|
|
table.setRowSelectionAllowed(false);
|
|
|
|
} else {
|
|
table.setModel(model);
|
|
}
|
|
return table;
|
|
}
|
|
|
|
public void tubiao() {
|
|
MyFrame.setTitleImage(this,"e39b4ce2ebe83d39adabb339c23a1e0.png" );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|