国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|JAVA教程|ASP教程|

香港云服务器
服務器之家 - 編程語言 - JAVA教程 - Java設計模塊系列之書店管理系統單機版(三)

Java設計模塊系列之書店管理系統單機版(三)

2020-06-07 12:18qq_26525215 JAVA教程

這篇文章主要為大家詳細介紹了Java單機版的書店管理系統設計模塊和思想第三章,感興趣的小伙伴們可以參考一下

介紹

今天對系列二的一個添加用戶的輸入小bug進行了解決, 增加了用戶模塊的,刪除用戶,和修改用戶模塊。

下面的代碼是相對于系列二來說進行了修改或者是增加的類.

先看AddPanel類的修改:
在收集參數的時候進行防范就可防止那個bug了。

cn.hncu.bookStore.user.ui;

AddPanel類:(添加用戶模塊)

?
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
 * AddPanel.java
 *
 * Created on __DATE__, __TIME__
 */
 
package cn.hncu.bookStore.user.ui;
 
import javax.swing.JFrame;
import javax.swing.JOptionPane;
 
import cn.hncu.bookStore.common.UserTypeEnum;
import cn.hncu.bookStore.user.business.ebi.UserEbi;
import cn.hncu.bookStore.user.business.factory.UserEbiFactory;
import cn.hncu.bookStore.user.vo.UserModel;
import cn.hncu.bookStore.util.FileIoUtil;
 
/**
 *
 * @author 陳浩翔
 */
public class AddPanel extends javax.swing.JPanel {
 private JFrame mainFrame = null;
 
 /** Creates new form AddPanel */
 public AddPanel(JFrame mainFrame) {
  this.mainFrame = mainFrame;
  initComponents();
  myInitData();
 }
 
 private void myInitData() {
  for (UserTypeEnum type : UserTypeEnum.values()) {
   combType.addItem(type.getName());
  }
 }
 
