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; using System.Transactions; using CY.BLL.OA; using CY.Infrastructure.Common; namespace CY.BLL.OA { public class OA_SpecificationBLL { IOA_SpecificationDAL specificationDAL = null; OA_CommoditySpeciAssociateBLL _OA_CommoditySpeciAssociateBLL = null; public OA_SpecificationBLL() { _OA_CommoditySpeciAssociateBLL = new OA_CommoditySpeciAssociateBLL(); specificationDAL = Factory.GetDALByInterfaceName(DALInterface.IOA_SpecificationDAL) as IOA_SpecificationDAL; } /// /// 插入一个规格 /// /// /// public bool InsertModel(OA_Specification model, string CommidityId) { bool isSuccess = true; using (TransactionScope tran = new TransactionScope()) { isSuccess = specificationDAL.InserModel(model); if (isSuccess) { string[] a = { model.Keyid.ToString() }; isSuccess = _OA_CommoditySpeciAssociateBLL.InsertModel(a, CommidityId); } if (isSuccess) { tran.Complete(); } } return isSuccess; } /// /// 更新规格信息 /// /// /// public bool UpdateModel(OA_Specification model, string CommidityId) { bool isSuccess = true; isSuccess = specificationDAL.UpdateModel(model); return isSuccess; } public bool DeleteModel(OA_Specification model) { return specificationDAL.DeleteModel(model); } /// /// 获取全部规格 /// /// /// /// /// public IEnumerable getAllSpecification(Pagination pa, Guid FirmId, string SpecificationName, string GoodsName, string CommdityName) { IEnumerable SpecificationList = specificationDAL.getAllSpecification(pa, FirmId, SpecificationName, GoodsName, CommdityName); IList templist = new List(); if (SpecificationList != null) { foreach (OA_Specification model in SpecificationList) { templist.Add(getModel(model.GoodsId.ToString())); } } return templist; } /// /// 根据货品Id获取所对应的规格 /// /// /// public OA_Specification getModel(string GoodsId) { IList OldList = specificationDAL.getAllModelByGoodsId(GoodsId).ToList(); OA_Specification model = new OA_Specification(); 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.Operator = OldList[0].Operator; model.OrderNum = OldList[0].OrderNum; model.Remark = OldList[0].Remark; foreach (OA_Specification 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 specificationDAL.getAllModelByGoodsId(pa, GoodsId); } public DataTable getAllSpecification(Guid FirmId, string CommodityId, string GoodsId) { return specificationDAL.getAllSpecification(FirmId, CommodityId, GoodsId); } /// /// 获取单个规格 /// /// /// public Model.OA_Specification getSingleSpecification(string Keyid) { return specificationDAL.getSingleSpecification(Keyid); } public DataTable getAllSpecification(Guid FirmId) { return specificationDAL.getAllSpecification(FirmId); } } }