package com.four;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import com.four.Config.jdbcConfig;
import com.four.Entity.Order;
import com.four.Entity.OrderDetail;
import com.four.service.userService;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JTextArea;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class ShowGoods {
private JFrame frame;
private JTextField textbprice;
private JTextField textsprice;
private JTextField textbnum;
private JTextField textsnum;
Integer UID = null;
private String serverIP;
public static void main(String[] args) {
new ShowGoods(28);
}
public Integer getUID() {
return UID;
}
public ShowGoods( Integer u_id) {
initialize();
this.UID = u_id;
serverIP = jdbcConfig.getValue("serverIP");
}
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(new Color(220, 220, 220));
frame.getContentPane().setForeground(Color.WHITE);
frame.setBounds(100, 100, 562, 462);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("\u6B22\u8FCE\u9009\u8D2D");
lblNewLabel.setBounds(0, 10, 132, 27);
lblNewLabel.setFont(new Font("幼圆", Font.PLAIN, 18));
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
frame.getContentPane().add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("\u7EAF\u51C0\u6C34\u5927\u6876");
lblNewLabel_1.setBounds(30, 83, 78, 32);
lblNewLabel_1.setFont(new Font("幼圆", Font.PLAIN, 14));
lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
frame.getContentPane().add(lblNewLabel_1);
JLabel lblNewLabel_2 = new JLabel("\u7EAF\u51C0\u6C34\u5C0F\u6876");
lblNewLabel_2.setBounds(30, 144, 78, 18);
lblNewLabel_2.setFont(new Font("幼圆", Font.PLAIN, 14));
frame.getContentPane().add(lblNewLabel_2);
textbprice = new JTextField();
textbprice.setFont(new Font("幼圆", Font.BOLD, 12));
textbprice.setBounds(143, 89, 66, 26);
textbprice.setEnabled(false);
frame.getContentPane().add(textbprice);
textbprice.setColumns(10);
String price1 = userService.showPrice("0").toString();
textbprice.setText(price1);
textsprice = new JTextField();
textsprice.setFont(new Font("幼圆", Font.BOLD, 12));
textsprice.setForeground(Color.BLACK);
textsprice.setBounds(143, 138, 66, 27);
textsprice.setEnabled(false);
frame.getContentPane().add(textsprice);
textsprice.setColumns(10);
String price2 = userService.showPrice("1").toString();
textsprice.setText(price2);
textbnum = new JTextField();
textbnum.setBounds(253, 89, 66, 26);
frame.getContentPane().add(textbnum);
textbnum.setColumns(10);
textsnum = new JTextField();
textsnum.setBounds(253, 138, 66, 27);
frame.getContentPane().add(textsnum);
textsnum.setColumns(10);
JLabel lblNewLabel_3 = new JLabel("\u4EF7\u683C");
lblNewLabel_3.setBounds(143, 57, 54, 22);
lblNewLabel_3.setHorizontalAlignment(SwingConstants.CENTER);
lblNewLabel_3.setFont(new Font("幼圆", Font.PLAIN, 14));
frame.getContentPane().add(lblNewLabel_3);
JLabel lblNewLabel_4 = new JLabel("\u8D2D\u4E70\u6570\u91CF");
lblNewLabel_4.setBounds(253, 57, 66, 22);
lblNewLabel_4.setFont(new Font("幼圆", Font.PLAIN, 14));
frame.getContentPane().add(lblNewLabel_4);
JButton textsubmitorder = new JButton("\u63D0\u4EA4\u8BA2\u5355");
textsubmitorder.setBounds(285, 355, 121, 34);
textsubmitorder.setFont(new Font("幼圆", Font.PLAIN, 16));
frame.getContentPane().add(textsubmitorder);
JTextArea txtrHh = new JTextArea();
txtrHh.setBounds(105, 202, 301, 114);
txtrHh.setToolTipText("");
frame.getContentPane().add(txtrHh);
JLabel lblNewLabel_5 = new JLabel("\u5356\u5BB6\u7559\u8A00");
lblNewLabel_5.setBounds(30, 200, 65, 27);
lblNewLabel_5.setFont(new Font("幼圆", Font.PLAIN, 16));
frame.getContentPane().add(lblNewLabel_5);
JLabel label = new JLabel("\u67E5\u770B\u8BA2\u5355");
label.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
new orderManager(UID);
}
});
label.setFont(new Font("幼圆", Font.PLAIN, 12));
label.setBounds(445, 17, 66, 18);
frame.getContentPane().add(label);
textsubmitorder.addActionListener(new SendDataListener());
frame.setVisible(true);
}
private class SendDataListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
Double bprice = Double.parseDouble(textbprice.getText());
Double sprice = Double.parseDouble(textsprice.getText());
Integer bnum = Integer.parseInt(textbnum.getText());
Integer snum = Integer.parseInt(textsnum.getText());
Integer bID = 0;
Integer sID = 1;
Double totalMoney = bnum*bprice +snum*sprice;
Integer u_id =UID ;
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");//可以方便地修改日期格式
String time = dateFormat.format(now);
List<OrderDetail> ods = new ArrayList<OrderDetail>();
Integer o_id = userService.getCurrentOrderId()+1;
OrderDetail orderDetail1= new OrderDetail(o_id,bID, bnum);
OrderDetail orderDetail2 = new OrderDetail(o_id,sID, snum);
ods.add(orderDetail2);
ods.add(orderDetail1);
System.out.println(ods.toString());
Order order = new Order(o_id, UID, totalMoney, time ,ods);
System.out.println(order.toString());
try {
Socket Socket = new Socket(serverIP, 6669);
ObjectOutputStream oos = new ObjectOutputStream(Socket.getOutputStream());
oos.writeObject(order);
oos.flush();
ObjectInputStream ois= new ObjectInputStream(Socket.getInputStream());
int number = (int) ois.readObject();
if(number == 1) {
JOptionPane.showMessageDialog(null, "下单成功!!!", "提示",
JOptionPane.INFORMATION_MESSAGE);
}
else {
JOptionPane.showMessageDialog(null, "下单失败!!!", "提示",
JOptionPane.INFORMATION_MESSAGE);
}
oos.close();
ois.close();
Socket.close();
} catch (Exception ex) {
ex.printStackTrace();}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
WB.zip (58个子文件)
WB
jgoodies-forms-1.8.0-sources.jar 170KB
.project 378B
bin
Mysql.properties 200B
com
four
net
DmsNetServer$AcceptOrderSubmitThread.class 2KB
DmsNetServer.class 1016B
test123$3.class 637B
orderManager$1.class 2KB
orderManager.class 4KB
DmsNetServer$AcceptRegisterThread.class 2KB
test123$2.class 857B
DmsNetServer$AcceptLoginThread.class 2KB
test123.class 3KB
orderManager$UpdateTableThread.class 1KB
test123$1.class 730B
mainUI.class 3KB
mainUI$3.class 667B
Register.class 4KB
Util
jdbcUtil.class 3KB
orderManager.class 4KB
ShowGoods.class 5KB
Config
jdbcConfig.class 991B
Register$SendDataListener.class 4KB
ShowGoods$SendDataListener.class 4KB
mainUI$2.class 771B
mainUI$SendDataListener.class 3KB
ShowGoods$1.class 733B
mainUI$1.class 771B
Entity
Order.class 4KB
User.class 3KB
Goods.class 3KB
OrderDetail.class 3KB
service
userService.class 5KB
Test
JDBCTest.class 277B
orderManager$UpdateTableThread.class 1KB
sql数据
order.csv 188B
user.csv 311B
goods表.csv 75B
orderdetail.csv 193B
.settings
org.eclipse.core.resources.prefs 265B
org.eclipse.jdt.core.prefs 598B
Config
Mysql.properties 200B
src
com
four
net
DmsNetServer.java 5KB
orderManager.java 4KB
test123.java 3KB
orderManager.java 3KB
Util
jdbcUtil.java 2KB
Config
jdbcConfig.java 425B
Register.java 6KB
mainUI.java 4KB
Entity
Goods.java 528B
Order.java 908B
User.java 674B
OrderDetail.java 538B
service
userService.java 4KB
ShowGoods.java 7KB
Test
JDBCTest.java 56B
.classpath 4KB
jgoodies-forms-1.8.0.jar 129KB
共 58 条
- 1
资源评论
- weixin_476454352020-05-18这里面哪有报告
four_WW
- 粉丝: 3
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功