zoukankan      html  css  js  c++  java
  • 3-商品管理Co

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using MEH.Month.Test.BLL;
    using MEH.Month.Test.Model;
    using MEH.Month.Test.Models;
    using System.Linq.Expressions;
    using Newtonsoft.Json;
    using MEH.Month.Test.Unit;

    namespace MEH.Month.Test.Controllers
    {
    public class HomeController : Controller
    {
    // GET: Home
    public ActionResult Index()
    {
    return View();
    }
    [HttpGet]
    public string Show(int PageIndex, int PageSize, string Name, int State)
    {
    Expression<Func<ProductInfo, bool>> expression = t => true;
    if (Name != "")
    {
    expression = expression.And(t => t.ProductTitle.Contains(Name));
    }
    if (State!=-1)
    {
    expression = expression.And(t => t.State.Equals(State));
    }
    List<ProductInfo> List = new CommonBLL().Show(expression).ToList();
    ViewModel vm = new ViewModel();
    vm.PageCount = List.Count();
    List=List.Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
    vm.List = List;
    return JsonConvert.SerializeObject(vm);
    }

    public ActionResult Add()
    {
    return View();

    }
    public ActionResult Update(int ID)
    {
    ProductInfo List = new CommonBLL().Fill(ID);
    return View(List);

    }
    [HttpPost]
    [ValidateInput(false)]
    public ActionResult UpdateData(ProductInfo m)
    {
    m.State = 1;
    if (new CommonBLL().Update(m) < 1)
    {
    return Content("<script>alert('修改出现错误')</script>");
    }
    return Content("<script>alert('修改成功');location.href='/Home/Index'</script>");
    }

    [HttpPost]
    [ValidateInput(false)]
    public ActionResult Insert(ProductInfo m)
    {
    m.State = 1;
    if (new CommonBLL().Add(m) < 1)
    {
    return Content("<script>alert('添加出现错误')</script>");
    }
    return Content("<script>alert('添加成功');location.href='/Home/Index'</script>");
    }
    /// <summary>
    /// 上传文件
    /// </summary>
    /// <returns></returns>
    [HttpPost]

    public JsonResult UpLoadFiles()
    {
    string Path = Server.MapPath("/Files");
    if (!Directory.Exists(Path))
    {
    Directory.CreateDirectory(Path);
    }
    HttpFileCollectionBase Files = Request.Files;
    IList<string> ImgList = new List<string>();
    for (int i = 0; i < Files.Keys.Count; i++)
    {
    var EveFiles = Request.Files[i];
    string ImgPath = Path + "/" + EveFiles.FileName;
    EveFiles.SaveAs(ImgPath);
    ImgList.Add(EveFiles.FileName);
    }
    return Json(ImgList, JsonRequestBehavior.AllowGet);
    }
    public int Del(int ID )
    {
    return new CommonBLL().Del(ID);
    }
    [HttpGet]
    public int UpdateState(int ID,int State)
    {

    return new CommonBLL().UpdateState(ID,State);

    }
    [HttpPost]
    public int Dels(string IDs)
    {
    return new CommonBLL().Dels(IDs);
    }


    }
    }

  • 相关阅读:
    C# 技能鉴定 第三单元 第四单元题目总结
    C# 技能鉴定 第三单元 test 3_5
    C# 技能鉴定 第三单元 Test3_4
    C# 技能鉴定 第三单元的题目
    班级通讯录修改与维护
    C# 技能鉴定
    Windows 编程入门,如何注册账号
    Windows 编程入门,了解开发UWP应用的准备工作
    logback-spring.xml
    springboot和mybatis 配置多数据源
  • 原文地址:https://www.cnblogs.com/PingShengI/p/10147502.html
Copyright © 2011-2022 走看看