11
huanghongfeng
5 天以前 f4c3f82a3bd142bc555ec7f632dabc66ef86f5af
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
using AngleSharp.Dom;
using System.Reflection;
using WIDESEA_Core.Utilities;
using WIDESEA_IServices;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_BasicInfoService
{
    public partial class Dt_SelectionStandardsService : ServiceBase<Dt_SelectionStandards, IDt_SelectionStandardsRepository>, IDt_SelectionStandardsService
    {
        public Dt_SelectionStandardsService(IDt_SelectionStandardsRepository BaseDal) : base(BaseDal)
        {
 
        }
 
        public override WebResponseContent AddData(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                string carType = saveModel.MainData["carType"].ToString();
                string mttype = saveModel.MainData["mttype"].ToString();
                string neworold = saveModel.MainData["neworold"].ToString();
                string gkdj = saveModel.MainData["gkdj"].ToString();
                decimal lowerValue = Convert.ToDecimal(saveModel.MainData["lowerValue"]);
                decimal upperValue = Convert.ToDecimal(saveModel.MainData["upperValue"]);
                int isCantainGK = saveModel.MainData["isCantainGK"].ObjToInt();
                string PostContainer = saveModel.MainData["postContainer"].ToString();
 
 
                if (lowerValue < 0 || upperValue < 0) throw new Exception("过盈量值异常");
 
                decimal lowerValue_gk = 0;
                decimal upperValue_gk = 0;
                if (isCantainGK != 0)
                {
 
                     lowerValue_gk = Convert.ToDecimal(saveModel.MainData["lowerValue_gk"]);
                     upperValue_gk = Convert.ToDecimal(saveModel.MainData["upperValue_gk"]);
                    if (isCantainGK != 0)
                    {
                        if (lowerValue_gk < 0 || upperValue_gk < 0) throw new Exception("截面过盈量值异常");
                    }
 
                }
 
                    
 
                Dt_SelectionStandards selectionStandards = new Dt_SelectionStandards
                {
                    CarType = carType,
                    CreateDate = DateTime.Now,
                    Creater = App.User.UserName,
                    gkdj = gkdj,
                    isCantainGK = isCantainGK != 0 ? true : false,
                    lowerValue = lowerValue,
                    lowerValue_gk = lowerValue_gk,
                    mttype = mttype,
                    neworold = neworold,
                    upperValue_gk = upperValue_gk,
                    upperValue = upperValue,
                    PostContainer = PostContainer,
                };
 
                if (BaseDal.AddData(selectionStandards) > 0)
                {
                    return content.OK("添加成功");
                }
                else
                {
                    return content.Error("添加失败");
                }
            }
            catch (Exception ex)
            {
                return content.Error($"添加失败:{ex.Message}");
            }
        }
 
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="saveModel"></param>
        /// <returns></returns>
        public virtual WebResponseContent UpdateData(SaveModel saveModel)
        {
            try
            {
                int id = int.Parse(saveModel.MainData["id"].ToString());
                string carType = saveModel.MainData["carType"].ToString();
                string mttype = saveModel.MainData["mttype"].ToString();
                string neworold = saveModel.MainData["neworold"].ToString();
                string gkdj = saveModel.MainData["gkdj"].ToString();
                decimal lowerValue = Convert.ToDecimal(saveModel.MainData["lowerValue"]);
                decimal upperValue = Convert.ToDecimal(saveModel.MainData["upperValue"]);
                string PostContainer = saveModel.MainData["postContainer"].ToString();
                int isCantainGK = saveModel.MainData["isCantainGK"].ObjToInt();
 
                Dt_SelectionStandards dt_Selection = BaseDal.QueryFirst(x => x.ID == id);
 
                
 
                dt_Selection.CarType = carType;
                dt_Selection.mttype = mttype;
                dt_Selection.neworold = neworold;
                dt_Selection.gkdj = gkdj;
 
                dt_Selection.PostContainer = PostContainer;
 
                dt_Selection.isCantainGK = isCantainGK != 0 ? true : false;
                if (isCantainGK != 0)
                {
                    decimal lowerValue_gk = Convert.ToDecimal(saveModel.MainData["lowerValue_gk"]);
                    decimal upperValue_gk = Convert.ToDecimal(saveModel.MainData["upperValue_gk"]);
 
                    dt_Selection.lowerValue_gk = lowerValue_gk;
                    dt_Selection.upperValue_gk = upperValue_gk;
                }
                
 
                if (BaseDal.UpdateData(dt_Selection))
                {
                    return WebResponseContent.Instance.OK("添加成功");
                }
                else
                {
                    return WebResponseContent.Instance.Error("添加失败");
                }
 
 
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
    }
}