コード例 #1
0
        public ActionResult Edit(SearchWordBrandsConfig model)
        {
            string js = "<script>alert(\"保存失败 {0}\");location='/SearchWordBrandsConfig/Index';</script>";

            if (model.BrandsList == null || !model.BrandsList.Any() || model.BrandsList.Count > 3)
            {
                return(Content(string.Format(js, "品牌词不少于1个不多于3个")));
            }

            if (model.Pkid != 0)
            {
                if (DALDefaultSearchConfig.UpdateSearchWordBrandsConfig(model))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Content(string.Format(js, "")));
                }
            }
            else
            {
                if (DALDefaultSearchConfig.InsertSearchWordBrandsConfig(model))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Content(string.Format(js, "")));
                }
            }
        }
コード例 #2
0
 public ActionResult Edit(int id = 0)
 {
     if (id == 0)
     {
         SearchWordBrandsConfig model = new SearchWordBrandsConfig();
         return(View(model));
     }
     else
     {
         return(View(DALDefaultSearchConfig.GetSearchWordBrandsConfig(id)));
     }
 }
コード例 #3
0
        public static bool UpdateSearchWordBrandsConfig(SearchWordBrandsConfig model)
        {
            const string sql          = @"
UPDATE  Configuration..SearchWordBrandsConfig
SET     Keywords = @Keywords ,
        Brands = @Brands ,
        IsShow = @IsShow ,
        UpdateTime = GETDATE()
WHERE   PKID = @Pkid;";
            var          sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@Keywords", model.Keywords),
                new SqlParameter("@Brands", model.Brands),
                new SqlParameter("@IsShow", model.IsShow),
                new SqlParameter("@Pkid", model.Pkid)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0);
        }
コード例 #4
0
        public static bool InsertSearchWordBrandsConfig(SearchWordBrandsConfig model)
        {
            const string sql          = @"
INSERT INTO [Configuration].[dbo].[SearchWordBrandsConfig]
        ( [Keywords] ,
          [Brands] ,
          [IsShow] 
        )
VALUES  ( @Keywords , -- Keywords - nvarchar(200)
          @Brands , -- Brands - nvarchar(200)
          @IsShow 
        )";
            var          sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@Keywords", model.Keywords),
                new SqlParameter("@Brands", model.Brands),
                new SqlParameter("@IsShow", model.IsShow)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0);
        }