/// <summary> /// 根据房间ID显示设备 /// </summary> /// <param name="roomID"></param> private void ShowDevice(string roomID) { try { DataTable dt = _DepDeviceModel.GetDeviceInfo(roomID); dt.Columns.Add(new DataColumn("是否启用", typeof(bool))); dt.Columns.Add(new DataColumn("设备说明", typeof(string))); dt.Columns.Add(new DataColumn("负责人", typeof(string))); foreach (DataRow dr in dt.Rows) { string strj = dr["设备信息"].ToString(); JRoomDeviceInfo DeviceInfo = JsonHelper.DeserializeObject <JRoomDeviceInfo>(strj); dr["是否启用"] = bool.Parse(DeviceInfo.是否启用.ToString()); if (DeviceInfo.设备说明 != null) { dr["设备说明"] = DeviceInfo.设备说明.ToString(); } if (DeviceInfo.负责人 != null) { dr["负责人"] = DeviceInfo.负责人.ToString(); } } dgvDevice.DataSource = dt; if (dgvDevice.Columns.Contains("影像类别")) { dgvDevice.Columns["影像类别"].ReadOnly = true; } SetDgvDeviceFace(); } catch (Exception ex) { MsgBox.ShowException(ex, this); } }
/// <summary> /// 绑定设备 /// </summary> /// <param name="roomId"></param> private void BindDevice(string roomId) { //DataTable dtDevice = _scm.GetDeviceInfo(roomId); DataTable dtDevice = _depDeviceModel.GetDeviceInfo(roomId); DataTable dtFilter = dtDevice.Clone(); cbxDevice.DisplayMember = "设备名称"; cbxDevice.ValueMember = "设备ID"; string sFilter = "设备信息 like '%\"是否启用\":true%'"; DataRow[] dRows = dtDevice.Select(sFilter); foreach (DataRow item in dRows) { dtFilter.ImportRow(item); } cbxDevice.DataSource = dtFilter; if (cbxDevice.Items.Count > 0) { cbxDevice.SelectedIndex = 0; } }