3-商品管理Co

Posted pingshengi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);
}


}
}










































































































以上是关于3-商品管理Co的主要内容,如果未能解决你的问题,请参考以下文章

游戏商城毕业设计

毕业设计游戏商城项目

商品管理系统

商品管理系统

商品管理模块

python编写商品管理