/// <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)); }