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

📄 borrower.java

📁 用eclipse编写的图书管理系统
💻 JAVA
字号:
package client;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;
import javax.swing.WindowConstants;
import com.swtdesigner.SwingResourceManager;

import sever.business.iface.ILibrarianInfoIface;
import sever.business.impl.IlibrarianInfoImpl;
import sever.dao.BorrowInfoDAO;
import sever.db.ConnectionDB;
import sever.entity.BookInfo;

public class Borrower extends JFrame{

	private JTextArea textArea;
	private JTextField textField_1;
	private JComboBox comboBox;
	private JTextField textField;
	private JFrame frame;
	ImageIcon image=new ImageIcon("E:\\image\\10.JPG");
	ImageIcon image2=new ImageIcon("E:\\image\\11.JPG");
	ImageIcon image3=new ImageIcon("E:\\image\\12.JPG");
	ImageIcon image4=new ImageIcon("E:\\image\\2.JPG");
	ImageIcon image5=new ImageIcon("E:\\image\\7.JPG");
	ImageIcon image6=new ImageIcon("E:\\image\\one.JPG");
	ResultSet rs;

	/**
	 * Launch the application
	 * @param args
	 */
//	public static void main(String args[]) {
//		try {
//			Borrower window = new Borrower();
//			window.setVisible(true);
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}

	public Borrower() {
		new JFrame();
		getContentPane().setLayout(null);
		setTitle("借阅查询");
		getContentPane().setFont(new Font("@黑体", Font.PLAIN, 14));
		setBounds(190, 135, 481,479 );
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);


		final JLabel label = new JLabel();
		label.setFont(new Font("@黑体", Font.PLAIN, 14));
		label.setText("按书名查询");
		label.setBounds(81, 37, 72, 28);
		getContentPane().add(label);

		textField = new JTextField();
		textField.setBounds(182, 42, 149, 20);
		getContentPane().add(textField);
                                                                                //退出未设置
		final JLabel label_1 = new JLabel();
		label_1.setFont(new Font("@黑体", Font.PLAIN, 14));
		label_1.setText("按类别查询");
		label_1.setBounds(81, 88, 72, 28);
		getContentPane().add(label_1);

		comboBox = new JComboBox();
		comboBox.setFont(new Font("@黑体", Font.PLAIN, 14));
		
		comboBox.setBounds(182, 91, 149, 23);
		
		getContentPane().add(comboBox);
		comboBox.addItem("请选择类别");
		comboBox.addItem("计算机类");
		comboBox.addItem("经典著作类");
		comboBox.addItem("科学教育类");
		comboBox.addItem("社会科学类");
		comboBox.addItem("哲学类");
		comboBox.addItem("文学理论类");
		
		

		final JLabel label_2 = new JLabel();
		label_2.setFont(new Font("@黑体", Font.PLAIN, 14));
		label_2.setText("按编号查询");
		label_2.setBounds(81, 143, 72, 28);
		getContentPane().add(label_2);

		textField_1 = new JTextField();
		textField_1.setBounds(182, 148, 149, 20);
		getContentPane().add(textField_1);
		
		final JScrollPane scrollPane = new JScrollPane();
		scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		scrollPane.setBounds(20, 249, 430, 111);
		getContentPane().add(scrollPane);

		final JButton button = new JButton();
		button.setText("书名查询");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(textField.getText().length()==0){
					JOptionPane.showMessageDialog(null,"请输入书名");
				}
				else{
				ConnectionDB db=new ConnectionDB();
				try {
                     BookInfo book=new BookInfo();
                     book.setBookName(textField.getText().trim());
                     BorrowInfoDAO bif = new BorrowInfoDAO();
                     
                     ILibrarianInfoIface face=new IlibrarianInfoImpl();
                     
                     ResultSet rs=face.borrow(book);
                     ResultSetMetaData rsm=rs.getMetaData();
                     int count=rsm.getColumnCount();
                     
                   
                   
                     Vector row=new Vector();
					
					while(rs.next()){
						Vector cell=new Vector();
						cell.addElement(rs.getString(1));
						cell.addElement(rs.getString(2));
						cell.addElement(rs.getString(3));
						cell.addElement(rs.getInt(4));
						cell.addElement(rs.getInt(5));
						cell.addElement(rs.getInt(6));
						cell.addElement(rs.getString(7));
						cell.addElement(rs.getString(8));
						row.addElement(cell);
						
						String []h={"书名","作者","类型","编号","价格","数量","是否完好","入库时间"};
						
						Vector hh=new Vector();
						hh.addElement("书名");
						hh.addElement("作者");
						hh.addElement("类型");
						hh.addElement("编号");
						hh.addElement("价格");
						hh.addElement("数量");
						hh.addElement("是否完好");
						hh.addElement("入库时间");
						
			

						final JTable table = new JTable(row,hh);
						scrollPane.setViewportView(table);
						table.setEnabled(false);
						
					}
				} catch (SQLException e1) {
					e1.printStackTrace();
				}
				
				
				}
				
				
			}	
				
		});
		button.setFont(new Font("@黑体", Font.PLAIN, 14));
		button.setBounds(62, 202, 91, 23);
		getContentPane().add(button);
		
		final JScrollPane scrollPane1 = new JScrollPane();
		scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		scrollPane1.setBounds(20, 249, 430, 111);
		getContentPane().add(scrollPane1);

		final JButton button_1 = new JButton();
		button_1.setText("类别查询");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try {
                     BookInfo book=new BookInfo();
                     book.setBookTypes(comboBox.getSelectedItem().toString().trim());
                     BorrowInfoDAO bif = new BorrowInfoDAO();
                     
                     ILibrarianInfoIface face=new IlibrarianInfoImpl();
                     ResultSet rs=face.lookupType(book);
                     ResultSetMetaData rsm=rs.getMetaData();
                     int count=rsm.getColumnCount();
                     
                   
                   
                     Vector row=new Vector();
					
					while(rs.next()){
						Vector cell=new Vector();
						cell.addElement(rs.getString(1));
						cell.addElement(rs.getString(2));
						cell.addElement(rs.getString(3));
						cell.addElement(rs.getInt(4));
						cell.addElement(rs.getInt(5));
						cell.addElement(rs.getInt(6));
						cell.addElement(rs.getString(7));
						cell.addElement(rs.getString(8));
						row.addElement(cell);
						
						String []h={"书名","作者","类型","编号","价格","数量","是否完好","入库时间"};
						
						Vector hh=new Vector();
						hh.addElement("书名");
						hh.addElement("作者");
						hh.addElement("类型");
						hh.addElement("编号");
						hh.addElement("价格");
						hh.addElement("数量");
						hh.addElement("是否完好");
						hh.addElement("入库时间");
						


						final JTable table = new JTable(row,hh);
						scrollPane.setViewportView(table);
						table.setEnabled(false);
					}
				} catch (SQLException e1) {
					e1.printStackTrace();
				}

				
				
			}
		});
		button_1.setFont(new Font("@黑体", Font.PLAIN, 14));
		button_1.setBounds(186, 202, 91, 23);
		getContentPane().add(button_1);
		
		final JScrollPane scrollPane2 = new JScrollPane();
		scrollPane2.setAutoscrolls(true);
		scrollPane2.setDoubleBuffered(true);
		scrollPane2.setFocusCycleRoot(true);
		scrollPane2.setFocusTraversalPolicyProvider(true);
		scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
		scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		scrollPane2.setBounds(20, 249, 430, 111);
		getContentPane().add(scrollPane2);

		final JButton button_2 = new JButton();
		button_2.setText("编号查询");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(textField_1.getText().length()==0){
					JOptionPane.showMessageDialog(null,"请输入编号");
				}
				else{
				try {

                  BookInfo book=new BookInfo();
                  book.setBookNumber(Integer.parseInt(textField_1.getText().trim()));
                  BorrowInfoDAO bif = new BorrowInfoDAO();
                  
                  ILibrarianInfoIface face=new IlibrarianInfoImpl();
                  ResultSet rs=face.lookupNumber(book);
                  ResultSetMetaData rsm=rs.getMetaData();
                  int count=rsm.getColumnCount();
                  
                
                
                  Vector row=new Vector();
					
					while(rs.next()){
						Vector cell=new Vector();
						cell.addElement(rs.getString(1));
						cell.addElement(rs.getString(2));
						cell.addElement(rs.getString(3));
						cell.addElement(rs.getInt(4));
						cell.addElement(rs.getInt(5));
						cell.addElement(rs.getInt(6));
						cell.addElement(rs.getString(7));
						cell.addElement(rs.getString(8));
						row.addElement(cell);
						
						String []h={"书名","作者","类型","编号","价格","数量","是否完好","入库时间"};
						
						Vector hh=new Vector();
						hh.addElement("书名");
						hh.addElement("作者");
						hh.addElement("类型");
						hh.addElement("编号");
						hh.addElement("价格");
						hh.addElement("数量");
						hh.addElement("是否完好");
						hh.addElement("入库时间");
						


						final JTable table = new JTable(row,hh);
						scrollPane.setViewportView(table);
						table.setEnabled(false);
					}
				} catch (SQLException e1) {
					e1.printStackTrace();
				}
				}
			}
		});
		button_2.setFont(new Font("@黑体", Font.PLAIN, 14));
		button_2.setBounds(312, 202, 91, 23);
		getContentPane().add(button_2);

		final JLabel label_3 = new JLabel();
		label_3.setFont(new Font("@黑体", Font.PLAIN, 14));
		label_3.setText("结 果:");
		label_3.setBounds(20, 221, 36, 28);
		getContentPane().add(label_3);


		final JButton button_3 = new JButton();
		button_3.setText("重置");
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textField.setText("");
				textField_1.setText("");

				
			}
		});
		button_3.setFont(new Font("@黑体", Font.PLAIN, 14));
		button_3.setBounds(112, 366, 69, 25);
		getContentPane().add(button_3);

		final JButton button_4 = new JButton();
		button_4.setText("取消");
		button_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});
		
		button_4.setFont(new Font("@黑体", Font.PLAIN, 14));
		button_4.setBounds(283, 366, 69, 25);
		getContentPane().add(button_4);
		getContentPane().setBackground(new Color(224, 235, 237));
		setIconImage(SwingResourceManager.getImage(Borrower.class, "/LOGO.jpg"));


	}
	}

	/**
	 * Initialize the contents of the frame
	 */
	

⌨️ 快捷键说明

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