package com.ljh.excel.bean;

import java.util.List;

import com.ljh.excel.parser.BeanOperation;
import com.ljh.excel.parser.Parser;

public class BaseBean {
	public List selectAll() {
		Parser p = new Parser(this.getClass());
		try {
			List list = p.processAllSheets();
//			System.out.println(list);
			return list;

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	public List selectAll(String filename) throws Exception{
		Parser p = new Parser(this.getClass());
		try {
			List list = p.processAllSheets(filename);
//			System.out.println(list);
			return list;

		} catch (Exception e) {
			// TODO Auto-generated catch block
			throw e;
		}
	}

	// ����һ��bean����ݼ��ϣ��Ḳ��ԭ�ȵ����
	public void saveAll(List<? extends BaseBean> data) {
		BeanOperation p = new BeanOperation();
		try {
			p.saveAll(data);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public boolean saveAll(List<? extends BaseBean> data, String filename) {
		BeanOperation p = new BeanOperation();
		try {
			p.saveAll(data, filename);
			return true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}

	public void addAll(List<? extends BaseBean> data) {
		BeanOperation p = new BeanOperation();
		try {
			p.addAll(data);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public void deleteByIndex(int index) {
		BeanOperation p = new BeanOperation();
		p.deleteByIndex(index, this.getClass());
	}
}
