我的账户
啄木鸟学院

专注软件测试菁英教育

亲爱的游客,欢迎!

已有账号,请

如尚未注册?

Java_赵梦冰_20210316

[复制链接]
Loading...学员认证 发表于 2021-3-16 19:38:46 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
  /*
    添加按功能
     */
    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("");
        }
    }
}

回复

使用道具 举报

关注0

粉丝0

帖子26

发布主题
大家都在学
课堂讨论
一周热帖排行最近7x24小时热帖
关注我们
专注软件测试菁英教育

客服电话:17792550360

客服时间:9:00-21:00

卓目鸟学苑 - 专注软件测试菁英教育!( 陕ICP备2025058934号-2 )

版权所有 © 西安菁英教育科技有限公司 2023-2026