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;
|
|
}
|
|
/// <summary>
|
/// 插入一个规格
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
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;
|
}
|
|
/// <summary>
|
/// 更新规格信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
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);
|
}
|
|
/// <summary>
|
/// 获取全部规格
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <param name="FirmId"></param>
|
/// <param name="BrandName"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.OA_Specification> getAllSpecification(Pagination pa, Guid FirmId, string SpecificationName, string GoodsName, string CommdityName)
|
{
|
IEnumerable<OA_Specification> SpecificationList = specificationDAL.getAllSpecification(pa, FirmId, SpecificationName, GoodsName, CommdityName);
|
IList<OA_Specification> templist = new List<OA_Specification>();
|
if (SpecificationList != null)
|
{
|
foreach (OA_Specification model in SpecificationList)
|
{
|
templist.Add(getModel(model.GoodsId.ToString()));
|
}
|
}
|
return templist;
|
}
|
|
/// <summary>
|
/// 根据货品Id获取所对应的规格
|
/// </summary>
|
/// <param name="GoodsId"></param>
|
/// <returns></returns>
|
public OA_Specification getModel(string GoodsId)
|
{
|
IList<Model.OA_Specification> OldList = specificationDAL.getAllModelByGoodsId(GoodsId).ToList<OA_Specification>();
|
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;
|
}
|
|
/// <summary>
|
/// 获取一个货品下面的全部规格-分页
|
/// </summary>
|
/// <param name="pa"></param>
|
/// <param name="GoodsId"></param>
|
/// <returns></returns>
|
public IEnumerable<Model.OA_Specification> 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);
|
}
|
|
/// <summary>
|
/// 获取单个规格
|
/// </summary>
|
/// <param name="Keyid"></param>
|
/// <returns></returns>
|
public Model.OA_Specification getSingleSpecification(string Keyid)
|
{
|
return specificationDAL.getSingleSpecification(Keyid);
|
}
|
|
public DataTable getAllSpecification(Guid FirmId)
|
{
|
return specificationDAL.getAllSpecification(FirmId);
|
}
|
|
}
|
}
|