-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomerUI.java
185 lines (144 loc) · 4.29 KB
/
CustomerUI.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.awt.Desktop;
import java.io.File;
public class CustomerUI extends JDialog
{
// instance variables - replace the example below with your own
public Customer customer;
public JPanel jp1,jp2;
public JLabel jlbcate,jlbname,jlbnewcate;
public JTextField jtfname;
JComboBox jtfcate;
public JButton jbback,jbexit,jbmodify,jbsearch;
private String oldcate="";
public JPasswordField jtfpwd1,jtfpwd2;
/**
* Constructor for objects of class CustomerUI
*/
public CustomerUI(Account account)
{
this.customer = new Customer(account);
this.setModal(true);
jp1 = new JPanel();
jp2 = new JPanel();
jbback=new JButton("Back");
jbexit=new JButton("Exit");
jlbcate=new JLabel("Category");
jlbname=new JLabel("ProductName");
jbsearch=new JButton("Search");
jtfcate=new JComboBox();
jtfname =new JTextField(10);
this.setLayout(new GridLayout(2, 1));
initcate();
jp1.add(jlbcate);
jp1.add(jtfcate);
jp1.add(jlbname);
jp1.add(jtfname);
jp1.add(jbsearch);
//jp3.add(jbsend);
;
jp2.add(jbback);
jp2.add(jbexit);
this.add(jp1);
this.add(jp2);
jtfcate.setEditable(true);
jbsearch.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e) {
try
{
search();
}
catch(Exception ex)
{
MyMsgBox mbox = new MyMsgBox(ex.getMessage());
}
}
});
jbback.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e) {
try
{
dispose();
}
catch(Exception ex)
{
MyMsgBox mbox = new MyMsgBox(ex.getMessage());
}
}
});
jbexit.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e) {
try
{
exit();
}
catch(Exception ex)
{
MyMsgBox mbox = new MyMsgBox(ex.getMessage());
}
}
});
}
public void exit()
{
MyMsgBox mbox = new MyMsgBox("Login Out OJSS Successed!");
System.exit(0);
}
public void init() throws Exception
{
this.setTitle("MVF SYSTEM");
this.setSize(600, 300);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
this.setVisible(true);
this.setResizable(false);
}
public void initcate()
{
try
{
jtfcate.removeAllItems();
String strsql="select distinct([cate]) from [categories] order by [cate] ";
ConnectAccess ca=new ConnectAccess();
ca.OpenAccessFile();
ResultSet rs = ca.GetSet(strsql);
while (rs.next())
{
jtfcate.addItem(rs.getString(1));
}
rs.close();
ca.CloseAccessFile();
this.jtfcate.setSelectedItem("");
}
catch(Exception e)
{
MyMsgBox mbox = new MyMsgBox(e.getMessage());
}
}
public void search()
{
try
{
ProductSearchUI product = new ProductSearchUI(this.customer);
job.init();
}
catch(Exception e)
{
MyMsgBox mbox = new MyMsgBox(e.getMessage());
}
}
}