zoukankan      html  css  js  c++  java
  • C# 修改/新建判断

     //查询有无重复(新建用)

      public List<bloodBreedDetailsEntity> CodeList(string code)

        {

             var expression = ExtLinq.True<BloodBreedDetailsEntity>();

            expression = expression.And(t=>t.Code ==(code));

            return service.IQueryable(expression).ToList();

        }

     //查询有没有一样的数据(修改用)

        public List<BloodBreedDetailsEntity> CodeListForUpdate(int id,string code)

        {

           var expression =ExLinq.True<BloodBreedDetailsEntity>();

            expression = expression.And(t=>t.Id!=id);

            expression = expression.And(t=>t.Code== code);

            return service.IQueryable(expression).ToList();

        }

          public int SubmitFrom(BloodBreedDetailsEntity itemsEntity,int KeyValue=-1)

           {

               int lcqa=0

               if (KeyValue>0)

               {

                   List<BloodBreedDetailsEntity> detailList = CodeListForUpdate(itemsEntity.Id,itemsEntity.Code)

                    if(detailList.Count == 0)

                   {

                        service.Update(itemsEntity);

                         lcqa=1;

                    }

               }

                else

                  {

                       List<BloodBreedDetailsEntity> detailList = CodeList(itemsEntity.Code);

                        if(detailList.Count == 0)

                         {

                           service.Insert(itemsEntity);

                            lcqa=1;

                          }

                   }

                    return lcqa;

            }

    Controller界面

             public ActionResult SubmitForm(BloodBreedDetailsEntity bloodBreedDetailsEntity,int keyvalue=-1)

           {

             int a = bloodBreedDetailsApp.SubmitForm(bloodBreedDetailsEntity,keyvalue);

             if(a==1)

             {

               return Success("操作成功");

              }else{

                     return Error("操作失败");

                         }

        }

    前端js界面

    <script>

        function submitForm()

            {

             if(!$('#form1').formValid())

                  {

                      return false;

                  }

                var postData = $("form1").formSerialize();

                 postData["keyValue"] = keyValue;

                 $.submitForm({

                  url:"/DictManage/BloodBreedDetails/SubmitForm",

                  param:postData,

                  success:function(){

                    $.currentWindow().$("#gridList").trigger("reloadGrid");

                   }   

                  })

             }

    </script>

  • 相关阅读:
    UPS FAQ-不错的UPS资料
    HPL.dat FAQ
    Fortran77计算某段代码的CPU运行时间
    存储知识 什么是LUN?LUN有什么用?对理解存储设备很有好处
    HPL.dat Tune
    UPS-瓦特(W)和伏安(VA):易混淆的两个概念
    mysql sql 索引相关用法,加快查询速度
    mysql 数据库分类设计方法与PHP结合
    c# SQLServer 数据库连接类
    .net上传图片生成大小缩略图
  • 原文地址:https://www.cnblogs.com/lichangqing1997/p/11345561.html
Copyright © 2011-2022 走看看