基于java的Swing+MySQL车租赁管理系统(java+gui+文档)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

000123032402

010123032402

020123032402

040123032402

基于java的Swing+MySQL车租赁管理系统(java+gui+文档)

功能介绍:

登陆界面、管理员界面、用户界面、汽车租赁文档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
		
init();
setVisible(true);
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(500, 200, 620, 360);
setTitle("详细信息编辑界面");
}

void init()
{
JLabel label = new JLabel("车辆的详细信息:");
area = new JTextArea(10, 10);
buttonOfTijiao = new JButton("提交");
buttonOfFanHui = new JButton("返回");

box1 = Box.createVerticalBox();
box1.add(box1.createVerticalStrut(8));
box1.add(label);
box1.add(area);


box2 = Box.createHorizontalBox();
box2.add(box2.createHorizontalStrut(8));
box2.add(buttonOfTijiao);
box2.add(box2.createHorizontalStrut(8));
box2.add(buttonOfFanHui);


baseBox = Box.createHorizontalBox();
baseBox.add(baseBox.createHorizontalStrut(10));
baseBox.add(box1);
baseBox.add(baseBox.createHorizontalStrut(10));

baseBox2 = Box.createVerticalBox();
baseBox2.add(baseBox);
baseBox2.add(baseBox2.createVerticalStrut(10));
baseBox2.add(box2);
baseBox2.add(baseBox2.createVerticalStrut(10));

add(baseBox2);



}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub

}

}
package Index;

public class StartMain {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	field6.setText(hire);

}

public void actionPerformed(ActionEvent e) {
String cartype =null;
String carower=null;
String price=null;
String color=null;
String hire=null;
Object source = e.getSource();

this.connDB();



cartype = field2.getText() ;
carower = field3.getText() ;
price = field4.getText();
color = field5.getText();
hire = field6.getText();



if(source == buttonOfQueDing)//点击确定按钮
{
if(cartype.equals("")||carower.equals("")||price.equals("")||color.equals("")||hire.equals(""))
{
JOptionPane.showMessageDialog(null, "请填写完整!");
}
else
{

int n = JOptionPane.showConfirmDialog(this, "确定修改此车辆信息?","确认对话框",JOptionPane.YES_NO_OPTION);//确认文本框
if(n == JOptionPane.YES_OPTION)
{
this.connDB();
try {

stmt = con.createStatement();
String str = "update car_information set cartype='"+cartype+"',carower='"+carower+"',price='"+price+"',color='"+color+"',hire='"+hire+"' where number = '"+number+"';";
stmt.executeUpdate(str);
JOptionPane.showMessageDialog(null, "修改成功!");
this.closeDB();
this.dispose();
new Guanliyuan(true);//为ture

} catch (SQLException e1) {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

/*
* 信息录入界面
*/

public class Xiugai extends JFrame implements ActionListener {

JTextField field1,field2,field3,field4,field5,field6;

Box box1,box2,box3,box4,box5,box6,box7,baseBox;
JButton buttonOfQueDing,buttonOfReset,buttonOfQuXIAO;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String number;
public Xiugai(String number)
{

init();
setVisible(true);
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(550, 200, 550, 280);
setTitle("车辆信息修改界面");
this.number = number;
setText();
}

void init()
{
JLabel label1 = new JLabel(" 序 号 : ");
JLabel label2 = new JLabel(" 车 型 : ");
JLabel label3 = new JLabel(" 车 主 : ");
JLabel label4 = new JLabel(" 价 格 : ");
JLabel label5 = new JLabel(" 颜 色 : ");
JLabel label6 = new JLabel("是否被租用:");


field1 = new JTextField();
field2 = new JTextField();
field3 = new JTextField();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
				JOptionPane.showMessageDialog(null, "请填写完整!");
}
else if(!isNumeric(number))
{
JOptionPane.showMessageDialog(null, "序号 请输入整数!");
}
else
{
this.connDB();
try {
int numberint = Integer.parseInt(field1.getText());
stmt = con.createStatement();
String str = "insert into car_information (number,cartype,carower,price,color,hire)values('"+numberint+"','"+cartype+"','"+carower+"','"+price+"','"+color+"','"+hire+"');";
stmt.executeUpdate(str);
JOptionPane.showMessageDialog(null, "录入成功!");
this.closeDB();
this.dispose();
new Guanliyuan(true);
} catch (SQLException e1) {
// e1.printStackTrace();

JOptionPane.showMessageDialog(null, "此编号已经被使用,请换一个编号!");
}


}

}
else if(source == buttonOfQuXIAO)
{
this.dispose();
new Guanliyuan(false);

}
else if(source == buttonOfReset)
{
//field1.setText("");
field2.setText("");
field3.setText("");
field4.setText("");
field5.setText("");
field6.setText("");


}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
				"root", "123456");

} catch (SQLException e) {
e.printStackTrace();

}

}

public void closeDB() // 关闭连接
{
try {
stmt.close();
con.close();
}
catch (SQLException e) {
e.printStackTrace();
}

}

public void actionPerformed(ActionEvent e) {
Object source = e.getSource();
if(source == buttonOfBianJi)
{
area.setEnabled(true);
setEnable = 1;

}
else if (source == buttonOfFanHui)
{
this.dispose();
new Guanliyuan(false);
}
else if(source == buttonOfTi)
{
if(setEnable == 1)
{
String areaString = area.getText();
this.connDB();
try
{
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
		box2.add(box1);   //左边的按钮部分用 box布局

jPanel4 = new JPanel();
jPanel5 = new JPanel();
jPanel4.setLayout(new BorderLayout());
jPanel4.add(box2,BorderLayout.NORTH);//把左边的按钮部分放到jpanel4中。

// jPanel1 = new JPanel();
// jPanel2 = new JPanel();
// jPanel3 = new JPanel();
// jPanel4 = new JPanel();
// jPanel5 = new JPanel();
//
// jPanel1.setLayout(new BorderLayout());
// jPanel1.add(label2,BorderLayout.NORTH);
// jPanel1.add(field,BorderLayout.CENTER);
// jPanel1.add(buttonOfDelete,BorderLayout.SOUTH);//把删除的模块放一个jpanel1里
//
// jPanel2.setLayout(new BorderLayout());
// jPanel2.add(jPanel1,BorderLayout.NORTH);
// jPanel2.add(buttonOfLogout,BorderLayout.CENTER);//把删除模块和 退出登录模块放一个jpanel2里
//
// jPanel3.setLayout(new BorderLayout());
// jPanel3.add(buttonOfXinxiluru,BorderLayout.NORTH);
// jPanel3.add(buttonOfXinxiliulan,BorderLayout.CENTER);//信息录入浏览按钮放到jpanel3里
//
// jPanel4.setLayout(new BorderLayout());
// jPanel4.add(jPanel3,BorderLayout.NORTH);
// jPanel4.add(jPanel2,BorderLayout.CENTER);//把jpanel 2 3 放到 jpanel4里
//
jPanel5.setLayout(new BorderLayout());
jPanel5.add(label1,BorderLayout.NORTH);
jPanel5.add(scrollPane,BorderLayout.CENTER);//把表格 放jpanel5里

this.setLayout(new BorderLayout());
add(jPanel5,BorderLayout.EAST);
add(jPanel4,BorderLayout.WEST);//把两个大的panel放到窗口里面



}


public void connDB() { // 连接数据库
try {
Class.forName("com.mysql.jdbc.Driver");//注册驱动
} catch (ClassNotFoundException e) {
e.printStackTrace();
}


项目链接:
https://javayms.github.io?id=291222062008200xa
https://javayms.pages.dev?id=291222062008200xa