/// <summary> /// 更新设备 /// </summary> public bool UpdateDevice() { try { AMS_DeviceModel samedevice = AMS_DeviceBLL.GetDevicebyNo(_Number); if (samedevice == null || samedevice.Id == _Id) { AMS_DeviceModel newdevice = new AMS_DeviceModel(); newdevice.CampusId = _Campusid; newdevice.Id = _Id; newdevice.CaputrePath = _Caputrepath; newdevice.CaputreTime = _Caputretime; newdevice.IsDel = _Isdel; newdevice.Number = _Number; newdevice.Flag = true; newdevice.Describe = _Describe; if (AMS_DeviceBLL.UpdateDeviceModel(newdevice) == AdvertManage.Model.Enum.HandleResult.Failed) { throw new Exception("设备更新失败!详情请查看日志文件"); } return(true); } else { throw new Exception("该设备编号已存在!"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// 添加设备 /// </summary> public bool AddDevice() { try { AMS_DeviceModel samedevice = AMS_DeviceBLL.GetDevicebyNo(_Number); if (samedevice == null) { AMS_DeviceModel newdevice = new AMS_DeviceModel(); if (_Campusid == 0) { throw new Exception("请选择校区!"); } newdevice.CampusId = _Campusid; newdevice.IsDel = _Isdel; newdevice.Number = _Number; newdevice.Flag = _Flag; newdevice.Describe = _Describe; if (AMS_DeviceBLL.AddDeviceModel(newdevice) == AdvertManage.Model.Enum.HandleResult.Failed) { throw new Exception("设备添加失败!详情请查看日志文件"); } return(true); } else { throw new Exception("该设备编号已存在!"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }