?? letter.java
字號:
dt.st.execute("update 介紹信 set 成功標(biāo)志 = '1' where 編號 = "+"'"+tname+"'");
dt.st.close();
}
catch(SQLException e){}
}
else
{
DataBase dt=new DataBase();
try
{
dt.GetResultSet("select * from 介紹信 ");
dt.st.execute("update 介紹信 set 成功標(biāo)志 = '0' where 編號 = "+"'"+tname+"'");
dt.st.close();
}
catch(SQLException e){}
}
}
//表格選中行的顯示代碼
try
{
if(parm1.getClickCount()==2&&(parm1.getSource()==lockMore.tableTwo||parm1.getSource()==lockMore.tableOne))
{
Point pt=parm1.getPoint();
int row=lockMore.tableOne.rowAtPoint(pt);
String s=lockMore.tableOne.getValueAt(row,1).toString();
DataBase db=new DataBase();
db.GetResultSet("select * from 介紹信 ");
int cout=0;
try
{
while(db.rs.next())
{
cout++;
if(db.rs.getString(2).equalsIgnoreCase(s))
break;
}
pane.removeAll();
pane.setLayout(new BorderLayout());
pane.add(barLetter,BorderLayout.WEST);
pane.add(paneLetter,BorderLayout.CENTER);
getinfo(cout);
pane.setVisible(false);
pane.setVisible(true);
}catch(SQLException e){}
}
}catch(Exception e){}
}
public void mousePressed(MouseEvent parm1)
{
//首條記錄
if(parm1.getSource()==lblTool[0])
getinfo(1);
//末條記錄
if(parm1.getSource()==lblTool[1])
{
try
{
String s=txtMinxi[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=txtMinxi[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 介紹信");
int cout=0;
while(db.rs.next())
{
cout++;
if(db.rs.getString(2).trim().equalsIgnoreCase(s)==true)
break;
}
getinfo(cout-1);
db.st.close();
}catch(SQLException e){}
}
//后條記錄
if(parm1.getSource()==lblTool[3])
{
try
{
String s=txtMinxi[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 介紹信");
int cout=0;
while(db.rs.next())
{
cout++;
if(db.rs.getString(2).trim().equalsIgnoreCase(s)==true)
break;
}
getinfo(cout+1);
}catch(SQLException e){}
}
//新增記錄
if(parm1.getSource()==lblTool[4])
{
for(int i=0;i<16;i++)
txtMinxi[i].setText("");
lblTool[5].setEnabled(true);
lblTool[6].setEnabled(false);
}
//保存記錄
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();
db.rs.updateString(db.rsmd.getColumnName(1),"0");
for(int i=2;i<=17;i++)
db.rs.updateString(db.rsmd.getColumnName(i),txtMinxi[i-2].getText().trim());
db.rs.insertRow();
db.st.close();
}
catch(SQLException e)
{
JOptionPane.showMessageDialog(null,"單位編號重復(fù)");
txtMinxi[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=txtMinxi[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 介紹信 where 編號 = '"+s+"'");
db.rs.next();
for(int i=2;i<=db.rsmd.getColumnCount();i++)
db.rs.updateString(i,txtMinxi[i-2].getText().trim());
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,"確定要刪除這條記錄嗎?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
try
{
String s=txtMinxi[0].getText().trim();
DataBase db=new DataBase();
db.GetResultSet("select * from 介紹信");
db.st.execute("delete from 介紹信 where 編號 = "+"'"+s+"'");
db.st.close();
}catch(Exception e){}
for(int i=0;i<16;i++)
txtMinxi[i].setText("");
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(barLetter,BorderLayout.WEST);
pane.add(paneLetter,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)進入事件
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)
{
//簡單查詢
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=2;i<=db.rsmd.getColumnCount();i++)
txtMinxi[i-2].setText(db.rs.getString(i));
db.st.close();
}
catch(SQLException e){}
}
//////////一級查詢
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(model2);
}
//////////二級查詢
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(model2);
}
}
public void removeUpdate(DocumentEvent parm1)
{
//簡單查詢
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=2;i<=db.rsmd.getColumnCount();i++)
txtMinxi[i-2].setText(db.rs.getString(i));
db.st.close();
}
catch(SQLException e){}
}
//////////一級查詢
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(model2);
}
//////////二級查詢
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(model2);
}
}
public void changedUpdate(DocumentEvent parm1) {
// TODO: Add your code here
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -