找传奇、传世资源到传世资源站!

BMS

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

管理员账号:2020,密码:12345;学生端账号:2021,密码:12345管理端  ①管理员和学生不同的管理等级进行登录系统  ②管理员可以实现学生注册的管理,统一注册,统一注销等等,值得一提的是,这个地方使用了Excel技术,支持管理员通过Excel文件进行导入注册,同时支持所有用户的信息进行Excel文件的导出。技术大同小异,所以感兴趣的同学可以在书本借阅的界面增加同样的功能,导入导出的工具类我已经在项目中写出来。  ③管理员可进行图书的增加和删除,修改等等操作。以及图书类型的增删改查。  ④管理员端的借阅统计功能可以借鉴用户界面的功能实现,由于接下来的任务比较重,所以,并没有完成,等着感兴趣的小伙伴完成。但是在用户界面统计功能算是完成的。  学生端 ①借书和还书功能 ②借书超时罚款 ③修改密码 ④统计分析 等等 更多的功能来看看下面的截图吧 截图部 from clipboard from clipboardfrom clipboardfrom clipboard from clipboard from clipboard from clipboard from clipboard from clipboard from clipboard /**  
* @Title: logOnFrm.java  
* @Package com.view  
* @Description: TODO(用一句话描述该文件做什么)  
* @author 忘山  
* @date 2020年2月9日  
* @version V1.0  
*/  
package com.view;

import java.awt.Color;
import java.awt.Desktop;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

import com.dao.userDao;
import com.model.User;
import com.util.DbUtil;
import com.util.StringUtil;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**  
* @ClassName: logOnFrm  
* @Description: TODO(管理员登录界面)  
* @author 忘山  
* @date 2020年2月9日  
*  @类说明:
*  
*/
public class logOnFrm extends JFrame {

private JPanel contentPane;
private JTextField userIDText;
private JPasswordField passwordField;

private DbUtil dbUtil=new DbUtil();
private userDao userDao=new userDao();

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
logOnFrm frame = new logOnFrm();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the frame.
*/
public logOnFrm() {
setIconImage(Toolkit.getDefaultToolkit().getImage(logOnFrm.class.getResource("/images/Bookicon.png")));
setTitle("BMS-\u767B\u5F55\u754C\u9762");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 757, 560);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);

JLabel lblBookmanagersystem = new JLabel("BookManagerSystem");
lblBookmanagersystem.setIcon(new ImageIcon(logOnFrm.class.getResource("/images/book.png")));
lblBookmanagersystem.setFont(new Font("微软雅黑", Font.BOLD, 27));

JLabel lblNewLabel = new JLabel("\u7528\u6237ID\uFF1A");
lblNewLabel.setIcon(new ImageIcon(logOnFrm.class.getResource("/images/user.png")));
lblNewLabel.setFont(new Font("微软雅黑", Font.BOLD, 20));

JLabel lblNewLabel_1 = new JLabel("  \u5BC6   \u7801\uFF1A");
lblNewLabel_1.setIcon(new ImageIcon(logOnFrm.class.getResource("/images/password.png")));
lblNewLabel_1.setFont(new Font("微软雅黑", Font.BOLD, 20));

userIDText = new JTextField();
userIDText.setFont(new Font("微软雅黑", Font.PLAIN, 20));
userIDText.setColumns(10);

JButton login = new JButton("\u767B\u5F55");
login.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
LoginActionPerformed(event);
}
});
login.setBackground(UIManager.getColor("Button.background"));
login.setFont(new Font("微软雅黑", Font.BOLD, 20));
login.setIcon(new ImageIcon(logOnFrm.class.getResource("/images/login.png")));

JButton refresh = new JButton("\u91CD\u7F6E");
refresh.setBackground(UIManager.getColor("Button.background"));
refresh.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
refreshActionPerformed(event);
}
});
refresh.setFont(new Font("微软雅黑", Font.BOLD, 20));
refresh.setIcon(new ImageIcon(logOnFrm.class.getResource("/images/refrsh.png")));

passwordField = new JPasswordField();
passwordField.setFont(new Font("微软雅黑", Font.PLAIN, 20));

