?? 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 + -