theme: condensed-night-purple highlight: a11y-dark

This is the 18th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021″

🍅 author home page: Java Li Yangyong access to source code contact

Preface:

This project is the use of Java Swing development, can realize the warehouse management system login/registration/reset, login can be system management, raw material management, finished product management, management records and logout exit several modules. Interface design introduction, suitable for Java beginners design and learning technology use.

Abstract:

Nowadays, many enterprises have problems: insufficient information technology, low computer utilization rate, a large number of daily work are handled by hand, so low work efficiency, poor internal communication and other problems are difficult to overcome. In order to enhance the competitiveness of enterprises, internal informatization is an indispensable step. Therefore, it is necessary to implement advanced automation system to realize internal information management, sharing and communication, so that enterprises can get the first opportunity in the fierce competition in the 21st century. Warehouse management system is to plan and control the flow of goods and information as well as money. It will be warehousing, warehousing, warehousing to form a unified whole, so that the enterprise is in a comprehensive state of control, compression of investment scale, speed up capital turnover. On the basis of real-time reflection, the deviation in each link of the daily production and operation process of the enterprise is corrected to reduce the cost of finished products and the backlog of goods. This design is a basic warehouse management system, the program function is relatively simple, close to the reality. The system has carried on the effective management to the common business activities such as out of the warehouse, in the warehouse, inventory management and the relevant basic information such as suppliers. Therefore, it has universal applicability and can meet the needs of general enterprise warehouse. This system uses MySQL database management software and MySQL as the development platform of the system, and uses JavaSwing graphical programming language for program development.

 

Main modules:

User login, registration, and reset

Raw material management: raw material entry, raw material return, raw material inventory, production billing, production return, production waste

Finished product management: Finished product entry, Finished product inventory, Finished product Return, Finished product repair, Finished product return

Record management: Operation record, scrap record, shipment record, raw material record, finished product record

Help Center: Help, About, Exit system

Function screenshots:

The login

System home Page Function

System management:

On the system management page, you can register new users, delete users, and organize and view data

Raw material management:

Raw material management: including raw material entry, raw material return, raw material inventory, production billing, production return, production waste and other data entry and check

Finished product management:

Finished product management: including finished product entry, finished product inventory, finished product return, finished product repair, finished product return data entry and check operation, etc

Records Management:

Records management: including operation records, scrap records, shipping records, raw material records, finished product records of the data check operation

Other:

 

Some key codes:

User login registration:

public class Logo implements ActionListener{
	public static final String logoon = "Login";
	public static final String helpt = "Help";
	public static final String logooff ="Quit";
	public static final String user = "Users.";
	public static final String password = "The secret code.";
	private javax.swing.JTextField userText;
	private javax.swing.JPasswordField userpwd;
	private javax.swing.JPanel jp = new javax.swing.JPanel(){
		public void paintComponent(Graphics g){
			super.paintComponent(g);
			if(! isOpaque()){return; } Graphics2D g2d = (Graphics2D) g;//int rule = AlphaComposite.SRC_OVER;
			AlphaComposite opaque = AlphaComposite.SrcOver;
			/ / AlphaComposite blend = AlphaComposite. GetInstance (rule, 0.6 f);
			//AlphaComposite set = AlphaComposite.Src;
			int width = getWidth();
			int height = getHeight();
			GradientPaint gradientPaint = new GradientPaint(0.0,java.awt.Color.green,width/2,height/2,java.awt.Color.yellow,false);
			g2d.setComposite(opaque);
			g2d.setPaint(gradientPaint);
			g2d.fillRect(0.0, width,height); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF); }};private javax.swing.JButton logoin = null;
	private JFrame logo_Frame = new JFrame(logoon);
	Public Logo() {// TODO automatically generates constructor stubs} */
	public Logo(a){
		try{
			UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
		}catch(Exception exe){System.err.print(exe.getMessage()); } JFrame.setDefaultLookAndFeelDecorated(true);
		Toolkit tools = logo_Frame.getToolkit();
		Image logo = tools.getImage("res/logo.jpg");
		logo_Frame = new JFrame(logoon);
		logo_Frame.setIconImage(logo);
		
		
		jp.setLayout(new GridBagLayout());
		jp.setBackground(java.awt.Color.pink);
		javax.swing.ImageIcon pic = new javax.swing.ImageIcon("res/logo1.jpg");
		javax.swing.JLabel picture = new javax.swing.JLabel(pic);
		setupComponent(picture,0.0,GridBagConstraints.ABOVE_BASELINE_LEADING,1.true);
		javax.swing.JLabel users = new javax.swing.JLabel(user);
		setupComponent(users,0.1.1.1.false);
		javax.swing.JLabel pas = new javax.swing.JLabel(password);
		setupComponent(pas,0.2.1.1.false);
		userText = new javax.swing.JTextField(12);
		userText.requestFocus();
		userText.addKeyListener(new KeyListener(){
			public void keyTyped(KeyEvent e){}
			public void keyReleased(KeyEvent e){}
			public void keyPressed(KeyEvent e){
				if((e.getKeyChar() == KeyEvent.VK_ENTER )&&(userText.getText().trim() ! ="")){ userpwd.requestFocus(); }}}); setupComponent(userText,1.1.1.1.false);
		userpwd = new javax.swing.JPasswordField(12);
		userpwd.addKeyListener(new KeyListener(){
			public void keyTyped(KeyEvent e){}
			public void keyPressed(KeyEvent e){
				if((e.getKeyChar() == KeyEvent.VK_ENTER) && (userpwd.getText().trim() ! ="")){
					logoin.requestFocus();
				}
				else{ userpwd.requestFocus(); }}public void keyReleased(KeyEvent e){}}); setupComponent(userpwd,1.2.1.1.false);
		
		logoin = new javax.swing.JButton(logoon);
		logoin.addKeyListener(new KeyListener(){
			public void keyTyped(KeyEvent e){}
			public void keyReleased(KeyEvent e){}
			public void keyPressed(KeyEvent e){
				if((e.getKeyChar()==KeyEvent.VK_ENTER )){
					if(("".equals(userText.getText().trim())) ){
						javax.swing.JOptionPane.showMessageDialog(logo_Frame, "Username must be entered!"."Enter a user name",JOptionPane.ERROR_MESSAGE);
						userText.requestFocus();
						return;
					}
					if(("".equals(userpwd.getText().trim()))){
						javax.swing.JOptionPane.showMessageDialog(logo_Frame, "Password must be entered!"."Enter your password",JOptionPane.ERROR_MESSAGE);
						userpwd.requestFocus();
						return;
					}
					boolean b = USeDB.logoon(userText.getText().trim(), userpwd.getText().trim());
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					Date date = new Date(System.currentTimeMillis());
					String day = sdf.format(date);
					String s ="'"+day+"', '"+userText.getText().trim()+"', '"+"Login"+"'";
					String sql = "insert into handle_record values("+s+")";
					USeDB.UpdateDB(sql);
					if(b){
						logo_Frame.dispose();
						new My_MainFrame(userText.getText().trim());
					}
					userText.setText("");
					userpwd.setText(""); userText.requestFocus(); }}}); logoin.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				System.out.println(userText.getText());
				if(("".equals(userText.getText().trim()))){
					javax.swing.JOptionPane.showMessageDialog(logo_Frame, "Username must be entered!"."Enter a user name",JOptionPane.ERROR_MESSAGE);
					userText.requestFocus();
					return;
				}
				if(("".equals(userpwd.getText().trim()))){
					javax.swing.JOptionPane.showMessageDialog(logo_Frame, "Password must be entered!"."Enter your password",JOptionPane.ERROR_MESSAGE);
					userpwd.requestFocus();
					return;
				}
				if(userText.getText().trim()! =""&& userpwd.getText().trim()! ="") {boolean b = USeDB.logoon(userText.getText().trim(), userpwd.getText().trim());
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				Date date = new Date(System.currentTimeMillis());
				String day = sdf.format(date);
				String s ="'"+day+"', '"+userText.getText().trim()+"', '"+"Login"+"'";
				String sql = "insert into handle_record values("+s+")";
				USeDB.UpdateDB(sql);
				if(b==true){
					logo_Frame.dispose();
					new My_MainFrame(userText.getText().trim());
				}else{
					userText.setText("");
					userpwd.setText("");
					userText.requestFocus();
					javax.swing.JOptionPane.showMessageDialog(logo_Frame, "Wrong username or password"."Error message",JOptionPane.ERROR_MESSAGE); }}}}); setupComponent(logoin,0.3.1.1.true);
		
		javax.swing.JButton help = new javax.swing.JButton(helpt);
		