 /** 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.
  */
 //GEN-BEGIN:initComponents
 // <editor-fold defaultstate="collapsed" desc="Generated Code">
 private void initComponents() {
 
  jLabel1 = new javax.swing.JLabel();
  jLabel2 = new javax.swing.JLabel();
  tfdName = new javax.swing.JTextField();
  jLabel3 = new javax.swing.JLabel();
  tfdUuid = new javax.swing.JTextField();
  jLabel4 = new javax.swing.JLabel();
  tfdPwd2 = new javax.swing.JPasswordField();
  jLabel5 = new javax.swing.JLabel();
  jLabel6 = new javax.swing.JLabel();
  combType = new javax.swing.JComboBox();
  tfdPwd = new javax.swing.JPasswordField();
  btnAdd = new javax.swing.JButton();
  btnBack = new javax.swing.JButton();
 
  setMinimumSize(new java.awt.Dimension(800, 600));
  setLayout(null);
 
  jLabel1.setFont(new java.awt.Font("微軟雅黑", 1, 48));
  jLabel1.setForeground(new java.awt.Color(204, 0, 0));
  jLabel1.setText("\u6dfb\u52a0\u7528\u6237");
  add(jLabel1);
  jLabel1.setBounds(330, 30, 230, 80);
 
  jLabel2.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel2.setText("\u7528\u6237\u7c7b\u578b:");
  add(jLabel2);
  jLabel2.setBounds(90, 310, 90, 30);
 
  tfdName.setFont(new java.awt.Font("Dialog", 1, 18));
  tfdName.setAutoscrolls(false);
  add(tfdName);
  tfdName.setBounds(470, 160, 120, 30);
 
  jLabel3.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel3.setText("uuid:");
  add(jLabel3);
  jLabel3.setBounds(120, 160, 50, 30);
 
  tfdUuid.setFont(new java.awt.Font("Dialog", 1, 12));
  add(tfdUuid);
  tfdUuid.setBounds(190, 160, 110, 30);
 
  jLabel4.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel4.setText("\u59d3\u540d:");
  add(jLabel4);
  jLabel4.setBounds(410, 160, 50, 30);
 
  tfdPwd2.setFont(new java.awt.Font("宋體", 1, 18));
  add(tfdPwd2);
  tfdPwd2.setBounds(470, 240, 170, 30);
 
  jLabel5.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel5.setText("\u5bc6\u7801:");
  add(jLabel5);
  jLabel5.setBounds(120, 240, 50, 30);
 
  jLabel6.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel6.setText("\u786e\u8ba4\u5bc6\u7801:");
  add(jLabel6);
  jLabel6.setBounds(380, 240, 90, 30);
 
  combType.setFont(new java.awt.Font("Dialog", 1, 18));
  combType.setForeground(new java.awt.Color(51, 51, 255));
  combType.setModel(new javax.swing.DefaultComboBoxModel(
    new String[] { "請選擇..." }));
  add(combType);
  combType.setBounds(190, 310, 160, 30);
 
  tfdPwd.setFont(new java.awt.Font("宋體", 1, 18));
  add(tfdPwd);
  tfdPwd.setBounds(190, 240, 160, 30);
 
  btnAdd.setFont(new java.awt.Font("Dialog", 1, 24));
  btnAdd.setForeground(new java.awt.Color(0, 204, 204));
  btnAdd.setText("\u6dfb\u52a0");
  btnAdd.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnAddActionPerformed(evt);
   }
  });
  add(btnAdd);
  btnAdd.setBounds(190, 430, 120, 60);
 
  btnBack.setFont(new java.awt.Font("Dialog", 1, 24));
  btnBack.setForeground(new java.awt.Color(0, 204, 204));
  btnBack.setText("\u8fd4\u56de");
  btnBack.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnBackActionPerformed(evt);
   }
  });
  add(btnBack);
  btnBack.setBounds(520, 430, 120, 60);
 }// </editor-fold>
 //GEN-END:initComponents
 
 private void back() {
  mainFrame.setContentPane(new ListPanel(mainFrame));
  mainFrame.validate();
 }
 
 /**
  *監聽返回按鈕
  * @param 返回按鈕的點擊監聽
  */
 private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {
  back();
 }
 
 private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {
  //1收集參數
  String uuid = tfdUuid.getText();
  String name = tfdName.getText();
  String pwd = new String(tfdPwd.getPassword());
  String pwd2 = new String(tfdPwd2.getPassword());
  //System.out.println(uuid);
 
  //System.out.println(uuid+","+name+","+pwd);
  if (uuid.equals("") || uuid.equals(null)) {
   JOptionPane.showMessageDialog(mainFrame, "用戶ID為空,請重新輸入!");
   return;
  }
 
  if (name.equals("") || name.equals(null)) {
   JOptionPane.showMessageDialog(mainFrame, "用戶名為空,請重新輸入!");
   return;
  }
 
  if (!pwd.equals(pwd2) || pwd.equals("") || pwd.equals(null)
    || pwd2.equals("") || pwd2.equals(null)) {
   JOptionPane.showMessageDialog(mainFrame, "兩次密碼輸入不一致或密碼為空,請重新輸入!");
   return;
  }
  int type = 0;
 
  try {
   type = UserTypeEnum.getTypeByName(combType.getSelectedItem()
     .toString());
  } catch (Exception e) {
   JOptionPane.showMessageDialog(mainFrame, "請指定用戶類型!");
   return;
  }
 
  //2組織參數
  UserModel user = new UserModel();
  user.setName(name);
  user.setPwd(pwd);
  user.setType(type);
  user.setUuid(uuid);
 
  //3調用邏輯層
  UserEbi ebi = UserEbiFactory.getUserEbi();
 
  //4根據調用返回結果導向不同頁面
  if (ebi.create(user)) {
   back();
  } else {
   JOptionPane.showMessageDialog(null, "該用戶已經存在!");
  }
 }
 
 //GEN-BEGIN:variables
 // Variables declaration - do not modify
 private javax.swing.JButton btnAdd;
 private javax.swing.JButton btnBack;
 private javax.swing.JComboBox combType;
 private javax.swing.JLabel jLabel1;
 private javax.swing.JLabel jLabel2;
 private javax.swing.JLabel jLabel3;
 private javax.swing.JLabel jLabel4;
 private javax.swing.JLabel jLabel5;
 private javax.swing.JLabel jLabel6;
 private javax.swing.JTextField tfdName;
 private javax.swing.JPasswordField tfdPwd;
 private javax.swing.JPasswordField tfdPwd2;
 private javax.swing.JTextField tfdUuid;
 // End of variables declaration//GEN-END:variables
 
}

