/// <summary> /// 由一行数据得到一个实体 /// </summary> /// <param name="dr">SqlDataReader对象</param> /// <returns>实体对象</returns> private Sys_Dict GetModel(SqlDataReader dr) { Sys_Dict model = new Sys_Dict(); model.ID = dbHelper.GetInt(dr["ID"]); model.Type = dbHelper.GetString(dr["Type"]); model.Title = dbHelper.GetString(dr["Title"]); model.Url = dbHelper.GetString(dr["Url"]); model.Email = dbHelper.GetString(dr["Email"]); model.Click = dbHelper.GetInt(dr["Click"]); return(model); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="ID">编号ID</param> /// <returns>返回影响行数</returns> public int Add(Sys_Dict model) { StringBuilder strSql = new StringBuilder(); strSql.Append("INSERT INTO " + tablePrefix + "Sys_Dict("); strSql.Append("Type,Title,Url,Email,Click)"); strSql.Append(" VALUES ("); strSql.Append("@Type,@Title,@Url,@Email,@Click)"); SqlParameter[] cmdParms = { AddInParameter("@Type", SqlDbType.VarChar, 50, model.Type), AddInParameter("@Title", SqlDbType.NVarChar, 50, model.Title), AddInParameter("@Url", SqlDbType.VarChar, 255, model.Url), AddInParameter("@Email", SqlDbType.VarChar, 50, model.Email), AddInParameter("@Click", SqlDbType.Int, 4, model.Click) }; return(dbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms)); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">实体对象</param> /// <returns>返回影响行数</returns> public int Update(Sys_Dict model) { StringBuilder strSql = new StringBuilder(); strSql.Append("UPDATE " + tablePrefix + "Sys_Dict SET "); strSql.Append("Type=@Type,"); strSql.Append("Title=@Title,"); strSql.Append("Url=@Url,"); strSql.Append("Email=@Email,"); strSql.Append("Click=@Click"); strSql.Append(" WHERE ID=@ID"); SqlParameter[] cmdParms = { AddInParameter("@Type", SqlDbType.VarChar, 50, model.Type), AddInParameter("@Title", SqlDbType.NVarChar, 50, model.Title), AddInParameter("@Url", SqlDbType.VarChar, 255, model.Url), AddInParameter("@Email", SqlDbType.VarChar, 50, model.Email), AddInParameter("@Click", SqlDbType.Int, 4, model.Click), AddInParameter("@ID", SqlDbType.Int, 4, model.ID) }; return(dbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), cmdParms)); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">实体对象</param> /// <returns>返回影响行数</returns> public int Update(Sys_Dict model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">实体对象</param> /// <returns>返回影响行数</returns> public int Add(Sys_Dict model) { return(dal.Add(model)); }