/// <summary> /// 保存(新增、修改) /// </summary> /// <returns></returns> public ActionResult Save() { string AccountID = Request.Form["AccountID"]; //账套 string UserCode = Request.Form["UserCode"]; //用户编号 string UserName = Request.Form["UserName"]; //用户名 string Pwd = Request.Form["Pwd"]; //密码 if (!string.IsNullOrWhiteSpace(Pwd)) { DES des = new DES(); Pwd = des.Encrypt(Pwd); } string Employee = Request.Form["Employee"]; //员工编号 string Position = Request.Form["Position"]; //岗位 string Department = Request.Form["Department"]; //部门 string Phone = Request.Form["Phone"]; //电话 DateTime BeginDate = Convert.ToDateTime(Request.Form["BeginDate"]); //生效日期 DateTime EndDate = Convert.ToDateTime(Request.Form["EndDate"]); //失效日期 string IsAdmin = Request.Form["IsAdmin"]; //管理员 string IsEnable = Request.Form["IsEnable"]; //生效 string actionType = Request.Form["actiontype"]; //新增或者修改状态 UserInfo userInfo = new UserInfo(); userInfo.AccountID = AccountID; userInfo.UserCode = UserCode; userInfo.UserName = UserName; userInfo.Pwd = Pwd; userInfo.Employee = Employee; userInfo.Phone = Phone; userInfo.Department = Department; userInfo.Position = Position; userInfo.BeginDate = BeginDate; userInfo.EndDate = EndDate; userInfo.IsAdmin = Convert.ToInt32(IsAdmin); userInfo.IsEnable = Convert.ToInt32(IsEnable); bool sucesss = false; string message = ""; if (actionType == "add") { if (UserInfoBLL.CheckObjIsExist(userInfo)) { sucesss = false; message = "该用户已经存在,不能重复录入!"; } else { if (UserInfoBLL.Add(userInfo)) { sucesss = true; } } } else { int KeyID = Convert.ToInt32(Request.Form["KeyID"]);//主键 userInfo.KeyID = KeyID; if (UserInfoBLL.Update(userInfo)) { sucesss = true; } } return(Content(new JsonMessage { Success = sucesss, Message = message }.ToString())); }