cn.hncu.bookStore.user.ui;

DeletePanel類:(刪除用戶模塊)

?
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
/*
 * DeletePanel.java
 *
 * Created on __DATE__, __TIME__
 */
 
package cn.hncu.bookStore.user.ui;
 
import javax.swing.JFrame;
import javax.swing.JOptionPane;
 
import cn.hncu.bookStore.common.UserTypeEnum;
import cn.hncu.bookStore.user.business.ebi.UserEbi;
import cn.hncu.bookStore.user.business.factory.UserEbiFactory;
import cn.hncu.bookStore.user.vo.UserModel;
import cn.hncu.bookStore.util.FileIoUtil;
 
/**
 *
 * @author 陳浩翔
 *
 * @version 1.0
 */
public class DeletePanel extends javax.swing.JPanel {
 private JFrame mainFrame = null;
 private String uuid = null;
 
 /** Creates new form DeletePanel
  * @param uuid */
 public DeletePanel(JFrame mainFrame, String uuid) {
  this.mainFrame = mainFrame;
  this.uuid = uuid;
  initComponents();
  myInitData();
 }
 
 private void myInitData() {
  UserEbi user = UserEbiFactory.getUserEbi();
  UserModel userModel = user.getSingle(uuid);
  tfdName.setText(userModel.getName());
  tfdUuid.setText(userModel.getUuid());
  tfdPwd.setText(userModel.getPwd());
  tfdType.setText(UserTypeEnum.getNameByType(userModel.getType()));
 
  tfdName.setEditable(false);
  tfdPwd.setEditable(false);
  tfdType.setEditable(false);
  tfdUuid.setEditable(false);
 
 }
 
 //GEN-BEGIN:initComponents
 // <editor-fold defaultstate="collapsed" desc="Generated Code">
 private void initComponents() {
 
  jLabel1 = new javax.swing.JLabel();
  jLabel2 = new javax.swing.JLabel();
  tfdName = new javax.swing.JTextField();
  jLabel3 = new javax.swing.JLabel();
  tfdUuid = new javax.swing.JTextField();
  jLabel4 = new javax.swing.JLabel();
  jLabel5 = new javax.swing.JLabel();
  tfdPwd = new javax.swing.JTextField();
  tfdType = new javax.swing.JTextField();
  btnBack = new javax.swing.JButton();
  btnDelete = new javax.swing.JButton();
 
  setMinimumSize(new java.awt.Dimension(800, 600));
  setLayout(null);
 
  jLabel1.setFont(new java.awt.Font("微軟雅黑", 1, 48));
  jLabel1.setForeground(new java.awt.Color(204, 0, 0));
  jLabel1.setText("\u5220\u9664\u7528\u6237");
  add(jLabel1);
  jLabel1.setBounds(330, 30, 230, 80);
 
  jLabel2.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel2.setText("\u7528\u6237\u7c7b\u578b:");
  add(jLabel2);
  jLabel2.setBounds(100, 310, 90, 30);
 
  tfdName.setFont(new java.awt.Font("Dialog", 1, 18));
  tfdName.setAutoscrolls(false);
  add(tfdName);
  tfdName.setBounds(480, 160, 120, 30);
 
  jLabel3.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel3.setText("uuid:");
  add(jLabel3);
  jLabel3.setBounds(130, 160, 50, 30);
 
  tfdUuid.setFont(new java.awt.Font("Dialog", 0, 11));
  add(tfdUuid);
  tfdUuid.setBounds(200, 160, 110, 30);
 
  jLabel4.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel4.setText("\u59d3\u540d:");
  add(jLabel4);
  jLabel4.setBounds(420, 160, 50, 30);
 
  jLabel5.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel5.setText("\u5bc6\u7801:");
  add(jLabel5);
  jLabel5.setBounds(130, 240, 50, 30);
 
  tfdPwd.setFont(new java.awt.Font("Tahoma", 1, 12));
  add(tfdPwd);
  tfdPwd.setBounds(200, 240, 160, 30);
 
  tfdType.setFont(new java.awt.Font("Dialog", 1, 12));
  add(tfdType);
  tfdType.setBounds(200, 310, 160, 30);
 
  btnBack.setFont(new java.awt.Font("Dialog", 1, 24));
  btnBack.setForeground(new java.awt.Color(0, 204, 204));
  btnBack.setText("\u8fd4\u56de");
  btnBack.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnBackActionPerformed(evt);
   }
  });
  add(btnBack);
  btnBack.setBounds(540, 450, 120, 60);
 
  btnDelete.setFont(new java.awt.Font("Dialog", 1, 24));
  btnDelete.setForeground(new java.awt.Color(0, 204, 204));
  btnDelete.setText("\u5220\u9664");
  btnDelete.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnDeleteActionPerformed(evt);
   }
  });
  add(btnDelete);
  btnDelete.setBounds(210, 450, 120, 60);
 }// </editor-fold>
 //GEN-END:initComponents
 
 private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {
  //3調用邏輯層
  if (UserEbiFactory.getUserEbi().delete(uuid)) {
   back();
  } else {
   JOptionPane.showMessageDialog(mainFrame, "該用戶已經不存在!");
  }
 
  //4根據調用返回結果導向不同頁面
 
 }
 
 private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {
  back();
 }
 
 private void back() {
  mainFrame.setContentPane(new ListPanel(mainFrame));
  mainFrame.validate();
 }
 
 //GEN-BEGIN:variables
 // Variables declaration - do not modify
 private javax.swing.JButton btnBack;
 private javax.swing.JButton btnDelete;
 private javax.swing.JLabel jLabel1;
 private javax.swing.JLabel jLabel2;
 private javax.swing.JLabel jLabel3;
 private javax.swing.JLabel jLabel4;
 private javax.swing.JLabel jLabel5;
 private javax.swing.JTextField tfdName;
 private javax.swing.JTextField tfdPwd;
 private javax.swing.JTextField tfdType;
 private javax.swing.JTextField tfdUuid;
 // End of variables declaration//GEN-END:variables
 
}

