/// <summary> /// 登录用户 /// </summary> /// <param name="mes">返回信息情况</param> /// <returns>通过:true/失败:false</returns> public bool UserLogin() { using (System_User_DAL UserDAL = new System_User_DAL()) { bool value = true; var User_Entity = UserDAL.GetLoginInfo(UaserName).GetEntity <System_User>();//根据用户名来获取信息 if (User_Entity == null) { _ErrorMessage = "用户名错误,请重新输入!"; } else if (Encryption.EncryptDES(Password, ConfigurationManager.AppSettings["KeyValue"]) != User_Entity.Pwd) { //else if (User_Entity.Pwd != Encryption.SHA1_Encryption(Encryption.Md5_Encryption(Password))) //密码对比 _ErrorMessage = "密码错误,请重新输入!"; } else { value = false; UserInfoSave(User_Entity); _ErrorMessage = "登录系统成功!"; } using (Log_Login_Add_DAL log = new Log_Login_Add_DAL()) { log.Login_Name = UaserName; log.Result = (value ? "失败" : "成功"); log.ResultsDescribed = _ErrorMessage; log.Generatelog(); } return(value); } }
/// <summary> /// 查询实体列表 /// </summary> /// <returns></returns> public IList <System_User> Get_Entity_List() { if (system_User == null) { system_User = new System_User_DAL(); } if (System_User_Entity_List == null) { System_User_Entity_List = system_User.Get_Data().GetEntityList <System_User>(); } return(System_User_Entity_List); }
/// <summary> /// 更新密码 /// </summary> /// <param name="pwd">新密码</param> /// <param name="confirmPaw">确认密码</param> /// <param name="id">主键</param> /// <returns></returns> public int Update_Pwd(string pwd, string id) { if (system_User == null) { system_User = new System_User_DAL(); } string p = Encryption.EncryptDES(pwd, ConfigurationManager.AppSettings["KeyValue"]); int value = system_User.Update_Pwd(p, id); if (Combination == null) { Combination = new ContentsCombination(); } Contents = Combination.Log_Contents_PrimaryKey("T_SYS_USER", id.ToString()); Update_Log(value, "更新“" + id + "”用户主键的密码"); return(value); }
/// <summary> /// 添加 /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public int Add(System_User entity) { if (system_User == null) { system_User = new System_User_DAL(); } entity.Pwd = Encryption.EncryptDES(entity.Pwd, ConfigurationManager.AppSettings["KeyValue"]); entity.IsAdmin = "0"; System_User_Entity_List.Add(entity); int value = system_User.Add(entity); if (Combination == null) { Combination = new ContentsCombination(); } Contents = Combination.Log_Contents_Json("Sys_User", Json.Serialization(entity)); Add_Log(value, "创建“" + entity.LoginName + "”用户名"); return(value); }
/// <summary> /// 删除 /// </summary> /// <param name="id">主键</param> /// <returns></returns> public int Delete(int id) { if (system_User == null) { system_User = new System_User_DAL(); } int value = system_User.Delete(id); if (value > -1) { System_User_Entity_List.Remove(System_User_Entity_List.FirstOrDefault(f => f.Id == id)); } if (Combination == null) { Combination = new ContentsCombination(); } Contents = Combination.Log_Contents_PrimaryKey("T_SYS_USER", id.ToString()); Delete_Log(value, "删除“" + id + "”用户主键"); return(value); }
/// <summary> /// 更新 /// </summary> /// <param name="entity">实体</param> /// <returns></returns> public int Update(System_User entity) { if (system_User == null) { system_User = new System_User_DAL(); } if (CurrentPassword != entity.Pwd) { entity.Pwd = Encryption.EncryptDES(entity.Pwd, ConfigurationManager.AppSettings["KeyValue"]); } int value = system_User.Update(entity); if (value > -1) { System_User_Entity_List.Remove(System_User_Entity_List.FirstOrDefault(f => f.Id == entity.Id)); System_User_Entity_List.Add(entity); } ContentsArray[1] = Combination.Log_Contents_Json("更新后信息", "T_SYS_USER", Json.Serialization(entity)); Update_Log(value, Combination.Get_PartialContents_ResultsDescribed(entity.LoginName, "用户名")); return(value); }