菁英科技(卓目鸟学苑)- 专注软件测试菁英教育

标题: 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