-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddMemberController.java
85 lines (71 loc) · 2.35 KB
/
AddMemberController.java
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
package libraryAddMember;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXTextField;
import databaseHolder.DatabaseClass;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class AddMemberController implements Initializable {
@FXML
private JFXTextField id;
@FXML
private JFXButton saveButton;
@FXML
private JFXButton CancelButton;
@FXML
private JFXTextField name;
@FXML
private JFXTextField mobile;
@FXML
private JFXTextField email;
@FXML
private AnchorPane rootPane;
DatabaseClass databaseClass;
@Override
public void initialize(URL url, ResourceBundle rb) {
databaseClass = DatabaseClass.getInstance();
}
@FXML
private void saveMember(ActionEvent event) {
String mID = id.getText();
String mName = name.getText();
String mMobile = mobile.getText();
String mEmail = email.getText();
if(mID.isEmpty()||mName.isEmpty()||mMobile.isEmpty()||mEmail.isEmpty()){
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText(null);
alert.setContentText("Please Enter in all Fields!");
alert.showAndWait();
return;
}
String qu = "INSERT INTO MEMBER VALUES("
+ "'" + mID +"',"
+ "'" + mName +"',"
+ "'" + mMobile +"',"
+ "'" + mEmail +"'"
+")";
System.out.println(qu);
if(databaseClass.execAction(qu)){
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setHeaderText(null);
alert.setContentText("Success!");
alert.showAndWait();
}
else{
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText(null);
alert.setContentText("Error Occurred");
alert.showAndWait();
}
}
@FXML
private void cancel(ActionEvent event) {
Stage stage = (Stage) rootPane.getScene().getWindow();
stage.close();
}
}