📄 letter.java
字号:
dt.st.execute("update 介绍信 set 成功标志 = '1' where 编号 = "+"'"+tname+"'");
dt.st.close();
}
catch(SQLException e){}
}
else
{
DataBase dt=new DataBase();
try
{
dt.GetResultSet("select * from 介绍信 ");
dt.st.execute("update 介绍信 set 成功标志 = '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,"单位编号重复");
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,"记录已经更新!!!");
}
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,"该记录已经删除!!!","提示",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);
}
//返回标签
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)
{
//工具条鼠标进入事件
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)
{
//工具条鼠标离开事件
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
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -