-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfileController.java
More file actions
206 lines (133 loc) · 5.01 KB
/
Copy pathProfileController.java
File metadata and controls
206 lines (133 loc) · 5.01 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package com.carpooling.view;
import java.io.IOException;
import com.carpooling.Main;
import com.carpooling.User;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextField;
public class ProfileController extends Main {
ObservableList<String> routeList = FXCollections.observableArrayList("Route1", "Route2", "Route3", "Route4", "Route5");
ObservableList<String> routeOneList = FXCollections.observableArrayList("Harsha Hotel","Srinagar Garden","Ramdev Hotel", "Channamma Circle", "Fish Market", " 2nd Gate" );
ObservableList<String> routeTwoList = FXCollections.observableArrayList("Guard Room", " Mutaga", "Kudachi", "Gandhi Nagar", " Fort Circle");
ObservableList<String> routeThreeList =FXCollections.observableArrayList ("Manikbag","Kapileshwar","Tukaram Bank","Dutta Mandir","Goaves","RPD","3rd Gate");
ObservableList<String> routeFourList = FXCollections.observableArrayList ("Kumta","Dhareshwar","Haldipur","Karki","Ramthirtha","Honnavar");
ObservableList<String> routeFiveList = FXCollections.observableArrayList ("Ganesh Temple","Sahyadri Nagar","T.V.Center","Sadashiv Nagar","Bogar Ves");
@FXML
private Label username= new Label();
@FXML
private TextField fname= new TextField();
@FXML
private TextField lname= new TextField();
@FXML
private TextField password= new TextField();
@FXML
private TextField mobile= new TextField();
public static String usrnm;
@FXML
private ComboBox route;
@FXML
private ComboBox startingPt;
@FXML
private void cancelProfile() throws IOException {
if(null != Main.user) {
Main.regHome();
}
else
{
Main.showMainItems();
}
}
@FXML
private void RouteChoice() {
if(route.getValue().equals("Route1")) {
startingPt.setValue("Harsha Hotel");
startingPt.setItems(routeOneList);
}
else if(route.getValue().equals("Route2")) {
startingPt.setValue("Guard Room");
startingPt.setItems(routeTwoList);
}
else if(route.getValue().equals("Route3")) {
startingPt.setValue("Manikbag");
startingPt.setItems(routeThreeList);
}
else if(route.getValue().equals("Route4")) {
startingPt.setValue("Kumta");
startingPt.setItems(routeFourList);
}
else if(route.getValue().equals("Route5")) {
startingPt.setValue("Ganesh Temple");
startingPt.setItems(routeFiveList);
}
}
@FXML
private void create() throws IOException {
ErrController.error = null; //valid mobile number
try {
Long mob= Long.parseLong(mobile.getText().trim());
System.out.println(mob);
}catch(Exception e) {
ErrController.error="Enter 10 digits";
System.out.println(ErrController.error);
//Main.displayError();
}
if(mobile.getText().trim().length()==10 && ErrController.error == null) {
//create user
try {
User user= new User();
//int mob = Integer.parseInt(mobile.getText());
user.username=username.getText().trim();user.password=password.getText().trim();user.fname=fname.getText().trim();
user.lname=lname.getText().trim();user.mobile=mobile.getText().trim();user.route=(String) route.getValue();user.stpt=(String) startingPt.getValue();
Main.saveUser(user);
LoginSignupController.selected = 0;
Main.showMainItems();
}catch(Exception e) {
e.printStackTrace();
}
}
else {
if(ErrController.error == null)
{ErrController.error="Mobile# length should be 10";}
System.out.println("else");
System.out.println(ErrController.error);
Main.displayError();
}
}
@FXML
private void initialize() {
username.setText(usrnm);
route.setValue("Route1");
route.setItems(routeList);
startingPt.setValue("Harsha Hotel");
startingPt.setItems(routeOneList);
if(null!=Main.user) {
fname.setText(Main.user.fname);
lname.setText(Main.user.lname);
mobile.setText(Main.user.mobile);
if(Main.user.route.equals("Route1"))
startingPt.setItems(routeOneList);
if(Main.user.route.equals("Route2"))
startingPt.setItems(routeOneList);
route.setValue(Main.user.route);
startingPt.setValue(Main.user.stpt);
if(Main.user.route.equals("Route3"))
startingPt.setItems(routeThreeList);
route.setValue(Main.user.route);
startingPt.setValue(Main.user.stpt);
if(Main.user.route.equals("Route4"))
startingPt.setItems(routeFourList);
route.setValue(Main.user.route);
startingPt.setValue(Main.user.stpt);
if(Main.user.route.equals("Route5"))
startingPt.setItems(routeFiveList);
route.setValue(Main.user.route);
startingPt.setValue(Main.user.stpt);
}
}
}