/// <summary> /// 插入t_HealthConfig /// </summary> public virtual bool Insert(HealthConfigOR healthConfig) { string sql = @"insert into t_HealthConfig (ID,DeviceID, SDID,EffectLevel) values (@ID,@DeviceID, @SDID, @EffectLevel)"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.VarChar, 36, ParameterDirection.Input, false, 0, 0, "ID", DataRowVersion.Default, healthConfig.ID), new SqlParameter("@DeviceID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "DeviceID", DataRowVersion.Default, healthConfig.Deviceid), new SqlParameter("@SDID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "SDID", DataRowVersion.Default, healthConfig.Sdid), //new SqlParameter("@PDID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "PDID", DataRowVersion.Default, healthConfig.Pdid), new SqlParameter("@EffectLevel", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "EffectLevel", DataRowVersion.Default, healthConfig.Effectlevel) }; SqlParameter pChannel = new SqlParameter("@ChannelNO", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "ChannelNO", DataRowVersion.Default, healthConfig.Channelno); SqlParameter[] paraNew; if (healthConfig.Channelno.HasValue) { sql = @"insert into t_HealthConfig (ID,DeviceID, SDID,ChannelNO, EffectLevel) values (@ID,@DeviceID, @SDID,@ChannelNO, @EffectLevel)"; paraNew = InsertPara(parameters, pChannel); } else { paraNew = parameters; } return db.ExecuteNoQuery(sql, paraNew) > -1; }
private HealthConfigOR SetValue() { HealthConfigOR m_Heal = new HealthConfigOR(); if (Request.QueryString["opType"] == "alert") { m_Heal.ID = Request.QueryString["id"].ToString(); } else { m_Heal.Deviceid = Convert.ToInt32(Request.QueryString["DeviceID"]); } m_Heal.Sdid =Convert.ToInt32( dpdDeviceid.SelectedValue);// if (!string.IsNullOrEmpty(dpdchannelno.SelectedValue)) { m_Heal.Channelno = int.Parse(dpdchannelno.SelectedValue);// } m_Heal.Effectlevel = int.Parse(txtEffectlevel.Text);// return m_Heal; }
public HealthConfigOR selectARowDate(string m_id) { string sql = string.Format("select * from t_HealthConfig where id='{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]; HealthConfigOR m_Heal = new HealthConfigOR(dr); return m_Heal; }
/// <summary> /// 更新t_HealthConfig /// </summary> public virtual bool Update(HealthConfigOR healthConfig) { string sql = @"update t_HealthConfig set SDID = @SDID, ChannelNO = NULL, EffectLevel = @EffectLevel where ID = @ID"; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.VarChar, 36, ParameterDirection.Input, false, 0, 0, "ID", DataRowVersion.Default, healthConfig.ID), new SqlParameter("@SDID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "SDID", DataRowVersion.Default, healthConfig.Sdid), //new SqlParameter("@ChannelNO", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "ChannelNO", DataRowVersion.Default, healthConfig.Channelno), new SqlParameter("@EffectLevel", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "EffectLevel", DataRowVersion.Default, healthConfig.Effectlevel) }; SqlParameter pChannel = new SqlParameter("@ChannelNO", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "ChannelNO", DataRowVersion.Default, healthConfig.Channelno); SqlParameter[] paraNew; if (healthConfig.Channelno.HasValue) { sql = @"update t_HealthConfig set SDID = @SDID, ChannelNO = @ChannelNO, EffectLevel = @EffectLevel where ID = @ID"; paraNew = InsertPara(parameters, pChannel); } else { paraNew = parameters; } return db.ExecuteNoQuery(sql, paraNew) > -1; }