-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddCustomer.java
More file actions
135 lines (105 loc) · 4.33 KB
/
AddCustomer.java
File metadata and controls
135 lines (105 loc) · 4.33 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package airlinemanagementsystem;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class AddCustomer extends JFrame implements ActionListener{
JTextField tfname, tfphone, tfaadhar, tfnationality, tfaddress;
JRadioButton rbmale, rbfemale;
public AddCustomer() {
getContentPane().setBackground(Color.WHITE);
setLayout(null);
JLabel heading = new JLabel("ADD CUSTOMER DETAILS");
heading.setBounds(220, 20, 500, 35);
heading.setFont(new Font("Tahoma", Font.PLAIN, 32));
heading.setForeground(Color.BLUE);
add(heading);
JLabel lblname = new JLabel("Name");
lblname.setBounds(60, 80, 150, 25);
lblname.setFont(new Font("Tahoma", Font.PLAIN, 16));
add(lblname);
tfname = new JTextField();
tfname.setBounds(220, 80, 150, 25);
add(tfname);
JLabel lblnationality = new JLabel("Nationality");
lblnationality.setBounds(60, 130, 150, 25);
lblnationality.setFont(new Font("Tahoma", Font.PLAIN, 16));
add(lblnationality);
tfnationality = new JTextField();
tfnationality.setBounds(220, 130, 150, 25);
add(tfnationality);
JLabel lblaadhar = new JLabel("Aadhar Number");
lblaadhar.setBounds(60, 180, 150, 25);
lblaadhar.setFont(new Font("Tahoma", Font.PLAIN, 16));
add(lblaadhar);
tfaadhar = new JTextField();
tfaadhar.setBounds(220, 180, 150, 25);
add(tfaadhar);
JLabel lbladdress = new JLabel("Address");
lbladdress.setBounds(60, 230, 150, 25);
lbladdress.setFont(new Font("Tahoma", Font.PLAIN, 16));
add(lbladdress);
tfaddress = new JTextField();
tfaddress.setBounds(220, 230, 150, 25);
add(tfaddress);
JLabel lblgender = new JLabel("Gender");
lblgender.setBounds(60, 280, 150, 25);
lblgender.setFont(new Font("Tahoma", Font.PLAIN, 16));
add(lblgender);
ButtonGroup gendergroup = new ButtonGroup();
rbmale = new JRadioButton("Male");
rbmale.setBounds(220, 280, 70, 25);
rbmale.setBackground(Color.WHITE);
add(rbmale);
rbfemale = new JRadioButton("Female");
rbfemale.setBounds(300, 280, 70, 25);
rbfemale.setBackground(Color.WHITE);
add(rbfemale);
gendergroup.add(rbmale);
gendergroup.add(rbfemale);
JLabel lblphone = new JLabel("Phone");
lblphone.setBounds(60, 330, 150, 25);
lblphone.setFont(new Font("Tahoma", Font.PLAIN, 16));
add(lblphone);
tfphone = new JTextField();
tfphone.setBounds(220, 330, 150, 25);
add(tfphone);
JButton save = new JButton("SAVE");
save.setBackground(Color.BLACK);
save.setForeground(Color.WHITE);
save.setBounds(220, 380, 150, 30);
save.addActionListener(this);
add(save);
ImageIcon image = new ImageIcon(ClassLoader.getSystemResource("airlinemanagementsystem/icons/emp.png"));
JLabel lblimage = new JLabel(image);
lblimage.setBounds(450, 80, 280, 400);
add(lblimage);
setSize(900, 600);
setLocation(300, 150);
setVisible(true);
}
public void actionPerformed(ActionEvent ae) {
String name = tfname.getText();
String nationality = tfnationality.getText();
String phone = tfphone.getText();
String address = tfaddress.getText();
String aadhar = tfaadhar.getText();
String gender = null;
if (rbmale.isSelected()) {
gender = "Male";
} else {
gender = "Female";
}
try {
Conn conn = new Conn();
String query = "insert into passenger values('"+name+"', '"+nationality+"', '"+phone+"', '"+address+"', '"+aadhar+"', '"+gender+"')";
conn.s.executeUpdate(query);
JOptionPane.showMessageDialog(null, "Customer Details Added Successfully");
setVisible(false);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new AddCustomer();
}
}