Exemplo n.º 1
0
        /// <summary>
        /// CMS模板内容绑定
        /// </summary>
        /// <returns></returns>
        public ActionResult CmsProductBind()
        {
            int _cmsid = QueryString.IntSafeQ("cmsid");
            CmsContentEntity         _entity         = new CmsContentEntity();
            IList <VWProductEntity>  _cmsstyle       = new List <VWProductEntity>();
            IList <CmsTempletEntity> _cmstempletlist = new List <CmsTempletEntity>();
            int stylenum = 0;

            if (_cmsid > 0)
            {
                _entity         = CmsContentBLL.Instance.GetCmsContent(_cmsid);
                _cmstempletlist = CmsTempletBLL.Instance.GetCmsTempletListByType(_entity.CMSType);
                _cmsstyle       = CmsTemProductBLL.Instance.GetCmsTemProductByCmsid(_cmsid);

                for (int i = 0; i < _cmsstyle.Count; i++)
                {
                    _cmsstyle[i] = ProductBLL.Instance.GetProVWByDetailId(_cmsstyle[i].ProductDetailId);
                }

                if (_cmsstyle != null && _cmsstyle.Count > 0)
                {
                    stylenum = _cmsstyle.Count;
                }
            }
            ViewBag.ContentEntity = _entity;
            ViewBag.ContentStyles = _cmsstyle;
            ViewBag.CmsTemplets   = _cmstempletlist;
            ViewBag.StyleNum      = stylenum;
            return(View());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 判断当前节点是否已存在相同的
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int  ExistNum(CmsContentEntity entity)
        {
            ///id=0,判断总数,ID>0判断除自己之外的总数
            string sql = @"Select count(1) from dbo.[CmsContent] WITH(NOLOCK) ";

            string where = "where ";
            if (entity.Id == 0)
            {
            }
            else
            {
            }
            sql = sql + where;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            if (entity.Id > 0)
            {
                db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            }
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
Exemplo n.º 3
0
        public string CmsComtentAdd()
        {
            string           _str         = FormString.SafeQ("str", 1000000);
            string           title        = FormString.SafeQ("title", 200);
            int              cmstyleid    = FormString.IntSafeQ("cmstyleid");
            int              cmsid        = FormString.IntSafeQ("cmsid", 0);
            string           cmscontent   = FormString.SafeQNo("cmscontent", 1000000);
            int              cmstempletid = FormString.IntSafeQ("cmstempletid");
            CmsContentEntity _cmsentity   = CmsContentBLL.Instance.GetCmsContent(cmsid);

            _cmsentity.Id           = cmsid;
            _cmsentity.CmsContent   = cmscontent;
            _cmsentity.CMSType      = cmstyleid;
            _cmsentity.CreateTime   = DateTime.Now;
            _cmsentity.IsActive     = 1;
            _cmsentity.Title        = title;
            _cmsentity.CmsTempletId = cmstempletid;
            int cmsidresult = CmsContentBLL.Instance.AddCmsContent(_cmsentity);

            if (cmsidresult > 0)
            {
                if (!string.IsNullOrEmpty(_str))
                {
                    int cmsproducts = CmsTemProductBLL.Instance.AddCmsProc(_str, cmsidresult);
                }
                return(((int)CommonStatus.Success).ToString());
            }


            return(((int)CommonStatus.Fail).ToString());
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据主键值读取记录。如果数据库不存在这条数据将返回null
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public CmsContentEntity GetCmsContent(int id)
        {
            string    sql = @"SELECT  [Id],[Title]
      ,[CmsTempletId]
      ,[CMSType]
      ,[CmsContent]
      ,[IsActive]
      ,[CreateTime]
							FROM
							dbo.[CmsContent] WITH(NOLOCK)	
							WHERE [Id]=@id"                            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, id);
            CmsContentEntity entity = new CmsContentEntity();

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    entity.Id           = StringUtils.GetDbInt(reader["Id"]);
                    entity.Title        = StringUtils.GetDbString(reader["Title"]);
                    entity.CMSType      = StringUtils.GetDbInt(reader["CMSType"]);
                    entity.CmsTempletId = StringUtils.GetDbInt(reader["CmsTempletId"]);
                    entity.CmsContent   = StringUtils.GetDbString(reader["CmsContent"]);
                    entity.IsActive     = StringUtils.GetDbInt(reader["IsActive"]);
                    entity.CreateTime   = StringUtils.GetDbDateTime(reader["CreateTime"]);
                }
            }
            return(entity);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 插入一条记录到表CmsContent,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="cmsContent">要添加的CmsContent数据实体对象</param>
 public int AddCmsContent(CmsContentEntity cmsContent)
 {
     if (cmsContent.Id > 0)
     {
         return(UpdateCmsContent(cmsContent));
     }
     else
     {
         return(CmsContentDA.Instance.AddCmsContent(cmsContent));
     }
 }
Exemplo n.º 6
0
        public static string GetCms(int Model, string ImgType)
        {
            string           html    = "";
            CmsContentEntity _entity = CmsContentBLL.Instance.GetCmsContent(Model);

            if (_entity != null && !string.IsNullOrEmpty(_entity.CmsContent))
            {
                html = _entity.CmsContent;
            }
            return(html);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。
        /// 如果数据库有数据被更新了则返回True,否则返回False
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="cmsContent">待更新的实体对象</param>
        public int UpdateCmsContent(CmsContentEntity entity)
        {
            string    sql = @" UPDATE dbo.[CmsContent] SET
                       [CmsTempletId]=@CmsTempletId,Title=@Title,CMSType=@CMSType,[CmsContent]=@CmsContent,[IsActive]=@IsActive,[CreateTime]=@CreateTime
                       WHERE [Id]=@id";
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            db.AddInParameter(cmd, "@CmsTempletId", DbType.Int32, entity.CmsTempletId);
            db.AddInParameter(cmd, "@Title", DbType.String, entity.Title);
            db.AddInParameter(cmd, "@CMSType", DbType.Int32, entity.CMSType);
            db.AddInParameter(cmd, "@CmsContent", DbType.String, entity.CmsContent);
            db.AddInParameter(cmd, "@IsActive", DbType.Int32, entity.IsActive);
            db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime);
            return(db.ExecuteNonQuery(cmd));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 插入一条记录到表CmsContent,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="cmsContent">待插入的实体对象</param>
        public int AddCmsContent(CmsContentEntity entity)
        {
            string    sql = @"insert into CmsContent( [CmsTempletId],[Title],CMSType,[CmsContent],[IsActive],[CreateTime])VALUES
			            ( @CmsTempletId,@Title,@CMSType,@CmsContent,@IsActive,@CreateTime);
			SELECT SCOPE_IDENTITY();"            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@CmsTempletId", DbType.Int32, entity.CmsTempletId);
            db.AddInParameter(cmd, "@Title", DbType.String, entity.Title);
            db.AddInParameter(cmd, "@CMSType", DbType.Int32, entity.CMSType);
            db.AddInParameter(cmd, "@CmsContent", DbType.String, entity.CmsContent);
            db.AddInParameter(cmd, "@IsActive", DbType.Int32, entity.IsActive);
            db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime);
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <CmsContentEntity> GetCmsContentAll()
        {
            string sql = @"SELECT    [CMSType],[Id],[CmsTempletId],[CmsContent],[IsActive],[CreateTime] from dbo.[CmsContent] WITH(NOLOCK)	";
            IList <CmsContentEntity> entityList = new List <CmsContentEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    CmsContentEntity entity = new CmsContentEntity();
                    entity.Id           = StringUtils.GetDbInt(reader["Id"]);
                    entity.CmsTempletId = StringUtils.GetDbInt(reader["CmsTempletId"]);
                    entity.CmsContent   = StringUtils.GetDbString(reader["CmsContent"]);
                    entity.CMSType      = StringUtils.GetDbInt(reader["CMSType"]);
                    entity.IsActive     = StringUtils.GetDbInt(reader["IsActive"]);
                    entity.CreateTime   = StringUtils.GetDbDateTime(reader["CreateTime"]);
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <CmsContentEntity> GetCmsContentList(int pagesize, int pageindex, ref int recordCount, int cid, string title, int ctype, int status)
        {
            string where = " where 1=1 ";
            if (cid > 0)
            {
                where += " and a.Id=@CId ";
            }
            if (!string.IsNullOrEmpty(title))
            {
                where += " and a.Title like @Title ";
            }
            if (ctype > 0)
            {
                where += " and a.CMSType=@CMSType ";
            }
            if (status > -1)
            {
                where += " and a.IsActive=@IsActive ";
            }
            string sql = @"SELECT   [Id],[Title]
      ,[CmsTempletId]
      ,[CMSType]
      ,[CmsContent]
      ,[IsActive]
      ,[CreateTime]
						FROM
						(SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER,
						 [Id],[Title]
      ,[CmsTempletId]
      ,[CMSType]
      ,[CmsContent]
      ,[IsActive]
      ,[CreateTime] from dbo.[CmsContent] a WITH(NOLOCK)	
						"                         + where + @" ) as temp 
						where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize"                        ;

            string sql2 = @"Select count(1) from dbo.[CmsContent] a with (nolock) " + where;
            IList <CmsContentEntity> entityList = new List <CmsContentEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageindex);
            db.AddInParameter(cmd, "@PageSize", DbType.Int32, pagesize);
            if (cid > 0)
            {
                db.AddInParameter(cmd, "@CId", DbType.Int32, cid);
            }
            if (!string.IsNullOrEmpty(title))
            {
                db.AddInParameter(cmd, "@Title", DbType.String, "%" + title + "%");
            }
            if (ctype > 0)
            {
                db.AddInParameter(cmd, "@CMSType", DbType.Int32, ctype);
            }
            if (status > -1)
            {
                db.AddInParameter(cmd, "@IsActive", DbType.Int32, status);
            }
            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    CmsContentEntity entity = new CmsContentEntity();
                    entity.Id           = StringUtils.GetDbInt(reader["Id"]);
                    entity.Title        = StringUtils.GetDbString(reader["Title"]);
                    entity.CmsTempletId = StringUtils.GetDbInt(reader["CmsTempletId"]);
                    entity.CmsContent   = StringUtils.GetDbString(reader["CmsContent"]);
                    entity.CMSType      = StringUtils.GetDbInt(reader["CMSType"]);
                    entity.IsActive     = StringUtils.GetDbInt(reader["IsActive"]);
                    entity.CreateTime   = StringUtils.GetDbDateTime(reader["CreateTime"]);
                    entityList.Add(entity);
                }
            }
            cmd = db.GetSqlStringCommand(sql2);
            if (cid > 0)
            {
                db.AddInParameter(cmd, "@CId", DbType.Int32, cid);
            }
            if (!string.IsNullOrEmpty(title))
            {
                db.AddInParameter(cmd, "@Title", DbType.String, "%" + title + "%");
            }
            if (ctype > 0)
            {
                db.AddInParameter(cmd, "@CMSType", DbType.Int32, ctype);
            }
            if (status != -1)
            {
                db.AddInParameter(cmd, "@IsActive", DbType.Int32, status);
            }
            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    recordCount = StringUtils.GetDbInt(reader[0]);
                }
                else
                {
                    recordCount = 0;
                }
            }
            return(entityList);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 更新一条CmsContent记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="cmsContent">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateCmsContent(CmsContentEntity cmsContent)
 {
     return(CmsContentDA.Instance.UpdateCmsContent(cmsContent));
 }
Exemplo n.º 12
0
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(CmsContentEntity cmsContent)
 {
     return(CmsContentDA.Instance.ExistNum(cmsContent) > 0);
 }