Ejemplo n.º 1
0
        /// <summary>
        /// 根据DataRow获得分类信息
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        private static VideoCatInfo GetVideoCatInfoByDataRow(DataRow dr)
        {
            var model = new VideoCatInfo();

            if (dr == null)
            {
                return(model);
            }
            model.Id        = dr.Field <int>("Id");
            model.IsDeleted = dr.Field <bool>("IsDeleted");
            model.Name      = dr.Field <string>("Name");
            model.Sort      = dr.Field <int>("Sort");
            return(model);
        }
Ejemplo n.º 2
0
 public static VideoCatInfo Create(VideoCatInfo model)
 {
     if (model.Id == 0)
     {
         //Add
         int id = CategoryManage.AddVideoCatInfo(model);
         model.Id = id;
     }
     else
     {
         CategoryManage.UpdateVideoCatInfo(model);
     }
     return(model);
 }
Ejemplo n.º 3
0
        public ActionResult List()
        {
            var list = VideoCatService.List();

            ViewBag.List = list;
            int          id    = Controleng.Common.CECRequest.GetQueryInt("id", 0);
            VideoCatInfo model = null;

            if (id > 0)
            {
                model = VideoCatService.GetById(id);
            }
            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult List(VideoCatInfo model)
        {
            var list = VideoCatService.List();

            if (ModelState.IsValid)
            {
                VideoCatService.Create(model);
                ViewBag.Msg = "保存成功";
            }

            list         = VideoCatService.List();
            ViewBag.List = list;


            return(View());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 更新分类信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int UpdateVideoCatInfo(VideoCatInfo model)
        {
            string strSQL = "UPDATE Categories SET Name = @Name,Sort = @Sort,IsDeleted = @IsDeleted WHERE Id = @Id AND [Type] = 'video'";

            SqlParameter[] parms =
            {
                new SqlParameter("Id",        SqlDbType.Int),
                new SqlParameter("Name",      SqlDbType.NVarChar),
                new SqlParameter("Sort",      SqlDbType.Int),
                new SqlParameter("IsDeleted", SqlDbType.Bit),
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.Name;
            parms[2].Value = model.Sort;
            parms[3].Value = model.IsDeleted;

            return(SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加分类
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int AddVideoCatInfo(VideoCatInfo model)
        {
            string strSQL = "INSERT INTO Categories(ParentId,RootId,ParentIds,Name,Sort,IsDeleted,[Type],CreateDateTime) VALUES(0,0,'0',@Name,@Sort,@IsDeleted,@Type,GETDATE());SELECT @@IDENTITY;";

            SqlParameter[] param =
            {
                new SqlParameter("Name",      SqlDbType.NVarChar),
                new SqlParameter("Sort",      SqlDbType.Int),
                new SqlParameter("IsDeleted", SqlDbType.Bit),
                new SqlParameter("Type",      SqlDbType.VarChar)
            };
            param[0].Value = model.Name;
            param[1].Value = model.Sort;
            param[2].Value = model.IsDeleted;
            param[3].Value = CatType.Video.ToString().ToLower();

            return(Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, strSQL, param)));
        }