cn.hncu.bookStore.user.ui;

UpdatePanel類:(修改用戶模塊)

?
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/*
 * UpdatePanel.java
 *
 * Created on __DATE__, __TIME__
 */
 
package cn.hncu.bookStore.user.ui;
 
import javax.swing.JFrame;
import javax.swing.JOptionPane;
 
import cn.hncu.bookStore.common.UserTypeEnum;
import cn.hncu.bookStore.user.business.ebi.UserEbi;
import cn.hncu.bookStore.user.business.factory.UserEbiFactory;
import cn.hncu.bookStore.user.vo.UserModel;
 
/**
 *
 * @author 陳浩翔
 *
 * @version 1.0
 */
public class UpdatePanel extends javax.swing.JPanel {
 private JFrame mainFrame = null;
 private String uuid = null;
 
 /**
  * Creates new form UpdatePanel
  *
  * @param uuid
  * @param mainFrame
  */
 public UpdatePanel(JFrame mainFrame, String uuid) {
  this.mainFrame = mainFrame;
  this.uuid = uuid;
  initComponents();
  myInitData();
 }
 
 private void myInitData() {
  UserEbi ebi = UserEbiFactory.getUserEbi();
  UserModel user = ebi.getSingle(uuid);
  tfdUuid.setText(user.getUuid());
  tfdUuid.setEditable(false);
 
  tfdName.setText(user.getName());
  tfdPwd.setText(user.getPwd());
  tfdPwd2.setText(user.getPwd());
 
  combType.removeAllItems();
  String usert = UserTypeEnum.getNameByType(user.getType());
  combType.addItem(usert);
  for (UserTypeEnum userType : UserTypeEnum.values()) {
   if (!userType.getName().equals(usert)) {
    combType.addItem(userType.getName());
   }
  }
 
 }
 
