This is the 22nd day of my participation in the August More Text Challenge

Preface:

This project is to use Java swing development, which can realize the restaurant order system login/register/reset to restaurant meals, the administrator can information management, add a package, the package information maintenance, modification, and to track the status of order, order information processing, process control, query and modify the password, cancel to exit the and so on several big modules. Users can log in to view the package information. Order operation and view order status, brief introduction of interface design, suitable for Java beginners design and learning technology.

Abstract:

With the development of the catering industry in our country, because the restaurant industry threshold is low, most of China’s food and beverage enterprise boss started in a shop, the majority of family management, many or the “rule of man”, did not have a set of modern enterprise system and the supervision and management system, so from concept, management thought and management level has yet to be professional. With the improvement of people’s living standard, the catering industry plays an increasingly important role in the service industry. Striving to stand out in the increasingly fierce competition in the current catering industry has become the goal pursued by every catering operator. Network ordering has realized the cost-effectiveness of small stores as big as to solve the problem of small stores and can not improve the turnover, is a small investment big effect of the new business model. Today, after the popularization of computers, China has entered the Internet information age, and the way of life and the pace of work have become rapid with the speed of information transmission. From mail delivery to Email, from traditional telephone communication to IP telephone network, all the behaviors originally belonging to the real life are slowly transferred to the network, traditional shopping is also developing to the network, the emergence of “online shopping”, a more and more popular new consumption way. Similarly, as a pillar of the service industry, the catering industry inevitably tends to network development.

Main modules:

User login, registration, and reset

Administrator: package information maintenance, query, modify and delete operations, order information query, modify process status, modify password, etc

Client: view package information, order operation, view order status, modify password, etc

Function screenshots:

Log in to register

Add package information

The administrator click Add package information, input relevant information, select pictures and so on to complete the addition

Add result:

Description Succeeded in adding a data to the database

Package information maintenance:

The administrator can enter the package maintenance page, perform fuzzy data query according to the package name and price range, and modify or delete the package by selecting the package information

Order Management:

The administrator can enter the order management page, query the order data and status process according to the order information, and modify the transportation status of the order

 

Change password:

Enter the old password. After the authentication succeeds, enter the new password twice to change the password

User order page:

Add to shopping cart:

Order submission success:

 

View order status and cancel order operations:

Some key codes:

User login registration:

/** * User login module **@author admin
 */
public class LogOnFrm extends javax.swing.JFrame {

	DbUtil dbUtil = new DbUtil();
	UserDao userDao = new UserDao();
	public static User s_currentUser = null;// Save the login user's parameters

	/** Creates new form LogOnFrm */
	public LogOnFrm(a) {
		// Change the system default font
		Font font = new Font("Dialog", Font.PLAIN, 12);
		java.util.Enumeration keys = UIManager.getDefaults().keys();
		while (keys.hasMoreElements()) {
			Object key = keys.nextElement();
			Object value = UIManager.get(key);
			if (value instanceof javax.swing.plaf.FontUIResource) {
				UIManager.put(key, font);
			}
		}
		initComponents();
		// Center the frame display
		this.setLocationRelativeTo(null);
	}


	// Login verification displays the interface after login
	private void jb_logonActionPerformed(java.awt.event.ActionEvent evt) {
		String userName = this.userNameTxt.getText();
		String password = new String(this.passwordTxt.getPassword());
		if (StringUtil.isEmpty(userName)) {
			JOptionPane.showMessageDialog(null."User name cannot be empty");
			return;
		}
		if (StringUtil.isEmpty(password)) {
			JOptionPane.showMessageDialog(null."Password cannot be empty.");
			return;
		}
		User user = new User(userName, password);
		Connection con = null;
		try {
			con = dbUtil.getCon();
			User currentUser = userDao.login(con, user);
			if(currentUser ! =null) {
				s_currentUser = currentUser;// Save the login user
				int role = currentUser.getRank();
				if (role == 1) {
					this.dispose();
					new AdminFrm().setVisible(true);// Go to the administrator page
				} else if (role == 0) {
					this.dispose();
					new UserOrderFrm().setVisible(true);// The user ordering interface is displayed}}else {
				JOptionPane.showMessageDialog(null."Wrong username or password"); }}catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			JOptionPane.showMessageDialog(null."Wrong username or password");
		} finally {
			try {
				dbUtil.closeCon(con);
			} catch (Exception e) {
				// TODO Auto-generated catch blocke.printStackTrace(); }}}/ * * *@param args
	 *  the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run(a) {
				new LogOnFrm().setVisible(true); }}); }// GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JButton jb_logon;
	private javax.swing.JButton jb_register;
	private javax.swing.JButton jb_reset;
	private javax.swing.JPasswordField passwordTxt;
	private javax.swing.JTextField userNameTxt;
	// End of variables declaration//GEN-END:variables

}
Copy the code

