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

import java.util.List;

import android.content.Context;
import cn.net.caoyao.cpzshandset.bean.SaleBean;
import cn.net.caoyao.cpzshandset.common.config.Config;
import cn.net.caoyao.cpzshandset.common.config.ConfigCreateService;
import cn.net.caoyao.cpzshandset.common.util.CacheGet;
import cn.net.caoyao.cpzshandset.db.presenter.DealerOutDal;

public class DealerOutBll {
	private DealerOutDal dal;
	public DealerOutBll(Context context) {
		ConfigCreateService service = new ConfigCreateService();
		dal = service.createDealerOutDal(new CacheGet(), context);
	}
	
	/**
	 * 通过销售id查询销售信息
	 * @param id
	 * @return
	 */
	public SaleBean querySalesById(int id){
		if (dal == null) {
			return null;
		}
		return dal.querySalesById(id);
	}
	
	/**
	 * 插入销售信息
	 * @param saleBean
	 * @return
	 */
	public int insertSalesInfo(SaleBean saleBean){
		if (dal == null) {
			return -1;
		}
		return dal.insertSalesInfo(saleBean);
	}
	
	/**
	 * 修改销售信息
	 * @param saleBean
	 */
	public void updateSalesInfo(SaleBean saleBean){
		if (dal == null) {
			return;
		}
		dal.updateSalesInfo(saleBean);
	}
	/**
	 * 修改销售信息的提交
	 * @param status
	 * @param errorCode
	 * @param id
	 */
	public void updateSalesSubmitStatus(int status,int errorCode, int id){
		if (dal == null) {
			return;
		}
		dal.updateSalesSubmitStatus(status, errorCode, id);
	}
	
	/**
	 * 修改销售信息的提交状态为未提交
	 * @param id
	 */
	public void updateSalesNotSubmitStatusById(int id){
		if (dal == null) {
			return;
		}
		dal.updateSalesSubmitStatus(Config.SUBMIT_STATUS_NOT_SUBMIT, 0, id);
	}

	/**
	 * 删除销售信息
	 * @param saleBean
	 */
	public void deleteSalesById(SaleBean saleBean){
		if (dal == null) {
			return;
		}
		dal.deleteSalesById(saleBean);
	}
	/**
	 * 查询所有的销售信息
	 * @return 降序排列
	 */
	public List<SaleBean> queryAllSalesList(){
		if (dal == null) {
			return null;
		}
		return dal.queryAllSalesList();
	}
	
	/**
	 * 查询所有的销售信息   
	 * @return  升序排列
	 */
	public List<SaleBean> queryAllSalesListASC(){
		if (dal == null) {
			return null;
		}
		return dal.queryAllSalesListASC();
	}
	
	
}