 // GEN-BEGIN:initComponents
 // <editor-fold defaultstate="collapsed" desc="Generated Code">
 private void initComponents() {
 
  jLabel1 = new javax.swing.JLabel();
  jLabel2 = new javax.swing.JLabel();
  tfdName = new javax.swing.JTextField();
  jLabel3 = new javax.swing.JLabel();
  tfdUuid = new javax.swing.JTextField();
  jLabel4 = new javax.swing.JLabel();
  tfdPwd2 = new javax.swing.JPasswordField();
  jLabel5 = new javax.swing.JLabel();
  jLabel6 = new javax.swing.JLabel();
  tfdPwd = new javax.swing.JPasswordField();
  combType = new javax.swing.JComboBox();
  btnBack = new javax.swing.JButton();
  btnUpdate = new javax.swing.JButton();
 
  setMinimumSize(new java.awt.Dimension(800, 600));
  setLayout(null);
 
  jLabel1.setFont(new java.awt.Font("微軟雅黑", 1, 48));
  jLabel1.setForeground(new java.awt.Color(204, 0, 0));
  jLabel1.setText("\u4fee\u6539\u7528\u6237");
  add(jLabel1);
  jLabel1.setBounds(320, 30, 230, 80);
 
  jLabel2.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel2.setText("\u7528\u6237\u7c7b\u578b:");
  add(jLabel2);
  jLabel2.setBounds(90, 310, 90, 30);
 
  tfdName.setFont(new java.awt.Font("Dialog", 1, 18));
  tfdName.setAutoscrolls(false);
  add(tfdName);
  tfdName.setBounds(470, 160, 120, 30);
 
  jLabel3.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel3.setText("uuid:");
  add(jLabel3);
  jLabel3.setBounds(120, 160, 50, 30);
 
  tfdUuid.setFont(new java.awt.Font("Dialog", 1, 12));
  add(tfdUuid);
  tfdUuid.setBounds(190, 160, 110, 30);
 
  jLabel4.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel4.setText("\u59d3\u540d:");
  add(jLabel4);
  jLabel4.setBounds(410, 160, 50, 30);
 
  tfdPwd2.setFont(new java.awt.Font("Dialog", 1, 18));
  add(tfdPwd2);
  tfdPwd2.setBounds(470, 240, 170, 30);
 
  jLabel5.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel5.setText("\u5bc6\u7801:");
  add(jLabel5);
  jLabel5.setBounds(120, 240, 50, 30);
 
  jLabel6.setFont(new java.awt.Font("微軟雅黑", 0, 18));
  jLabel6.setText("\u786e\u8ba4\u5bc6\u7801:");
  add(jLabel6);
  jLabel6.setBounds(380, 240, 90, 30);
 
  tfdPwd.setFont(new java.awt.Font("宋體", 1, 18));
  add(tfdPwd);
  tfdPwd.setBounds(190, 240, 160, 30);
 
  combType.setFont(new java.awt.Font("Dialog", 1, 12));
  combType.setForeground(new java.awt.Color(51, 0, 255));
  combType.setModel(new javax.swing.DefaultComboBoxModel(
    new String[] { "" }));
  add(combType);
  combType.setBounds(190, 310, 170, 30);
 
  btnBack.setFont(new java.awt.Font("Dialog", 1, 24));
  btnBack.setForeground(new java.awt.Color(0, 204, 204));
  btnBack.setText("\u8fd4\u56de");
  btnBack.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnBackActionPerformed(evt);
   }
  });
  add(btnBack);
  btnBack.setBounds(500, 430, 120, 60);
 
  btnUpdate.setFont(new java.awt.Font("Dialog", 1, 24));
  btnUpdate.setForeground(new java.awt.Color(0, 204, 204));
  btnUpdate.setText("\u4fee\u6539");
  btnUpdate.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnUpdateActionPerformed(evt);
   }
  });
  add(btnUpdate);
  btnUpdate.setBounds(170, 430, 120, 60);
 }// </editor-fold>
  // GEN-END:initComponents
 
 private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {
  // 1收集參數
  String uuid = tfdUuid.getText();
  String name = tfdName.getText();
  String pwd = new String(tfdPwd.getPassword());
  String pwd2 = new String(tfdPwd2.getPassword());
 
  if (uuid.equals("") || uuid.equals(null)) {
   JOptionPane.showMessageDialog(mainFrame, "用戶ID為空,請重新輸入!");
   return;
  }
 
  if (name.equals("") || name.equals(null)) {
   JOptionPane.showMessageDialog(mainFrame, "用戶名為空,請重新輸入!");
   return;
  }
 
  if (!pwd.equals(pwd2) || pwd.equals("") || pwd.equals(null)
    || pwd2.equals("") || pwd2.equals(null)) {
   JOptionPane.showMessageDialog(mainFrame, "兩次密碼輸入不一致或密碼為空,請重新輸入!");
   return;
  }
  int type = 0;
 
  try {
   type = UserTypeEnum.getTypeByName(combType.getSelectedItem()
     .toString());
  } catch (Exception e) {
   JOptionPane.showMessageDialog(mainFrame, "請指定用戶類型!");
   return;
  }
 
  // 2組織參數
  UserModel user = new UserModel();
  user.setName(name);
  user.setPwd(pwd);
  user.setType(type);
  user.setUuid(uuid);
 
  // 3調用邏輯層
  UserEbi ebi = UserEbiFactory.getUserEbi();
 
  // 4根據調用返回結果導向不同頁面
  if (ebi.update(user)) {
   back();
  } else {
   JOptionPane.showMessageDialog(null, "該用戶已經不存在!");
  }
 
 }
 
 private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {
  back();
 }
 
 private void back() {
  mainFrame.setContentPane(new ListPanel(mainFrame));
  mainFrame.validate();
 }
 
 // GEN-BEGIN:variables
 // Variables declaration - do not modify
 private javax.swing.JButton btnBack;
 private javax.swing.JButton btnUpdate;
 private javax.swing.JComboBox combType;
 private javax.swing.JLabel jLabel1;
 private javax.swing.JLabel jLabel2;
 private javax.swing.JLabel jLabel3;
 private javax.swing.JLabel jLabel4;
 private javax.swing.JLabel jLabel5;
 private javax.swing.JLabel jLabel6;
 private javax.swing.JTextField tfdName;
 private javax.swing.JPasswordField tfdPwd;
 private javax.swing.JPasswordField tfdPwd2;
 private javax.swing.JTextField tfdUuid;
 // End of variables declaration//GEN-END:variables
 
}

