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
158
159
160
161
162
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_PaperWeightBLL
    {
        IOA_PaperWeightDAL brandDal = null;
 
        public OA_PaperWeightBLL()
        {
            brandDal = Factory.GetDALByInterfaceName(DALInterface.IOA_PaperWeightDAL) as IOA_PaperWeightDAL;
 
        }
 
        /// <summary>
        /// 插入一个品牌
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool InsertModel(OA_PaperWeight model)
        {
            return brandDal.InserModel(model);
 
        }
 
        /// <summary>
        /// 更新品牌
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateModel(OA_PaperWeight model)
        {
            return brandDal.UpdateModel(model);
 
        }
 
        public bool DeleteModel(OA_PaperWeight model)
        {
            return brandDal.DeleteModel(model);
        }
 
        /// <summary>
        /// 获取全部品牌
        /// </summary>
        /// <param name="pa"></param>
        /// <param name="FirmId"></param>
        /// <param name="BrandName"></param>
        /// <returns></returns>
        public IEnumerable<Model.OA_PaperWeight> getAllBrand(Pagination pa, Guid FirmId, string PaperweightName, string GoodsName)
        {
 
            return brandDal.getAllBrand(pa, FirmId, PaperweightName, GoodsName);
 
        }
 
        public DataTable getAllBrand(Guid FirmId)
        {
            return brandDal.getAllBrand(FirmId);
        }
 
        public DataTable getPaperWeight(Guid FrimId, string CommodityId, string GoodsId)
        {
 
            return brandDal.getPaperWeight(FrimId, CommodityId, GoodsId);
        }
 
        /// <summary>
        /// 获取单个品牌
        /// </summary>
        /// <param name="Keyid"></param>
        /// <returns></returns>
        public Model.OA_PaperWeight getSingleBrand(string Keyid)
        {
            return brandDal.getSingleBrand(Keyid);
        }
 
        /// <summary>
        /// 克重名称是否存在
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="FirmId"></param>
        /// <param name="ID"></param>
        /// <param name="GoodsId"></param>
        /// <returns></returns>
        public bool isExistPaperWeightName(String Name, Guid FirmId, int ID, int GoodsId)
        {
            return brandDal.isExistPaperWeightName(Name, FirmId, ID, GoodsId);
        }
 
        /// <summary>
        /// 获取全部货品Id
        /// </summary>
        /// <param name="pa"></param>
        /// <param name="FirmId"></param>
        /// <param name="BrandName"></param>
        /// <returns></returns>
        public IEnumerable<Model.OA_PaperWeight> getAllPaperWeight(Pagination pa, Guid FirmId, string PaperWeightName, string GoodsName)
        {
 
            IEnumerable<OA_PaperWeight> SpecificationList = brandDal.getAllPaperWeight(pa, FirmId, PaperWeightName, GoodsName);
            IList<OA_PaperWeight> templist = new List<OA_PaperWeight>();
            if (SpecificationList != null)
            {
                foreach (OA_PaperWeight model in SpecificationList)
                {
                    templist.Add(getModel(model.GoodsId.ToString()));
                }
            }
 
            return templist;
 
 
        }
 
        /// <summary>
        /// 根据货品Id获取所对应的规格
        /// </summary>
        /// <param name="GoodsId"></param>
        /// <returns></returns>
        public OA_PaperWeight getModel(string GoodsId)
        {
            IList<Model.OA_PaperWeight> OldList = brandDal.getAllModelByGoodsId(GoodsId).ToList<OA_PaperWeight>();
            OA_PaperWeight model = new OA_PaperWeight();
            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;
                foreach (OA_PaperWeight 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<Model.OA_PaperWeight> getAllModelByGoodsId(Pagination pa, string GoodsId)
        {
            return brandDal.getAllModelByGoodsId(pa, GoodsId);
        }
    }
}