ningshuxia
2022-08-19 594b3d1a2fa051d1aa8c3da15cbdff6195dbbfc5
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 SqlSugar;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Transactions;
 
namespace IStation.DAL
{
    /// <summary>
    /// 泵曲线
    /// </summary>
    public partial class PumpCurve : CorpTraceDAL<Entity.PumpCurve>
    {
        /// <summary>
        /// 
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.DefaultConnectionConfig; }
 
        }
 
 
        /// <summary>
        /// 更新曲线编码
        /// </summary>
        public bool UpdateCurveCode(long CorpID, long ID, string CurveCode,long UpdateUserID,DateTime UpdateTime)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<Entity.PumpCurve>()
                    .SetColumns(x => x.CurveCode == CurveCode)
                    .SetColumns(x=>x.UpdateUserID==UpdateUserID)
                    .SetColumns(x=>x.UpdateTime==UpdateTime)
                    .Where(x => x.CorpID == CorpID && x.ID == ID)
                    .ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 更新曲线来源
        /// </summary>
        public bool UpdateSourceFrom(long CorpID, long ID, int SourceFrom, long UpdateUserID, DateTime UpdateTime)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<Entity.PumpCurve>()
                    .SetColumns(x => x.SourceFrom == SourceFrom)
                    .SetColumns(x => x.UpdateUserID == UpdateUserID)
                    .SetColumns(x => x.UpdateTime == UpdateTime)
                    .Where(x => x.CorpID == CorpID && x.ID == ID).ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 更新创建方法
        /// </summary>
        public bool UpdateCreateMethod(long CorpID, long ID, int CreateMethod, long UpdateUserID, DateTime UpdateTime)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<Entity.PumpCurve>()
                    .SetColumns(x => x.CreateMethod == CreateMethod)
                    .SetColumns(x => x.UpdateUserID == UpdateUserID)
                    .SetColumns(x => x.UpdateTime == UpdateTime)
                    .Where(x => x.CorpID == CorpID && x.ID == ID).ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 更新曲线信息
        /// </summary>
        public bool UpdateCurveInfo(long CorpID, long ID, string CurveInfo, long UpdateUserID, DateTime UpdateTime)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<Entity.PumpCurve>()
                    .SetColumns(x => x.CurveInfo == CurveInfo)
                    .SetColumns(x => x.UpdateUserID == UpdateUserID)
                    .SetColumns(x => x.UpdateTime == UpdateTime)
                    .Where(x => x.CorpID == CorpID && x.ID == ID).ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 更新点信息
        /// </summary>
        public bool UpdatePointInfo(long CorpID, long ID, string PointInfo, long UpdateUserID, DateTime UpdateTime)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<Entity.PumpCurve>()
                    .SetColumns(x => x.PointInfo == PointInfo)
                    .SetColumns(x => x.UpdateUserID == UpdateUserID)
                    .SetColumns(x => x.UpdateTime == UpdateTime)
                    .Where(x => x.CorpID == CorpID && x.ID == ID).ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 更新坐标参数
        /// </summary>
        public bool UpdateCoordParas(long CorpID, long ID, string CoordParas, long UpdateUserID, DateTime UpdateTime)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<Entity.PumpCurve>()
                    .SetColumns(x => x.CoordParas == CoordParas)
                    .SetColumns(x => x.UpdateUserID == UpdateUserID)
                    .SetColumns(x => x.UpdateTime == UpdateTime)
                    .Where(x => x.CorpID == CorpID && x.ID == ID).ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 更新可信度
        /// </summary>
        public bool UpdateReliabilityStatus(long CorpID, long ID, int ReliabilityStatus, long UpdateUserID, DateTime UpdateTime)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<Entity.PumpCurve>()
                    .SetColumns(x => x.ReliabilityStatus == ReliabilityStatus)
                    .SetColumns(x => x.UpdateUserID == UpdateUserID)
                    .SetColumns(x => x.UpdateTime == UpdateTime)
                    .Where(x => x.CorpID == CorpID && x.ID == ID).ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 通过 ID 删除 同时删除映射
        /// </summary>
        public bool DeleteWithMappingByID(long CorpID, long ID)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                try
                {
                    db.BeginTran();
                    var bol = db.Deleteable<Entity.PumpCurve>().Where(x => x.CorpID == CorpID && x.ID == ID).ExecuteCommand() > 0;
                    if (!bol)
                    {
                        db.RollbackTran();
                        return default;
                    }
                    db.Deleteable<Entity.PumpCurveMapping>().Where(x => x.CorpID == CorpID && x.CurveID == ID).ExecuteCommand();
                    db.CommitTran();
                    return true;
                }
                catch
                {
                    db.RollbackTran();
                    throw;
                }
            }
        }
 
 
    }
}