cn.hncu.bookStore.user.ui;

ListPanel類(調用用戶功能模塊)

?
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
/*
 * ListPanel.java
 *
 * Created on __DATE__, __TIME__
 */
 
package cn.hncu.bookStore.user.ui;
 
import java.util.List;
 
import javax.swing.JFrame;
import javax.swing.JOptionPane;
 
import cn.hncu.bookStore.user.business.ebi.UserEbi;
import cn.hncu.bookStore.user.business.factory.UserEbiFactory;
import cn.hncu.bookStore.user.vo.UserModel;
 
/**
 * 表現層-用戶列表面板
 *
 * @author 陳浩翔
 * @version 1.0
 */
public class ListPanel extends javax.swing.JPanel {
 private JFrame mainFrame = null;
 
 /** Creates new form ListPanel */
 public ListPanel(JFrame mainFrame) {
  this.mainFrame = mainFrame;
  initComponents();
  myInitData();
 }
 
 /**
  * 讀取所有用戶并添加進列表
  */
 private void myInitData() {
  UserEbi user = UserEbiFactory.getUserEbi();
  List<UserModel> list = user.getAll();
  userLists.setListData(list.toArray());
 }
 
 //GEN-BEGIN:initComponents
 // <editor-fold defaultstate="collapsed" desc="Generated Code">
 private void initComponents() {
 
  jScrollPane1 = new javax.swing.JScrollPane();
  userLists = new javax.swing.JList();
  jLabel1 = new javax.swing.JLabel();
  btnToAdd = new javax.swing.JButton();
  btnToDelete = new javax.swing.JButton();
  btnToUpdate = new javax.swing.JButton();
 
  setMinimumSize(new java.awt.Dimension(800, 600));
  setLayout(null);
 
  userLists.setModel(new javax.swing.AbstractListModel() {
   String[] strings = { "" };
 
   public int getSize() {
    return strings.length;
   }
 
   public Object getElementAt(int i) {
    return strings[i];
   }
  });
  jScrollPane1.setViewportView(userLists);
 
  add(jScrollPane1);
  jScrollPane1.setBounds(170, 80, 480, 230);
 
  jLabel1.setFont(new java.awt.Font("Tahoma", 1, 48));
  jLabel1.setForeground(new java.awt.Color(204, 0, 51));
  jLabel1.setText("User List");
  add(jLabel1);
  jLabel1.setBounds(300, 0, 260, 80);
 
  btnToAdd.setFont(new java.awt.Font("Dialog", 1, 24));
  btnToAdd.setForeground(new java.awt.Color(0, 102, 102));
  btnToAdd.setText("\u6dfb\u52a0\u7528\u6237");
  btnToAdd.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnToAddActionPerformed(evt);
   }
  });
  add(btnToAdd);
  btnToAdd.setBounds(160, 350, 150, 50);
 
  btnToDelete.setFont(new java.awt.Font("Dialog", 1, 24));
  btnToDelete.setForeground(new java.awt.Color(0, 102, 102));
  btnToDelete.setText("\u5220\u9664\u7528\u6237");
  btnToDelete.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnToDeleteActionPerformed(evt);
   }
  });
  add(btnToDelete);
  btnToDelete.setBounds(510, 350, 150, 50);
 
  btnToUpdate.setFont(new java.awt.Font("Dialog", 1, 24));
  btnToUpdate.setForeground(new java.awt.Color(0, 102, 102));
  btnToUpdate.setText("\u4fee\u6539\u7528\u6237");
  btnToUpdate.addActionListener(new java.awt.event.ActionListener() {
   public void actionPerformed(java.awt.event.ActionEvent evt) {
    btnToUpdateActionPerformed(evt);
   }
  });
  add(btnToUpdate);
  btnToUpdate.setBounds(160, 450, 150, 50);
 }// </editor-fold>
 //GEN-END:initComponents
 
 private void btnToUpdateActionPerformed(java.awt.event.ActionEvent evt) {
  UserModel user = (UserModel) userLists.getSelectedValue();
 
  if (user == null) {
   JOptionPane.showMessageDialog(mainFrame, "請選擇要修改的用戶!");
   return;
  }
 
  String uuid = user.getUuid();
 
  mainFrame.setContentPane(new UpdatePanel(mainFrame, uuid));
  mainFrame.validate();
 }
 
 private void btnToDeleteActionPerformed(java.awt.event.ActionEvent evt) {
  UserModel user = (UserModel) userLists.getSelectedValue();
 
  if (user == null) {
   JOptionPane.showMessageDialog(mainFrame, "請選擇要刪除的用戶!");
   return;
  }
 
  String uuid = user.getUuid();
 
  mainFrame.setContentPane(new DeletePanel(mainFrame, uuid));
  mainFrame.validate();
 }
 
 private void btnToAddActionPerformed(java.awt.event.ActionEvent evt) {
  mainFrame.setContentPane(new AddPanel(mainFrame));
  mainFrame.validate();
 }
 
 //GEN-BEGIN:variables
 // Variables declaration - do not modify
 private javax.swing.JButton btnToAdd;
 private javax.swing.JButton btnToDelete;
 private javax.swing.JButton btnToUpdate;
 private javax.swing.JLabel jLabel1;
 private javax.swing.JScrollPane jScrollPane1;
 private javax.swing.JList userLists;
 // End of variables declaration//GEN-END:variables
 
}

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。

