forked from rishikavk-08/Library_Management_System_DBMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShowMemberController.java
113 lines (85 loc) · 3.63 KB
/
ShowMemberController.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
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
package sample;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.application.Application;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import java.net.URL;
import java.sql.*;
import java.util.ResourceBundle;
public class ShowMemberController implements Initializable {
@FXML
private Button Back;
@FXML
private TableView <TableviewMember> table;
@FXML
private TableColumn<TableviewMember, Integer> id;
@FXML
private TableColumn<TableviewMember, String> first;
@FXML
private TableColumn<TableviewMember, String> last;
@FXML
private TableColumn<TableviewMember, String> address;
@FXML
private TableColumn<TableviewMember, String> phone;
@FXML
private TableColumn<TableviewMember, String> email;
@FXML
private TableColumn<TableviewMember, String> username;
@FXML
private TableColumn<TableviewMember, String> password;
ObservableList<TableviewMember> list = FXCollections.observableArrayList();
@Override
public void initialize(URL url, ResourceBundle resources) //tried backend dint work! so finished the front end part
{
try {
Connection con =DriverManager.getConnection("jdbc:mysql://localhost:3306/library", "root", "mypass");
ResultSet rs = con.createStatement().executeQuery("select * from member");
while(rs.next())
{
list.add(new TableviewMember(rs.getInt("member_ID"),rs.getString("Firstname"),rs.getString("lastname"),rs.getString("address"),rs.getString("phone_number"),rs.getString("emailID"),rs.getString("username"),rs.getString("password")));
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
id.setCellValueFactory(new PropertyValueFactory<TableviewMember,Integer>("id"));
first.setCellValueFactory(new PropertyValueFactory<TableviewMember,String>("first"));
last.setCellValueFactory(new PropertyValueFactory<TableviewMember,String>("last"));
address.setCellValueFactory(new PropertyValueFactory<TableviewMember,String>("address"));
phone.setCellValueFactory(new PropertyValueFactory<TableviewMember,String>("phone"));
email.setCellValueFactory(new PropertyValueFactory<TableviewMember,String>("email"));
username.setCellValueFactory(new PropertyValueFactory<TableviewMember,String>("username"));
password.setCellValueFactory(new PropertyValueFactory<TableviewMember,String>("password"));
table.setItems(list);
} //backend end here
public void Backclicked()
{
Stage stage = (Stage) Back.getScene().getWindow();
stage.close();
try
{
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
Stage loginStage = new Stage();
loginStage.setTitle("Librarian Page");
loginStage.setScene(new Scene(root, 703, 547));
loginStage.show();
}
catch(Exception e)
{
e.printStackTrace();
e.getCause();
}
}
}