Copy the code

The DB connection:

public class DBUtil{
private static String dbUrl="jdbc:mysql://localhost:3307/stock_manager2? characterEncoding=utf8"; // Database connection address
	private static String dbUserName="root"; // user name, here is your mysql user name, usually root
	private static String dbPassword="crit@2019"; / / password, the mysql password, the password is empty, don't write to me is empty, so he didn't write
	private static String jdbcName="com.mysql.jdbc.Driver"; // Driver name
	//private static String driver="sun.jdbc.odbc.JdbcOdbcDriver"; // Declare the driver class string
	// Declare a database connection string
	//private static String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)}; DBQ=db/mydb.mdb";
	private static Connection con=null;// Declare a database connection object reference
	private static Statement stat=null;// Declare the statement object reference
	private static PreparedStatement psInsert=null;// Declare a precompiled statement object reference
	private static ResultSet rs=null;// Declare a result set object reference
	public DBUtil(a) {
		// TODO automatically generates constructor stubs}
	public static Connection getConnection(a){// Get the database connection method
		try{
			Class.forName(jdbcName);// Load the driver class
			con=DriverManager.getConnection(dbUrl,dbUserName,dbPassword);// Get the connection
		}
		catch(Exception e){e.printStackTrace(); }return con;// Return the connection
	}
	public static void closeCon(a){// Close the database connection method
		try{
			if(rs! =null){rs.close(); rs=null; }If the result set is not null, close the result set and assign null
			if(stat! =null){stat.close(); stat=null; }// Close the statement object and assign null if the statement object is not null
			if(con! =null){con.close(); con=null; }// Close the connection if it is not null and assign null
		}
		catch(Exception e){e.printStackTrace(); }}}Copy the code

Database design:

The users table:

CREATE TABLE `NewTable` (
`user_id`  int(11) NOT NULL AUTO_INCREMENT ,
`user_name`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`password`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`u_text`  longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
PRIMARY KEY (`user_id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=5
ROW_FORMAT=DYNAMIC
;
Copy the code

Raw material entry Form:

CREATE TABLE `NewTable` (
`product_ID`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`product_client`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`product_name`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`product_spec`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`product_unit`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`product_value`  float NULL DEFAULT NULL ,
`product_make`  varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stock_date`  datetime NULL DEFAULT NULL ,
`product_text`  longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
PRIMARY KEY (`product_ID`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
ROW_FORMAT=DYNAMIC
;
Copy the code

Shipment record Form:

CREATE TABLE `NewTable` (
`scrap_id`  int(11) NOT NULL AUTO_INCREMENT ,
`user_name`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`handle_date`  datetime NULL DEFAULT NULL ,
`scrap_text`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
PRIMARY KEY (`scrap_id`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=3
ROW_FORMAT=DYNAMIC
;
Copy the code

Waste Information Sheet:

CREATE TABLE `NewTable` (
`stuff_ID`  varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`stuff_name`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stuff_company`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stuff_people`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`check_people`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stuff_unit`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stuff_value`  int(11) NULL DEFAULT NULL ,
`stuff_spec`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stuff_color`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stuff_place`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`stock_date`  datetime NULL DEFAULT NULL ,
`stuff_text`  longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
PRIMARY KEY (`stuff_ID`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
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 operation of system management, raw material management, finished product management, and management records after the user logs in. Because OF my lack of knowledge and experience, and the short time in the development process, the system will have some defects and deficiencies. 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.

To obtain source code contact:

Everyone likes, favorites, follows, comments, check the author’s homepage: Java Li Yangyong to get contact

Clocked articles updated 105/365 days

** 👇🏻👇🏻 🏻👇 👇

Excellent practical case of Java Project 100 Sets