Add package information:

/** * add ** to package@author admin
 */
public class GoodsAddInterFrm extends javax.swing.JInternalFrame {

	DbUtil dbUtil = new DbUtil();
	GoodsDao goodsDao = new GoodsDao();

	/** Creates new form GoodsAddInterFrm */
	public GoodsAddInterFrm(a) {
		initComponents();
		this.setLocation(200.80);

	}

	private void jb_addActionPerformed(java.awt.event.ActionEvent evt) {
		String goodsName = this.goodsNameTxt.getText();
		String goodsDesc = this.goodsDescTxt.getText();
		String price = this.priceTxt.getText();
		String imageLink = this.imageLinkTxt.getText();
		if (StringUtil.isEmpty(goodsName)) {
			JOptionPane.showMessageDialog(null."The package name cannot be empty!");
			return;
		}
		if (StringUtil.isEmpty(price)) {
			JOptionPane.showMessageDialog(null."Package price cannot be empty!");
			return;
		}
		if(! StringUtil.isNum(price)) { JOptionPane.showMessageDialog(null."Please re-enter package price!");
			return;
		}
		Goods goods = new Goods(goodsName, goodsDesc, Float.parseFloat(price), imageLink);
		Connection con = null;
		try {
			con = dbUtil.getCon();
			int n = goodsDao.GoodsAdd(con, goods);
			if (n == 1) {
				JOptionPane.showMessageDialog(null."Package added successfully");
				this.resetValues();
			} else {
				JOptionPane.showMessageDialog(null."Failed to add package"); }}catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			JOptionPane.showMessageDialog(null."Failed to add package 2"); }}// Click select image operation
	private void jb_chooserActionPerformed(java.awt.event.ActionEvent evt) {
		JFileChooser chooser = new JFileChooser();// Create file dialog box
		FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG & GIF Images"."jpg"."gif");// Create a file filter
		chooser.setFileFilter(filter);// Set the file filter for the file dialog box
		int returnValue = chooser.showOpenDialog(getParent());// Open the file selection dialog box
		if (returnValue == JFileChooser.APPROVE_OPTION) { // Check whether the file is selected
			File file = chooser.getSelectedFile(); // Get the file object
			/ * * the if (file. The length () / 1024.0 > 50.0) {* JOptionPane. ShowMessageDialog (null, "please select less than or equal to 50 KB image files." ); return; *} * /
			String picturePath = file.getAbsolutePath();// Get the path
			// System.out.println(picturePath);
			Icon icon = new ImageIcon(picturePath);// Create a new icon
			this.iamgeLb.setIcon(icon);// Set the image and display it
			this.imageLinkTxt.setText(picturePath);// The text box displays the path}}}Copy the code

Query order record:

/** **@author admin
 */
public class CheckOrderInterFrm extends javax.swing.JInternalFrame {
	private static final JTable j_orderTable = null;
	DbUtil dbUtil = new DbUtil();
	OrderDao orderDao = new OrderDao();
	GoodsDao goodsDao = new GoodsDao();

	/** Creates new form checkOrderInterFrm */
	public CheckOrderInterFrm(a) {
		initComponents();
		this.setLocation(320.100);
		this.userNameTxt.setText(LogOnFrm.s_currentUser.getUserName());
	}

	// GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents(a) {

		jScrollPane2 = new javax.swing.JScrollPane();
		cartTable = new javax.swing.JTable();
		jLabel2 = new javax.swing.JLabel();
		totalNumTxt = new javax.swing.JTextField();
		totalMoneyTxt = new javax.swing.JTextField();
		jLabel1 = new javax.swing.JLabel();
		jLabel3 = new javax.swing.JLabel();
		orderStatusTxt = new javax.swing.JTextField();
		jb_status = new javax.swing.JButton();
		jLabel4 = new javax.swing.JLabel();
		userNameTxt = new javax.swing.JTextField();
		jLabel5 = new javax.swing.JLabel();
		orderIdTxt = new javax.swing.JTextField();
		jb_search = new javax.swing.JButton();
		jScrollPane1 = new javax.swing.JScrollPane();
		orderTable = new javax.swing.JTable();
		jPanel2 = new javax.swing.JPanel();
		iamgeLb = new javax.swing.JLabel();

		setClosable(true);
		setIconifiable(true);
		setTitle("\u67e5\u770b\u8ba2\u5355");

		
	/ / fill ordertable
	private void fillOrderTable(a) {
		String orderId = this.orderIdTxt.getText();
		String userName = this.userNameTxt.getText();
		Order order = new Order();
		order.setOrderId(orderId);
		order.setUserName(userName);
		DefaultTableModel dtm = (DefaultTableModel) orderTable.getModel();
		dtm.setRowCount(0);
		Connection con = null;
		try {
			con = dbUtil.getCon();
			ResultSet rs = orderDao.orderList(con, order);
			while (rs.next()) {
				Vector v = new Vector();
				v.add(rs.getString("orderId"));
				v.add(rs.getInt("orderNum"));
				v.add(rs.getFloat("orderTotalMoney"));
				int status = rs.getInt("orderStatus");
				switch (status) {
				case 0:
					v.add("Not processed");
					break;
				case 1:
					v.add("Cooking");
					break;
				case 2:
					v.add("Served");
					break;
				case 3:
					v.add("Paid");
					break;
				case 4:
					v.add("Cancelled");
					break; } 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 blocke.printStackTrace(); }}}// Click order table
	private void orderTableMousePressed(java.awt.event.MouseEvent evt) {
		// Get the selected row
		int row = orderTable.getSelectedRow();
		String orderId = (String) orderTable.getValueAt(row, 0);
		this.totalNumTxt.setText(orderTable.getValueAt(row, 1) + "");// Convert int, float to string
		this.totalMoneyTxt.setText(orderTable.getValueAt(row, 2) + "");
		String orderStatus = (String) orderTable.getValueAt(row, 3);
		this.orderStatusTxt.setText(orderStatus);
		this.iamgeLb.setIcon(null);
		// Change the status of the cancel button
		if(! orderStatus.equals("Not processed")) {
			jb_status.setEnabled(false);
		} else {
			jb_status.setEnabled(true);
		}
		Order order = new Order();
		order.setOrderId(orderId);
		DefaultTableModel dtm = (DefaultTableModel) cartTable.getModel();
		dtm.setRowCount(0);
		Connection con = null;
		try {
			con = dbUtil.getCon();
			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 blocke.printStackTrace(); }}}// Click to query the order
	private void jb_searchActionPerformed(java.awt.event.ActionEvent evt) { fillOrderTable(); }}Copy the code

Database design:

Set table:

CREATE TABLE `NewTable` (
`id`  int(10) NOT NULL AUTO_INCREMENT ,
`goodsName`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`price`  float NULL DEFAULT NULL ,
`goodsDesc`  varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`imageLink`  varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=17
ROW_FORMAT=DYNAMIC
;
Copy the code

Order Package Table:

CREATE TABLE `NewTable` (
`id`  int(10) NOT NULL AUTO_INCREMENT ,
`orderId`  varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`goodsTotalPrice`  float NULL DEFAULT NULL ,
`goodsId`  int(10) NULL DEFAULT NULL ,
`goodsPrice`  float NULL DEFAULT NULL ,
`goodsNum`  int(10) NULL DEFAULT NULL ,
`goodsName`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`id`),
INDEX `FK_order_goods_2` (`orderId`) USING BTREE ,
INDEX `FK_order_goods_1` (`goodsId`) USING BTREE 
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=48
ROW_FORMAT=DYNAMIC
;
Copy the code

Cashier table:

CREATE TABLE `NewTable` (
`id`  int(11) NOT NULL AUTO_INCREMENT ,
`type`  varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'type' ,
`money`  varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'value' ,
`remarks`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'note' ,
`time`  varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'Creation time' ,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=8
ROW_FORMAT=DYNAMIC
;
Copy the code

Order Information Sheet:

CREATE TABLE `NewTable` (
`orderId`  varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`orderStatus`  int(10) NULL DEFAULT NULL ,
`orderNum`  int(10) NULL DEFAULT NULL ,
`orderTotalMoney`  float NULL DEFAULT NULL ,
`userName`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`orderId`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
ROW_FORMAT=DYNAMIC
;
Copy the code

User information table:

CREATE TABLE `NewTable` (
`id`  int(10) NOT NULL AUTO_INCREMENT ,
`userName`  varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`password`  varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`email`  varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`rank`  int(1) NULL DEFAULT 0 ,
PRIMARY KEY (`id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=11
ROW_FORMAT=DYNAMIC
;
Copy the code

Conclusion:

Through this course design. I learned a lot of knowledge which benefited me a lot. It feels like Java interface design is similar to MFC. It’s just that Java is too much work without a visual interface. Others are mostly class and object problems. It’s pretty simple to implement. Using a database mysql with high stability and security, the two software together to complete the design and development of the system. Also fully consider the needs of users,. The operator can query all the information at any time, and each module provides the information browsing function. This system realizes the online ordering system website consumption customers can search through the system to their own needs of the package information, buy their own needs of the package, online order. And then by the online ordering system background to deal with the relevant order information, such as information. Due to my lack of knowledge and experience and short time in the development process, there will be some defects and deficiencies in the system. In the future, more efforts will be made to improve this system, but it is still a good choice as a reference for students and curriculum design.

Javascript project updates 8/100

Everyone can like, like, follow and comment on me now