public ActionResult Edit(BLL.FW.BF_ST_NODE.Entity entity, FormCollection collection) { JsonResultData result = new JsonResultData(); ViewBag.UserName = BF_USER.Instance.GetDictionary("ID", "NAME"); #region 验证 if (string.IsNullOrEmpty(entity.NAME)) { result.Message = "任务名称不能为空,提交失败!"; return(Json(result, JsonRequestBehavior.AllowGet)); } #endregion int intResult = 0; int intUserId = SystemSession.UserID;//当前登录 #region 封装数据 Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("NAME", entity.NAME); dic.Add("TYPE_ID", entity.TYPE_ID); dic.Add("DB_ID", entity.DB_ID); dic.Add("CONTENT", entity.CONTENT); dic.Add("REMARK", entity.REMARK); dic.Add("UPDATE_TIME", DateTime.Now); dic.Add("UPDATE_UID", intUserId); #endregion try { if (entity.ID > 0) //增加与修改的判断 { //修改 intResult = BF_ST_NODE.Instance.UpdateByKey(dic, entity.ID); } else { //增加 dic.Add("CREATE_TIME", DateTime.Now); dic.Add("CREATE_UID", intUserId); intResult = BF_ST_NODE.Instance.Add(dic); } result.IsSuccess = intResult > 0; result.Message = intResult > 0 ? "数据提交成功!" : "数据提交失败!"; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { result.IsSuccess = false; result.Message = ex.Message;; } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 编辑及新增 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Edit(int id = 0) { ViewBag.Result = false; ViewBag.Message = string.Empty; ViewBag.UserName = BLL.FW.BF_USER.Instance.GetDictionary("ID", "NAME"); BLL.FW.BF_ST_NODE.Entity entity = new BLL.FW.BF_ST_NODE.Entity(); if (id > 0) { entity = BF_ST_NODE.Instance.GetEntityByKey <BLL.FW.BF_ST_NODE.Entity>(id); if (entity == null) { ViewBag.Message = "任务名称不存在"; entity = new BLL.FW.BF_ST_NODE.Entity(); entity.ID = -1; } } GetStatus(); //运行状态 GetDatabaseSelectData(); //数据库下拉 GetScriptTypeSelectData(); //类型加载下拉 ModelState.Clear(); return(View(entity)); }