原文鏈接:http://blog.csdn.net/qq_26525215/article/details/51099202

延伸 · 閱讀

精彩推薦
385
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 免费观看a视频 | www.avtt天堂网 | 久久久久a| 激情一区二区三区 | 日韩精品一区二区三区在线观看 | 一本大道久久精品 | 日韩欧美在线一区二区 | 99久久久 | 欧美日一本| 欧美亚洲三级 | 亚洲国产成人91精品 | 国产精品一码二码三码在线 | 成人av一级片 | 久久久一区二区 | 视频一区 中文字幕 | 亚洲精品久久久久久久久久久久久 | 亚洲国产成人av好男人在线观看 | 欧美日韩精品在线 | 1000部精品久久久久久久久 | 欧美日韩成人在线观看 | 天堂网中文在线 | 成人1区2区 | 亚洲精品视频免费 | 欧美日韩国产在线 | 国产一级黄色大片 | 国产日韩一级片 | 综合伊人久久 | 亚洲精品久久久久久下一站 | 国产成人精品午夜视频' | 干片网| 美女羞羞网站 | 欧产日产国产一区 | 亚洲人视频在线观看 | 成人国产电影 | 99精品国产高清在线观看 | 狠狠狠狠狠狠干 | 国产精品一区二区三区在线 | 亚洲人体视频 | 亚洲天堂成人在线 | 自拍偷拍色 | 日韩电影二区 |