username@email.com
2025-05-14 99ddfbcecf0fa2881eb3a91028257eef87dab6de
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
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);
        }
 
    }
}