public ActionResult Edit(string id, SysPerson entity) { if (entity != null && ModelState.IsValid) { //数据校验 //string currentPerson = GetCurrentPerson(); //entity.UpdateTime = DateTime.Now; //entity.UpdatePerson = currentPerson; string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateSucceed + ",人员信息的Id为" + id, "人员", Result.Succeed); //写入日志 return(Json(Suggestion.UpdateSucceed)); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.UpdateFail + ",人员信息的Id为" + id + "," + returnValue, "人员", Result.Fail); //写入日志 return(Json(Suggestion.UpdateFail + returnValue)); //提示更新失败 } } return(Json(Suggestion.UpdateFail + "请核对输入的数据的格式")); //提示输入的数据的格式不对 }
public ActionResult Details(string id) { SysPerson item = m_BLL.GetById(id); ViewBag.OldPic = item.HDpic; return(View(item)); }
public ActionResult Create(SysPerson entity) { if (entity != null && ModelState.IsValid) { //string currentPerson = GetCurrentPerson(); //entity.CreateTime = DateTime.Now; //entity.CreatePerson = currentPerson; entity.Id = Result.GetNewId(); string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.InsertSucceed + ",人员的信息的Id为" + entity.Id, "人员", Result.Succeed);//写入日志 return(Json(Suggestion.InsertSucceed)); } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(LogType.Operation, Suggestion.InsertFail + ",人员的信息," + returnValue, "人员", Result.Fail); //写入日志 return(Json(Suggestion.InsertFail + returnValue)); //提示插入失败 } } return(Json(Suggestion.InsertFail + ",请核对输入的数据的格式")); //提示输入的数据的格式不对 }
public ActionResult Create(string id) { SysPerson p = new SysPerson(); p.PageStyle = "default"; return(View(p)); }
public ActionResult Index(LogOnModel model) { #region 验证码验证 if (Session["__VCode"] == null || (Session["__VCode"] != null && model.ValidateCode != Session["__VCode"].ToString())) { ModelState.AddModelError("PersonName", "验证码错误!"); //return ""; return(View()); } #endregion if (ModelState.IsValid) { IAccountBLL accountBLL = new BLL.AccountBLL(); SysPerson person = accountBLL.ValidateUser(model.PersonName, EncryptAndDecrypte.EncryptString(model.Password)); if (person != null) {//登录成功 Account account = new Account(); account.Name = person.Name; account.PersonName = person.MyName; account.Id = person.Id.ToString(); account.LastLogonIP = person.LastLogonIP; account.LastLogonTime = person.LastLogonTime; account.LogonNum = person.LogonNum; Utils.WriteCookie("account", account, 7); //Session["account"] = account; return(RedirectToAction("Index", "Home")); } } ModelState.AddModelError("PersonName", "用户名或者密码出错。"); return(View()); }
public ActionResult Index(LogOnModel model) { #region 验证码验证 if (Session["__VCode"] == null || (Session["__VCode"] != null && model.ValidateCode != Session["__VCode"].ToString())) { ModelState.AddModelError("PersonName", "验证码错误!"); //return ""; return(View()); } #endregion if (ModelState.IsValid) { SysPerson person = AccountBLL.ValidateUser(model.PersonName, model.Password); if (person != null) {//登录成功 Account account = new Account(); account.Name = person.MyName; account.PersonName = model.PersonName; account.Id = person.Id.ToString(); Session["account"] = account; return(RedirectToAction("Index", "Home")); } } ModelState.AddModelError("PersonName", "用户名或者密码出错。"); return(View()); }
/// <summary> /// 创建一个人员 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个人员</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, SysEntities db, SysPerson entity) { int count = 1; if (CheckName(entity.Name)) { validationErrors.Add("用户名已被占用,请换一个新的用户名"); return(false); } foreach (string item in entity.SysRoleId.GetIdSort()) { SysRole sys = new SysRole { Id = item }; db.SysRole.Attach(sys); entity.SysRole.Add(sys); count++; } repository.Create(db, entity); if (count == repository.Save(db)) { return(true); } else { validationErrors.Add("创建出错了"); } return(false); }
/// <summary> /// 创建一个人员 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个人员</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, SysEntities db, SysPerson entity) { int count = 1; foreach (string item in entity.SysRoleId.GetIdSort()) { SysRole sys = new SysRole { Id = item }; db.SysRole.Attach(sys); entity.SysRole.Add(sys); count++; } foreach (string item in entity.FileUploaderId.GetIdSort()) { FileUploader sys = new FileUploader { Id = item }; db.FileUploader.Attach(sys); entity.FileUploader.Add(sys); count++; } repository.Create(db, entity); if (count == repository.Save(db)) { return(true); } else { validationErrors.Add("创建出错了"); } return(false); }
public Result SignIn(Login login) { Result ret = new Result(); try { string pwd = EncryptionMD5.EncryptString(login.password); if (LoadEntities(l => l.Name == login.username && l.Password == pwd).Any()) { SysPerson sp = LoadEntities(l => l.Name == login.username && l.Password == pwd).FirstOrDefault(); string UserData = login.username + "#" + login.password + "#" + sp.MyName; //数据放入ticket FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, login.username, DateTime.Now, DateTime.Now.AddSeconds(30), false, UserData); //数据加密 string enyTicket = FormsAuthentication.Encrypt(ticket); CookieHelper.SetCookie(FormsAuthentication.FormsCookieName, enyTicket); ret.Msg = "登录成功!"; // } else { ret.Msg = "用户名或密码错误!"; } } catch (Exception) { ret.Msg = "登录失败!"; throw; } return(ret); }
/// <summary> /// 登录页面 /// </summary> /// <returns></returns> public ActionResult Index() { return(View()); //开发的时候,只需要注释此行代码 #if DEBUG //Debug 测试时使用 AccountBLL accountBLL = new BLL.AccountBLL(); SysPerson person = accountBLL.ValidateUser("Admin", EncryptAndDecrypte.EncryptString("123456")); if (person != null) {//登录成功 Account account = new Account(); account.Name = person.MyName; account.PersonName = person.Name; account.Id = person.Id.ToString(); account.LastLogonIP = person.LastLogonIP; account.LastLogonTime = person.LastLogonTime; account.LogonNum = person.LogonNum; account.Theme = person.PageStyle; //Session["account"] = account; Utils.WriteCookie("account", account, 7); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); #else //Release 正式平台使用 return(View()); #endif }
/// <summary> /// 创建一个文档管理 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个文档管理</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, SysEntities db, SysDocument entity) { int count = 1; foreach (string item in entity.SysPersonId.GetIdSort()) { SysPerson sys = new SysPerson { Id = item }; db.SysPerson.Attach(sys); entity.SysPerson.Add(sys); count++; } foreach (string item in entity.SysDepartmentId.GetIdSort()) { SysDepartment sys = new SysDepartment { Id = item }; db.SysDepartment.Attach(sys); entity.SysDepartment.Add(sys); count++; } repository.Create(db, entity); if (count == repository.Save(db)) { return(true); } else { validationErrors.Add("创建出错了"); } return(false); }
public ActionResult Edit(string id) { SysPerson item = m_BLL.GetById(id); ViewBag.OldPic = item.HDpic; ViewBag.OldProvince = item.Province; return(View(item)); }
/// <summary> /// 添加员工基本信息 /// </summary> /// <param name="parm"></param> /// <returns></returns> public async Task <ApiResult <string> > AddAsync(SysPersonDto parm) { var res = new ApiResult <string>(); try { parm.HeadPic = !string.IsNullOrEmpty(parm.HeadPic) ? parm.HeadPic : "/themes/img/headpic.png"; parm.LoginPwd = DESCrypt.Encrypt(parm.LoginPwd); var newGuid = Guid.NewGuid().ToString(); var model = new SysPerson() { Guid = newGuid, RoleGuid = parm.RoleGuid, DepartmentGuid = parm.DepartmentGuid, CompayGuid = parm.CompayGuid, LoginName = parm.LoginName, LoginPwd = parm.LoginPwd, TrueName = parm.TrueName, Codes = parm.Codes, HeadPic = parm.HeadPic, Sex = parm.Sex, Mobile = parm.Mobile, Email = parm.Email, QQ = parm.QQ, WebXin = parm.WebXin, WorkTel = parm.WorkTel, LoginStatus = parm.LoginStatus, DelStatus = false, PostStatus = parm.PostStatus, AuditStatus = true, Birthday = parm.Birthday, IDCard = parm.IDCard, NativePlaceCity = parm.NativePlaceCity, AccountCity = parm.AccountCity, LiveCity = parm.LiveCity, PoliticalStatus = parm.PoliticalStatus, Ethnic = parm.Ethnic, Faith = parm.Faith, Marriage = parm.Marriage, Education = parm.Education, Hobbies = parm.Hobbies, LanguageSkills = parm.LanguageSkills, Specialty = parm.Specialty, AddTime = DateTime.Now, EditTime = DateTime.Now }; var isok = SysPersonDb.Insert(model); res.statusCode = isok ? (int)ApiEnum.Status : (int)ApiEnum.Error; res.data = newGuid; } catch (Exception ex) { res.message = ApiEnum.Error.GetEnumText() + ex.Message; res.statusCode = (int)ApiEnum.Error; res.success = false; } return(await Task.Run(() => res)); }
/// <summary> /// 编辑一个角色 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据上下文</param> /// <param name="entity">一个角色</param> /// <returns>是否编辑成功</returns> public bool Edit(ref ValidationErrors validationErrors, SysEntities db, SysRole entity) { /* * 不操作 原有 现有 * 增加 原没 现有 * 删除 原有 现没 */ if (entity == null) { return(false); } int count = 1; SysRole editEntity = repository.Edit(db, entity); List <string> addSysPersonId = new List <string>(); List <string> deleteSysPersonId = new List <string>(); DataOfDiffrent.GetDiffrent(entity.SysPersonId.GetIdSort(), entity.SysPersonIdOld.GetIdSort(), ref addSysPersonId, ref deleteSysPersonId); if (addSysPersonId != null && addSysPersonId.Count() > 0) { foreach (var item in addSysPersonId) { SysPerson sys = new SysPerson { Id = item }; db.SysPerson.Attach(sys); editEntity.SysPerson.Add(sys); count++; } } if (deleteSysPersonId != null && deleteSysPersonId.Count() > 0) { List <SysPerson> listEntity = new List <SysPerson>(); foreach (var item in deleteSysPersonId) { SysPerson sys = new SysPerson { Id = item }; listEntity.Add(sys); db.SysPerson.Attach(sys); } foreach (SysPerson item in listEntity) { editEntity.SysPerson.Remove(item);//查询数据库 count++; } } if (count == repository.Save(db)) { return(true); } else { validationErrors.Add("编辑角色出错了"); } return(false); }
public ActionResult Edit(string id) { SysPerson entity = m_BLL.GetById(id); entity.Password = EncryptAndDecrypte.DecrypteString(entity.Password);//解密 entity.SurePassword = entity.Password; return(View(entity)); }
/// <summary> /// 保存皮肤 /// </summary> /// <param name="theme"></param> /// <param name="id"></param> public bool SaveTheme(string theme, string id) { SysPerson p = this.GetById(id); p.PageStyle = theme; repository.Edit(db, p); int count = repository.Save(db); return(count > 0); }
public ActionResult Create(SysPerson entity) { if (entity != null && ModelState.IsValid) { //用户名重名判断 List <SysPerson> sp = m_BLL.GetAll(); foreach (var item in sp) { if (item.Name == entity.Name) { return(Json(Suggestion.InsertFail + ",用户名已被使用")); } } string currentPerson = GetCurrentPerson(); entity.CreateTime = DateTime.Now; entity.CreatePerson = currentPerson; entity.Id = Result.GetNewId(); string returnValue = string.Empty; //谢承忠添加 //登入时做了加密检验 entity.Password = EncryptAndDecrypte.EncryptString(entity.Password); entity.SurePassword = EncryptAndDecrypte.EncryptString(entity.SurePassword); if (m_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",人员的信息的Id为" + entity.Id, "人员" );//写入日志 return(Json(Suggestion.InsertSucceed)); } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",人员的信息," + returnValue, "人员" ); //写入日志 return(Json(Suggestion.InsertFail + returnValue)); //提示插入失败 } } return(Json(Suggestion.InsertFail + ",请核对输入的数据的格式")); //提示输入的数据的格式不对 }
public ActionResult Edit(string id, SysPerson entity) { if (entity != null && ModelState.IsValid) { //数据校验 string oldPic = Request.Form["OldPic"]; if (entity.HDpic != oldPic) //修改头像删除老的头像文件 { DirFile.DeleteFile(oldPic); } string currentPerson = GetCurrentPerson(); entity.UpdateTime = DateTime.Now; entity.UpdatePerson = currentPerson; //如果修改了密码,就将密码加密 2016830 IBLL.IAccountBLL accountBLL = new AccountBLL(); if (null == (accountBLL.ValidateUser(entity.Name, entity.Password))) { entity.Password = EncryptAndDecrypte.EncryptString(entity.Password); entity.SurePassword = EncryptAndDecrypte.EncryptString(entity.SurePassword); } string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",人员信息的Id为" + id, "人员" ); //写入日志 App.Codes.MenuCaching.ClearCache(id); //清除缓存 return(Json(Suggestion.UpdateSucceed)); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",人员信息的Id为" + id + "," + returnValue, "人员" ); //写入日志 return(Json(Suggestion.UpdateFail + returnValue)); //提示更新失败 } } return(Json(Suggestion.UpdateFail + "请核对输入的数据的格式")); //提示输入的数据的格式不对 }
/// <summary> /// 验证用户名是否改变 /// </summary> /// <param name="name">用户名</param> /// <returns></returns> public bool CheckName(SysPerson sysPerson) { using (SysEntities dbCheckName = new SysEntities()) { SysPerson person = dbCheckName.SysPerson.FirstOrDefault(f => f.Id == sysPerson.Id); if (person != null) { if (sysPerson.Name == person.Name) { return(false);//没有修改用户名 } else { return(CheckName(sysPerson.Name)); } } } return(true); }
/// <summary> /// 创建一个人员 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="entity">一个人员</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, SysPerson entity) { try { //using (TransactionScope transactionScope = new TransactionScope()) { if (Create(ref validationErrors, db, entity)) { //transactionScope.Complete(); return(true); } else { //Transaction.Current.Rollback(); } } } catch (Exception ex) { ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <summary> /// 编辑一个人员 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="entity">一个人员</param> /// <returns>是否编辑成功</returns> public bool Edit(ref ValidationErrors validationErrors, SysPerson entity) { try { using (TransactionScope transactionScope = new TransactionScope()) { if (Edit(ref validationErrors, db, entity)) { transactionScope.Complete(); return(true); } else { Transaction.Current.Rollback(); } } } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <summary> /// 编辑一个人员 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据上下文</param> /// <param name="entity">一个人员</param> /// <returns>是否编辑成功</returns> public bool Edit(ref ValidationErrors validationErrors, SysEntities db, SysPerson entity) { /* * 不操作 原有 现有 * 增加 原没 现有 * 删除 原有 现没 */ if (entity == null) { return(false); } int count = 1; List <string> addSysRoleId = new List <string>(); List <string> deleteSysRoleId = new List <string>(); DataOfDiffrent.GetDiffrent(entity.SysRoleId.GetIdSort(), entity.SysRoleIdOld.GetIdSort(), ref addSysRoleId, ref deleteSysRoleId); List <SysRole> listEntitySysRole = new List <SysRole>(); if (deleteSysRoleId != null && deleteSysRoleId.Count() > 0) { foreach (var item in deleteSysRoleId) { SysRole sys = new SysRole { Id = item }; listEntitySysRole.Add(sys); entity.SysRole.Add(sys); } } List <string> addSysDocumentId = new List <string>(); List <string> deleteSysDocumentId = new List <string>(); DataOfDiffrent.GetDiffrent(entity.SysDocumentId.GetIdSort(), entity.SysDocumentIdOld.GetIdSort(), ref addSysDocumentId, ref deleteSysDocumentId); List <SysDocument> listEntitySysDocument = new List <SysDocument>(); if (deleteSysDocumentId != null && deleteSysDocumentId.Count() > 0) { foreach (var item in deleteSysDocumentId) { SysDocument sys = new SysDocument { Id = item }; listEntitySysDocument.Add(sys); entity.SysDocument.Add(sys); } } SysPerson editEntity = repository.Edit(db, entity); if (addSysRoleId != null && addSysRoleId.Count() > 0) { foreach (var item in addSysRoleId) { SysRole sys = new SysRole { Id = item }; db.SysRole.Attach(sys); editEntity.SysRole.Add(sys); count++; } } if (deleteSysRoleId != null && deleteSysRoleId.Count() > 0) { foreach (SysRole item in listEntitySysRole) { editEntity.SysRole.Remove(item); count++; } } if (addSysDocumentId != null && addSysDocumentId.Count() > 0) { foreach (var item in addSysDocumentId) { SysDocument sys = new SysDocument { Id = item }; db.SysDocument.Attach(sys); editEntity.SysDocument.Add(sys); count++; } } if (deleteSysDocumentId != null && deleteSysDocumentId.Count() > 0) { foreach (SysDocument item in listEntitySysDocument) { editEntity.SysDocument.Remove(item); count++; } } if (count == repository.Save(db)) { return(true); } else { validationErrors.Add("编辑人员出错了"); } return(false); }
public ActionResult Details(string id) { SysPerson item = m_BLL.GetById(id); return(View(item)); }