当前位置: 首页 > article >正文

CategoriesController

目录

1、 CategoriesController

1.1、 /// 新增

1.1.1、 //判断配件大类表中是否已经存在新增的配件大类信息

1.2、 /// 删除

1.2.1、 //判断配件大类表中是否已经存在新增的配件大类信息

1.2.2、 //保存数据库

  1. CategoriesController 

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();

    1.         /// 新增

        /// </summary>

        /// <param name="FittingsType"></param>

        /// <returns></returns>

        public ActionResult InsertFittingsType(SYS_FittingsType FittingsType)

        {

            string strMsg = "failed";

            try

            {

      1.                 //判断配件大类表中是否已经存在新增的配件大类信息

                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>

    1.         /// 删除

        /// </summary>

        /// <param name="FittingsType"></param>

        /// <returns></returns>

        public ActionResult UpdateFittingsType(SYS_FittingsType FittingsType)

        {

            var strMsg = "failed";

            try

            {

      1.                 //判断配件大类表中是否已经存在新增的配件大类信息

                var oldFittingsTypeRow = (from tbFittingsType in myModels.SYS_FittingsType

                                          where tbFittingsType.FittingsTypeID != FittingsType.FittingsTypeID &&

                                          (tbFittingsType.FittingsTypeNum == FittingsType.FittingsTypeNum)

                                          // && tbFittingsType.FittingsTypeName == FittingsType.FittingsTypeName

                                          select tbFittingsType).Count();

                if (oldFittingsTypeRow == 0)

                {

                    myModels.Entry(FittingsType).State = System.Data.Entity.EntityState.Modified;

      1.                     //保存数据库

                    myModels.SaveChanges();

                    strMsg = "success";

                }

                else

                {

                    strMsg = "该配件大类已经存在,不需要重复输入数据!";

                }

            }

            catch (Exception)

            {

                strMsg = "failed";

            }

            return Json(strMsg, JsonRequestBehavior.AllowGet);

        }

    }

}


http://www.kler.cn/a/303410.html

相关文章:

  • Llama架构及代码详解
  • 优化时钟网络之时钟抖动
  • 【前端】Vue中如何避免出现内存泄漏
  • 【AI技术对电商的影响】
  • idea的mapper.xml文件里写sql语句出现Tag name expected错误提示
  • 实战指南:理解 ThreadLocal 原理并用于Java 多线程上下文管理
  • 什么是图像的边缘?说说边缘检测的任务以及基本原理?
  • 无人机应用新纪元:图形工作站配置推荐与硬件解析
  • 网络安全-dom破坏结合jq漏洞以及框架漏洞造成的xss-World War 3
  • Python | Leetcode Python题解之第402题移掉K位数字
  • labview禁用8080端口
  • 合宙低功耗4G模组Air780EX——硬件设计手册01
  • 同步和异步是两种不同的程序执行方式
  • duckdb 连接postgres 和 jdbc 的使用
  • Prism 教程
  • Java集合框架(Collections Framework)入门
  • Compose Multiplatform+kotlin Multiplatfrom第三弹
  • 车辆检测与分类系统源码分享
  • [图论]街道赛跑
  • 【EI会议征稿通知】第四届材料工程与应用力学国际学术会议(ICMEAAE 2025)
  • Spring下载文件
  • 《征服数据结构》滚动数组
  • uni-app生命周期(三)
  • 基于vue框架的城市网约车管理系统v34td(程序+源码+数据库+调试部署+开发环境)系统界面在最后面。
  • 民间故事推广系统小程序的设计
  • PMP--一模--解题--41-50