tangxu
2023-12-01 394d05e64b6742a3a9a1862896cebd65e5cdbc33
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
namespace Yw.DAL
{
    /// <summary>
    /// 泵曲线
    /// </summary>
    public partial class PumpCurve : BaseDAL<Entity.PumpCurve>
    {
        /// <summary>
        /// 
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.DefaultConnectionConfig; }
 
        }
 
 
        /// <summary>
        /// 更新 CurveInfo
        /// </summary>
        public bool UpdateCurveInfo(long ID, string CurveInfo, long UpdateUserID, DateTime UpdateTime)
        {
            using (var 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.ID == ID).ExecuteCommandHasChange();
            }
        }
 
        /// <summary>
        /// 更新 CoordParas
        /// </summary>
        public bool UpdateCoordParas(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.ID == ID).ExecuteCommandHasChange();
            }
        }
 
        /// <summary>
        /// 更新可信度
        /// </summary>
        public bool UpdateReliabilityStatus(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.ID == ID).ExecuteCommandHasChange();
            }
        }
 
        /// <summary>
        /// 通过 ID 删除 同时删除映射
        /// </summary>
        public bool DeleteExByID(long ID)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                try
                {
                    db.BeginTran();
                    var bol = db.Deleteable<Entity.PumpCurve>().Where(x => x.ID == ID).ExecuteCommand() > 0;
                    if (!bol)
                    {
                        db.RollbackTran();
                        return default;
                    }
                    db.Deleteable<Entity.PumpCurveMapping>().Where(x => x.CurveID == ID).ExecuteCommand();
                    db.CommitTran();
                    return true;
                }
                catch
                {
                    db.RollbackTran();
                    throw;
                }
            }
        }
 
 
 
 
    }
}