/// <summary> /// 插入t_LightAlarm /// </summary> public virtual bool Insert(LightAlarmOR lightAlarm) { string sql = "insert into t_LightAlarm (LightID, LightName, DeviceID, ChannelNO) values (@LightID, @LightName, @DeviceID, @ChannelNO)"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@LightID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "LightID", DataRowVersion.Default, lightAlarm.Lightid), new SqlParameter("@LightName", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "LightName", DataRowVersion.Default, lightAlarm.Lightname), new SqlParameter("@DeviceID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "DeviceID", DataRowVersion.Default, lightAlarm.Deviceid), new SqlParameter("@ChannelNO", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "ChannelNO", DataRowVersion.Default, lightAlarm.Channelno) }; return db.ExecuteNoQuery(sql, parameters) > -1; }
public ObservableCollection<LightAlarmOR> selectAllDate() { string sql = "select * from t_LightAlarm"; DataTable dt = null; try { dt = db.ExecuteQuery(sql); } catch (Exception ex) { throw ex; } ObservableCollection<LightAlarmOR> _List = new ObservableCollection<LightAlarmOR>(); foreach (DataRow dr in dt.Rows) { LightAlarmOR obj = new LightAlarmOR(dr); _List.Add(obj); } return _List; }
public LightAlarmOR selectARowDate(string m_id) { string sql = string.Format("select * from t_LightAlarm where Lightid='{0}'", m_id); DataTable dt = null; try { dt = db.ExecuteQueryDataSet(sql).Tables[0]; } catch (Exception ex) { throw ex; } if (dt == null) return null; if (dt.Rows.Count == 0) return null; DataRow dr = dt.Rows[0]; LightAlarmOR m_Ligh = new LightAlarmOR(dr); return m_Ligh; }
/// <summary> /// 更新t_LightAlarm /// </summary> public virtual bool Update(LightAlarmOR lightAlarm) { string sql = "update t_LightAlarm set LightName = @LightName, DeviceID = @DeviceID, ChannelNO = @ChannelNO where LightID = @LightID"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@LightID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "LightID", DataRowVersion.Default, lightAlarm.Lightid), new SqlParameter("@LightName", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "LightName", DataRowVersion.Default, lightAlarm.Lightname), new SqlParameter("@DeviceID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "DeviceID", DataRowVersion.Default, lightAlarm.Deviceid), new SqlParameter("@ChannelNO", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "ChannelNO", DataRowVersion.Default, lightAlarm.Channelno) }; return db.ExecuteNoQuery(sql, parameters) > -1; }
public void Clone(LightAlarmOR obj) { // Lightid = obj.Lightid; // Lightname = obj.Lightname; // Deviceid = obj.Deviceid; // Channelno = obj.Channelno; }
/// <summary> /// 绑定下拉列表 /// </summary> private void BindEvent() { if (EventTypeList == null) { EventTypeList = new EventTypeDA().selectAllDate(); if (EventTypeList == null) EventTypeList = new ObservableCollection<EventTypeOR>(); EventTypeOR tempOR = new EventTypeOR() { Eventid = -1, Eventname = "" }; EventTypeList.Insert(0, tempOR); SelectSwitchEventTypeOR = tempOR; SelectHiEventTypeOR = tempOR; SelectLoEventTypeOR = tempOR; } if (LightAlarmList == null) { LightAlarmList = new LightAlarmDA().selectAllDate(); LightAlarmOR tempOR = new LightAlarmOR() { Lightid = -1, Lightname = "未启用声光报警" }; if (LightAlarmList == null) LightAlarmList = new ObservableCollection<LightAlarmOR>(); LightAlarmList.Insert(0, tempOR); SelectLightAlarmOR = tempOR; SelectReleaseLightAlarmOR = tempOR; } SwitchvalueArr = new ObservableCollection<string>() { "", "高电平", "低电平" }; selectSwitchvalue = ""; }