📄 pnlbookmanage_modify.java
字号:
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import java.sql.ResultSet;
public class PnlBookManage_Modify extends JPanel {
FrmBook fm;
public PnlBookManage_Modify(FrmBook f) {
fm=f;
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(null);
jLabel1.setText("编号:");
jLabel1.setBounds(new Rectangle(18, 13, 39, 30));
txtNumber.setBounds(new Rectangle(57, 13, 92, 30));
jLabel2.setText("书名:");
jLabel2.setBounds(new Rectangle(169, 17, 41, 23));
txtName.setBounds(new Rectangle(206, 13, 92, 30));
jLabel3.setText("作者:");
jLabel3.setBounds(new Rectangle(316, 10, 40, 34));
txtAuthor.setText("");
txtAuthor.setBounds(new Rectangle(363, 13, 92, 30));
jLabel4.setText("价格:");
jLabel4.setBounds(new Rectangle(16, 62, 30, 28));
txtPrice.setBounds(new Rectangle(58, 61, 91, 30));
jLabel5.setText("出版社:");
jLabel5.setBounds(new Rectangle(161, 59, 46, 30));
txtPublish.setText("");
txtPublish.setBounds(new Rectangle(205, 55, 152, 30));
jLabel6.setText("入库日期:");
jLabel6.setBounds(new Rectangle(16, 106, 53, 26));
txtAddDate.setBounds(new Rectangle(67, 102, 115, 30));
jLabel7.setText("是否在库:");
jLabel7.setBounds(new Rectangle(192, 101, 60, 36));
txtIsExist.setBounds(new Rectangle(263, 106, 92, 30));
btnModify.setBounds(new Rectangle(382, 50, 75, 38));
btnModify.setText("修改");
btnModify.addActionListener(new
PnlBookManage_Modify_btnModify_actionAdapter(this));
btnReturn.setBounds(new Rectangle(382, 97, 75, 38));
btnReturn.setText("返回");
btnReturn.addActionListener(new
PnlBookManage_Modify_btnReturn_actionAdapter(this));
this.add(txtNumber);
this.add(jLabel2);
this.add(txtName);
this.add(txtAuthor);
this.add(jLabel1);
this.add(jLabel3);
this.add(jLabel4);
this.add(txtPrice);
this.add(jLabel5);
this.add(jLabel6);
this.add(txtAddDate);
this.add(txtPublish);
this.add(txtIsExist);
this.add(jLabel7);
this.add(btnModify);
this.add(btnReturn);
/*
txtNumber.setText( FrmBook.SearchContent.get(0).toString());
txtName.setText( FrmBook.SearchContent.get(1).toString());
txtAuthor.setText( FrmBook.SearchContent.get(2).toString());
txtPrice.setText( FrmBook.SearchContent.get(3).toString());
txtPublish.setText( FrmBook.SearchContent.get(4).toString());
txtAddDate.setText( FrmBook.SearchContent.get(5).toString());
txtIsExist.setText( FrmBook.SearchContent.get(6).toString());
*/
/**
* 在文本框显示要修改的内容
*/
ArrayList arr=new ArrayList();
arr=bookadd_condb.ShowModifyData(pnlBookManage_ModifyToSearch.txtNumber.getText());
txtNumber.setText( arr.get(0).toString());
txtName.setText( arr.get(1).toString());
txtAuthor.setText( arr.get(2).toString());
txtPrice.setText( arr.get(3).toString());
txtPublish.setText( arr.get(4).toString());
txtAddDate.setText( arr.get(5).toString());
txtIsExist.setText( arr.get(6).toString());
}
JLabel jLabel1 = new JLabel();
JTextField txtNumber = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField txtName = new JTextField();
JLabel jLabel3 = new JLabel();
JTextField txtAuthor = new JTextField();
JLabel jLabel4 = new JLabel();
JTextField txtPrice = new JTextField();
JLabel jLabel5 = new JLabel();
JTextField txtPublish = new JTextField();
JLabel jLabel6 = new JLabel();
JTextField txtAddDate = new JTextField();
JLabel jLabel7 = new JLabel();
JTextField txtIsExist = new JTextField();
JButton btnModify = new JButton();
JButton btnReturn = new JButton();
public void btnReturn_actionPerformed(ActionEvent e) {
pnlBookManage_ModifyToSearch bms=new pnlBookManage_ModifyToSearch(fm);
fm.spnV.setTopComponent(bms);
bookadd_condb.initSearch();
bookadd_condb.initInfo(fm.tblData,bookadd_condb.rs);
ResultSet rstemp=bookadd_condb.rsBook();
String tab="bookinfo";
fm.DataPane(rstemp,tab);
fm.page=0;
}
public void btnModify_actionPerformed(ActionEvent e) {
int re=JOptionPane.showConfirmDialog(fm,"是否真的要修改","确认",JOptionPane.INFORMATION_MESSAGE);
if(re==0)
{
String str = pnlBookManage_ModifyToSearch.txtNumber.getText();
bookadd_condb.Modify(str, txtNumber.getText(), txtName.getText(),
txtAuthor.getText(),
Integer.parseInt(txtPrice.getText()),
txtPublish.getText(), txtAddDate.getText(),
Integer.parseInt(txtIsExist.getText()));
}
bookadd_condb.initSearch();
bookadd_condb.initInfo(fm.tblData,bookadd_condb.rs);
ResultSet rstemp=bookadd_condb.rsBook();
String tab="bookinfo";
fm.DataPane(rstemp,tab);
fm.page=0;
}
}
class PnlBookManage_Modify_btnModify_actionAdapter implements ActionListener {
private PnlBookManage_Modify adaptee;
PnlBookManage_Modify_btnModify_actionAdapter(PnlBookManage_Modify adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnModify_actionPerformed(e);
}
}
class PnlBookManage_Modify_btnReturn_actionAdapter implements ActionListener {
private PnlBookManage_Modify adaptee;
PnlBookManage_Modify_btnReturn_actionAdapter(PnlBookManage_Modify adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnReturn_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -