?? people.java
字號(hào):
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記 ");
int cout=0;
try
{
while(db.rs.next())
{
cout++;
if(db.rs.getString(1).equalsIgnoreCase(s))
break;
}
pane.removeAll();
pane.setLayout(new BorderLayout());
pane.add(barPeople,BorderLayout.WEST);
pane.add(panePeople,BorderLayout.CENTER);
getinfo(cout);
pane.setVisible(false);
pane.setVisible(true);
}catch(SQLException e){}
}
}catch(Exception e){}
}
public void mousePressed(MouseEvent parm1)
{
if(parm1.getSource()==lblImage)
{
chooser=new JFileChooser();
JFrame ff=new JFrame();
int result=chooser.showDialog(ff,"文件選擇");
File file=chooser.getSelectedFile();
String s=file.toString();
ImageIcon ico=new ImageIcon(s);
lblImage.setIcon(ico);
}
//首條記錄
if(parm1.getSource()==lblTool[0])
getinfo(1);
//末條記錄
if(parm1.getSource()==lblTool[1])
{
try
{
String s=txtPeople[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記");
int cout=0;
while(db.rs.next())
{
cout++;
}
getinfo(cout);
db.st.close();
}catch(SQLException e){}
}
//前條記錄
if(parm1.getSource()==lblTool[2])
{
try
{
String s=txtPeople[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記");
int cout=0;
while(db.rs.next())
{
cout++;
if(db.rs.getString(1).trim().equalsIgnoreCase(s)==true)
break;
}
getinfo(cout-1);
db.st.close();
}catch(SQLException e){}
}
//后條記錄
if(parm1.getSource()==lblTool[3])
{
try
{
String s=txtPeople[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記");
int cout=0;
while(db.rs.next())
{
cout++;
if(db.rs.getString(1).trim().equalsIgnoreCase(s)==true)
break;
}
getinfo(cout+1);
}catch(SQLException e){}
}
//新增記錄
if(parm1.getSource()==lblTool[4])
{
clear();
}
//保存記錄
if(parm1.getSource()==lblTool[5])
{
int flag=1;
int op=JOptionPane.showConfirmDialog(null,"確定要添加這條記錄嗎?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
try
{
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記");
db.rs.moveToInsertRow();
for(int i=0;i<16;i++)
db.rs.updateString(db.rsmd.getColumnName(i+1),txtPeople[i].getText().trim());
for(int i=0;i<4;i++)
db.rs.updateString(db.rsmd.getColumnCount()-4+i,areaPeople[i].getText().trim());
String str=lblImage.getIcon().toString();
db.rs.updateString(db.rsmd.getColumnCount(),str);
db.rs.insertRow();
db.st.close();
}
catch(SQLException e)
{
JOptionPane.showMessageDialog(null,"單位編號(hào)重復(fù)");
txtPeople[0].setText("");
flag=0;
}
if(flag==1)
{
JOptionPane.showMessageDialog(null,"記錄添加成功!!!","提示",JOptionPane.WARNING_MESSAGE);
}
}
else
JOptionPane.showMessageDialog(null,"該記錄添加失敗!!!","警告",JOptionPane.WARNING_MESSAGE);
}
//更新記錄
if(parm1.getSource()==lblTool[6])
{
int op=JOptionPane.showConfirmDialog(null,"確定要更新這條記錄嗎?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
try
{
String s=txtPeople[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記 where 編號(hào) = '"+s+"'");
db.rs.next();
for(int i=0;i<16;i++)
db.rs.updateString(db.rsmd.getColumnName(i+1),txtPeople[i].getText().trim());
for(int i=0;i<4;i++)
db.rs.updateString(db.rsmd.getColumnCount()-4+i,areaPeople[i].getText().trim());
String str=lblImage.getIcon().toString();
db.rs.updateString(db.rsmd.getColumnCount(),str);
db.rs.updateRow();
db.st.close();
}catch(Exception e){}
JOptionPane.showMessageDialog(null,"記錄已經(jīng)更新!!!");
}
else
JOptionPane.showMessageDialog(null,"記錄更新失敗!!!");
}
//刪除記錄
if(parm1.getSource()==lblTool[7])
{
int op=JOptionPane.showConfirmDialog(null,"確定要?jiǎng)h除這條記錄嗎?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
try
{
String s=txtPeople[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記");
db.st.execute("delete from 人才登記 where 編號(hào) = "+"'"+s+"'");
db.st.close();
}catch(Exception e){}
clear();
JOptionPane.showMessageDialog(null,"該記錄已經(jīng)刪除!!!","提示",JOptionPane.WARNING_MESSAGE);
}
else
JOptionPane.showMessageDialog(null,"該記錄刪除失敗!!!","警告",JOptionPane.WARNING_MESSAGE);
}
//更多條件
if(parm1.getSource()==lblMore)
{
pane.removeAll();
pane.add(paneTable,BorderLayout.CENTER);
pane.setVisible(false);
pane.setVisible(true);
}
//返回標(biāo)簽
if(parm1.getSource()==lblBack)
{
pane.removeAll();
pane.setLayout(new BorderLayout());
pane.add(barPeople,BorderLayout.WEST);
pane.add(panePeople,BorderLayout.CENTER);
getinfo(1);
pane.setVisible(false);
pane.setVisible(true);
}
}
public void mouseReleased(MouseEvent parm1) {
// TODO: Add your code here
}
public void mouseEntered(MouseEvent parm1)
{
//工具條鼠標(biāo)進(jìn)入事件
for(int i=0;i<8;i++)
{
if(parm1.getSource()==lblTool[i])
{
lblTool[i].setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red));
}
}
if(parm1.getSource()==lblMore)
{
lblMore.setForeground(Color.red);
}
if(parm1.getSource()==lblBack)
{
lblBack.setBorder(BorderFactory.createMatteBorder(0,0,1,0,Color.blue));
}
}
public void mouseExited(MouseEvent parm1)
{
//工具條鼠標(biāo)離開事件
for(int i=0;i<8;i++)
{
if(parm1.getSource()==lblTool[i])
lblTool[i].setBorder(null);
}
if(parm1.getSource()==lblMore)
{
lblMore.setForeground(Color.blue);
}
if(parm1.getSource()==lblBack)
{
lblBack.setBorder(null);
}
}
public void insertUpdate(DocumentEvent parm1)
{
//簡(jiǎn)單查詢
if(parm1.getDocument()==txtSimple.getDocument())
{
try
{
String s1=choiceSimple.getSelectedItem().trim();
String s2=txtSimple.getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記 where "+s1+" like "+"'%"+s2+"%'");
db.rs.next();
for(int i=0;i<db.rsmd.getColumnCount()-4;i++)
txtPeople[i].setText(db.rs.getString(i+1));
for(int i=0;i<4;i++)
areaPeople[i].setText(db.rs.getString(db.rsmd.getColumnCount()-4+i));
String s=db.rs.getString(db.rsmd.getColumnCount());
ImageIcon ico=new ImageIcon(s);
lblImage.setIcon(ico);
db.st.close();
}
catch(SQLException e){}
}
//////////一級(jí)查詢
if(parm1.getDocument()==txtTable[0].getDocument())
{
String s1=choice[0].getSelectedItem().trim();
String s2=txtTable[0].getText().trim();
getmodel("select * from 人才登記 where "+s1+" like"+" '%"+s2+"%'",0);
lockMore.tableOne.setModel(model);
getmodel("select * from 人才登記 where "+s1+" like"+" '%"+s2+"%'",3);
lockMore.tableTwo.setModel(model);
}
//////////二級(jí)查詢
if(parm1.getDocument()==txtTable[1].getDocument())
{
String s1=choice[0].getSelectedItem().trim();
String s2=txtTable[0].getText().trim();
String s3=choice[1].getSelectedItem().trim();
String s4=choice[2].getSelectedItem().trim();
String s5=txtTable[1].getText();
getmodel("select * from 人才登記 where "+s1+" like"+" '%"+s2+"%' "+s3+" "+s4+" like"+" '%"+s5+"%' ",0);
lockMore.tableOne.setModel(model);
getmodel("select * from 人才登記 where "+s1+" like"+" '%"+s2+"%' "+s3+" "+s4+" like"+" '%"+s5+"%' ",3);
lockMore.tableTwo.setModel(model);
}
}
public void removeUpdate(DocumentEvent parm1)
{
//簡(jiǎn)單查詢
if(parm1.getDocument()==txtSimple.getDocument())
{
try
{
String s1=choiceSimple.getSelectedItem().trim();
String s2=txtSimple.getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 人才登記 where "+s1+" like "+"'%"+s2+"%'");
db.rs.next();
for(int i=0;i<db.rsmd.getColumnCount()-4;i++)
txtPeople[i].setText(db.rs.getString(i+1));
for(int i=0;i<4;i++)
areaPeople[i].setText(db.rs.getString(db.rsmd.getColumnCount()-4+i));
String s=db.rs.getString(db.rsmd.getColumnCount());
ImageIcon ico=new ImageIcon(s);
lblImage.setIcon(ico);
db.st.close();
}
catch(SQLException e){}
}
//////////一級(jí)查詢
if(parm1.getDocument()==txtTable[0].getDocument())
{
String s1=choice[0].getSelectedItem().trim();
String s2=txtTable[0].getText().trim();
getmodel("select * from 人才登記 where "+s1+" like"+" '%"+s2+"%'",0);
lockMore.tableOne.setModel(model);
getmodel("select * from 人才登記 where "+s1+" like"+" '%"+s2+"%'",3);
lockMore.tableTwo.setModel(model);
}
//////////二級(jí)查詢
if(parm1.getDocument()==txtTable[1].getDocument())
{
String s1=choice[0].getSelectedItem().trim();
String s2=txtTable[0].getText().trim();
String s3=choice[1].getSelectedItem().trim();
String s4=choice[2].getSelectedItem().trim();
String s5=txtTable[1].getText();
getmodel("select * from 人才登記 where "+s1+" like"+" '%"+s2+"%' "+s3+" "+s4+" like"+" '%"+s5+"%' ",0);
lockMore.tableOne.setModel(model);
getmodel("select * from 人才登記 where "+s1+" like"+" '%"+s2+"%' "+s3+" "+s4+" like"+" '%"+s5+"%' ",3);
lockMore.tableTwo.setModel(model);
}
}
public void changedUpdate(DocumentEvent parm1) {
// TODO: Add your code here
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -