Пример #1
0
        private void EditLink()
        {
            ClassLibrary.Model.InternalLink linksModel = new ClassLibrary.Model.InternalLink();

            linksModel.ID = newsId;

            if (string.IsNullOrEmpty(Request.Form["Title"]))
            {
                Response.Write("<script>alert('请输入标题!');history.back(-1);</script>");
                return;
            }
            else
            {
                linksModel.Title = Request.Form["Title"];
            }

            linksModel.LinkURL = Request.Form["LinkURL"];

            if (linksBLL.Update(linksModel) > 0)
            {
                Function.goMessagePage("修改友情链接", "操作成功", "Links/InternalLinkList.aspx");
            }
            else
            {
                Function.goMessagePage("修改友情链接", "操作失败,请稍后再试", "Links/InternalLinkList.aspx");
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="ID">主键ID</param>
        /// <returns>Links对象</returns>
        public ClassLibrary.Model.InternalLink GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT ID,Title,LinkURL");
            strSql.Append(" FROM ");
            strSql.Append(table);
            strSql.Append(string.Format(" WHERE {0}=@{0}", pk));
            SqlParameter[] parameters =
            {
                new SqlParameter("@" + pk, SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;
            ClassLibrary.Model.InternalLink model = new ClassLibrary.Model.InternalLink();
            DataTable dt = SQLHelper.Query(strSql.ToString(), parameters);

            model.ID = ID;
            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["Title"] != DBNull.Value)
                {
                    model.Title = Convert.ToString(dt.Rows[0]["Title"]);
                }
                if (dt.Rows[0]["LinkURL"] != DBNull.Value)
                {
                    model.LinkURL = Convert.ToString(dt.Rows[0]["LinkURL"]);
                }
            }
            return(model);
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">Links对象</param>
        public int Add(ClassLibrary.Model.InternalLink model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(string.Format("INSERT INTO {0}(", table));
            strSql.Append("Title,LinkURL");
            strSql.Append(") VALUES (");
            strSql.Append("@Title,@LinkURL)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Title",   SqlDbType.NVarChar, 100),
                new SqlParameter("@LinkURL", SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.Title;
            parameters[1].Value = model.LinkURL;
            return(SQLHelper.Execute(strSql.ToString(), parameters));
        }
Пример #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">Links对象</param>
        /// <returns>影响行数</returns>
        public int Update(ClassLibrary.Model.InternalLink model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append(string.Format("UPDATE {0} SET ", table));
            strSql.Append("Title=@Title,");
            strSql.Append("LinkURL=@LinkURL");
            strSql.Append(" WHERE ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",      SqlDbType.Int,        4),
                new SqlParameter("@Title",   SqlDbType.NVarChar, 100),
                new SqlParameter("@LinkURL", SqlDbType.NVarChar, 500)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Title;
            parameters[2].Value = model.LinkURL;
            return(SQLHelper.Execute(strSql.ToString(), parameters));
        }