Пример #1
0
        public ActionResult UpdateRepairClass(SYS_RepairClass RepairClass)
        {
            //定义返回
            string strMsg = "fail";

            try
            {
                if (!string.IsNullOrEmpty(RepairClass.RepairClassNum) && !string.IsNullOrEmpty(RepairClass.RepairClassName))
                {
                    myModels.Entry(RepairClass).State = System.Data.Entity.EntityState.Modified;
                    if (myModels.SaveChanges() > 0)
                    {
                        strMsg = "success";
                    }
                }
                else
                {
                    strMsg = "nofull";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(Json(strMsg, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="RepairClass"></param>
        /// <returns></returns>
        public ActionResult InsertRepairClass(SYS_RepairClass RepairClass)
        {
            //定义返回
            string strMsg = "fail";

            try
            {
                //大类名称不能为空
                if (!string.IsNullOrEmpty(RepairClass.RepairClassNum) && !string.IsNullOrEmpty(RepairClass.RepairClassName))
                {
                    //查询是否已经存在该大类
                    var oldCount = (from tbRepairClass in myModels.SYS_RepairClass
                                    where tbRepairClass.RepairClassID == RepairClass.RepairClassID ||
                                    tbRepairClass.RepairClassNum == RepairClass.RepairClassNum ||
                                    tbRepairClass.RepairClassName == RepairClass.RepairClassName
                                    select tbRepairClass).Count();
                    if (oldCount == 0)
                    {
                        //新增大类
                        myModels.SYS_RepairClass.Add(RepairClass);
                        if (myModels.SaveChanges() > 0)
                        {
                            strMsg = "success";
                        }
                    }
                    else
                    {
                        strMsg = "exist";
                    }
                }
                else
                {
                    strMsg = "nofull";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(Json(strMsg, JsonRequestBehavior.AllowGet));
        }