📄 mainframe.java
字号:
//工具栏<<就业>>标签
if(parm1.getSource()==lblTool[3])
{
Letter letter=new Letter();
cpMain.removeAll();
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(letter.pane,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
//工具栏<<统计>>标签
if(parm1.getSource()==lblTool[4])
{
try
{
TongJi tj=new TongJi();
cpMain.removeAll();
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(tj.pane,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}catch(ParseException e){}
} //工具栏<<系统>>标签
if(parm1.getSource()==lblTool[5])
{
cpMain.removeAll();
paneSys.removeAll();
paneSys.add(txtTemp[0],BorderLayout.NORTH);
paneSys.add(txtTemp[1],BorderLayout.WEST);
paneSys.add(txtTemp[2],BorderLayout.SOUTH);
paneSys.add(txtTemp[3],BorderLayout.EAST);
paneSys.add(paneSystem,BorderLayout.CENTER);
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(paneSys,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
//工具栏<<系统>>标签
if(parm1.getSource()==lblTool[6])
{
new About();
}
//注册用户
if(parm1.getSource()==lblSystem[0])
{
if(admi==1)
{
cpMain.removeAll();
paneSys.removeAll();
paneSys.add(txtTemp[0],BorderLayout.NORTH);
paneSys.add(txtTemp[1],BorderLayout.WEST);
paneSys.add(txtTemp[2],BorderLayout.SOUTH);
paneSys.add(txtTemp[3],BorderLayout.EAST);
paneSys.add(paneZhuce,BorderLayout.CENTER);
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(paneSys,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
else
JOptionPane.showMessageDialog(null,"您不是系统管理员,无权操作!!");
}
//更改密码
if(parm1.getSource()==lblSystem[1])
{
cpMain.removeAll();
paneSys.removeAll();
paneSys.add(txtTemp[0],BorderLayout.NORTH);
paneSys.add(txtTemp[1],BorderLayout.WEST);
paneSys.add(txtTemp[2],BorderLayout.SOUTH);
paneSys.add(txtTemp[3],BorderLayout.EAST);
//setchoice(choiceUpdate,"select * from 用户");
choiceUpdate.removeAll();
choiceUpdate.addItem(name);
paneSys.add(paneUpdate,BorderLayout.CENTER);
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(paneSys,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
//删除用户
if(parm1.getSource()==lblSystem[2])
{
if(admi==1)
{
cpMain.removeAll();
paneSys.removeAll();
paneSys.add(txtTemp[0],BorderLayout.NORTH);
paneSys.add(txtTemp[1],BorderLayout.WEST);
paneSys.add(txtTemp[2],BorderLayout.SOUTH);
paneSys.add(txtTemp[3],BorderLayout.EAST);
setchoice(choiceDel,"select * from 用户");
paneSys.add(paneDel,BorderLayout.CENTER);
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(paneSys,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
else
JOptionPane.showMessageDialog(null,"您不是系统管理员,无权操作!!");
}
//重新登陆
if(parm1.getSource()==lblSystem[3])
{
setchoice(choice,"select * from 用户");
pass.setText("");
dialog.show();
}
}
public void mouseReleased(MouseEvent parm1) {
// TODO: Add your code here
}
public void mouseEntered(MouseEvent parm1)
{
//工具栏鼠标进入事件代码
for(int i=0;i<7;i++)
{
if(parm1.getSource()==lblTool[i])
lblTool[i].setBorder(BorderFactory.createLoweredBevelBorder());
}
for(int i=0;i<4;i++)
{
if(parm1.getSource()==lblSystem[i])
lblSystem[i].setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.blue));
}
}
public void mouseExited(MouseEvent parm1)
{
//工具栏鼠标离开事件代码
for(int i=0;i<7;i++)
{
if(parm1.getSource()==lblTool[i])
lblTool[i].setBorder(BorderFactory.createRaisedBevelBorder());
}
for(int i=0;i<4;i++)
{
if(parm1.getSource()==lblSystem[i])
lblSystem[i].setBorder(BorderFactory.createMatteBorder(2,2,2,2,Color.orange));
}
}
public void actionPerformed(ActionEvent parm1)
{
if(parm1.getSource()==cmd[0])
{
String s1=choice.getSelectedItem();
String s2=pass.getText();
DataBase db=new DataBase();
db.GetResultSet("select * from 用户 where 用户名 ='"+s1+"'");
try
{
db.rs.next();
if(db.rs.getString(2).equalsIgnoreCase(s2)==false)
{
JOptionPane.showMessageDialog(dialog,"密码错误");
pass.setText("");
}
else
{
dialog.dispose();
name=s1;
if(s1.equalsIgnoreCase("系统管理员")==false)
{
admi=0;
}
else
admi=1;
}
}catch(SQLException e){}
}
if(parm1.getSource()==cmd[1])
{
int op=JOptionPane.showConfirmDialog(dialog,"确定要退出吗?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
System.exit(0);
}
}
//注册确认
if(parm1.getSource()==cmdZhuce[0])
{
String s1=txtZhuce[0].getText();
String s2=txtZhuce[1].getText();
String s3=txtZhuce[2].getText();
if(s1.equalsIgnoreCase("")==true)
JOptionPane.showMessageDialog(txtZhuce[0],"用户名不能为空!!!");
else
if(s2.equalsIgnoreCase(s3)==false)
{
JOptionPane.showMessageDialog(txtZhuce[2],"密码确认错误!!!");
txtZhuce[2].setText("");
txtZhuce[1].setText("");
}
else
{
int flag=0;
int op=JOptionPane.showConfirmDialog(null,"确定要注册该用户吗?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
DataBase db=new DataBase();
db.GetResultSet("select * from 用户 ");
try
{
db.rs.moveToInsertRow();
db.rs.updateString(1,s1);
db.rs.updateString(2,s2);
db.rs.insertRow();
db.st.close();
}catch(SQLException e)
{
JOptionPane.showMessageDialog(txtZhuce[0],"用户名重复!!!");
txtZhuce[0].setText("");
flag=1;
}
if(flag==0)
{
JOptionPane.showMessageDialog(txtZhuce[2],"用户注册成功!!!");
for(int i=0;i<3;i++)
txtZhuce[i].setText("");
}
}
}
}
//注册返回
if(parm1.getSource()==cmdZhuce[1])
{
cpMain.removeAll();
paneSys.removeAll();
paneSys.add(txtTemp[0],BorderLayout.NORTH);
paneSys.add(txtTemp[1],BorderLayout.WEST);
paneSys.add(txtTemp[2],BorderLayout.SOUTH);
paneSys.add(txtTemp[3],BorderLayout.EAST);
paneSys.add(paneSystem,BorderLayout.CENTER);
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(paneSys,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
//更新确认
if(parm1.getSource()==cmdUpdate[0])
{
String s1=choiceUpdate.getSelectedItem().toString().trim();
String s2=txtUpdate[0].getText();
String s3=txtUpdate[1].getText();
if(s2.equalsIgnoreCase(s3)==false)
{
JOptionPane.showMessageDialog(txtUpdate[1],"新密码确认错误!!!");
txtUpdate[0].setText("");
txtUpdate[1].setText("");
}
else
{
int op=JOptionPane.showConfirmDialog(null,"确定要更改密码吗?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
DataBase db=new DataBase();
db.GetResultSet("select * from 用户 where 用户名 ='"+s1+"'");
try
{
db.rs.next();
db.rs.updateString(2,s2);
db.rs.updateRow();
db.st.close();
}catch(SQLException e)
{
}
JOptionPane.showMessageDialog(txtZhuce[2],"密码更改成功!!!");
for(int i=0;i<2;i++)
txtZhuce[i].setText("");
}
}
}
//更新返回
if(parm1.getSource()==cmdUpdate[1])
{
cpMain.removeAll();
paneSys.removeAll();
paneSys.add(txtTemp[0],BorderLayout.NORTH);
paneSys.add(txtTemp[1],BorderLayout.WEST);
paneSys.add(txtTemp[2],BorderLayout.SOUTH);
paneSys.add(txtTemp[3],BorderLayout.EAST);
paneSys.add(paneSystem,BorderLayout.CENTER);
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(paneSys,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
//删除确认
if(parm1.getSource()==cmdDel[0])
{
String s1=choiceDel.getSelectedItem().toString().trim();
if(s1.equalsIgnoreCase("系统管理员")==true)
JOptionPane.showMessageDialog(choiceDel,"系统管理员不能删除!!!");
else
{
int op=JOptionPane.showConfirmDialog(null,"确定要删除该用户吗?","提示",JOptionPane.YES_NO_OPTION);
if(op==JOptionPane.YES_OPTION)
{
DataBase db=new DataBase();
db.GetResultSet("select * from 用户");
try
{
db.st.execute("delete * from 用户 where 用户名 = '"+s1+"'");
}catch(SQLException e){}
JOptionPane.showMessageDialog(txtZhuce[2],"该用户已经删除!!!");
cpMain.removeAll();
paneSys.removeAll();
paneSys.add(txtTemp[0],BorderLayout.NORTH);
paneSys.add(txtTemp[1],BorderLayout.WEST);
paneSys.add(txtTemp[2],BorderLayout.SOUTH);
paneSys.add(txtTemp[3],BorderLayout.EAST);
setchoice(choiceDel,"select * from 用户");
paneSys.add(paneDel,BorderLayout.CENTER);
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(paneSys,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
}
}
//删除返回
if(parm1.getSource()==cmdDel[1])
{
cpMain.removeAll();
paneSys.removeAll();
paneSys.add(txtTemp[0],BorderLayout.NORTH);
paneSys.add(txtTemp[1],BorderLayout.WEST);
paneSys.add(txtTemp[2],BorderLayout.SOUTH);
paneSys.add(txtTemp[3],BorderLayout.EAST);
paneSys.add(paneSystem,BorderLayout.CENTER);
cpMain.add(barMain,BorderLayout.NORTH);
cpMain.add(paneSys,BorderLayout.CENTER);
cpMain.setVisible(false);
cpMain.setVisible(true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -