package cn.net.caoyao.cpzshandset.service.bll;

import java.util.List;

import android.content.Context;
import cn.net.caoyao.cpzshandset.bean.TrainInvoiceBean;
import cn.net.caoyao.cpzshandset.db.dal.yth.YthTrainInvoiceDal;

public class TrainInvoiceBll {
	private cn.net.caoyao.cpzshandset.db.presenter.TrainInvoiceDal dal;
	public TrainInvoiceBll(Context context) {
		dal = new YthTrainInvoiceDal(context);
	}

	/**
	 * 生成火车订单信息
	 * 
	 * @param trainInvoice
	 */
	public int insertTrainInvoice(TrainInvoiceBean trainInvoice) {
		return dal.insertTrainInvoice(trainInvoice);
	}
	
	/**
	 * 修改火车订单信息
	 * 
	 * @param trainInvoice
	 */
	public void updateTrainInvoice(TrainInvoiceBean trainInvoice) {
		dal.updateTrainInvoice(trainInvoice);
	}
	/**
	 * 根据火车订单信息，删除本地订单及其对应的标签
	 * @param trainInvoice
	 */
	public void deleteTrainInvoiceById(TrainInvoiceBean trainInvoice){
		dal.deleteTrainInvoiceById(trainInvoice);
	}
	
	/**
	 * 修改当前订单个标签的上传类型
	 * @param invoice
	 * @return
	 */
	public TrainInvoiceBean updateTrainLabelMode(TrainInvoiceBean invoice){
		return dal.updateTrainLabelMode(invoice);
	}
	
	public void updateTrainErrorStatus(int status,int errorCode,int id){
		dal.updateTrainErrorStatus(status, errorCode, id);
	}
	/**
	 * 根据运单ID获取订单信息
	 * @param id
	 * @return
	 */
	public TrainInvoiceBean queryTrainInvoiceById(int id) {
		return dal.queryTrainInvoiceById(id);
	}
	/**
	 * 获取所有的有效订单
	 * @return
	 */
	public List<TrainInvoiceBean> queryAllTrainInvoices() {
		return dal.queryAllTrainInvoices();
	}
	
	/**
	 * 获取所有的有效订单
	 * @return
	 */
	public List<TrainInvoiceBean> queryAllTrainInvoicesASC() {
		return dal.queryAllTrainInvoicesASC();
	}
	
	/**
	 * 删除所有的无效订单
	 * @param status 0:有效    1:无效
	 */
	public void deleteAllInvalidInvoice(){
		dal.deleteAllInvalidInvoice();
	}
	/**
	 * 插入时检测已经数据库中已经存在该订单
	 * @param trainInvoice
	 * @return
	 */
	public boolean insertHasExist(TrainInvoiceBean trainInvoice){
		return dal.insertHasExist(trainInvoice);
	}
	/**
	 * 修改时检测数据库中已经存在该订单
	 * @param trainInvoice
	 * @return
	 */
	public boolean updateHasExist(TrainInvoiceBean trainInvoice){
		return dal.updateHasExist(trainInvoice);
	}
	
}
