-
Notifications
You must be signed in to change notification settings - Fork 0
/
DaftarMember.java
171 lines (146 loc) · 6.5 KB
/
DaftarMember.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
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.gym;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.table.DefaultTableModel;
/**
*
* @author ACER RYZEN 5
*/
public class DaftarMember extends javax.swing.JPanel implements database{
static Connection conn;
static Statement stmt;
static ResultSet rs;
/**
* Creates new form LaporanTransaksi
*/
public DaftarMember() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
bodyPanel = new javax.swing.JPanel();
mainPanel = new javax.swing.JPanel();
Read = new javax.swing.JPanel();
TablePekerja = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
btnBack = new javax.swing.JButton();
setLayout(new java.awt.CardLayout());
bodyPanel.setMaximumSize(new java.awt.Dimension(717, 316));
bodyPanel.setMinimumSize(new java.awt.Dimension(717, 316));
mainPanel.setMaximumSize(new java.awt.Dimension(600, 400));
mainPanel.setMinimumSize(new java.awt.Dimension(600, 400));
mainPanel.setPreferredSize(new java.awt.Dimension(600, 400));
mainPanel.setLayout(new java.awt.CardLayout());
Read.setBackground(new java.awt.Color(204, 204, 204));
Read.setMinimumSize(new java.awt.Dimension(540, 370));
DefaultTableModel model = new DefaultTableModel();
String[] columnNames={"No", "Nama", "NIK", "Tanggal Lahir", "Jenis Kelamin", "Alamat Lengkap",
"Email", "Password", "Nomor HP", "Tanggal Mulai Bergabung", "Status Member", "Jumlah Transaksi", "Total Transaksi"};
model.setColumnIdentifiers(columnNames);
jTable1.setModel(model);
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DB_URL, USER, PASS);
stmt = conn.createStatement();
String sql = "SELECT * FROM Member ORDER BY NoMember ASC";
rs = stmt.executeQuery(sql);
while (rs.next()) {
model.addRow(new Object[]{rs.getString("NoMember"), rs.getString("Nama"), rs.getString("NIK"), rs.getString("TanggalLahir"), rs.getString("JenisKelamin"), rs.getString("AlamatLengkap"),
rs.getString("Email"), rs.getString("Password"), rs.getString("NomorHP"), rs.getString("TanggalMulaiBergabung"), rs.getString("StatusMember"),
rs.getString("JumlahTransaksi"), "Rp. "+rs.getString("TotalTransaksi")});
}
stmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Pengambilan Data Gagal", "", JOptionPane.ERROR_MESSAGE);
}
TablePekerja.setViewportView(jTable1);
btnBack.setText("Kembali");
btnBack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBackActionPerformed(evt);
}
});
javax.swing.GroupLayout ReadLayout = new javax.swing.GroupLayout(Read);
Read.setLayout(ReadLayout);
ReadLayout.setHorizontalGroup(
ReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(ReadLayout.createSequentialGroup()
.addContainerGap()
.addComponent(TablePekerja, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE)
.addContainerGap())
.addGroup(ReadLayout.createSequentialGroup()
.addGap(250, 250, 250)
.addComponent(btnBack)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
ReadLayout.setVerticalGroup(
ReadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(ReadLayout.createSequentialGroup()
.addContainerGap()
.addComponent(TablePekerja, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(btnBack)
.addContainerGap())
);
mainPanel.add(Read, "card7");
javax.swing.GroupLayout bodyPanelLayout = new javax.swing.GroupLayout(bodyPanel);
bodyPanel.setLayout(bodyPanelLayout);
bodyPanelLayout.setHorizontalGroup(
bodyPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(bodyPanelLayout.createSequentialGroup()
.addGap(648, 648, 648)
.addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
bodyPanelLayout.setVerticalGroup(
bodyPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
add(bodyPanel, "card2");
}// </editor-fold>//GEN-END:initComponents
private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBackActionPerformed
// TODO add your handling code here:
mainPanel.removeAll();
mainPanel.repaint();
mainPanel.revalidate();
Login admin = new Login();
mainPanel.add(admin.getAdminPanel());
mainPanel.repaint();
mainPanel.revalidate();
}//GEN-LAST:event_btnBackActionPerformed
public JPanel getPanel()
{
mainPanel.removeAll();
mainPanel.repaint();
mainPanel.revalidate();
mainPanel.add(Read);
mainPanel.repaint();
mainPanel.revalidate();
return mainPanel;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel Read;
private javax.swing.JScrollPane TablePekerja;
private javax.swing.JPanel bodyPanel;
private javax.swing.JButton btnBack;
private javax.swing.JTable jTable1;
private javax.swing.JPanel mainPanel;
// End of variables declaration//GEN-END:variables
}