⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 returnframe.java

📁 本系统的设计模拟一般学校特别是高校的图书借阅管理内容
💻 JAVA
字号:
/* * Copyright (c) 2006 guodongping. All  Rights Reserved. *  * E-mail: yayajike_0305@163.com * QQ:     445938759 *///package library;import java.awt.Dimension;import java.awt.Rectangle;import javax.swing.JPanel;import java.sql.ResultSet;import java.sql.SQLException;/*** This code was generated using CloudGarden's Jigloo* SWT/Swing GUI Builder, which is free for non-commercial* use. If Jigloo is being used commercially (ie, by a corporation,* company or business for any purpose whatever) then you* should purchase a license for each developer using Jigloo.* Please visit www.cloudgarden.com for details.* Use of Jigloo implies acceptance of these licensing terms.* ************************************** A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED* for this machine, so Jigloo or this code cannot be used legally* for any corporate or commercial purpose.* **************************************/import java.awt.GridBagLayout;import java.awt.BorderLayout;import javax.swing.JLabel;import javax.swing.JButton;import javax.swing.JOptionPane;import javax.swing.JTextField;import java.awt.Insets;import java.awt.GridBagConstraints;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;import java.sql.Connection;/** * @author guodongping * 创建日期 2006-1-15 * 还书界面 */public class ReturnFrame extends javax.swing.JInternalFrame {	private JPanel jPanel1;	private JTextField idText;	private JTextField nameText;	private JButton okButton;	private JLabel jLabel2;	private JLabel jLabel1;	public ReturnFrame() {		super(" 还书",true,true,true,true);		initGUI();	}		private void initGUI() {		try {						setPreferredSize(new Dimension(400, 300));			setBounds(new Rectangle(0, 0, 400, 300));			setVisible(true);			{				jPanel1 = new JPanel();				GridBagLayout jPanel1Layout = new GridBagLayout();				jPanel1Layout.columnWidths = new int[] {7,7};				jPanel1Layout.rowHeights = new int[] {7,7,7};				jPanel1Layout.columnWeights = new double[] {0.05,0.1};				jPanel1Layout.rowWeights = new double[] {0.1,0.1,0.1};				this.getContentPane().add(jPanel1, BorderLayout.CENTER);				jPanel1.setLayout(jPanel1Layout);				{					jLabel1 = new JLabel();					jPanel1.add(jLabel1, new GridBagConstraints(						0,						0,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));					jLabel1.setText("书名:");				}				{					jLabel2 = new JLabel();					jPanel1.add(jLabel2, new GridBagConstraints(						0,						1,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));					jLabel2.setText("读者号:");				}				{					okButton = new JButton();					jPanel1.add(okButton, new GridBagConstraints(						1,						2,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));					okButton.setText("还书");					okButton.addActionListener(new ActionListener() {						public void actionPerformed(ActionEvent evt) {							okPressed();							//TODO add your code for okButton.actionPerformed						}					});				}				{					nameText = new JTextField(15);					jPanel1.add(nameText, new GridBagConstraints(						1,						0,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));				}				{					idText = new JTextField(15);					jPanel1.add(idText, new GridBagConstraints(						1,						1,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));				}			}		} catch (Exception e) {			e.printStackTrace();		}	}		private void okPressed(){		if( nameText.getText()!="" && idText.getText()!="" ){			try{				Bridge bridge = new Bridge();				DbManage manage = new DbManage();				ResultSet rs ,rs1,rs2;				Connection conn = bridge.getConnection( );				manage.setStatement( conn );				String sql = "select * from reserve where book_name =\'"+nameText.getText()+"\'";				rs = manage.executeQuery(sql);				if( !rs.next() ){					sql = "select * from book where book_name =\'"+nameText.getText()+"\'";					rs = manage.executeQuery( sql );					if( !rs.next()||rs.getString("status").equals("可借") ){						JOptionPane.showMessageDialog(null,"还书失败!","错误",JOptionPane.ERROR_MESSAGE);					}					else{						ResultSet s;						sql = "update book set status ='可借',user_id='',borrow_date='' where book_name =\'"+nameText.getText()+"\'";						manage.executeUpdate( sql );						sql = "select * from user where user_id=\'"+idText.getText()+"\'";						s = manage.executeQuery(sql);						s.next();						int inhand = s.getInt("inhand");						--inhand;						sql = "update user set inhand=\'"+inhand+"\' where user_id=\'"+idText.getText()+"\'";						manage.executeUpdate(sql);						JOptionPane.showMessageDialog(null,"还书成功!","恭喜",JOptionPane.INFORMATION_MESSAGE);						s.close();					}				}				else{					String name = rs.getString("user_id");					sql = "update book set status ='可借',user_id='',borrow_date='' where book_name =\'"+nameText.getText()+"\'";					manage.executeUpdate( sql );					sql = "select * from user where user_id=\'"+idText.getText()+"\'";					rs1 = manage.executeQuery(sql);					rs1.next();					int inhand = rs1.getInt("inhand");					--inhand;					sql = "update user set inhand=\'"+inhand+"\' where user_id=\'"+idText.getText()+"\'";					manage.executeUpdate(sql);					sql = "delete from reserve where book_name= \'"+nameText.getText()+"\'";					manage.executeDelete(sql);					JOptionPane.showMessageDialog(null,"还书成功!\n用户"+name+"预定了此书","提示",JOptionPane.INFORMATION_MESSAGE);				}			}			catch(SQLException ex)			{				JOptionPane.showMessageDialog(null,ex.toString(),"错误",JOptionPane.WARNING_MESSAGE);				ex.printStackTrace();			}			}		else			JOptionPane.showInternalMessageDialog(this,"请填写完整!","错误",JOptionPane.WARNING_MESSAGE);	}		/**	* Auto-generated method for setting the popup menu for a component	*/	private void setComponentPopupMenu(		final java.awt.Component parent,		final javax.swing.JPopupMenu menu) {		parent.addMouseListener(new java.awt.event.MouseAdapter() {			public void mousePressed(java.awt.event.MouseEvent e) {				if (e.isPopupTrigger())					menu.show(parent, e.getX(), e.getY());			}			public void mouseReleased(java.awt.event.MouseEvent e) {				if (e.isPopupTrigger())					menu.show(parent, e.getX(), e.getY());			}		});	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -