/// <summary> /// 根据用户编号更新用户信息 /// </summary> /// <param name="entity">用户信息</param> public void UpdateUserBySysNo(Users entity) { //check if (string.IsNullOrWhiteSpace(entity.UserID)) { throw new BusinessException("必须输入用户ID!"); } if (string.IsNullOrWhiteSpace(entity.UserName)) { throw new BusinessException("必须输入用户名!"); } var userList = UsersMgtDA.GetValidUserListByUserID(entity.UserID); if (userList != null && userList.Count > 0) { if (userList.Count == 1 && userList[0].SysNo.Value != entity.SysNo.Value) { throw new BusinessException("用户ID已经存在!"); } if (userList.Count > 1) { throw new BusinessException("用户ID已经存在!"); } } UsersMgtDA.UpdateUserBySysNo(entity); }
/// <summary> /// 添加用户 /// </summary> /// <param name="entity">用户信息</param> /// <returns></returns> public int InsertUser(Users entity) { //check if (string.IsNullOrWhiteSpace(entity.UserID)) { throw new BusinessException("必须输入用户ID!"); } if (string.IsNullOrWhiteSpace(entity.UserName)) { throw new BusinessException("必须输入用户名!"); } if (string.IsNullOrWhiteSpace(entity.Password)) { throw new BusinessException("必须输入密码!"); } var userList = UsersMgtDA.GetValidUserListByUserID(entity.UserID); if (userList != null && userList.Count > 0) { throw new BusinessException("用户ID已经存在!"); } entity.UserAuthCode = GuidCode.GetGuid("D"); entity.Password = MD5Encrypt.MD5Encrypt32(string.Format("{0}-{1}", entity.Password, entity.UserAuthCode)).ToLower(); return(UsersMgtDA.InsertUser(entity)); }