예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(M_td_about_news model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update hx_td_about_news set ");
            strSql.Append("web_Type_menu_id=@web_Type_menu_id,");
            strSql.Append("News_title=@News_title,");
            strSql.Append("News_Key=@News_Key,");
            strSql.Append("news_Des=@news_Des,");
            strSql.Append("context=@context,");

            strSql.Append("adminuserid=@adminuserid");
            strSql.Append(" where newid=@newid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@web_Type_menu_id", SqlDbType.Int,       4),
                new SqlParameter("@News_title",       SqlDbType.VarChar, 300),
                new SqlParameter("@News_Key",         SqlDbType.VarChar, 100),
                new SqlParameter("@news_Des",         SqlDbType.VarChar, 100),
                new SqlParameter("@context",          SqlDbType.VarChar,  -1),

                new SqlParameter("@adminuserid",      SqlDbType.Int,       4),
                new SqlParameter("@newid",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.web_Type_menu_id;
            parameters[1].Value = model.News_title;
            parameters[2].Value = model.News_Key;
            parameters[3].Value = model.news_Des;
            parameters[4].Value = model.context;

            parameters[5].Value = model.adminuserid;
            parameters[6].Value = model.newid;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public M_td_about_news DataRowToModel(DataRow row)
        {
            M_td_about_news model = new M_td_about_news();

            if (row != null)
            {
                if (row["newid"] != null && row["newid"].ToString() != "")
                {
                    model.newid = int.Parse(row["newid"].ToString());
                }
                if (row["web_Type_menu_id"] != null && row["web_Type_menu_id"].ToString() != "")
                {
                    model.web_Type_menu_id = int.Parse(row["web_Type_menu_id"].ToString());
                }
                if (row["News_title"] != null)
                {
                    model.News_title = row["News_title"].ToString();
                }
                if (row["News_Key"] != null)
                {
                    model.News_Key = row["News_Key"].ToString();
                }
                if (row["news_Des"] != null)
                {
                    model.news_Des = row["news_Des"].ToString();
                }
                if (row["context"] != null)
                {
                    model.context = row["context"].ToString();
                }
                if (row["createtime"] != null && row["createtime"].ToString() != "")
                {
                    model.createtime = DateTime.Parse(row["createtime"].ToString());
                }
                if (row["adminuserid"] != null && row["adminuserid"].ToString() != "")
                {
                    model.adminuserid = int.Parse(row["adminuserid"].ToString());
                }
            }
            return(model);
        }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(M_td_about_news model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into hx_td_about_news(");
            strSql.Append("web_Type_menu_id,News_title,News_Key,news_Des,context,createtime,adminuserid)");
            strSql.Append(" values (");
            strSql.Append("@web_Type_menu_id,@News_title,@News_Key,@news_Des,@context,@createtime,@adminuserid)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@web_Type_menu_id", SqlDbType.Int,         4),
                new SqlParameter("@News_title",       SqlDbType.VarChar,   300),
                new SqlParameter("@News_Key",         SqlDbType.VarChar,   100),
                new SqlParameter("@news_Des",         SqlDbType.VarChar,   100),
                new SqlParameter("@context",          SqlDbType.VarChar,    -1),
                new SqlParameter("@createtime",       SqlDbType.DateTime),
                new SqlParameter("@adminuserid",      SqlDbType.Int, 4)
            };

            parameters[0].Value = model.web_Type_menu_id;
            parameters[1].Value = model.News_title;
            parameters[2].Value = model.News_Key;
            parameters[3].Value = model.news_Des;
            parameters[4].Value = model.context;
            parameters[5].Value = model.createtime;
            parameters[6].Value = model.adminuserid;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public M_td_about_news GetModel(int newid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 newid,web_Type_menu_id,News_title,News_Key,news_Des,context,createtime,adminuserid from hx_td_about_news ");
            strSql.Append(" where newid=@newid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@newid", SqlDbType.Int, 4)
            };
            parameters[0].Value = newid;

            M_td_about_news model = new M_td_about_news();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(M_td_about_news model)
 {
     return(dal.Update(model));
 }
예제 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(M_td_about_news model)
 {
     return(dal.Add(model));
 }