📄 mainframe.java
字号:
if(obj==PressItem)//出版社菜单事件
{new PressSetup();}
if(obj==StockItem)//存放位置菜单事件
{new StockAddress();}
if(obj==BookInfoItem)//图书资料菜单事件
{new BookInfomation();}
if(obj==ReaderBorrow)//借阅图书菜单事件
{new BorrowBook();}
if(obj==KeepBorrow)//续借图书菜单事件
{new RBorrowBook();}
if(obj==ReaderReturn)//归还图书菜单事件
{new ReturnBook();}
if(obj==LookBook) //图书挂失菜单事件
{new GuaShiBook();}
if(obj==TypeSetItem) //类型设置菜单事件
{new ReaderType();}
if(obj==EnableZheng) //有效证件菜单事件
{new EnabledZJ();}
if(obj==ReaderInfo) //读者信息菜单事件
{new ReaderInfomation();}
if(obj==LookZheng) //读者挂失菜单事件
{new ReaderManagement();}
if(obj==CancelLook) //解除挂失菜单事件
{new ReaderManagement();}
if(obj==XuZheng) //到期续证菜单事件
{new ReaderManagement();}
if(obj==BookInfoF) //图书信息查询菜单事件
{new BookInfomationF();}
if(obj==BorrowF) //借阅图书查询菜单事件
{new BorrowInfomationF();}
if(obj==ReturnF) //归还图书查询菜单事件
{new ReturnInfomationF();}
if(obj==GuaShiF) //挂失图书查询菜单事件
{new NotInfomationF();}
if(obj==ReaderInfoF) //读者信息查询菜单事件
{new ReaderInfomationF();}
if(obj==TBorrowF) //借阅图书信息菜单事件
{new TodayBorrowInfo();}
if(obj==TReturnF) //归还图书信息菜单事件
{new TodayReturnInfo();}
if(obj==DandCF) //到期/超期信息菜单事件
{new TodayDCInfo();}
if(obj==BBpm) //图书借阅排名菜单事件
{new BookBorrowPM();}
if(obj==RBpm) //读者借阅排名菜单事件
{new ReaderBorrowPM();}
if(obj==FKtj) //罚款统计菜单事件
{new Fktj();}
if(obj==SHelp)//系统帮助按钮事件
{new AboutSystem();}
if(obj==BggkBtn)//本馆概况按钮事件
{Jlb.setVisible(false);
String home=null;
try{
home="file:"
+System.getProperty("user.dir")
+System.getProperty("file.separator")
+"LibraryHome/bggk.html";
try
{tp.setPage(home);}
catch(IOException ioe)
{System.err.println("Attempted to read a bad URL:"+home);}
}
catch(Exception es)
{ System.err.println("Couldn't create help URL:"+home);}
contPane.setVisible(true);
}
if(obj==RyzcBtn)//人员组成按钮事件
{Jlb.setVisible(false);
String home2=null;
try{
home2="file:"
+System.getProperty("user.dir")
+System.getProperty("file.separator")
+"LibraryHome/ryzc.html";
try
{tp.setPage(home2);}
catch(IOException ioe)
{System.err.println("Attempted to read a bad URL:"+home2);}
}
catch(Exception es)
{ System.err.println("Couldn't create help URL:"+home2);}
contPane.setVisible(true);
}
if(obj==KgsjBtn)//开馆时间按钮事件
{Jlb.setVisible(false);
String home3=null;
try{
home3="file:"
+System.getProperty("user.dir")
+System.getProperty("file.separator")
+"LibraryHome/kgsj.html";
try
{tp.setPage(home3);}
catch(IOException ioe)
{System.err.println("Attempted to read a bad URL:"+home3);}
}
catch(Exception es)
{ System.err.println("Couldn't create help URL:"+home3);}
contPane.setVisible(true);
}
if(obj==GcfbBtn)//馆藏分布按钮事件
{Jlb.setVisible(false);
String home4=null;
try{
home4="file:"
+System.getProperty("user.dir")
+System.getProperty("file.separator")
+"LibraryHome/gcfb.html";
try
{tp.setPage(home4);}
catch(IOException ioe)
{System.err.println("Attempted to read a bad URL:"+home4);}
}
catch(Exception es)
{ System.err.println("Couldn't create help URL:"+home4);}
contPane.setVisible(true);
}
if(obj==GnbjBtn)//馆内布局按钮事件
{Jlb.setVisible(false);
String home5=null;
try{
home5="file:"
+System.getProperty("user.dir")
+System.getProperty("file.separator")
+"LibraryHome/gnbj.html";
try
{tp.setPage(home5);}
catch(IOException ioe)
{System.err.println("Attempted to read a bad URL:"+home5);}
}
catch(Exception es)
{ System.err.println("Couldn't create help URL:"+home5);}
contPane.setVisible(true);
}
if(obj==GzzdBtn)//规章制度按钮事件
{Jlb.setVisible(false);
String home6=null;
try{
home6="file:"
+System.getProperty("user.dir")
+System.getProperty("file.separator")
+"LibraryHome/gzzd.html";
try
{tp.setPage(home6);}
catch(IOException ioe)
{System.err.println("Attempted to read a bad URL:"+home6);}
}
catch(Exception es)
{ System.err.println("Couldn't create help URL:"+home6);}
contPane.setVisible(true);
}
if(obj==Xstb)//新书通报按钮事件
{new NewBookReport(); }
if(obj==Xsld)//新书亮点按钮事件
{Jlb.setVisible(false);
String home8=null;
try{
home8="file:"
+System.getProperty("user.dir")
+System.getProperty("file.separator")
+"LibraryHome/xsld.html";
try
{tp.setPage(home8);}
catch(IOException ioe)
{System.err.println("Attempted to read a bad URL:"+home8);}
}
catch(Exception es)
{ System.err.println("Couldn't create help URL:"+home8);}
contPane.setVisible(true);
}
if(obj==Xxfk)//信息反馈按钮事件
{new LookInformation();}
}
////////////////////////////////////////////////登录系统按钮代码///////////////////////////////////////////////
public void Login() throws SQLException
{ String user = Jtfld1.getText().trim();
String pass = Jtfld2.getText().trim();
String strurl =
"jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=DataBase/Library.mdb";
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch (ClassNotFoundException e) {}
con= DriverManager.getConnection(strurl);
Statement stmt = con.createStatement();
if (user.equals("")|| pass.equals(""))
JOptionPane.showMessageDialog(null, "用户名或密码不能为空", "警告",
JOptionPane.WARNING_MESSAGE);
else
{ ResultSet rs = stmt.executeQuery("select * from 用户资料 where 用户名='" +
user + "' AND 密码='" + pass + "'");
if(rs.next())
{
if (rs.getString("身份").equals(JCB.getSelectedItem()))
{ if(JCB.getSelectedIndex()==0)
{ JOptionPane.showMessageDialog(null, "登陆成功,欢迎进入商院图书馆管理系统!");
statusLB2.setText("用户身份:图书馆管理员");
MSystem.setEnabled(true);
ManagerItem.setEnabled(true);
FajinItem.setEnabled(true);
MSBook.setEnabled(true);
MBook.setEnabled(true);
MReader.setEnabled(true);
BookAccount.setEnabled(true);
TjpmMenu.setEnabled(true);
BookTypeItem.setEnabled(true);
PressItem.setEnabled(true);
StockItem.setEnabled(true);
BookInfoItem.setEnabled(true);
ReaderBorrow.setEnabled(true);
KeepBorrow.setEnabled(true);
ReaderReturn.setEnabled(true);
LookBook.setEnabled(true);
TypeSetItem.setEnabled(true);
EnableZheng.setEnabled(true);
ReaderInfo.setEnabled(true);
LookZheng.setEnabled(true);
CancelLook.setEnabled(true);
XuZheng.setEnabled(true);
Jtfld1.setEnabled(false);
Jtfld2.setEnabled(false);
JCB.setEnabled(false);
Ok_btn.setEnabled(false);
Register_btn.setEnabled(false);
Cancel_btn.setEnabled(false);
}
else if(JCB.getSelectedIndex()==1)
{ JOptionPane.showMessageDialog(null, "登陆成功,欢迎进入商院图书馆管理系统!");
statusLB2.setText("用户身份:教师");
MSystem.setEnabled(true);
ManagerItem.setEnabled(false);
FajinItem.setEnabled(false);
MSBook.setEnabled(true);
BookTypeItem.setEnabled(false);
PressItem.setEnabled(false);
StockItem.setEnabled(false);
MBook.setEnabled(true);
BookInfoItem.setEnabled(false);
ReaderBorrow.setEnabled(false);
KeepBorrow.setEnabled(false);
ReaderReturn.setEnabled(false);
LookBook.setEnabled(false);
MReader.setEnabled(true);
TypeSetItem.setEnabled(false);
EnableZheng.setEnabled(false);
ReaderInfo.setEnabled(false);
LookZheng.setEnabled(false);
CancelLook.setEnabled(false);
XuZheng.setEnabled(false);
BookAccount.setEnabled(true);
TjpmMenu.setEnabled(true);
Jtfld1.setEnabled(false);
Jtfld2.setEnabled(false);
JCB.setEnabled(false);
Ok_btn.setEnabled(false);
Register_btn.setEnabled(false);
Cancel_btn.setEnabled(false);
}
else if(JCB.getSelectedIndex()==2)
{JOptionPane.showMessageDialog(null, "登陆成功,欢迎进入商院图书馆管理系统!");
statusLB2.setText("用户身份:学生");
MSystem.setEnabled(true);
ManagerItem.setEnabled(false);
FajinItem.setEnabled(false);
MSBook.setEnabled(true);
BookTypeItem.setEnabled(false);
PressItem.setEnabled(false);
StockItem.setEnabled(false);
MBook.setEnabled(true);
BookInfoItem.setEnabled(false);
ReaderBorrow.setEnabled(false);
KeepBorrow.setEnabled(false);
ReaderReturn.setEnabled(false);
LookBook.setEnabled(false);
MReader.setEnabled(true);
TypeSetItem.setEnabled(false);
EnableZheng.setEnabled(false);
ReaderInfo.setEnabled(false);
LookZheng.setEnabled(false);
CancelLook.setEnabled(false);
XuZheng.setEnabled(false);
BookAccount.setEnabled(true);
TjpmMenu.setEnabled(true);
Jtfld1.setEnabled(false);
Jtfld2.setEnabled(false);
JCB.setEnabled(false);
Ok_btn.setEnabled(false);
Register_btn.setEnabled(false);
Cancel_btn.setEnabled(false);
}
}
else
{ JOptionPane.showMessageDialog(null, "登陆失败,您的身份不正确,请重新选择!", "警告",
JOptionPane.WARNING_MESSAGE);
}
}
else
{ JOptionPane.showMessageDialog(null, "此用户名尚未注册,请注册后再登录!", "警告",JOptionPane.WARNING_MESSAGE);
Jtfld1.setText("");
Jtfld2.setText("");
}
}
}
////////////////////////////////////////////////////注销用户按钮事件////////////////////////////////////////////////
public void Delete() throws SQLException
{ String user = Jtfld1.getText().trim();
String pass = Jtfld2.getText().trim();
String strurl =
"jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=DataBase/Library.mdb";
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch (ClassNotFoundException e) {}
con= DriverManager.getConnection(strurl);
Statement stmt = con.createStatement();
if (user.equals("")|| pass.equals("")||JCB.getSelectedItem().equals(""))
JOptionPane.showMessageDialog(null, "您尚未登录,请您先登录本系统!", "友情提示",
JOptionPane.WARNING_MESSAGE);
else
{ ResultSet rs = stmt.executeQuery("select * from 用户资料 where 用户名='" + user + "'AND 身份='"+JCB.getSelectedItem()+"'AND 密码='"+pass+"'");
if(rs.next())
{ if(JOptionPane.showConfirmDialog(this, "确实要删除该用户的所有信息吗?\n删除的信息将不能恢复,是否继续?",
"删除确定", JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE) == 0)
{ stmt.executeUpdate("delete from 用户资料 where 用户名='"+user+"'");
JOptionPane.showMessageDialog(null, "注销用户成功!");
MSystem.setEnabled(false);
MSBook.setEnabled(false);
MBook.setEnabled(false);
MReader.setEnabled(false);
BookAccount.setEnabled(false);
TjpmMenu.setEnabled(false);
Jtfld1.setText("");
Jtfld2.setText("");
Jtfld1.setEnabled(true);
Jtfld2.setEnabled(true);
JCB.setEnabled(true);
Ok_btn.setEnabled(true);
Register_btn.setEnabled(true);
Cancel_btn.setEnabled(true);
}
}
}
}
public void windowClosing(WindowEvent e)
{ int returnValue;
returnValue=JOptionPane.showConfirmDialog(null,"确实要退出本管理系统吗?","退出系统",JOptionPane.YES_NO_OPTION);
if(returnValue==JOptionPane.YES_OPTION)
System.exit(0);
}
public static void main(String[]args)
{ try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch(Exception e) {
e.printStackTrace();
}
new MainFrame();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -