网站服务器好,一般通过后补贴什么时候到,做网站编辑需要经验吗,店铺设计效果图软件一、语言和环境
实现语言#xff1a;Java。
环境要求#xff1a;IDEA2023.3、JDK 17 、MySQL8.0、Navicat 16 for MySQL。
二、技术要求
该系统采用 SWING 技术配合 JDBC 使用 JAVA 编程语言完成桌面应用开发。
三、功能要求
某电商公司为了方便客服查看用户的订单信…一、语言和环境
实现语言Java。
环境要求IDEA2023.3、JDK 17 、MySQL8.0、Navicat 16 for MySQL。
二、技术要求
该系统采用 SWING 技术配合 JDBC 使用 JAVA 编程语言完成桌面应用开发。
三、功能要求
某电商公司为了方便客服查看用户的订单信息需开发一个用户订单管理系统。要求本系统实现以下功能
启动程序后进入主界面显示所有订单信息效果如图 1 所示 2.在订单编号文本框中输入正确订单号显示该订单信息如图 2 3.选中某个订单后点击删除按钮提示是否真的要删除确定后删除该数据。如图 3 4.删除成功后显示删除后订单信息。如图 4 四、数据库设计
数据库名为 OrderDb表结构如下。
表 1 订单表tb_order 列名 含义 数据类型 约束描述 id 编号 int 主键自动增长 name 商品名称 varchar(20) 非空 price 价格 decimal(5,2) 非空 orderID 所属订单单号 varchar(20) 非空 descinfo 描述 varchar(100)
五、具体要求及推荐实现步骤
创建数据库和表
创建订单实体类
创建 BaseDAO 类完成数据库的连接和关闭
创建 OrderDAO 完成对订单的查询与删除功能
创建 MainFrame 类并添加相应组件完成界面设计
在 MainFrame 中添加 JTable 完成数据展示。
在 MainFrame 中添加 Jbutton 完成数据删除
在 MainFrame 中添加文本框完成单条数据搜索
六、注意事项 题目物流跟踪管理系统 该程序的评分标准如下测试时间90分钟 10 数据库和表 正确创建数据库和表 6 分测试数据 4 分。必须以分离数据库或脚本方式提交 否则该项不得分 5 正确创建和编写实体类包含所有属性及方法 10 正确创建并编写 BaseDAO 完成数据库的连接5 分和关闭5 分。 30 正确创建并编写 OrderDAO 完成数据查询与删除 10 列表数据查询 10 单条数据查询 10 数据删除 40 创建并编写 MainFrame 类完成界面设计及功能调用 5 图 1 中各个组件的设计 10 图 1 中数据展示 10 图 2 中单条数据并正确展示在 JTable 中 5 图 3 中单条数据删除询问 10 图 4 中数据删除并展示新数据在 Jtable 中。 5 总体编程技术 2 编码规范 3 注释完善 总分 100 分
七、参考答案
一新建数据库orderdb,表tb_order,并插入实验数据
-- ------------------------------ Table structure for tb_order-- ----------------------------DROP TABLE IF EXISTS tb_order;CREATE TABLE tb_order (id int(11) NOT NULL AUTO_INCREMENT,name varchar(20) NOT NULL,price decimal(10,2) NOT NULL,orderid varchar(20) DEFAULT NULL,descinfo varchar(100) DEFAULT NULL,PRIMARY KEY (id)) ENGINEInnoDB AUTO_INCREMENT4 DEFAULT CHARSETutf8; -- ------------------------------ Records of tb_order-- ----------------------------INSERT INTO tb_order VALUES (1, iphones Max, 8999.00, 5325781, 刘公保的订单);INSERT INTO tb_order VALUES (2, 小米10, 3655.00, 20240405, 梁思琪的订单);INSERT INTO tb_order VALUES (3, 华为荣耀10, 3200.00, 20241102, 曾炳粮的订单);
二Java Swing
①新建com.hnjt.Bean.tb_order.java具体代码如下。
package com.hnjt.Bean;public class tb_order {private int id;private String name;private double price;private int orderID;private String descinfo;public tb_order() {super();}public tb_order(int id, String name, double price, int orderID, String descinfo) {super();this.id id;this.name name;this.price price;this.orderID orderID;this.descinfo descinfo;}public int getId() {return id;}public void setId(int id) {this.id id;}public String getName() {return name;}public void setName(String name) {this.name name;}public double getPrice() {return price;}public void setPrice(double price) {this.price price;}public int getOrderID() {return orderID;}public void setOrderID(int orderID) {this.orderID orderID;}public String getDescinfo() {return descinfo;}public void setDescinfo(String descinfo) {this.descinfo descinfo;}}
②新建com.hnjt.BaseDAO.DbConnection.java具体代码如下。
package com.hnjt.BaseDAO;
import java.sql.*;
import javax.swing.JOptionPane;public class DbConnection {//驱动类的类名private static final String DRIVERNAMEcom.mysql.cj.jdbc.Driver;//连接数据的URL路径private static final String URLjdbc:mysql://localhost:3306/orderdb?serverTimezoneGMT;//数据库登录账号private static final String USERroot;//数据库登录密码private static final String PASSWORD123456;//加载驱动static{try {Class.forName(DRIVERNAME);} catch (ClassNotFoundException e) {e.printStackTrace();}}//获取数据库连接public static Connection getConnection() {try {return DriverManager.getConnection(URL,USER,PASSWORD);} catch (SQLException e) {e.printStackTrace();}return null;}//查询public static ResultSet query(String sql) {System.out.println(sql);//获取连接Connection connectiongetConnection();PreparedStatement psd;try {psd connection.prepareStatement(sql);return psd.executeQuery();} catch (SQLException e) {JOptionPane.showMessageDialog(null,执行语句出错\ne.toString());e.printStackTrace();}return null;}//增、删、改、查public static int updataInfo(String sql) {System.out.println(sql);//获取连接Connection connectiongetConnection();try {PreparedStatement psdconnection.prepareStatement(sql);return psd.executeUpdate();} catch (SQLException e) {JOptionPane.showMessageDialog(null,执行语句出错\ne.toString());e.printStackTrace();}return 0;}//关闭连接public static void colse(ResultSet rs, Statement stmt, Connection conn) throws Exception{try {if (rs ! null){rs.close();}if (stmt ! null){stmt.cancel();}if (conn ! null) { conn.close(); }} catch (Exception e) {e.printStackTrace(); throw new Exception();}}
}
③新建com.hnjt.OrderDAO.Update.java具体代码如下。
package com.hnjt.OrderDAO;import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.hnjt.Bean.tb_order;
import com.hnjt.BaseDAO.DbConnection;
public class Update {//查询主页信息public Object[][] getMainInfo(String id) {String sql;if (id.equals()) {sql select * from tb_order;}else {sql select * from tb_order WHERE orderid LIKE id%;;}ResultSet re DbConnection.query(sql);ArrayListtb_order list new ArrayListtb_order();try {while (re.next()) {tb_order tb new tb_order();tb.setId(re.getInt(1));tb.setName(re.getString(2));tb.setPrice(re.getDouble(3));tb.setOrderID(re.getInt(4));tb.setDescinfo(re.getString(5));list.add(tb);}} catch (SQLException e) {e.printStackTrace();}Object[][] ob new Object[list.size()][5];for (int i 0; i list.size(); i) {ob[i][0] list.get(i).getId();ob[i][1] list.get(i).getName();ob[i][2] list.get(i).getPrice();ob[i][3] list.get(i).getOrderID();ob[i][4] list.get(i).getDescinfo();}return ob;}//删除数据public int addData(int id) {String sql DELETE FROM tb_order WHERE idid;;return DbConnection.updataInfo(sql);}}
④新建com.hnjt.Vive.MainFrame.java具体代码如下。
package com.hnjt.Vive;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import com.hnjt.OrderDAO.Update;
import javax.swing.JButton;
public class MainFrame extends JFrame {private JTextField orderid;Update update new Update();Object[] header {编号,商品名称,商品价格,订单编号,订单描述};Object[][] data update.getMainInfo();DefaultTableModel df new DefaultTableModel(data, header);public MainFrame() {super(物流跟踪管理系统);this.setBounds(0, 0, 700, 500);getContentPane().setLayout(null);this.setLocationRelativeTo(null);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);JLabel title new JLabel(物流跟踪管理系统);title.setFont(new Font(宋体, Font.BOLD, 40));title.setBounds(182, 13, 336, 50);getContentPane().add(title);JLabel orderid_text new JLabel(订单编号);orderid_text.setBounds(14, 70, 72, 18);getContentPane().add(orderid_text);orderid new JTextField();orderid.setBounds(80, 67, 179, 24);getContentPane().add(orderid);orderid.setColumns(10);JButton seach new JButton(搜索);seach.setBounds(273, 66, 90, 27);getContentPane().add(seach);seach.addActionListener(new ActionListener() {Overridepublic void actionPerformed(ActionEvent e) {if (orderid.equals()) {JOptionPane.showMessageDialog(null, 请输入要查询的订单编号);} else {String id orderid.getText();data update.getMainInfo(id);df.setDataVector(data, header);}}});JTable jTable new JTable(df);JScrollPane scrollPane new JScrollPane(jTable);scrollPane.setBounds(14, 104, 666, 302);getContentPane().add(scrollPane);JButton delete new JButton(删除);delete.setBounds(590, 425, 90, 27);getContentPane().add(delete);delete.addActionListener(new ActionListener() {Overridepublic void actionPerformed(ActionEvent e) {if (jTable.getSelectedColumn()0) {JOptionPane.showMessageDialog(null, 请选择要删除的数据);} else {int num JOptionPane.showConfirmDialog(null, 您真的真的要删除吗,温馨提示, 0,1);int id Integer.parseInt(jTable.getValueAt(jTable.getSelectedRow(), 0).toString());if(num JOptionPane.OK_OPTION){int result update.addData(id);if (result0) {JOptionPane.showMessageDialog(null, 删除成功);orderid.setText();} else {JOptionPane.showMessageDialog(null, 删除失败);}}}}});}
⑤新建com.hnjt.Test.Test.java测试运行具体代码如下。
package com.hnjt.Test;
import com.hnjt.Vive.MainFrame;
public class Test {public static void main(String[] args) {new MainFrame().setVisible(true);}
} 文章转载自: http://www.morning.ghpld.cn.gov.cn.ghpld.cn http://www.morning.ynbyk.cn.gov.cn.ynbyk.cn http://www.morning.jtwck.cn.gov.cn.jtwck.cn http://www.morning.xczyj.cn.gov.cn.xczyj.cn http://www.morning.mqwdh.cn.gov.cn.mqwdh.cn http://www.morning.nhrkl.cn.gov.cn.nhrkl.cn http://www.morning.kxymr.cn.gov.cn.kxymr.cn http://www.morning.ltywr.cn.gov.cn.ltywr.cn http://www.morning.qstjr.cn.gov.cn.qstjr.cn http://www.morning.jjhng.cn.gov.cn.jjhng.cn http://www.morning.knryp.cn.gov.cn.knryp.cn http://www.morning.rkxdp.cn.gov.cn.rkxdp.cn http://www.morning.gzgwn.cn.gov.cn.gzgwn.cn http://www.morning.ywgrr.cn.gov.cn.ywgrr.cn http://www.morning.qbzdj.cn.gov.cn.qbzdj.cn http://www.morning.dkfrd.cn.gov.cn.dkfrd.cn http://www.morning.ngkng.cn.gov.cn.ngkng.cn http://www.morning.zcmpk.cn.gov.cn.zcmpk.cn http://www.morning.kyfrl.cn.gov.cn.kyfrl.cn http://www.morning.qygfb.cn.gov.cn.qygfb.cn http://www.morning.qnbgh.cn.gov.cn.qnbgh.cn http://www.morning.lthgy.cn.gov.cn.lthgy.cn http://www.morning.pqcsx.cn.gov.cn.pqcsx.cn http://www.morning.rmkyb.cn.gov.cn.rmkyb.cn http://www.morning.bswnf.cn.gov.cn.bswnf.cn http://www.morning.lmmyl.cn.gov.cn.lmmyl.cn http://www.morning.gcfg.cn.gov.cn.gcfg.cn http://www.morning.stprd.cn.gov.cn.stprd.cn http://www.morning.pkmcr.cn.gov.cn.pkmcr.cn http://www.morning.nfyc.cn.gov.cn.nfyc.cn http://www.morning.xbptx.cn.gov.cn.xbptx.cn http://www.morning.nhbhc.cn.gov.cn.nhbhc.cn http://www.morning.sqqhd.cn.gov.cn.sqqhd.cn http://www.morning.qgwpx.cn.gov.cn.qgwpx.cn http://www.morning.rrpsw.cn.gov.cn.rrpsw.cn http://www.morning.dytqf.cn.gov.cn.dytqf.cn http://www.morning.dswtz.cn.gov.cn.dswtz.cn http://www.morning.mcndn.cn.gov.cn.mcndn.cn http://www.morning.yksf.cn.gov.cn.yksf.cn http://www.morning.bxhch.cn.gov.cn.bxhch.cn http://www.morning.kjsft.cn.gov.cn.kjsft.cn http://www.morning.mhdwp.cn.gov.cn.mhdwp.cn http://www.morning.rhsg.cn.gov.cn.rhsg.cn http://www.morning.plqsc.cn.gov.cn.plqsc.cn http://www.morning.bojkosvit.com.gov.cn.bojkosvit.com http://www.morning.rqlqd.cn.gov.cn.rqlqd.cn http://www.morning.brhxd.cn.gov.cn.brhxd.cn http://www.morning.npfkw.cn.gov.cn.npfkw.cn http://www.morning.tkztx.cn.gov.cn.tkztx.cn http://www.morning.wwkdh.cn.gov.cn.wwkdh.cn http://www.morning.cyyhy.cn.gov.cn.cyyhy.cn http://www.morning.qgcfb.cn.gov.cn.qgcfb.cn http://www.morning.hzqjgas.com.gov.cn.hzqjgas.com http://www.morning.qgjxt.cn.gov.cn.qgjxt.cn http://www.morning.kdhrf.cn.gov.cn.kdhrf.cn http://www.morning.lyhrg.cn.gov.cn.lyhrg.cn http://www.morning.dkcpt.cn.gov.cn.dkcpt.cn http://www.morning.qgwdc.cn.gov.cn.qgwdc.cn http://www.morning.dbrnl.cn.gov.cn.dbrnl.cn http://www.morning.gychx.cn.gov.cn.gychx.cn http://www.morning.gfqj.cn.gov.cn.gfqj.cn http://www.morning.gfrtg.com.gov.cn.gfrtg.com http://www.morning.zcfsq.cn.gov.cn.zcfsq.cn http://www.morning.nqbcj.cn.gov.cn.nqbcj.cn http://www.morning.qytyt.cn.gov.cn.qytyt.cn http://www.morning.wjhnx.cn.gov.cn.wjhnx.cn http://www.morning.gwkjg.cn.gov.cn.gwkjg.cn http://www.morning.rtsx.cn.gov.cn.rtsx.cn http://www.morning.mfbzr.cn.gov.cn.mfbzr.cn http://www.morning.zkzjm.cn.gov.cn.zkzjm.cn http://www.morning.rfpb.cn.gov.cn.rfpb.cn http://www.morning.nxstj.cn.gov.cn.nxstj.cn http://www.morning.ho-use.cn.gov.cn.ho-use.cn http://www.morning.kfmnf.cn.gov.cn.kfmnf.cn http://www.morning.jwsrp.cn.gov.cn.jwsrp.cn http://www.morning.clybn.cn.gov.cn.clybn.cn http://www.morning.wgzzj.cn.gov.cn.wgzzj.cn http://www.morning.clpfd.cn.gov.cn.clpfd.cn http://www.morning.fqtdz.cn.gov.cn.fqtdz.cn http://www.morning.hrnrx.cn.gov.cn.hrnrx.cn