Ir para conteúdo
Fórum Script Brasil

Iceguy

Membros
  • Total de itens

    274
  • Registro em

  • Última visita

Tudo que Iceguy postou

  1. Iceguy

    (Resolvido) Calcular data

    É certo isso? menor que agora e menor que agora - 30? porque dai é redundante, pois o conjunto "é menor que agora - 30" contém o conjunto "é menor que agora". Se for mesmo, é assim: SELECT seuCampo1, seuCampo2, seuCampoN FROM suaTabela WHERE seuCampoData < DATEADD("d", 30, NOW());
  2. cola o código aí, de com e sem parâmetro.
  3. Iceguy

    Access e SQL

    1) SELECT * FROM tabela UNION SELECT * FROM tabela2; Com isso você junta registros distintos de duas tabelas com estrutura idêntica. Pode ser somente alguns campos, mas os campos precisam ser iguais em tipo, tamanho, coisa do tipo. É possível usar UNION ALL ao invés de UNION, e com isso você terá todos os registros, incluindo dados duplicados. 2) No excel esse campo é um campo de Data? Se for é só mudar a máscara do campo pra "ddmmyyyy", se não tenta usar na select FORMAT(seuCampo, "yyyymmdd") e depois muda a máscara do campo.
  4. Acho que é algo +- assim: cria um enumerador para o tipo de mídia public enum TipoMidia { LIVRO, MUSICA, VIDEO; } Library.java import java.util.*; public class Library{ private Map<Integer, Midia> biblioteca = new HashMap<Integer, Midia>(); public synchronized void insertElement(Midia novaMidia, int key){ biblioteca.put(key, novaMidia); } public synchronized Midia recoverElement(int key){ return biblioteca.get(key); } public synchronized void orderLibraryByKey(){ Map<Integer,Midia> bibliotecaOrdenada = new TreeMap<Integer,Midia>(); bibliotecaOrdenada.putAll(biblioteca); biblioteca = null; biblioteca.putAll(bibliotecaOrdenada); bibliotecaOrdenada = null; } } Midia.java public abstract class Midia { private TipoMidia tipo; /* * demais atributos de uma mídia em geral * */ public TipoMidia getTipo(){ return this.tipo; } public void setTipo(TipoMidia tipo){ this.tipo = tipo; } /* * demais getters e setter dos atributos * */ public final void salvar(){ Library biblioteca = new Library(); biblioteca.insertElement(this, 1); } public final void recuperar(int key){ Library biblioteca = new Library(); carregarMidia(biblioteca.recoverElement(key)); } private final void carregarMidia(Midia midiaRecuperada) { this.tipo = midiaRecuperada.tipo; /* * continua carregando */ carregarEspecifico(midiaRecuperada); } public final void ordenar(){ Library biblioteca = new Library(); biblioteca.orderLibraryByKey(); } public abstract void carregarEspecifico(Midia midiaRecuperada); } Daí você cria os três tipos de mídia herdando Midia, e neles você coloca só os atributos específicos e implementa o carregaEspecifico em cada um deles, que é onde você carrega os itens específicos de cada tipo de mídia, os comuns são carregados pelo carregaMidia Livro.java public class Livro extends Midia{ /*atriutos específicos de um livro*/ /*getters e setters*/ @Override public void carregarEspecifico(Midia midiaRecuperada) { /* * Carrega os dados específicos recuperados nos atributos * ex: this.paginas = midiaRecuperada.paginas; */ } } O resto ali é de boa, a Thread e o ShowProperties() ShowProperties() tu pode reescrever o ToString dos objetos
  5. Deve ser +- isso: import java.lang.Math.round; public class CalculaValor{ private double valor; public CalculaValor(double valor){ this.valor = valor; } public double custoArea(double altura, double largura){ if(altura < 0 || largura < 0){ throw IllegalArgumentException("Parâmetro com valor negativo."); } return Math.round(altura * largura * valor, 2); } } Daí chama assim: /* passa o valor do m² no construtor*/ CalculaValor cv = new CalculaValor(20); /*@param1: altura*/ /*@param2: largura*/ resultado = cv.custoArea(0.8, 1);
  6. Pra buscar um item de um ArrayList você usa o método get(int) passando a posição que você quer. Lembrando que a primeira posição é 0.
  7. Iceguy

    Cliente com varias opções

    tabela cliente com cod cliente e nome cliente tabela ordem de serviço com cod OS, cliente OS, etc tabela itens OS com cod OS, item, status aí seleciona cliente e vem as OS dele, daí seleciona a OS e consulta os itens dela, e cada um tem um status (aberto, fechado, em execução, cancelado, etc) e você vai atualizando isso
  8. Iceguy

    (Resolvido) movenext

    Inverte ué... Do While Not rs.EOF If Not x = y Then rs("seuCampo") End If rs.MoveNext Loop
  9. Não não... Só comentei que no excel (macro do excel) você usa esse código. Não testei com ASP, nem sei se funciona isso no ASP. Resolvi pesquisar um pouco no Google, achei exemplo do vbLf e Chr(10) que ele usou e que não funcionou, então achei >>ISSO<< que parece que soluciona o problema.
  10. <br> quebra HTML, pelo que ele falou no post ele precisa de algo que faça o excel quebrar linha. O que eu sei que num macro do excel faz quebrar linha são as constante vbNewLine, vbLf e vbCrLf. Havia colocado no post a vbNewLine porque achei que era ela que quebrava linha sem deixar um "caracter de quadradinho" no fim da linha, mas testei agora no excel e é o vbLf que quebra linha sem o caracter. Rodando dentro de um macro no excel, ficaria assim: Plan.Cells(linha, coluna) = "Texto da primeira linha" & vbLf & "texto da segunda linha."
  11. Isso funciona no ASP? "Texto da primeira linha" & vbNewLine & "texto da segunda linha."
  12. Iceguy

    FOR EACH

    Tipo isso (ta com cara de gambizona, mas...) Dim nomes() Dim presencas() i = 0 For Each item In Request("nome") Redim Preserve nomes(i) nomes(i) = item i = i + 0 Next For Each item In Request("presenca") Redim Preserve presencas(i) presencas(i) = item i = i + 0 Next For i = 0 To UBound(nomes) rst.AddNew rst("nome") = nomes(i) rst("presenca") = presencas(i) Next
  13. Iceguy

    FOR EACH

    você ta fazendo algo assim: pega o nome e adiciona na lista, pega o próximo e adiciona novamente, e faz isso até acabar todos. Depois no final você (com o último registro selecionado) sai adicionando a presença. Ideal seria você pegar primeiro nome e primeira presença e add os dois, e depois ir para o próximo
  14. Iceguy

    FOR EACH

    Pelo que entendi você vai lendo os nomes e adicionando novos records na sua recordset, depois que adicionou todos os nomes você lê todas as presenças e vai adicionando elas sempre na última posição, porque você não move o registro quando lê presença.
  15. Qual valor você usou pra testar? Você pegou um número e criptografou, depois jogou o resultado na função e ele voltou com asterisco no meio?
  16. Vê se isso te ajuda: Classe Criptografia.asp <% '======================================================= 'CLASSE DE CRIPTOGRAFIA DE STRINGS '======================================================= Class Criptografia '----------------------------------------------------- 'Atributos/Constantes da Classe '----------------------------------------------------- Private dblCenterY Private dblCenterX Private LastResult Private LastErrDes Private LastErrNum Private errInvalidKeyLength Private errInvalidKey Private errInvalidSize Private errKeyMissing Private errClearTextMissing Private errCipherTextMissing Private A Private B Private C Private D Private E Private F '----------------------------------------------------- 'Procedimentos de Inicialização de Destruição da Classe '----------------------------------------------------- Private Sub Class_Initialize() 'Inivializando as variáveis errInvalidKeyLength = 65101 errInvalidKey = 65102 errInvalidSize = 65103 errKeyMissing = 65303 errClearTextMissing = 65304 errCipherTextMissing = 65305 A = 10 B = 11 C = 12 D = 13 E = 14 F = 15 End Sub Private Sub Class_Terminate() End Sub Function QuickEncrypt(strClear, strKey) Dim intRet intRet = EncryptText(strClear, strKey) If intRet = -1 Then QuickEncrypt = "ERROR" Else QuickEncrypt = LastResult End If End Function Function QuickDecrypt(strCipher, strKey) Dim intRet intRet = DecryptText(strCipher, strKey) If intRet = -1 Then QuickDecrypt = "ERROR" Else QuickDecrypt = LastResult End If End Function Function GetStrength(strPassword) strPassword = CStr(strPassword) GetStrength = (Len(strPassword) * 8) + (Len(GetSerial) * 8) End Function Function GetSerial() GetSerial = Now End Function Function GetHash(strKey) Dim strCipher Dim byKey() ReDim byKey(Len(strKey)) For i = 1 To Len(strKey) byKey(i) = Asc(Mid(strKey, i, 1)) Next For i = 1 To UBound(byKey) / 2 strCipher = strCipher & NumToHex(byKey(i) Xor byKey((UBound(byKey) - i) + 1)) Next GetHash = strCipher End Function Function CreatePassword(strSeed, lngLength) Dim bySeed() Dim bySerial() Dim strTimeSerial Dim Random Dim lngPosition Dim lngSerialPosition strCipher = "" lngPosition = 1 lngSerialPosition = 1 ReDim bySeed(Len(strSeed)) For i = 1 To Len(strSeed) bySeed(i) = Asc(Mid(strSeed, i, 1)) Next strTimeSerial = GetSerial() ReDim bySerial(Len(strTimeSerial)) For i = 1 To Len(strTimeSerial) bySerial(i) = Asc(Mid(strTimeSerial, i, 1)) Next ReCenter CDbl(bySeed(lngPosition)), CDbl(bySerial(lngSerialPosition)) lngPosition = lngPosition + 1 lngSerialPosition = lngSerialPosition + 1 For i = 1 To (lngLength / 2) Generate CDbl(bySeed(lngPosition)), CDbl(bySerial(lngSerialPosition)), False strCipher = strCipher & NumToHex(MakeRandom(dblCenterX, 255)) strCipher = strCipher & NumToHex(MakeRandom(dblCenterY, 255)) If lngPosition = Len(strSeed) Then lngPosition = 1 Else lngPosition = lngPosition + 1 End If If lngSerialPosition = Len(strTimeSerial) Then lngSerialPosition = 1 Else lngSerialPosition = lngSerialPosition + 1 End If Next CreatePassword = Left(strCipher, lngLength) End Function Sub ReCenter(mdblCenterY, mdblCenterX) dblCenterY = mdblCenterY dblCenterX = mdblCenterX End Sub Sub Generate(dblRadius, dblTheta, blnRad) Const Pi = 3.14159265358979 Const sngMaxUpper = 2147483647 Const sngMaxLower = -2147483648 If blnRad = False Then If (dblRadius * Cos((dblTheta / 180) * Pi)) + dblCenterX > sngMaxUpper Or (dblRadius * Cos((dblTheta / 180) * Pi)) + dblCenterX < sngMaxLower Then ReCenter dblCenterY, 0 Else dblCenterX = (dblRadius * Cos((dblTheta / 180) * Pi)) + dblCenterX End If If (dblRadius * Sin((dblTheta / 180) * Pi)) + dblCenterY > sngMaxUpper Or (dblRadius * Sin((dblTheta / 180) * Pi)) + dblCenterY < sngMaxLower Then ReCenter 0, dblCenterX Else dblCenterY = (dblRadius * Sin((dblTheta / 180) * Pi)) + dblCenterY End If Else If (dblRadius * Cos(dblTheta)) + dblCenterX > sngMaxUpper Or (dblRadius * Cos(dblTheta)) + dblCenterX < sngMaxLower Then ReCenter dblCenterY, 0 Else dblCenterX = (dblRadius * Cos(dblTheta)) + dblCenterX End If If (dblRadius * Sin(dblTheta)) + dblCenterY > sngMaxUpper Or (dblRadius * Sin(dblTheta)) + dblCenterY < sngMaxLower Then ReCenter 0, dblCenterX Else dblCenterY = (dblRadius * Sin(dblTheta)) + dblCenterY End If End If End Sub Function MakeRandom(dblValue, lngMax) Dim lngRandom lngRandom = Int(dblValue Mod (lngMax + 1)) If lngRandom > lngMax Then lngRandom = 0 End If MakeRandom = Abs(lngRandom) End Function Sub RaiseError(lngErrNum, strErrDes) LastErrDes = strErrDes LastErrNum = lngErrNum End Sub Function EncryptText(strClear, strKey) Dim byClear() Dim byKey() Dim byCipher() Dim lngPosition Dim lngSerialPosition Dim strTimeSerial Dim blnSecondValue Dim strCipher Dim i strKey = CStr(strKey) strClear = CStr(strClear) If strKey = "" Then RaiseError errKeyMissing, "Key Missing" EncryptText = -1 Exit Function End If If Len(strKey) <= 1 Then RaiseError errInvalidKeyLength, "Invalid Key Length" EncryptText = -1 Exit Function End If strTimeSerial = GetSerial() ReDim byKey(Len(strKey)) For i = 1 To Len(strKey) byKey(i) = Asc(Mid(strKey, i, 1)) Next If Len(strClear) = 0 Then RaiseError errInvalidSize, "Text Has Zero Length" EncryptText = -1 Exit Function End If ReDim byClear(Len(strClear)) For i = 1 To Len(strClear) byClear(i) = Asc(Mid(strClear, i, 1)) Next lngPosition = 1 lngSerialPosition = 1 For i = 1 To UBound(byKey) / 2 strCipher = strCipher & NumToHex(byKey(i) Xor byKey((UBound(byKey) - i) + 1)) Next lngPosition = 1 strCipher = strCipher & NumToHex(Len(strTimeSerial) Xor byKey(lngPosition)) lngPosition = lngPosition + 1 For i = 1 To Len(strTimeSerial) strCipher = strCipher & NumToHex(byKey(lngPosition) Xor Asc(Mid(strTimeSerial, i, 1))) If lngPosition = UBound(byKey) Then lngPosition = 1 Else lngPosition = lngPosition + 1 End If Next lngPosition = 1 lngSerialPosition = 1 ReCenter CDbl(byKey(lngPosition)), Asc(Mid(strTimeSerial, lngSerialPosition, 1)) lngPosition = lngPosition + 1 lngSerialPosition = lngSerialPosition + 1 blnSecondValue = False For i = 1 To UBound(byClear) If blnSecondValue = False Then Generate CDbl(byKey(lngPosition)), Asc(Mid(strTimeSerial, lngSerialPosition, 1)), False strCipher = strCipher & NumToHex(byClear(i) Xor MakeRandom(dblCenterX, 255)) blnSecondValue = True Else strCipher = strCipher & NumToHex(byClear(i) Xor MakeRandom(dblCenterY, 255)) blnSecondValue = False End If If lngPosition = UBound(byKey) Then lngPosition = 1 Else lngPosition = lngPosition + 1 End If If lngSerialPosition = Len(strTimeSerial) Then lngSerialPosition = 1 Else lngSerialPosition = lngSerialPosition + 1 End If Next LastResult = strCipher EncryptText = 1 Exit Function End Function Public Function DecryptText(strCipher, strKey) Dim strClear Dim byCipher() Dim byKey() Dim strTimeSerial Dim strCheckKey Dim lngPosition Dim lngSerialPosition Dim lngCipherPosition Dim bySerialLength Dim blnSecondValue Dim i strCipher = CStr(strCipher) strKey = CStr(strKey) If Len(strCipher) = 0 Then RaiseError errCipherTextMissing, "Cipher Text Missing" DecryptText = -1 Exit Function End If If Len(strCipher) < 10 Then RaiseError errInvalidSize, "Bad Text Length" DecryptText = -1 Exit Function End If If Len(strKey) = 0 Then RaiseError errKeyMissing, "Key Missing" DecryptText = -1 Exit Function End If If Len(strKey) <= 1 Then RaiseError errInvalidKeyLength, "Invalid Key Length" DecryptText = -1 Exit Function End If ReDim byKey(Len(strKey)) For i = 1 To Len(strKey) byKey(i) = Asc(Mid(strKey, i, 1)) Next ReDim byCipher(Len(strCipher) / 2) lngCipherPosition = 1 For i = 1 To Len(strCipher) Step 2 byCipher(lngCipherPosition) = HexToNum(Mid(strCipher, i, 2)) lngCipherPosition = lngCipherPosition + 1 Next lngCipherPosition = 1 For i = 1 To UBound(byKey) / 2 strCheckKey = strCheckKey & NumToHex(byKey(i) Xor byKey((UBound(byKey) - i) + 1)) Next If Left(strCipher, Len(strCheckKey)) <> strCheckKey Then RaiseError errInvalidKey, "Invalid Key" DecryptText = -1 Exit Function Else lngCipherPosition = (Len(strCheckKey) / 2) + 1 End If lngPosition = 1 bySerialLength = byCipher(lngCipherPosition) Xor byKey(lngPosition) lngCipherPosition = lngCipherPosition + 1 lngPosition = lngPosition + 1 For i = 1 To bySerialLength strTimeSerial = strTimeSerial & Chr(byCipher(lngCipherPosition) Xor byKey(lngPosition)) If lngPosition = UBound(byKey) Then lngPosition = 1 Else lngPosition = lngPosition + 1 End If lngCipherPosition = lngCipherPosition + 1 Next lngPosition = 1 lngSerialPosition = 1 ReCenter CDbl(byKey(lngPosition)), Asc(Mid(strTimeSerial, lngSerialPosition, 1)) lngPosition = lngPosition + 1 lngSerialPosition = lngSerialPosition + 1 blnSecondValue = False For i = 1 To UBound(byCipher) - lngCipherPosition + 1 If blnSecondValue = False Then Generate CDbl(byKey(lngPosition)), Asc(Mid(strTimeSerial, lngSerialPosition, 1)), False strClear = strClear & Chr(byCipher(lngCipherPosition) Xor MakeRandom(dblCenterX, 255)) blnSecondValue = True Else strClear = strClear & Chr(byCipher(lngCipherPosition) Xor MakeRandom(dblCenterY, 255)) blnSecondValue = False End If If lngPosition = UBound(byKey) Then lngPosition = 1 Else lngPosition = lngPosition + 1 End If If lngSerialPosition = Len(strTimeSerial) Then lngSerialPosition = 1 Else lngSerialPosition = lngSerialPosition + 1 End If lngCipherPosition = lngCipherPosition + 1 Next LastResult = strClear DecryptText = 1 Exit Function End Function Function NumToHex(bByte) Dim strOne Dim strTwo strOne = CStr(Int((bByte / 16))) strTwo = bByte - (16 * strOne) If CDbl(strOne) > 9 Then If CDbl(strOne) = 10 Then strOne = "A" ElseIf CDbl(strOne) = 11 Then strOne = "B" ElseIf CDbl(strOne) = 12 Then strOne = "C" ElseIf CDbl(strOne) = 13 Then strOne = "D" ElseIf CDbl(strOne) = 14 Then strOne = "E" ElseIf CDbl(strOne) = 15 Then strOne = "F" End If End If If CDbl(strTwo) > 9 Then If strTwo = "10" Then strTwo = "A" ElseIf strTwo = "11" Then strTwo = "B" ElseIf strTwo = "12" Then strTwo = "C" ElseIf strTwo = "13" Then strTwo = "D" ElseIf strTwo = "14" Then strTwo = "E" ElseIf strTwo = "15" Then strTwo = "F" End If End If NumToHex = Right(strOne & strTwo, 2) End Function Function HexToNum(hexnum) Dim X Dim y Dim cur hexnum = UCase(hexnum) cur = CStr(Right(hexnum, 1)) Select Case cur Case "A" y = A Case "B" y = B Case "C" y = C Case "D" y = D Case "E" y = E Case "F" y = F Case Else y = CDbl(cur) End Select Select Case Left(hexnum, 1) Case "0" X = (16 * CInt(Left(hexnum, 1))) + y Case "1" X = (16 * CInt(Left(hexnum, 1))) + y Case "2" X = (16 * CInt(Left(hexnum, 1))) + y Case "3" X = (16 * CInt(Left(hexnum, 1))) + y Case "4" X = (16 * CInt(Left(hexnum, 1))) + y Case "5" X = (16 * CInt(Left(hexnum, 1))) + y Case "6" X = (16 * CInt(Left(hexnum, 1))) + y Case "7" X = (16 * CInt(Left(hexnum, 1))) + y Case "8" X = (16 * CInt(Left(hexnum, 1))) + y Case "9" X = (16 * CInt(Left(hexnum, 1))) + y Case "A" X = 160 + y Case "B" X = 176 + y Case "C" X = 192 + y Case "D" X = 208 + y Case "E" X = 224 + y Case "F" X = 240 + y End Select HexToNum = X End Function End Class %> <% '------------------------------------------------ 'EXEMPLO DE CHAMADA '------------------------------------------------ Dim objCriptografia Set objCriptografia = New Criptografia Response.Write "Encriptação: " & objCriptografia.QuickEncrypt("CodigoFonte", "minhachave") Response.Write "<br />Decriptação: " & objCriptografia.QuickDecrypt(objCriptografia.QuickEncrypt("CodigoFonte", "minhachave"), "minhachave") Set objCriptografia = Nothing %> FONTE E quanto ao teu código, pra voltar o que tu fez é só reverter a função q tu usou
  17. Você pode até fazer via código, fica mais "porco" e depois se precisar criar novo tipo f3rr0u, tem que alterar o fonte. Via código fica tipo isso: exemplo.asp <% Select Case rs("tipo") Case 1:%> <!--HTML com o Resultado do tipo 1 --> <%Case 2:%> <!--HTML com o Resultado do tipo 2 --> <%Case n:%> <!--HTML com o Resultado do tipo n --> <%End Select%>
  18. Aquele exemplo que passei alí resolve isso, você cria uma tabela com o valor correspondente ao código e traz ele usando JOIN
  19. Quanto a primeira pergunta, usa JOINs tblEmpregado -codEmpregado -nomeEmpregado tblEmpregado 1 | João 2 | Maria tblVenda -codEmpredado -codVenda tblVenda 1 | 1 1 | 2 2 | 3 1 | 4 2 | 5 2 | 6 Aí eu preciso o nome de quem fez a venda 5 SELECT tblEmpregado.nomeEmpregado FROM tblVenda INNER JOIN tblEmpregado ON(tblVenda.codEmpregado = tblVenda.codEmpregado) WHERE tblVenda.codVenda = 5 Nisso ele retorna "Maria"
  20. Faz algo assim: tblAnuncio -codAnuncio -dataCriacao -dataPublicacao -dataContratada SELECT tblAnuncio.codAnuncio FROM tblAnuncio WHERE tblAnuncio.dataContratada <= NOW() ORDER BY tblAnuncio.dataPublicacao, tblAnuncio.dataCriacao NOW() é a data de hoje no access, dependendo do teu banco é outro comando Aí você tem sempre como o primeiro registro o anuncio que foi publicado a mais tempo, e usa como critério de desempate que o anuncio criado primeiro vem primeiro. Depois que exibir o anuncio tu da um UPDATE na tabela atualizando o campo dataPublicacao (data e hora) pra NOW()
  21. troca Dim vetor(0 To 3) por Dim vetor(3)
  22. com UTF-8 você tem que escrever J&uacute;nior e não Júnior
  23. Você está desenvolvendo um componente no VB.NET para o Access 2007?? Vê ISSO então, pra ver se ajuda.
×
×
  • Criar Novo...