JLabel label = new JLabel("\u7CFB\u7EDF\u6982\u8FF0");
label.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
openURL();
}
});
label.setForeground(Color.BLUE);
label.setFont(new Font("微软雅黑", Font.PLAIN, 20));
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(175)
.addComponent(lblBookmanagersystem))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(105)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblNewLabel)
.addComponent(lblNewLabel_1))
.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(passwordField, GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)
.addComponent(userIDText, GroupLayout.DEFAULT_SIZE, 348, Short.MAX_VALUE)))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(207)
.addComponent(login)
.addGap(117)
.addComponent(refresh)))
.addGap(131))
.addGroup(Alignment.LEADING, gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(label)
.addContainerGap(647, Short.MAX_VALUE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(49)
.addComponent(lblBookmanagersystem)
.addGap(32)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel)
.addComponent(userIDText, GroupLayout.PREFERRED_SIZE, 43, GroupLayout.PREFERRED_SIZE))
.addGap(29)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNewLabel_1)
.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, 46, GroupLayout.PREFERRED_SIZE))
.addGap(32)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(refresh)
.addComponent(login))
.addPreferredGap(ComponentPlacement.RELATED, 127, Short.MAX_VALUE)
.addComponent(label))
);
contentPane.setLayout(gl_contentPane);

this.setLocationRelativeTo(null);//设置页面居中显示
//this.userNameText.setSize(10);
}

/**  
* @Title: openURL  
* @Description: TODO 启用系统默认浏览器来打开网址
* @param     参数  
* @return void    返回类型  
* @throws  
*/  
private void openURL() {
// TODO 自动生成的方法存根
//启用系统默认浏览器来打开网址。
        try {
            URI uri = new URI("https://www.baidu.com/");
            Desktop.getDesktop().browse(uri);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

}

/**  
* @Title: LoginActionPerformed  
* @Description: TODO(实现登录事件)  
* @param @param event    参数  
* @return void    返回类型  
* @throws  
*/  
private User LoginActionPerformed(ActionEvent event) {
// TODO 实现登录事件
String userID = this.userIDText.getText();
String password = new String(this.passwordField.getPassword());
String isAdmin = null;//判断是否是管理员
User user=new User();
/*7
* 验证用户输入的字符串是否为空
* 判断是否为空的方法 统一封装在stringutil中
*/

if (StringUtil.isEmpty(userID)) {
JOptionPane.showMessageDialog(null, "用户ID不能为空!!");
return user;

if (StringUtil.isEmpty(password)) {
JOptionPane.showMessageDialog(null, "密码不能为空");
return user;
}

/*
* 用户登录验证

*/
user=new User(Integer.parseInt(userID),password);
Connection connection=null;
try {
connection = dbUtil.getConnection();
User currentUser=userDao.login(connection, user);//如果查到数据之后,就可以返回包含数据的用户对象
if (currentUser !=null) {
//说明用户名,密码正确,登录成功,切换页面
//JOptionPane.showMessageDialog(null, "登录成功!");//测试验证用
dispose(); //如果登录成功,则销毁当前登录页面,使主页面可见即可

/**
* 获取是否是管理员
*/
if (currentUser.getIsAdmin().equals("1")) {
//说明是管理员
new MainFrm().setVisible(true);//设置主页可见
} else {
//说明不是管理员
new UserMainFrm(user).setVisible(true);//设置主页可见
}

}else {
JOptionPane.showMessageDialog(null, "用户名或密码错误!");
this.userIDText.setText("");//获取输入框的值,并设置为空,相当于重置
this.passwordField.setText("");
}
return user;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return user;
}finally {
try {
dbUtil.closeConn((com.mysql.jdbc.Connection) connection);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}

}
}

/**  
* @Title: refreshActionPerformed  
* @Description: TODO(这里用一句话描述这个方法的作用)  
* @param @param event    参数  
* @return void    返回类型  
* @throws  
*/  
private void refreshActionPerformed(ActionEvent event) {
// TODO 重置按钮的事件,实现输入框重置
this.userIDText.setText("");//获取输入框的值,并设置为空
this.passwordField.setText("");
}
}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复