• 大小: 25.83MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-06
  • 语言: Java
  • 标签: Swing  

资源简介

功能:订单,公司的增删改查,订单导出或批量导出成Excel表格 使用技术:java基础与核心 poi操作Excel技术

资源截图

代码片段和文件信息

package com.liping.qilin.dao;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.objectInputStream;
import java.io.objectOutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import com.liping.qilin.pojo.Company;
import com.liping.qilin.pojo.Order;

public class CompanyDao {
public static List getAllCompany(){
List result=new ArrayList<>();
File companyDB=new File(“source/companyDB“);
File[] coms=companyDB.listFiles();
objectInputStream in=null;
try {
for(File file:coms){
in=new objectInputStream(new FileInputStream(file));
Company com=(Company) in.readobject();
in.close();
result.add(com);
}
} catch (Exception e) {
e.printStackTrace();
}
return result;
}

public static Company addCompany(Company com) {
if(com.getComId() ==0)
com.setComId(getComId());
objectOutputStream out=null;
try {
out=new objectOutputStream(new FileOutputStream(“source/companyDB/“+com.getComId()));
out.writeobject(com);
} catch (Exception e) {
e.printStackTrace();
return null;
}finally{
try {
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return com;
}

public static int getComId(){
boolean flag=true;
String id=““;
while(flag){
flag=false;
id=““+new Random().nextInt(1000);
for(String fileName:new File(“source/companyDB“).list()){
if(fileName.equals(id)){
flag=true;
}
}
}
return Integer.parseInt(id);
}

public static void deleteCom(Company selCom) {
System.gc();

List orders=OrderDao.getAllOrder();
for(Order o:orders){
if(o.getCompany().getComId()==selCom.getComId()){
new File(“source/orderDB/“+o.getOrderId()).delete();
}
}
new File(“source/companyDB/“+selCom.getComId()).delete();


}
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-01-22 19:49  FireControl\
     文件        1044  2017-01-21 14:46  FireControl\.classpath
     文件         387  2017-01-16 12:23  FireControl\.project
     目录           0  2017-01-16 12:23  FireControl\.settings\
     文件         598  2017-01-16 12:23  FireControl\.settings\org.eclipse.jdt.core.prefs
     文件         369  2017-01-22 16:21  FireControl\MANIFEST.MF
     目录           0  2017-01-22 18:55  FireControl\bin\
     目录           0  2017-01-22 18:55  FireControl\bin\com\
     目录           0  2017-01-22 18:55  FireControl\bin\com\liping\
     目录           0  2017-01-22 18:55  FireControl\bin\com\liping\qilin\
     目录           0  2017-01-22 18:55  FireControl\bin\com\liping\qilin\dao\
     文件        3893  2017-01-22 19:01  FireControl\bin\com\liping\qilin\dao\CompanyDao.class
     文件        1196  2017-01-22 18:55  FireControl\bin\com\liping\qilin\dao\GoodsDao.class
     文件        1097  2017-01-22 18:55  FireControl\bin\com\liping\qilin\dao\OrderDao$1.class
     文件        6384  2017-01-22 18:55  FireControl\bin\com\liping\qilin\dao\OrderDao.class
     目录           0  2017-01-22 18:55  FireControl\bin\com\liping\qilin\init\
     文件        3916  2017-01-22 18:55  FireControl\bin\com\liping\qilin\init\AutoCompleter.class
     文件        2097  2017-01-22 18:55  FireControl\bin\com\liping\qilin\init\DataInit.class
     文件        3205  2017-01-22 18:55  FireControl\bin\com\liping\qilin\init\JAutoCompleteComboBox.class
     文件        1654  2017-01-22 18:55  FireControl\bin\com\liping\qilin\init\JScrollPaneAndJPanel.class
     文件        1641  2017-01-22 18:55  FireControl\bin\com\liping\qilin\init\Test.class
     目录           0  2017-01-22 18:55  FireControl\bin\com\liping\qilin\pojo\
     文件        3120  2017-01-22 18:55  FireControl\bin\com\liping\qilin\pojo\Company.class
     文件        1266  2017-01-22 18:55  FireControl\bin\com\liping\qilin\pojo\Goods.class
     文件        2139  2017-01-22 18:55  FireControl\bin\com\liping\qilin\pojo\Order.class
     目录           0  2017-01-22 18:55  FireControl\bin\com\liping\qilin\util\
     文件        7798  2017-01-22 18:55  FireControl\bin\com\liping\qilin\util\CreateExcle.class
     目录           0  2017-01-22 18:55  FireControl\bin\com\liping\qilin\view\
     文件        3715  2017-01-22 18:55  FireControl\bin\com\liping\qilin\view\AddComPanel$1.class
     文件        1773  2017-01-22 18:55  FireControl\bin\com\liping\qilin\view\AddComPanel$2.class
     文件        5423  2017-01-22 18:55  FireControl\bin\com\liping\qilin\view\AddComPanel.class
............此处省略101个文件信息

评论

共有 条评论