public JsonResult Edit(WN_WarningSett entity)
        {
            if (entity != null && ModelState.IsValid)
            {
                using (MBREntities db = new MBREntities())
                {
                    WarningSettService us = new WarningSettService(db);

                    if (us.Edit(ref errors, entity))
                    {
                        LogHandler.WriteServiceLog(LogonUser.RealName, "WarningSettID:" + entity.WarningSettID + ",Title:" + entity.Title, Resource.EditSucceed, Resource.Edit, "预警规则设置");
                        return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed)));
                    }
                    else
                    {
                        string ErrorCol = errors.Error;
                        LogHandler.WriteServiceLog(LogonUser.RealName, "WarningSettID:" + entity.WarningSettID + ",Title:" + entity.Title, Resource.EditFail, Resource.Edit, "预警规则设置");
                        return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ErrorCol)));
                    }
                }
            }
            else
            {
                return(Json(JsonHandler.CreateMessage(0, Resource.EditFail)));
            }
        }
        public ActionResult Edit(int id)
        {
            WN_WarningSett entity = null;

            using (MBREntities db = new MBREntities())
            {
                entity = db.WN_WarningSett.Find(id);
            }

            List <SelectListItem> WarningLevelList      = new List <SelectListItem>();
            DATADICTIONARYService DATADICTIONARYService = new DATADICTIONARYService();
            var dicValues = DATADICTIONARYService.GetDicValuesByCode("WarningLevel");

            if (dicValues != null)
            {
                foreach (var item in dicValues)
                {
                    bool selected = item.Key.Equals((entity.WarningLevel ?? 0).ToString());
                    WarningLevelList.Add(new SelectListItem()
                    {
                        Text     = item.Value,
                        Value    = item.Key,
                        Selected = selected
                    });
                }
            }


            ViewBag.WarningLevel = WarningLevelList;

            return(View(entity));
        }
 public JsonResult Create(WN_WarningSett entity)
 {
     using (MBREntities db = new MBREntities())
     {
         WarningSettService us = new WarningSettService(db);
         if (us.Create(ref errors, entity))
         {
             LogHandler.WriteServiceLog(LogonUser.RealName, "WarningSettID:" + entity.WarningSettID + ",Title:" + entity.Title, Resource.InsertSucceed, Resource.Create, "预警规则设置");
             return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed), JsonRequestBehavior.AllowGet));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(LogonUser.RealName, "WarningSettID:" + entity.WarningSettID + ",Title:" + entity.Title, Resource.InsertFail, Resource.Create, "预警规则设置");
             return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet));
         }
     }
 }