/**
* OA_DeliverPlanBLL.cs
*
* 功 能: 合作客户业务逻辑类
* 类 名: OA_DeliverPlanBLL
*
* Ver 变更日期 负责人 变更内容
* ───────────────────────────────────
* V0.01 2013-4-2 15:11 吴辉 初版
* V0.02 2013-5-29 17:43 吴崎均 增加转换在线会员为厂商客户方法
*
*
*
*
*
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CY.IDAL;
using CY.Model;
using AbstractFactory;
using CY.IBaseDAL;
using CY.Infrastructure.DESEncrypt;
using CY.Infrastructure.Query;
namespace CY.BLL
{
public class OA_DeliverPlanPaicheBLL
{
IOA_DeliverPlanPaicheDAL _IOA_DeliverPlanPaicheDAL = null;
///
/// 初始化构造
///
public OA_DeliverPlanPaicheBLL()
{
//获取OA_DeliverPlan DAL实现
_IOA_DeliverPlanPaicheDAL = Factory.GetDALByInterfaceName(DALInterface.IOA_DeliverPlanPaicheDAL) as IOA_DeliverPlanPaicheDAL;
}
///
/// 新增送货安排
///
///
///
///
///
public bool InsertModel(CY.Model.OA_DeliverPlan m_OA_DeliverPlan)
{
try
{
if (m_OA_DeliverPlan.Yichangchuli == null)
{
m_OA_DeliverPlan.Yichangchuli = "";
}
if (m_OA_DeliverPlan.Xingzhengzhuize == null)
{
m_OA_DeliverPlan.Xingzhengzhuize = "";
}
return _IOA_DeliverPlanPaicheDAL.InserModel(m_OA_DeliverPlan);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 修改送货安排
///
///
///
public bool UpdateModel(CY.Model.OA_DeliverPlan m_OA_DeliverPlan)
{
try
{
if (m_OA_DeliverPlan.Yichangchuli == null)
{
m_OA_DeliverPlan.Yichangchuli = "";
}
if (m_OA_DeliverPlan.Xingzhengzhuize == null)
{
m_OA_DeliverPlan.Xingzhengzhuize = "";
}
return _IOA_DeliverPlanPaicheDAL.UpdateModel(m_OA_DeliverPlan);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 获取全部合作客户
///
/// 主键id
///
public IEnumerable GetModelList()
{
Query query = new Query();
return _IOA_DeliverPlanPaicheDAL.SelectAllModel(query);
}
///
/// 根据formid获得信息
///
/// 编号
///
public IEnumerable GetModelByformid(Guid formid)
{
return _IOA_DeliverPlanPaicheDAL.GetModelByformid(formid);
}
///
/// 根据formid获得信息
///
/// 编号
///
public IEnumerable GetModelByDeliveredTime(Guid FirmId, DateTime DeliverTime)
{
return _IOA_DeliverPlanPaicheDAL.GetModelByDeliveredTime(FirmId, DeliverTime);
}
///
/// 获取全部合作客户
///
/// 主键id
///
public OA_DeliverPlan GetModelByKeyid(Guid? keyid, Guid? BuyerId, DateTime? DeliveryTime)
{
return _IOA_DeliverPlanPaicheDAL.GetModelByKeyid(keyid, BuyerId, DeliveryTime);
}
///
/// 删除合作客户
///
///
///
public bool DeleteModel(CY.Model.OA_DeliverPlan rType)
{
try
{
_IOA_DeliverPlanPaicheDAL.DeleteModel(rType);
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 查询合作客户分页列表
///
///
///
public IEnumerable SelectModelPage(Pagination pa, Guid FirmId, string DeliveredTime,
string CarId, string DriverId, string DeliveredTimeStart, string DeliveredTimeEnd, string trueMemberId = "", string CustormerName = "", string BusinessManager = "", string wancheng = "")
{
string Condition = " and od.FirmId ='" + FirmId + "' and od.shifouDelivery = 1 ";
string sort = " [Sort] asc ";
if (string.IsNullOrEmpty(DeliveredTimeStart) && string.IsNullOrEmpty(DeliveredTimeEnd) && !string.IsNullOrEmpty(DeliveredTime))
{
if (DeliveredTime != "一周后")
{
Condition += " and DATEDIFF(day,od.[DeliverTime],'" + DeliveredTime + "')=0 ";
}
else
{
Condition += " and DATEDIFF(day,GETDATE(),od.[DeliverTime]) >= 6 ";
//sort = " DeliverTime desc,[Sort] asc ";
}
}
if (!string.IsNullOrEmpty(DeliveredTimeStart))
{
Condition += " and DATEDIFF(day,'"+ DeliveredTimeStart + "',od.[DeliverTime]) >= 0 ";
sort = " DeliverTime desc,[Sort] asc ";
}
if (!string.IsNullOrEmpty(DeliveredTimeEnd))
{
Condition += " and DATEDIFF(day,'" + DeliveredTimeEnd + "',od.[DeliverTime]) <= 0 ";
sort = " DeliverTime desc,[Sort] asc ";
}
if (!string.IsNullOrEmpty(CarId))
Condition += " and od.CarId = '" + CarId + "'";
if (!string.IsNullOrEmpty(DriverId))
Condition += " and od.DriverId = '" + DriverId + "'";
if (!string.IsNullOrEmpty(trueMemberId))
Condition += " and oss.MemberId = '" + trueMemberId + "'";
if (!string.IsNullOrEmpty(BusinessManager))
Condition += " and od.BusinessManagerId = '" + BusinessManager + "'";
if (!string.IsNullOrEmpty(CustormerName))
Condition += " and od.CompanyName like '%" + CustormerName + "%'";
if (!string.IsNullOrEmpty(wancheng))
{
if (wancheng == "1")
{
Condition += " and od.DeliveredTime is not null ";
}
else
{
Condition += " and od.DeliveredTime is null";
}
}
Query query = new Query();
IList criterias = new List()
{
new Criterion("", Condition),
new Criterion("orderBy",sort)
};
query.Criteria = criterias;
return _IOA_DeliverPlanPaicheDAL.SelectModelPage(query, pa);
}
///
/// 查询合作客户分页列表
///
///
///
public IEnumerable SelectModelPageWenti(Pagination pa, Guid FirmId,
string DeliveredTimeStart, string DeliveredTimeEnd, string DriverId, string Zerenren , string CustormerName , string Wanjiestatus )
{
string Condition = " and od.FirmId ='" + FirmId + "' and od.DeliveredTime is not null and od.wentifankui is not null and od.wentifankui!='' "; // and od.shifouDelivery = 1
string sort = "DeliveredTime desc ";
if (!string.IsNullOrEmpty(DeliveredTimeStart))
{
Condition += " and DATEDIFF(day,'" + DeliveredTimeStart + "',od.[DeliveredTime]) >= 0 ";
}
if (!string.IsNullOrEmpty(DeliveredTimeEnd))
{
Condition += " and DATEDIFF(day,'" + DeliveredTimeEnd + "',od.[DeliveredTime]) <= 0 ";
}
if (!string.IsNullOrEmpty(DriverId))
Condition += " and od.DriverId = '" + DriverId + "'";
if (!string.IsNullOrEmpty(Zerenren))
Condition += " and od.Zerenren = '" + Zerenren + "'";
if (!string.IsNullOrEmpty(CustormerName))
Condition += " and od.CompanyName like '%" + CustormerName + "%'";
if (!string.IsNullOrEmpty(Wanjiestatus))
{
if (Wanjiestatus == "1")
{
Condition += " and od.Wanjiestatus = 1 ";
}
else
{
Condition += " and ( od.Wanjiestatus is null or od.Wanjiestatus = 0 )";
}
}
Query query = new Query();
IList criterias = new List()
{
new Criterion("", Condition),
new Criterion("orderBy",sort)
};
query.Criteria = criterias;
return _IOA_DeliverPlanPaicheDAL.SelectModelPageWenti(query, pa);
}
}
}