沈阳理工大学课程实践(论文)
}
if(e.getSource()==itemPersonsc) { }
if(e.getSource()==itemBookcx) { }
if(e.getSource()==itemchaoshi) { }
if(e.getSource()==itemBorrowjs) {
Borrowbook win=new Borrowbook();
day win=new day();
Windowjj ok=new Windowjj();
Winpersondelete winperson=new Winpersondelete(\读者删除\
}
if(e.getSource()==itemBorrowhs) { }
Returnbook win=new Returnbook();
5.1.2 管理员添加功能实现
功能介绍:该程序主要实现管理员的添加,以便于让实行对图书管理员的管理。按照标签提示输入信息,然后点击确定按钮。首先判断管理员名文本框中输入的文本信息是否符合大于3个字符并小于10个字符的规则,如果不符合规则,则提示错误,如果符合规则,再到Admi表中进行查询,如果相同则用提示框提示错误。若无相同则可注册。但还需要保证前后两次的密码相同,才能成功注册,管理员登陆窗口如图5-2所示。
18
沈阳理工大学课程实践(论文)
图5-2管理员添加成功界面
主要程序代码如下:
public void actionPerformed(ActionEvent c)
{
String b=textUser.getText(); String d=textPassword1.getText(); String g=textPassword2.getText(); if(c.getSource()==buttonqk) { }
if(c.getSource()==buttonEnter||c.getSource()==textPassword2) {
if(b.length()<3||b.length()>10) { } else { try {
}
Class.forName(\
JOptionPane.showMessageDialog(null,\用户名应在3~10个字符之间\textUser.setText(null);
textUser.setText(null); textPassword1.setText(null); textPassword2.setText(null);
catch(ClassNotFoundException e)
{
System.out.println(\
19
沈阳理工大学课程实践(论文)
}
try {
con=DriverManager.getConnection(\
sql=con.createStatement();
rs=sql.executeQuery(\用户名=\f(rs.next())
{
String user=rs.getString(1); if(b.equals(user))
{
JOptionPane.showMessageDialog(null,\此管理员已被注册\警
\
}
}
else
{
if(d.equals(g)) {
sql.executeUpdate(\VALUES\
this.dispose();
JOptionPane.showMessageDialog(null,\管理员注册成功\
}
else JOptionPane.showMessageDialog(null,\两次输入密码不一致\警\
}
con.close();
}
catch(SQLException e)
{ }
System.out.println(\
20
沈阳理工大学课程实践(论文)
}
}}
5.1.3管理员切换
此模块功能是退出当前管理员界面,进入管理员切换窗口,另一用户可以通过输入自己的用户名和密码直接进入该系统。但此用户名和密码都必须与已经连接好的数据库中表Admi中的用户名和密码相吻合。管理员切换界面如图5-3所示。
图5-3 管理员切换
主要程序代码如下:
public void windowClosing(W
public void windowClosing(WindowEvent e) {
e.getWindow().dispose(); }
5.2 读者管理模块功能实现
5.2.1 读者添加
功能介绍:添加新的读者,使其能够进入图书系统阅览图书,读者添加如图5-4所示。
21
沈阳理工大学课程实践(论文)
图5-4 读者添加
主要程序代码如下:
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==button1) // 添加 } {
sex=box1.getLabel();
}
else{ //连接数据库
String number,name,sex,dept,classes,record,insertStr; number=text1.getText(); name=text2.getText(); if(box1.getState()==true) {
String ch=text1.getText(); if(ch.length()!=5){
JOptionPane.showMessageDialog(null,\请输入5位图书证号!\ text1.setText(null);
else {
sex=box2.getLabel();
22