using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CY.IDAL;
using CY.Model;
using AbstractFactory;
using CY.Infrastructure.Query;
using System.Data;
namespace CY.BLL.OA
{
public class OA_BrandBLL
{
IOA_BrandDAL brandDal = null;
public OA_BrandBLL()
{
brandDal = Factory.GetDALByInterfaceName(DALInterface.IOA_BrandDAL) as IOA_BrandDAL;
}
///
/// 插入一个品牌
///
///
///
public bool InsertModel(OA_Brand model)
{
return brandDal.InserModel(model);
}
///
/// 更新品牌
///
///
///
public bool UpdateModel(OA_Brand model)
{
return brandDal.UpdateModel(model);
}
public bool DeleteModel(OA_Brand model)
{
return brandDal.DeleteModel(model);
}
///
/// 获取全部品牌
///
///
///
///
///
public IEnumerable getAllBrand(Pagination pa, Guid FirmId, string BrandName, string CommodityName, string GoodsName)
{
return brandDal.getAllBrand(pa, FirmId, BrandName, CommodityName, GoodsName);
}
public DataTable getAllBrand(Guid FrimId, string CommodityId, string GoodsId)
{
return brandDal.getAllBrand(FrimId, CommodityId, GoodsId);
}
///
/// 获取单个品牌
///
///
///
public Model.OA_Brand getSingleBrand(string Keyid)
{
return brandDal.getSingleBrand(Keyid);
}
public string GetMaxOrderNum(Guid FirmId, string TName)
{
return brandDal.GetMaxOrderNum(FirmId, TName);
}
public string GetMaxOrderNumMemberId(Guid FirmId, string TName)
{
return brandDal.GetMaxOrderNumMemberId(FirmId, TName);
}
///
/// 获取全部规格
///
///
///
///
///
public IEnumerable getAllBrandNameByGoods(Pagination pa, Guid FirmId, string SpecificationName, string GoodsName, string CommdityName)
{
IEnumerable SpecificationList = brandDal.getAllBrandnew(pa, FirmId, SpecificationName, GoodsName, CommdityName);
IList templist = new List();
if (SpecificationList != null)
{
foreach (OA_Brand model in SpecificationList)
{
templist.Add(getModel(model.GoodsId.ToString()));
}
}
return templist;
}
///
/// 根据货品Id获取所对应的规格
///
///
///
public OA_Brand getModel(string GoodsId)
{
IList OldList = brandDal.getAllModelByGoodsId(GoodsId).ToList();
OA_Brand model = new OA_Brand();
if (OldList != null && OldList.Count() > 0)
{
model.CommodityId = OldList[0].CommodityId;
model.CommodityName = OldList[0].CommodityName;
model.FirmId = OldList[0].FirmId;
model.GoodsId = OldList[0].GoodsId;
model.GoodsName = OldList[0].GoodsName;
model.Keyid = OldList[0].Keyid;
model.LastUpdateTime = OldList[0].LastUpdateTime;
model.Remark = "";
model.Operator = OldList[0].Operator;
model.OrderNum = OldList[0].OrderNum;
model.Remark = OldList[0].Remark;
foreach (OA_Brand modl in OldList)
{
model.Name += modl.Name.ToString() + "|";
}
if (!string.IsNullOrEmpty(model.Name))
{
model.Name = model.Name.Substring(0, model.Name.Length - 1);
}
}
return model;
}
///
/// 获取一个货品下面的全部规格-分页
///
///
///
///
public IEnumerable getAllModelByGoodsId(Pagination pa, string GoodsId)
{
return brandDal.getAllModelByGoodsId(pa, GoodsId);
}
}
}