mysql租车管理系统_基于java实现租车管理系统
概述
基于java + swing + JFrame 的圖書館管理系統(tǒng),租車,還車,管理員管理用戶,付款等。
部分代碼
public class Login extends JFrame {
private static final long serialVersionUID = 1L;
/**
* 登錄窗體
*/
public Login() {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
// 設(shè)置頂部提示文字和主窗體的寬,高,x值,y值
setTitle("登錄");
setBounds(300, 300, 300, 280);
// 添加一個(gè)cp容器
Container cp = getContentPane();
// 設(shè)置添加的cp容器為流布局管理器
cp.setLayout(null);
// 設(shè)置左側(cè)用戶名文字
JLabel jl = new JLabel("用戶名:");
jl.setBounds(10, 10, 200, 18);
// 用戶名框
final JTextField name = new JTextField();
//設(shè)置用戶名框的寬,高,x值,y值
name.setBounds(80, 10, 150, 18);
// 設(shè)置左側(cè)密碼文字
JLabel jl2 = new JLabel("密碼:");
jl2.setBounds(10, 50, 200, 18);
// 密碼框:為加密的***
final JPasswordField password = new JPasswordField();
// 設(shè)置密碼框的寬,高,x值,y值
password.setBounds(80, 50, 150, 18);
// 設(shè)置左側(cè)密碼文字
JLabel jl3 = new JLabel("用戶類型:");
jl3.setBounds(10, 90, 200, 18);
// 用戶類型選擇框
final JComboBox type = new JComboBox();
type.addItem("普通用戶");
type.addItem("管理員");
// 設(shè)置密碼框的寬,高,x值,y值
type.setBounds(80, 90, 150, 18);
// 將jl、name、jl2、password、jl3、type添加到容器cp中
cp.add(jl);
cp.add(name);
cp.add(jl2);
cp.add(password);
cp.add(jl3);
cp.add(type);
// 確定按鈕
JButton jb = new JButton("確定");
// 為確定按鈕添加監(jiān)聽事件
jb.addActionListener(arg0 -> {
if (name.getText().trim().length() == 0 || new String(password.getPassword()).trim().length() == 0) {
JOptionPane.showMessageDialog(null, "用戶名密碼不允許為空");
return;
}
UserService userService = new UserServiceImpl();
User user = userService.selectUserByParams(name.getText().trim(), new String(password.getPassword()).trim(), (String) type.getSelectedItem());
if (null != user) {
JOptionPane.showMessageDialog(null, "登錄成功");
EventQueue.invokeLater(() -> {
try {
MainFrame frame = new MainFrame(user);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
});
} else {
JOptionPane.showMessageDialog(null, "用戶名或密碼錯(cuò)誤");
}
});
// 設(shè)置確定按鈕的寬,高,x值,y值
jb.setBounds(80, 120, 60, 18);
// 將確定按鈕添加到cp容器中
cp.add(jb);
// 重置按鈕
final JButton button = new JButton();
button.setText("重置");
// 為重置按鈕添加監(jiān)聽事件
// 同時(shí)清空name、password的數(shù)據(jù)
button.addActionListener(arg0 -> {
name.setText("");
password.setText("");
});
// 設(shè)置重置按鈕的寬,高,x值,y值
button.setBounds(150, 120, 60, 18);
getContentPane().add(button);
}
/**
* main方法入口
*/
public static void main(String[] args) {
// 調(diào)用Login()
Login login = new Login();
login.setVisible(true);
}
}
運(yùn)行配置
1、首先安裝Mysql5.7,設(shè)置用戶名為root,密碼為root,并保證其在運(yùn)行狀態(tài),執(zhí)行sql文件導(dǎo)入數(shù)據(jù)。
2、運(yùn)行main方法即可
概念設(shè)計(jì)
實(shí)現(xiàn)了登錄、租車、還車、查看、管理等功能
Common 為通用包,其中的entity為通用實(shí)體類,jdbc為數(shù)據(jù)庫(kù)連接,utils為工具包
Constant為常量類,包含數(shù)據(jù)庫(kù)連接所需要的參數(shù)和一個(gè)DateFormat
Dao為數(shù)據(jù)庫(kù)增刪改查
Service為組合dao層,實(shí)現(xiàn)界面的操作
Ui為界面設(shè)計(jì)
數(shù)據(jù)庫(kù)E-R圖
功能展示
1. 首頁(yè)登陸
2.1 登錄判斷
2.2 管理員車輛增加
2.3 車輛管理
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
總結(jié)
以上是生活随笔為你收集整理的mysql租车管理系统_基于java实现租车管理系统的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: cstring移除指定字符串_从Stri
- 下一篇: vs里安装了mysql吗_vs2017安