Ejemplo n.º 1
0
        /// <summary>
        /// 获取一条信息 条件 Tops the WebGroupNews.
        /// </summary>
        /// <returns></returns>
        public ROYcms.Sys.Model.ROYcms_WebGroupNews TopNews(string where)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 * ");
            strSql.Append(" FROM [" + PubConstant.date_prefix + "WebGroupNews] ");
            if (where.Trim() != "")
            {
                strSql.Append(" where " + where);
            }

            ROYcms.Sys.Model.ROYcms_WebGroupNews model = new ROYcms.Sys.Model.ROYcms_WebGroupNews();
            DataSet ds = ROYcms.DB.DbHelpers.GetDataSet(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["bh"].ToString() != "")
                {
                    model.bh = int.Parse(ds.Tables[0].Rows[0]["bh"].ToString());
                }
                model.pic     = ds.Tables[0].Rows[0]["pic"].ToString();
                model.title   = ds.Tables[0].Rows[0]["title"].ToString();
                model.keyword = ds.Tables[0].Rows[0]["keyword"].ToString();
                model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString();
                if (ds.Tables[0].Rows[0]["classname"].ToString() != "")
                {
                    model.classname = int.Parse(ds.Tables[0].Rows[0]["classname"].ToString());
                }
                model.contents = ds.Tables[0].Rows[0]["contents"].ToString();
                model.jumpurl  = ds.Tables[0].Rows[0]["jumpurl"].ToString();
                model.infor    = ds.Tables[0].Rows[0]["infor"].ToString();
                model.author   = ds.Tables[0].Rows[0]["author"].ToString();
                model.url      = ds.Tables[0].Rows[0]["url"].ToString();
                if (ds.Tables[0].Rows[0]["ding"].ToString() != "")
                {
                    model.ding = int.Parse(ds.Tables[0].Rows[0]["ding"].ToString());
                }
                if (ds.Tables[0].Rows[0]["dig"].ToString() != "")
                {
                    model.dig = int.Parse(ds.Tables[0].Rows[0]["dig"].ToString());
                }
                model.tag = ds.Tables[0].Rows[0]["tag"].ToString();
                if (ds.Tables[0].Rows[0]["hits"].ToString() != "")
                {
                    model.hits = int.Parse(ds.Tables[0].Rows[0]["hits"].ToString());
                }
                if (ds.Tables[0].Rows[0]["time"].ToString() != "")
                {
                    model.time = DateTime.Parse(ds.Tables[0].Rows[0]["time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["orders"].ToString() != "")
                {
                    model.orders = int.Parse(ds.Tables[0].Rows[0]["orders"].ToString());
                }
                if (ds.Tables[0].Rows[0]["tuijian"].ToString() != "")
                {
                    model.tuijian = int.Parse(ds.Tables[0].Rows[0]["tuijian"].ToString());
                }
                if (ds.Tables[0].Rows[0]["switchs"].ToString() != "")
                {
                    model.switchs = int.Parse(ds.Tables[0].Rows[0]["switchs"].ToString());
                }
                if (ds.Tables[0].Rows[0]["link"].ToString() != "")
                {
                    model.link = ds.Tables[0].Rows[0]["link"].ToString();
                }
                if (ds.Tables[0].Rows[0]["type"].ToString() != "")
                {
                    model.type = ds.Tables[0].Rows[0]["type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["GUID"].ToString() != "")
                {
                    model.GUID = ds.Tables[0].Rows[0]["GUID"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ROYcms.Sys.Model.ROYcms_WebGroupNews model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + PubConstant.date_prefix + "WebGroupNews set ");
            strSql.Append("pic=@pic,");
            strSql.Append("title=@title,");
            strSql.Append("keyword=@keyword,");
            strSql.Append("zhaiyao=@zhaiyao,");
            strSql.Append("classname=@classname,");
            strSql.Append("contents=@contents,");
            strSql.Append("jumpurl=@jumpurl,");
            strSql.Append("infor=@infor,");
            strSql.Append("author=@author,");
            strSql.Append("url=@url,");
            strSql.Append("ding=@ding,");
            strSql.Append("dig=@dig,");
            strSql.Append("tag=@tag,");
            strSql.Append("hits=@hits,");
            strSql.Append("time=@time,");
            strSql.Append("orders=@orders,");
            strSql.Append("tuijian=@tuijian,");
            strSql.Append("switchs=@switchs,");
            strSql.Append("link=@link,");
            strSql.Append("type=@type,");
            strSql.Append("GUID=@GUID");
            strSql.Append(" where bh=@bh ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@bh",        SqlDbType.Int,          4),
                new SqlParameter("@pic",       SqlDbType.VarChar,    500),
                new SqlParameter("@title",     SqlDbType.VarChar,    100),
                new SqlParameter("@keyword",   SqlDbType.VarChar,    100),
                new SqlParameter("@zhaiyao",   SqlDbType.VarChar,   1000),
                new SqlParameter("@classname", SqlDbType.Int,          4),
                new SqlParameter("@contents",  SqlDbType.Text),
                new SqlParameter("@jumpurl",   SqlDbType.VarChar,    100),
                new SqlParameter("@infor",     SqlDbType.VarChar,     50),
                new SqlParameter("@author",    SqlDbType.VarChar,     50),
                new SqlParameter("@url",       SqlDbType.VarChar,    100),
                new SqlParameter("@ding",      SqlDbType.Int,          4),
                new SqlParameter("@dig",       SqlDbType.Int,          4),
                new SqlParameter("@tag",       SqlDbType.VarChar,    100),
                new SqlParameter("@hits",      SqlDbType.Int,          4),
                new SqlParameter("@time",      SqlDbType.DateTime),
                new SqlParameter("@orders",    SqlDbType.Int,          4),
                new SqlParameter("@tuijian",   SqlDbType.Int,          4),
                new SqlParameter("@switchs",   SqlDbType.Int,          4),
                new SqlParameter("@link",      SqlDbType.VarChar,     50),
                new SqlParameter("@type",      SqlDbType.VarChar,     50),
                new SqlParameter("@GUID",      SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.bh;
            parameters[1].Value  = model.pic;
            parameters[2].Value  = model.title;
            parameters[3].Value  = model.keyword;
            parameters[4].Value  = model.zhaiyao;
            parameters[5].Value  = model.classname;
            parameters[6].Value  = model.contents;
            parameters[7].Value  = model.jumpurl;
            parameters[8].Value  = model.infor;
            parameters[9].Value  = model.author;
            parameters[10].Value = model.url;
            parameters[11].Value = model.ding;
            parameters[12].Value = model.dig;
            parameters[13].Value = model.tag;
            parameters[14].Value = model.hits;
            parameters[15].Value = model.time;
            parameters[16].Value = model.orders;
            parameters[17].Value = model.tuijian;
            parameters[18].Value = model.switchs;
            parameters[19].Value = model.link;
            parameters[20].Value = model.type;
            parameters[21].Value = model.GUID;


            ROYcms.DB.DbHelpers.NonQuery(strSql.ToString(), parameters);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_WebGroupNews GetModel(int bh)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from " + PubConstant.date_prefix + "WebGroupNews ");
            strSql.Append(" where bh=@bh ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@bh", SqlDbType.Int, 4)
            };
            parameters[0].Value = bh;

            ROYcms.Sys.Model.ROYcms_WebGroupNews model = new ROYcms.Sys.Model.ROYcms_WebGroupNews();
            DataSet ds = ROYcms.DB.DbHelpers.GetDataSet(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["bh"].ToString() != "")
                {
                    model.bh = int.Parse(ds.Tables[0].Rows[0]["bh"].ToString());
                }
                model.pic     = ds.Tables[0].Rows[0]["pic"].ToString();
                model.title   = ds.Tables[0].Rows[0]["title"].ToString();
                model.keyword = ds.Tables[0].Rows[0]["keyword"].ToString();
                model.zhaiyao = ds.Tables[0].Rows[0]["zhaiyao"].ToString();
                if (ds.Tables[0].Rows[0]["classname"].ToString() != "")
                {
                    model.classname = int.Parse(ds.Tables[0].Rows[0]["classname"].ToString());
                }
                model.contents = ds.Tables[0].Rows[0]["contents"].ToString();
                model.jumpurl  = ds.Tables[0].Rows[0]["jumpurl"].ToString();
                model.infor    = ds.Tables[0].Rows[0]["infor"].ToString();
                model.author   = ds.Tables[0].Rows[0]["author"].ToString();
                model.url      = ds.Tables[0].Rows[0]["url"].ToString();
                if (ds.Tables[0].Rows[0]["ding"].ToString() != "")
                {
                    model.ding = int.Parse(ds.Tables[0].Rows[0]["ding"].ToString());
                }
                if (ds.Tables[0].Rows[0]["dig"].ToString() != "")
                {
                    model.dig = int.Parse(ds.Tables[0].Rows[0]["dig"].ToString());
                }
                model.tag = ds.Tables[0].Rows[0]["tag"].ToString();
                if (ds.Tables[0].Rows[0]["hits"].ToString() != "")
                {
                    model.hits = int.Parse(ds.Tables[0].Rows[0]["hits"].ToString());
                }
                if (ds.Tables[0].Rows[0]["time"].ToString() != "")
                {
                    model.time = DateTime.Parse(ds.Tables[0].Rows[0]["time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["orders"].ToString() != "")
                {
                    model.orders = int.Parse(ds.Tables[0].Rows[0]["orders"].ToString());
                }
                if (ds.Tables[0].Rows[0]["tuijian"].ToString() != "")
                {
                    model.tuijian = int.Parse(ds.Tables[0].Rows[0]["tuijian"].ToString());
                }
                if (ds.Tables[0].Rows[0]["switchs"].ToString() != "")
                {
                    model.switchs = int.Parse(ds.Tables[0].Rows[0]["switchs"].ToString());
                }
                if (ds.Tables[0].Rows[0]["link"].ToString() != "")
                {
                    model.link = ds.Tables[0].Rows[0]["link"].ToString();
                }
                if (ds.Tables[0].Rows[0]["type"].ToString() != "")
                {
                    model.type = ds.Tables[0].Rows[0]["type"].ToString();
                }
                if (ds.Tables[0].Rows[0]["GUID"].ToString() != "")
                {
                    model.GUID = ds.Tables[0].Rows[0]["GUID"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public int Add(ROYcms.Sys.Model.ROYcms_WebGroupNews model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + PubConstant.date_prefix + "WebGroupNews(");
            strSql.Append("pic,title,keyword,zhaiyao,classname,contents,jumpurl,infor,author,url,ding,dig,tag,hits,orders,tuijian,switchs,link,type,GUID)");
            strSql.Append(" values (");
            strSql.Append("@pic,@title,@keyword,@zhaiyao,@classname,@contents,@jumpurl,@infor,@author,@url,@ding,@dig,@tag,@hits,@orders,@tuijian,@switchs,@link,@type,@GUID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@pic",       SqlDbType.VarChar,  500),
                new SqlParameter("@title",     SqlDbType.VarChar,  100),
                new SqlParameter("@keyword",   SqlDbType.VarChar,  100),
                new SqlParameter("@zhaiyao",   SqlDbType.VarChar, 1000),
                new SqlParameter("@classname", SqlDbType.Int,        4),
                new SqlParameter("@contents",  SqlDbType.Text),
                new SqlParameter("@jumpurl",   SqlDbType.VarChar,  100),
                new SqlParameter("@infor",     SqlDbType.VarChar,   50),
                new SqlParameter("@author",    SqlDbType.VarChar,   50),
                new SqlParameter("@url",       SqlDbType.VarChar,  100),
                new SqlParameter("@ding",      SqlDbType.Int,        4),
                new SqlParameter("@dig",       SqlDbType.Int,        4),
                new SqlParameter("@tag",       SqlDbType.VarChar,  100),
                new SqlParameter("@hits",      SqlDbType.Int,        4),
                new SqlParameter("@orders",    SqlDbType.Int,        4),
                new SqlParameter("@tuijian",   SqlDbType.Int,        4),
                new SqlParameter("@switchs",   SqlDbType.Int,        4),
                new SqlParameter("@link",      SqlDbType.VarChar,   50),
                new SqlParameter("@type",      SqlDbType.VarChar,   50),
                new SqlParameter("@GUID",      SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.pic;
            parameters[1].Value  = model.title;
            parameters[2].Value  = model.keyword;
            parameters[3].Value  = model.zhaiyao;
            parameters[4].Value  = model.classname;
            parameters[5].Value  = model.contents;
            parameters[6].Value  = model.jumpurl;
            parameters[7].Value  = model.infor;
            parameters[8].Value  = model.author;
            parameters[9].Value  = model.url;
            parameters[10].Value = model.ding;
            parameters[11].Value = model.dig;
            parameters[12].Value = model.tag;
            parameters[13].Value = model.hits;
            parameters[14].Value = model.orders;
            parameters[15].Value = model.tuijian;
            parameters[16].Value = model.switchs;
            parameters[17].Value = model.link;
            parameters[18].Value = model.type;
            parameters[19].Value = model.GUID;
            object obj = ROYcms.DB.DbHelpers.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }