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 CoreDeliverOrderBLL { ICoreDeliverOrderDAL _ICoreDeliverOrderDAL = null; OA_StaffBLL staffBLL = null; /// /// 初始化构造 /// public CoreDeliverOrderBLL() { //获取CoreDeliverOrder DAL实现 _ICoreDeliverOrderDAL = Factory.GetDALByInterfaceName(DALInterface.ICoreDeliverOrderDAL) as ICoreDeliverOrderDAL; staffBLL = new OA_StaffBLL(); } /// /// 新增送货安排 /// /// /// /// /// public bool InsertModel(CY.Model.CoreDeliverOrder m_CoreDeliverOrder) { try { return _ICoreDeliverOrderDAL.InserModel(m_CoreDeliverOrder); } catch (Exception ex) { throw ex; } } /// /// 新增送货安排 /// /// /// /// /// public int InsertModelIden(CY.Model.CoreDeliverOrder m_CoreDeliverOrder) { try { return _ICoreDeliverOrderDAL.InsertModelIden(m_CoreDeliverOrder); } catch (Exception ex) { throw ex; } } /// /// 修改送货安排 /// /// /// public bool UpdateModel(CY.Model.CoreDeliverOrder m_CoreDeliverOrder) { try { return _ICoreDeliverOrderDAL.UpdateModel(m_CoreDeliverOrder); } catch (Exception ex) { throw ex; } } /// /// 获取全部合作客户 /// /// 主键id /// public IEnumerable GetModelList() { Query query = new Query(); return _ICoreDeliverOrderDAL.SelectAllModel(query); } /// /// 根据formid获得信息 /// /// 编号 /// public IEnumerable GetModelByformid(Guid formid) { return _ICoreDeliverOrderDAL.GetModelByformid(formid); } /// /// 根据formid获得信息 /// /// 编号 /// public IEnumerable GetModelByorderid(int orderid) { return _ICoreDeliverOrderDAL.GetModelByorderid(orderid); } /// /// 获取全部合作客户 /// /// 主键id /// public CoreDeliverOrder GetModelByKeyid(string keyid) { return _ICoreDeliverOrderDAL.GetModelByKeyid(keyid); } /// /// 删除合作客户 /// /// /// public bool DeleteModel(CY.Model.CoreDeliverOrder rType) { try { _ICoreDeliverOrderDAL.DeleteModel(rType); } catch (Exception ex) { throw ex; } return true; } /// /// 查询合作客户分页列表 /// /// /// public IEnumerable SelectModelPage(Pagination pa, Guid FirmId, int? DriverId, string shipAddress, string BuyerName, string createTimeStart, string createTimeEnd) { string Condition = " and b.FirmId ='" + FirmId + "' and a.OrderState = 0 "; if (DriverId.HasValue) { var oA_Staff = staffBLL.GetModelByKeyid(DriverId); Condition += " and ( a.DeliveryMoble = '" + oA_Staff.MobieNum + "' or a.DriverId = '" + DriverId + "' )"; } if (!string.IsNullOrEmpty(shipAddress)) Condition += " and b.shipAddress = '" + shipAddress + "'"; if (!string.IsNullOrEmpty(BuyerName)) Condition += " and c.BuyerName like '%" + BuyerName + "%'"; if (!string.IsNullOrEmpty(createTimeStart)) Condition += " and DATEDIFF(day,a.[MakeTime],'" + createTimeStart + "')<=0 "; if (!string.IsNullOrEmpty(createTimeEnd)) Condition += " and DATEDIFF(day,a.[MakeTime],'" + createTimeEnd + "')>=0 "; Query query = new Query(); IList criterias = new List() { new Criterion("", Condition), new Criterion("orderBy"," MakeTime desc ") }; query.Criteria = criterias; return _ICoreDeliverOrderDAL.SelectModelPage(query, pa); } /// /// 查询合作客户分页列表 /// /// /// public IEnumerable SelectModelPageLishi(Pagination pa, Guid FirmId, int? DriverId, string shipAddress, string BuyerName, string createTimeStart, string createTimeEnd,string OrderState,string shifou) { string Condition = " and b.FirmId ='" + FirmId + "' "; if (!string.IsNullOrEmpty(OrderState)) { Condition += " and a.OrderState = " + OrderState + " "; } else { if (!string.IsNullOrEmpty(shifou)) { Condition += " and a.OrderState in( 0,1 ) "; } else { Condition += " and a.OrderState in( 0,1,2 ) "; } } if (DriverId.HasValue) { var oA_Staff = staffBLL.GetModelByKeyid(DriverId); Condition += " and ( a.DeliveryMoble = '" + oA_Staff.MobieNum + "' or a.DriverId = '" + DriverId + "' )"; } if (!string.IsNullOrEmpty(shipAddress)) Condition += " and b.shipAddress = '" + shipAddress + "'"; if (!string.IsNullOrEmpty(BuyerName)) Condition += " and c.BuyerName like '%" + BuyerName + "%'"; if (!string.IsNullOrEmpty(createTimeStart)) Condition += " and DATEDIFF(day,a.[MakeTime],'" + createTimeStart + "')<=0 "; if (!string.IsNullOrEmpty(createTimeEnd)) Condition += " and DATEDIFF(day,a.[MakeTime],'" + createTimeEnd + "')>=0 "; Query query = new Query(); IList criterias = new List() { new Criterion("", Condition), new Criterion("orderBy"," MakeTime desc ") }; query.Criteria = criterias; return _ICoreDeliverOrderDAL.SelectModelPage(query, pa); } } }