|
/**
|
* 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_DeliverPlanBLL
|
{
|
IOA_DeliverPlanDAL _IOA_DeliverPlanDAL = null;
|
|
/// <summary>
|
/// 初始化构造
|
/// </summary>
|
public OA_DeliverPlanBLL()
|
{
|
//获取OA_DeliverPlan DAL实现
|
_IOA_DeliverPlanDAL = Factory.GetDALByInterfaceName(DALInterface.IOA_DeliverPlanDAL) as IOA_DeliverPlanDAL;
|
|
|
}
|
|
/// <summary>
|
/// 新增送货安排
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <param name="m_OA_CustomerCommunications"></param>
|
/// <param name="m_EC_AcceptWayByCustomers"></param>
|
/// <returns></returns>
|
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_DeliverPlanDAL.InserModel(m_OA_DeliverPlan);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 修改送货安排
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <returns></returns>
|
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_DeliverPlanDAL.UpdateModel(m_OA_DeliverPlan);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
}
|
|
/// <summary>
|
/// 获取全部合作客户
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public IEnumerable<OA_DeliverPlan> GetModelList()
|
{
|
Query query = new Query();
|
return _IOA_DeliverPlanDAL.SelectAllModel(query);
|
}
|
|
|
/// <summary>
|
/// 根据formid获得信息
|
/// </summary>
|
/// <param name="Keyid">编号</param>
|
/// <returns></returns>
|
public IEnumerable<Model.OA_DeliverPlan> GetModelByformid(Guid formid)
|
{
|
|
return _IOA_DeliverPlanDAL.GetModelByformid(formid);
|
}
|
|
/// <summary>
|
/// 获取全部合作客户
|
/// </summary>
|
/// <param name="Keyid">主键id</param>
|
/// <returns></returns>
|
public OA_DeliverPlan GetModelByKeyid(Guid? keyid ,Guid? BuyerId ,DateTime? DeliveryTime)
|
{
|
|
return _IOA_DeliverPlanDAL.GetModelByKeyid(keyid,BuyerId, DeliveryTime);
|
}
|
|
/// <summary>
|
/// 删除合作客户
|
/// </summary>
|
/// <param name="rType"></param>
|
/// <returns></returns>
|
public bool DeleteModel(CY.Model.OA_DeliverPlan rType)
|
{
|
try
|
{
|
_IOA_DeliverPlanDAL.DeleteModel(rType);
|
}
|
catch (Exception ex)
|
{
|
throw ex;
|
}
|
return true;
|
}
|
|
/// <summary>
|
/// 查询合作客户分页列表
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <returns></returns>
|
public IEnumerable<OA_DeliverPlan> SelectModelPage(Pagination pa, Guid FirmId, string DeliveredTime,
|
string CarId, string DriverId,string trueMemberId ="", string CustormerName = "", string BusinessManager = "")
|
{
|
string Condition = " and od.FirmId ='" + FirmId + "' and od.shifouDelivery = 1 ";
|
string sort = " Dizhi asc ";
|
if (!string.IsNullOrEmpty(DeliveredTime) )
|
{
|
if(DeliveredTime != "逾期")
|
{
|
Condition += " and DATEDIFF(day,od.[DeliverTime],'" + DeliveredTime + "')=0 ";
|
|
}
|
else
|
{
|
Condition += " and DATEDIFF(day,GETDATE(),od.[DeliverTime])<0 and od.[DeliveredTime] is null ";
|
sort = " DeliverTime desc,Dizhi 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 + "%'";
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy",sort)
|
};
|
query.Criteria = criterias;
|
return _IOA_DeliverPlanDAL.SelectModelPage(query, pa);
|
}
|
|
|
|
/// <summary>
|
/// 查询合作客户分页列表
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <returns></returns>
|
public IEnumerable<OA_DeliverPlan> SelectModelPageLishi(Pagination pa, Guid FirmId, string DeliveredTimestart, string DeliveredTimeend,
|
string CarId, string DriverId, string trueMemberId = "")
|
{
|
string Condition = " and od.FirmId ='" + FirmId + "' and od.shifouDelivery = 1 ";
|
|
if (!string.IsNullOrEmpty(DeliveredTimestart))
|
{
|
|
Condition += " and DATEDIFF(day,'"+ DeliveredTimestart + "',od.[DeliverTime])>=0 ";
|
|
}
|
|
if (!string.IsNullOrEmpty(DeliveredTimeend))
|
{
|
|
Condition += " and DATEDIFF(day,'" + DeliveredTimeend + "',od.[DeliverTime])<=0 ";
|
|
}
|
|
|
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 + "'";
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy"," case when Sort is null then 1 else 0 end asc,Sort asc ")
|
};
|
query.Criteria = criterias;
|
return _IOA_DeliverPlanDAL.SelectModelPage(query, pa);
|
}
|
|
|
|
/// <summary>
|
/// 查询合作客户分页列表
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <returns></returns>
|
public IEnumerable<OA_DeliverPlan> SelectModelPageunusual(Pagination pa, Guid FirmId, string DeliverTimestart,
|
string DeliverTimeend)
|
{
|
string Condition = " and od.FirmId ='" + FirmId + "' and od.shifouDelivery = 1 and od.[wentifankui] !='' and od.[wentifankui] is not null ";
|
|
if (!string.IsNullOrEmpty(DeliverTimestart))
|
Condition += " and DATEDIFF(day,od.[DeliveredTime],'" + DeliverTimestart + "')<=0 ";
|
|
if (!string.IsNullOrEmpty(DeliverTimeend))
|
Condition += " and DATEDIFF(day,od.[DeliveredTime],'" + DeliverTimeend + "')>=0 ";
|
|
Query query = new Query();
|
IList<Criterion> criterias = new List<Criterion>()
|
{
|
new Criterion("", Condition),
|
|
new Criterion("orderBy"," [DeliveredTime] desc ")
|
};
|
query.Criteria = criterias;
|
return _IOA_DeliverPlanDAL.SelectModelPage(query, pa);
|
}
|
}
|
}
|