用C#实现对MSSqlServer数据库的增删改查---Server层(WaterLevelSetServer.cs、DeviceSetServer.cs)...

在Server层定义WaterLevelSetServer和WaterLevelRecordServer两个子类,分别继承DeviceSetServer和DeviceRecordServer。

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using SMOS.DAL.Device;
 6 using SMOS.Model.Device;
 7 
 8 namespace SMOS.Server.Impl.Device
 9 {
10     public class WaterLevelSetServer:DeviceSetServer
11     {
12         private WaterLevelSetDao WaterLevelSetDao = new WaterLevelSetDao();
13         /// <summary>
14         /// 查询水位计设置信息
15         /// </summary>
16         /// <param name="deviceID">水位计设置信息</param>
17         /// <returns>设备信息</returns>
18         public override object GetDeviceSetInfo(int deviceID)
19         {
20             return WaterLevelSetDao.GetWaterLevelSetInfo(deviceID);
21         }
22 
23         /// <summary>
24         /// 查询所有水位计设备信息
25         /// </summary>
26         /// <returns>设备列表</returns>
27         public override IList<object> GetAllDeviceSetInfo()
28         {
29             return WaterLevelSetDao.GetAllWaterLevelSetInfo().ToList<Object>();
30         }
31         /// <summary>
32         /// 增加水位计设置
33         /// </summary>
34         /// <param name="DeviceSetInfo"></param>
35         /// <returns>操作记录数</returns>
36         public override int AddDeviceSetInfo(object waterLevelSetInfo)
37         {
38             WaterLevelSetInfo entity = waterLevelSetInfo as WaterLevelSetInfo;
39             if (entity == null)
40             {
41                 throw new Exception("水位计设置信息不能为空!");
42             }
43             WaterLevelSetInfo dbInfo = WaterLevelSetDao.GetWaterLevelSetInfo(entity.DeviceID);
44             if (dbInfo != null)
45             {
46                 //throw new Exception("该水位计设备设置信息已存在!");
47                 return WaterLevelSetDao.ModifyWaterLevelSetInfo(entity);
48             }
49             else 
50             {
51                 return WaterLevelSetDao.AddWaterLevelSetInfo(waterLevelSetInfo as WaterLevelSetInfo);
52             }
53 
54         }
55         /// <summary>
56         /// 修改水位计设置
57         /// </summary>
58         /// <param name="deviceSetInfo"></param>
59         /// <returns>操作记录</returns>
60         public override int ModifyDeviceSetInfo(object waterLevelSetInfo)
61         {
62             return WaterLevelSetDao.ModifyWaterLevelSetInfo(waterLevelSetInfo as WaterLevelSetInfo);
63         }
64         /// <summary>
65         /// 删除水位计设置
66         /// </summary>
67         /// <param name="deviceSetInfo"></param>
68         /// <returns>操作记录</returns>
69         public override int DelDeviceSetInfo(object waterLevelSetInfo)
70         {
71             return WaterLevelSetDao.DelWaterLevelSetInfo(waterLevelSetInfo as WaterLevelSetInfo);
72         }
73     }
74 }

DeviceSetServer.cs

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using SMOS.IServer.Device;
 6 
 7 namespace SMOS.Server.Impl.Device
 8 {
 9     public abstract class DeviceSetServer:IDeviceSetServer
10     {
11         public abstract object GetDeviceSetInfo(int deviceID);
12 
13         public abstract IList<object> GetAllDeviceSetInfo();
14 
15         public abstract int AddDeviceSetInfo(object deviceSetInfo);
16 
17         public abstract int ModifyDeviceSetInfo(object deviceSetInfo);
18 
19         public abstract int DelDeviceSetInfo(object deviceSetInfo);
20     }
21 }

若需转载请标明出处或链接http://www.cnblogs.com/EaIE099/,本人初入职场,对编程也是一个菜鸟,只想把自己所学点滴记录下来,如有不合理的地方希望各位高手多多指点,非常感谢!

转载于:https://www.cnblogs.com/EaIE099/p/TuString.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值