/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.T_WarningRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_WarningRecord set "); strSql.Append("PointID=@PointID,"); strSql.Append("GeneID=@GeneID,"); strSql.Append("Value=@Value,"); strSql.Append("Content=@Content,"); strSql.Append("WriteTime=@WriteTime,"); strSql.Append("WarningType=@WarningType"); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@PointID", SqlDbType.Int, 4), new SqlParameter("@GeneID", SqlDbType.Int, 4), new SqlParameter("@Value", SqlDbType.Decimal, 9), new SqlParameter("@Content", SqlDbType.NVarChar, -1), new SqlParameter("@WriteTime", SqlDbType.DateTime), new SqlParameter("@WarningType", SqlDbType.NVarChar, 25), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.PointID; parameters[1].Value = model.GeneID; parameters[2].Value = model.Value; parameters[3].Value = model.Content; parameters[4].Value = model.WriteTime; parameters[5].Value = model.WarningType; parameters[6].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.T_WarningRecord model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_WarningRecord("); strSql.Append("Id,PointID,GeneID,Value,Content,WriteTime,WarningType)"); strSql.Append(" values ("); strSql.Append("@Id,@PointID,@GeneID,@Value,@Content,@WriteTime,@WarningType)"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@PointID", SqlDbType.Int, 4), new SqlParameter("@GeneID", SqlDbType.Int, 4), new SqlParameter("@Value", SqlDbType.Decimal, 9), new SqlParameter("@Content", SqlDbType.NVarChar, -1), new SqlParameter("@WriteTime", SqlDbType.DateTime), new SqlParameter("@WarningType", SqlDbType.NVarChar, 25) }; parameters[0].Value = model.Id; parameters[1].Value = model.PointID; parameters[2].Value = model.GeneID; parameters[3].Value = model.Value; parameters[4].Value = model.Content; parameters[5].Value = model.WriteTime; parameters[6].Value = model.WarningType; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.T_WarningRecord DataRowToModel(DataRow row) { Maticsoft.Model.T_WarningRecord model = new Maticsoft.Model.T_WarningRecord(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["PointID"] != null && row["PointID"].ToString() != "") { model.PointID = int.Parse(row["PointID"].ToString()); } if (row["GeneID"] != null && row["GeneID"].ToString() != "") { model.GeneID = int.Parse(row["GeneID"].ToString()); } if (row["Value"] != null && row["Value"].ToString() != "") { model.Value = decimal.Parse(row["Value"].ToString()); } if (row["Content"] != null) { model.Content = row["Content"].ToString(); } if (row["WriteTime"] != null && row["WriteTime"].ToString() != "") { model.WriteTime = DateTime.Parse(row["WriteTime"].ToString()); } if (row["WarningType"] != null) { model.WarningType = row["WarningType"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.T_WarningRecord GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,PointID,GeneID,Value,Content,WriteTime,WarningType from T_WarningRecord "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; Maticsoft.Model.T_WarningRecord model = new Maticsoft.Model.T_WarningRecord(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }