菁英科技(卓目鸟学苑)- 专注软件测试菁英教育
标题:
Java_赵梦冰_20210316
[打印本页]
作者:
Loading...
时间:
2021-3-16 19:38
标题:
Java_赵梦冰_20210316
/*
添加按
钮
功能
*/
private class
AddAction
implements
ActionListener {
@Override
public void
actionPerformed
(ActionEvent e){
new
AddView()
;
}
}
/*
修改按
钮
功能
*/
private class
ModifyAction
implements
ActionListener {
@Override
public void
actionPerformed
(ActionEvent e){
int
row =
table
.getSelectedRow()
;
String id = (String)
table
.getValueAt(row
,
0
)
;
String name = (String)
table
.getValueAt(row
,
1
)
;
String location = (String)
table
.getValueAt(row
,
2
)
;
String baoFei = (String)
table
.getValueAt(row
,
3
)
;
String buyTime = (String)
table
.getValueAt(row
,
4
)
;
String baoFeiTime = (String)
table
.getValueAt(row
,
5
)
;
String record = (String)
table
.getValueAt(row
,
6
)
;
//
构
造
设备对
象
Equ equ =
new
Equ(id
,
name
,
location
,
baoFei
,
buyTime
,
baoFeiTime
,
record)
;
//
打
开
修改
页
面
new
ModifyView(equ)
;
}
}
/*
删
除按
钮
功能
*/
private class
DeleteAction
implements
ActionListener {
@Override
public void
actionPerformed
(ActionEvent e){
int
[] rows =
table
.getSelectedRows()
;
String[] ids =
new
String[rows.
length
]
;
//
获
取
选
中行
设备
的
ID
for
(
int
i =
0
;
i < rows.
length
;
i++) {
ids
= (String)
table
.getValueAt(rows
,
0
)
;
}
System.
out
.println(
"
选
中行的
编号为
:
"
+ Arrays.
toString
(ids))
;
int
msg = JOptionPane.
showConfirmDialog
(
null,
"
请
确
认
是否
删
除
编号为
"
+ Arrays.
toString
(ids) +
"
的
设备
?
"
,
"
确
认删
除
"
,
JOptionPane.
YES_NO_OPTION
,
JOptionPane.
QUESTION_MESSAGE
)
;
System.
out
.println(msg)
;
if
(msg ==
0
){
for
(String id:ids){
SqliteDb.
deleteEqu
(id)
;
}
refreshTable
(
table
,
SqliteDb.
queryAll
())
;
JOptionPane.
showMessageDialog
(
null,
"
删
除完
毕
"
)
;
}
}
}
/*
搜素按
钮
功能
*/
private class
SearchAction
implements
ActionListener {
@Override
public void
actionPerformed
(ActionEvent e){
java.util.List<Equ> equs =
new
ArrayList<>()
;
String temp =
searchText
.getText()
;
//
获
取
输
入的
内
容
//
如果
输
入的
内
容
为
空,全量搜素
if
(temp ==
null
|| temp.equals(
""
) ){
SqliteDb.
queryAll
()
;
}
else
{
//
否
则
,根据名字搜素
equs = SqliteDb.
queryByName
(temp)
;
}
//
搜素的
结
果刷新到表格中
refreshTable
(
table
,
equs)
;
//
清
空搜素框
searchText
.setText(
""
)
;
}
}
}
欢迎光临 菁英科技(卓目鸟学苑)- 专注软件测试菁英教育 (http://www.zmnxy.com/)
Powered by Discuz! X3.4