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

📄 borrowframe.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 java.util.*;/*** 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 javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import java.awt.Insets;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import javax.swing.JLabel;import java.awt.BorderLayout;import java.sql.Connection;import java.sql.ResultSet;import javax.swing.JButton;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;/** * @author guodongping * 创建日期 2006-1-14 * 借书界面 */public class BorrowFrame extends javax.swing.JInternalFrame {	private JPanel jPanel1;	private JButton borrowButton;	private JTextField noText;	private JLabel jLabel3;	private JLabel statusText;	private JLabel jLabel2;	private JButton queryButton;	private JTextField nameText;	private JLabel jLabel1;	public BorrowFrame() {		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.columnWeights = new double[] {0.05,0.15,0.05};				jPanel1Layout.columnWidths = new int[] {7,7,7};				jPanel1Layout.rowWeights = new double[] {0.1,0.1,0.1};				jPanel1Layout.rowHeights = new int[] {7,7,7};				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("书号:");				}				{					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));				}				{					queryButton = new JButton();					jPanel1.add(queryButton, new GridBagConstraints(						2,						0,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));					queryButton.setText("查询");					queryButton.addActionListener(new ActionListener() {						public void actionPerformed(ActionEvent evt) {							queryPressed();							//TODO add your code for queryButton.actionPerformed						}					});				}				{					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("状态:");				}				{					statusText = new JLabel();					jPanel1.add(statusText, new GridBagConstraints(						1,						1,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));				}				{					jLabel3 = new JLabel();					jPanel1.add(jLabel3, new GridBagConstraints(						0,						2,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));					jLabel3.setText("读者号:");				}				{					noText = new JTextField(15);					jPanel1.add(noText, new GridBagConstraints(						1,						2,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));				}				{					borrowButton = new JButton();					jPanel1.add(borrowButton, new GridBagConstraints(						2,						2,						1,						1,						0.0,						0.0,						GridBagConstraints.CENTER,						GridBagConstraints.NONE,						new Insets(0, 0, 0, 0),						0,						0));					borrowButton.setText("借阅");					borrowButton.setEnabled(false);					borrowButton.addActionListener(new ActionListener() {						public void actionPerformed(ActionEvent evt) {							borrowPressed();							//TODO add your code for borrowButton.actionPerformed						}					});				}			}		} catch (Exception e) {			e.printStackTrace();		}	}		private void queryPressed(){		if(nameText.getText()==""){			JOptionPane.showInternalMessageDialog(null,"请输入书名!","错误",JOptionPane.WARNING_MESSAGE);		}		else{			try{				Bridge bridge = new Bridge();				DbManage manage = new DbManage();				ResultSet rs ;				//Connection conn = bridge.getConnection( );				//manage.setStatement( conn );				String sqlCommand = "select count(*) as\'rcount\' from book where book_id=\'"+				nameText.getText()+"\' and status ='1'";				MySQL ms=new MySQL("sa","",null,sqlCommand);				//rs = manage.executeQuery(sqlCommand);				rs=ms.search();				int num;				if(!rs.next())					num=0;				else					num = rs.getInt("rcount");				String status = String.valueOf(num)+"本可借";				statusText.setText(status);				if(num!=0){					borrowButton.setEnabled(true);				}				rs.close();			}			catch(Exception e){				e.printStackTrace();				JOptionPane.showMessageDialog(null,e.toString(),"错误",JOptionPane.WARNING_MESSAGE);					}		}	}		private void borrowPressed(){		if(noText.getText()==""){			JOptionPane.showMessageDialog(null,"请输入读者号!","错误",JOptionPane.WARNING_MESSAGE);		}		else{			try{				Bridge bridge = new Bridge();				DbManage manage = new DbManage();				ResultSet rs ;				Connection conn = bridge.getConnection( );				manage.setStatement( conn );				String sqlCommand = "select * from buser where user_id=\'"+noText.getText()+"\'";				rs = manage.executeQuery(sqlCommand);				rs.next();				int sum = rs.getInt("sum");				int inhand = rs.getInt("inhand");				++sum;				++inhand;				sqlCommand = "update buser set sum=\'"+sum+"\',inhand=\'"+				             inhand+"\' where user_id =\'"+noText.getText()+"\'";				manage.executeUpdate(sqlCommand);				MySQL ms=new MySQL("sa","",null,sqlCommand);				//rs = manage.executeQuery(sqlCommand);				ms.input();				Date d = new Date();				String date = d.toString();				sqlCommand = "update book set status='0', user_id=\'"+noText.getText()+"\',borrow_date=\'"+				            date+"\' where book_name=\'"+nameText.getText()+"\'";				 MySQL ms2=new MySQL("sa","",null,sqlCommand);				//rs = manage.executeQuery(sqlCommand);				ms2.input();				//manage.executeUpdate( sqlCommand );				JOptionPane.showMessageDialog(null,"借阅完成!","",JOptionPane.INFORMATION_MESSAGE);			}			catch(Exception e){				e.printStackTrace();				JOptionPane.showMessageDialog(null,e.toString(),"错误",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 + -