package com.view;
import java.awt.EventQueue;
import javax.swing.JInternalFrame;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import com.dao.BookDao;
import com.dao.BookTypeDao;
import com.model.Book;
import com.model.BookType;
import com.util.DbUtil;
import com.util.Stringutil;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Vector;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextArea;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class BookManageInterFrm extends JInternalFrame {
private JTable bookTable;
private JTextField s_bookNameTxt;
private JTextField s_authorTex;
private JComboBox s_bookTypejcb;
private JTextArea bookDescTxt;
private DbUtil dbUtil= new DbUtil();
private BookTypeDao bookTypeDao=new BookTypeDao();
private BookDao bookDao=new BookDao();
private JTextField idtxt;
private JTextField bookNametxt;
private JTextField authorTxt;
private JTextField priceTxt;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
BookManageInterFrm frame = new BookManageInterFrm();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public BookManageInterFrm() {
setIconifiable(true);
setClosable(true);
setTitle("\u56FE\u4E66\u7BA1\u7406");
setBounds(100, 100, 518, 459);
JScrollPane scrollPane = new JScrollPane();
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(null, "\u641C\u7D22\u6761\u4EF6", TitledBorder.LEADING, TitledBorder.TOP, null, null));
JPanel panel_1 = new JPanel();
panel_1.setBorder(new TitledBorder(null, "\u8868\u5355\u64CD\u4F5C", TitledBorder.LEADING, TitledBorder.TOP, null, null));
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
.addComponent(panel_1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
.addComponent(panel, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 478, GroupLayout.PREFERRED_SIZE)
.addComponent(scrollPane, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE))
.addContainerGap())
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(panel, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 122, GroupLayout.PREFERRED_SIZE)
.addGap(18)
.addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 165, Short.MAX_VALUE)
.addContainerGap())
);
JLabel lblNewLabel_3 = new JLabel("\u7F16\u53F7\uFF1A");
lblNewLabel_3.setFont(new Font("宋体", Font.BOLD, 14));
JLabel lblNewLabel_3_1 = new JLabel("\u56FE\u4E66\u540D\u79F0\uFF1A");
lblNewLabel_3_1.setFont(new Font("宋体", Font.BOLD, 14));
JLabel lblNewLabel_3_2 = new JLabel("\u4F5C\u8005\uFF1A");
lblNewLabel_3_2.setFont(new Font("宋体", Font.BOLD, 14));
idtxt = new JTextField();
idtxt.setEditable(false);
idtxt.setColumns(10);
bookNametxt = new JTextField();
bookNametxt.setColumns(10);
authorTxt = new JTextField();
authorTxt.setColumns(10);
JLabel lblNewLabel_3_3 = new JLabel("\u4EF7\u683C\uFF1A");
lblNewLabel_3_3.setFont(new Font("宋体", Font.BOLD, 14));
priceTxt = new JTextField();
priceTxt.setColumns(10);
JLabel lblNewLabel_3_3_1 = new JLabel("\u56FE\u4E66\u63CF\u8FF0\uFF1A");
lblNewLabel_3_3_1.setFont(new Font("宋体", Font.BOLD, 14));
bookDescTxt = new JTextArea();
JButton btnNewButton_1 = new JButton("\u4FEE\u6539");
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
bookUpdateActionPerformed(evt);
}
});
btnNewButton_1.setFont(new Font("宋体", Font.BOLD, 14));
JButton btnNewButton_1_1 = new JButton("\u5220\u9664");
btnNewButton_1_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
bookDeleteAction(e);
}
});
btnNewButton_1_1.setFont(new Font("宋体", Font.BOLD, 14));
GroupLayout gl_panel_1 = new GroupLayout(panel_1);
gl_panel_1.setHorizontalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addContainerGap()
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addComponent(lblNewLabel_3_3_1)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(bookDescTxt, GroupLayout.PREFERRED_SIZE, 302, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_1.createSequentialGroup()
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addComponent(lblNewLabel_3)
.addComponent(lblNewLabel_3_3, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(ComponentPlacement.RELATED)
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING, false)
.addComponent(priceTxt)
.addComponent(idtxt, GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(lblNewLabel_3_1)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(bookNametxt, GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)
.addGap(18)
.addComponent(lblNewLabel_3_2, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addComponent(authorTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(btnNewButton_1, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE)
.addComponent(btnNewButton_1_1, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE))
.addGap(59))
);
gl_panel_1.setVerticalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addContainerGap()
.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel_3_1, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)
.addComponent(idtxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(bookNametxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(lblNewLabel_3)
.addComponent(lblNewLabel_3_2, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)
.addComponent(authorTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addPreferredGap(ComponentPlacement.UNRELATED)
.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNe