/// <summary> /// 根据主键ID更新一条记录 /// </summary> /// <param name="model">更新后的实体</param> /// <returns>执行结果受影响行数</returns> public int Update(CheckEmail model) { #region SQL语句 const string sql = @" UPDATE [dbo].[CheckEmail] SET [Actived] = @Actived ,[ActiveCode] = @ActiveCode WHERE [Id] = @Id"; #endregion return(SqlHelper.ExecuteNonQuery(sql, new SqlParameter("@Id", model.Id), new SqlParameter("@Actived", model.Actived), new SqlParameter("@ActiveCode", model.ActiveCode) )); }
/// <summary> /// 向数据库中添加一条记录 /// </summary> /// <param name="model">要添加的实体</param> /// <returns>插入数据的ID</returns> public int Insert(CheckEmail model) { #region SQL语句 const string sql = @" INSERT INTO [dbo].[CheckEmail] ( [Actived] ,[ActiveCode] ) VALUES ( @Actived ,@ActiveCode );select @@IDENTITY"; #endregion var res = SqlHelper.ExecuteScalar(sql, new SqlParameter("@Actived", model.Actived), new SqlParameter("@ActiveCode", model.ActiveCode) ); return(res == null ? 0 : Convert.ToInt32(res)); }