?? searchresultpanel.java
字號:
package src;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import db.Service;
public class SearchResultPanel extends JPanel
{
JTable table=null;
JPanel psave=new JPanel();
JButton save=new JButton("保存");
public SearchResultPanel(SearchResultModel model)
{
table=new JTable(model);
psave.add(save);
this.setLayout(new GridLayout(1,2));
save.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
List data=((SearchResultModel)table.getModel()).getStoringData();
for(int i=0;i<data.size();i++)
{
String[] row=(String[])data.get(i);
String insertSql="update book set sh='"+row[1]+"',sm='"+row[2]+"',zz='"+row[3]+"',cbs='"+row[4]+"',cbsj='"+row[5]+"' where id="+row[0];
try
{
Service.execute(insertSql, 1, -1);
}
catch (ClassNotFoundException e)
{
System.out.println("未找到驅動");
}
catch (SQLException e)
{
System.out.println("數據庫訪問異常");
}
}
JOptionPane.showMessageDialog(null,"保存成功","提示信息",JOptionPane.INFORMATION_MESSAGE);
}
});
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -