private void Autoquery() { Vector<Vehicle> vehicles; Vector<Vector> datas; String departmentName = this.comboBox_query_choosebusiness.getSelectedItem().toString(); if (departmentName.equals("所有")) { vehicles = vehicleblservice.getAll(); datas = changeDatas(vehicles); setDatas(datas); refreshTable(); } else { Vector<Department> departments = vehicleblservice.getBusiness(); for (Department department : departments) { if (department.getDepartment_name().equals(departmentName)) { vehicles = vehicleblservice.getByCondition("department_id_fk", department.getId()); datas = changeDatas(vehicles); setDatas(datas); refreshTable(); } } } }
@Override public void setViewDatas() { Vector<Vehicle> vehicles = vehicleblservice.getAll(); // 转换显示格式 Vector<Vector> datas = changeDatas(vehicles); // 调用父类方法设置结果集合 setDatas(datas); }
/** * 获得所有的tips提示,自动补全查询文本框 * * @return */ private Vector<String> getAllTips() { Vector<Vehicle> vehicles = vehicleblservice.getAll(); tips.clear(); for (Vehicle vehicle : vehicles) { tips.add(vehicle.getVehicle_num()); tips.add(vehicle.getLicense_plate_number()); } return tips; }
private void view() { int id = getSelectId(getJTable()); Vehicle vehicle = vehicleblservice.getById(id); MainFrame.getLoglabel().setText("查看车辆(车辆编号:" + vehicle.getVehicle_num() + ")"); this.textField_vehicleId.setText(id + ""); this.comboBox_showBusiness.setSelectedItem(makeDepartment(vehicle.getDepartment())); this.textField_vehicleNum.setText(vehicle.getVehicle_num()); this.textField_license.setText(vehicle.getLicense_plate_number()); this.textField_usetime.setText(DateUtil.getStringByDate(vehicle.getUsetime())); this.textField_vehicleinfo.setText(vehicle.getVehicle_info()); }
private void query() { String text = this.textField_query.getText().trim(); Vector<Vehicle> vehicles; Vector<Vector> datas; String departmentName = this.comboBox_query_choosebusiness.getSelectedItem().toString(); String sql = ""; MainFrame.getLoglabel().setText("查询车辆(" + departmentName + " " + text + ")"); logger.info("查询车辆(" + departmentName + " " + text + ")"); if (departmentName.equals("所有")) { sql = "select * from vehicle where vehicle_num = '" + text + "' or license_plate_number = '" + text + "' "; vehicles = vehicleblservice.getBySql(sql); datas = changeDatas(vehicles); setDatas(datas); refreshTable(); } else { sql = "select * from vehicle , department where (vehicle.department_id_fk=department.id ) " + " and (" + "department.department_name = '" + departmentName + "' )" + "and (vehicle_num = '" + text + "' or license_plate_number = '" + text + "' ) "; vehicles = vehicleblservice.getBySql(sql); datas = changeDatas(vehicles); setDatas(datas); refreshTable(); } }
private void addDepartment() { // 加入的部门为营业厅 Vector<Department> departments = vehicleblservice.getBusiness(); this.comboBox_query_choosebusiness.addItem("所有"); for (Department department : departments) { Department itemDepartment = makeDepartment(department); this.comboBox_query_choosebusiness.addItem(itemDepartment); this.comboBox_showBusiness.addItem(itemDepartment); } }
private void delete() { if (!this.textField_vehicleId.getText().equals("")) { int vehicleId = Integer.parseInt(this.textField_vehicleId.getText()); boolean result = vehicleblservice.delete(vehicleId); // 重新读取数据 setViewDatas(); // 刷新列表, 清空表单 clear(); if (result) { MainFrame.getLoglabel().setText("刪除车辆信息成功"); logger.info("刪除车辆信息成功"); } else { MainFrame.getLoglabel().setText("刪除车辆信息失败"); logger.error("刪除车辆信息失败"); } } else { showWarn("未选择车辆"); } }
private void add() { if (isTextExist() && isTextValidate()) { Vehicle vehicle = getVehicle(); int result = vehicleblservice.add(vehicle); // 重新读取数据 setViewDatas(); // 刷新列表, 清空表单 clear(); // 通知添加结果 if (result == 0) { MainFrame.getLoglabel().setText("新增车辆信息失败"); logger.error("新增车辆信息失败"); } else { MainFrame.getLoglabel().setText("新增车辆信息成功"); logger.info("新增车辆信息成功"); } } }
private void update() { // getvehicle方法已经保存了department Vehicle vehicle = getVehicle(); int vehicleId = Integer.parseInt(this.textField_vehicleId.getText()); vehicle.setId(vehicleId); boolean result = vehicleblservice.update(vehicle); // 重新读取数据 setViewDatas(); // 刷新列表, 清空表单 clear(); // 通知更新结果 if (result) { MainFrame.getLoglabel().setText("更新车辆信息成功"); logger.info("更新车辆信息成功"); } else { MainFrame.getLoglabel().setText("更新车辆信息失败"); logger.error("更新车辆信息失败"); } }