目录
1.3.1、 //判断配件大类表中是否已经存在新增的配件大类信息
using QXQPS.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace QXQPS.Areas.BasicdataManagment.Controllers
{
public class CategoriesController : Controller
{
// GET: BasicdataManagment/Categories
Models.QXQPEntities myModels = new Models.QXQPEntities();
public ActionResult Accessories()//配件大类设置
{
return View();
}
/// <summary>
/// </summary>
/// <returns></returns>
public ActionResult SelectAccessories()
{
var list = from tbAccessories in myModels.SYS_FittingsType
select tbAccessories;
return Json(list, JsonRequestBehavior.AllowGet);
}
/// <summary>
/// </summary>
/// <param name="FittingsType"></param>
/// <returns></returns>
public ActionResult InsertFittingsType(SYS_FittingsType FittingsType)
{
string strMsg = "failed";
try
{
var SelectCount = (from tbFittingsType in myModels.SYS_FittingsType
where tbFittingsType.FittingsTypeID == FittingsType.FittingsTypeID ||
tbFittingsType.FittingsTypeNum == FittingsType.FittingsTypeNum &&
tbFittingsType.FittingsTypeName == FittingsType.FittingsTypeName
select tbFittingsType).Count();
if (SelectCount == 0)
{
myModels.SYS_FittingsType.Add(FittingsType);
myModels.SaveChanges();
strMsg = "success";
}
else
{
strMsg = "该配件大类已经存在,不需要重复输入数据!";
}
}
catch (Exception e)
{
strMsg = "failed";
}
return Json(strMsg, JsonRequestBehavior.AllowGet);
}
/// <summary>