Example #1
0
        public ActionResult _ArticleListForChannelIndex(string title,int catId,TechInfo techInfo) {
            var articleList = ArticleService.ListWithoutPage(3, new int[] { catId }, new int[] { techInfo.Id });

            ViewBag.Title = title;
            ViewBag.CatId = catId;
            ViewBag.TechInfo = techInfo;
            ViewBag.ArticleList = articleList;

            return View();
        }
Example #2
0
 public static TechInfo Create(TechInfo model) {
     if (model.Id == 0)
     {
         //Add
         int id = CategoryManage.AddTechInfo(model);
         model.Id = id;
     }
     else {
         CategoryManage.UpdateTechInfo(model);
     }
     return model;
 }
Example #3
0
        public ActionResult List(TechInfo model) {
            //检查
            //如果添加,判断别名是否存在
            bool isAdd = true;
            var list = TechService.List();
            if(model.Id>0){
                isAdd = false;
            }
            if (isAdd)
            {
                //判断是否别名存在
                if (!string.IsNullOrEmpty(model.Alias))
                {
                    if (list.Where(m => m.Alias == model.Alias).Count() > 0)
                    {
                        ModelState.AddModelError("ALIASEXISTS", "别名存在,请选择其他别名");
                    }
                }
            }
            else { 
                //编辑,除了自身之外,判断是否存在
                if(!string.IsNullOrEmpty(model.Alias)){
                    if(list.Where(m=> (m.Alias == model.Alias && m.Id != model.Id) ).Count() >0){
                        ModelState.AddModelError("ALIASEXISTS", "别名存在,请选择其他别名");
                    }
                }
            }
            
            if(ModelState.IsValid){
                TechService.Create(model);
                ViewBag.Msg = "保存成功";
            }

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

            
            return View();
        }
Example #4
0
        public static int UpdateTechInfo(TechInfo model) {
            string strSQL = "UPDATE Categories SET Name = @Name,Alias = @Alias,Sort = @Sort,IsDeleted = @IsDeleted WHERE Id = @Id AND [Type] = 'tech'";
            SqlParameter[] parms = { 
                                    new SqlParameter("Id",SqlDbType.Int),
                                    new SqlParameter("Name",SqlDbType.NVarChar),
                                    new SqlParameter("Alias",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.Alias;
            parms[3].Value = model.Sort;
            parms[4].Value = model.IsDeleted;

            return SQLPlus.ExecuteNonQuery(CommandType.Text,strSQL,parms);
        }
Example #5
0
 /// <summary>
 /// 根据DataRow获得技术分类信息
 /// </summary>
 /// <param name="dr"></param>
 /// <returns></returns>
 private static TechInfo GetTechInfoByDataRow(DataRow dr) {
     var model = new TechInfo();
     if (dr == null) { return model; }
     model.Alias = dr.Field<string>("Alias").ToLower();
     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;
 }
Example #6
0
        /// <summary>
        /// 添加技术分类
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int AddTechInfo(TechInfo model) {
            string strSQL = "INSERT INTO Categories(ParentId,RootId,ParentIds,Name,Alias,Sort,IsDeleted,[Type],CreateDateTime) VALUES(0,0,'0',@Name,@Alias,@Sort,@IsDeleted,@Type,GETDATE());SELECT @@IDENTITY;";
            SqlParameter[] param = { 
                                    new SqlParameter("Name",SqlDbType.NVarChar),
                                    new SqlParameter("Alias",SqlDbType.VarChar),
                                    new SqlParameter("Sort",SqlDbType.Int),
                                    new SqlParameter("IsDeleted",SqlDbType.Bit),
                                    new SqlParameter("Type",SqlDbType.VarChar)
                                   };
            param[0].Value = model.Name;
            param[1].Value = model.Alias.ToLower();
            param[2].Value = model.Sort;
            param[3].Value = model.IsDeleted;
            param[4].Value = CatType.Tech.ToString().ToLower();

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