Advertisement
lekao2009

Untitled

Jun 17th, 2016
2,996
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. Select csgcdite
  4. Set Relation To
  5.  
  6. If Messagebox('Confirma a Exportação?',4 + 32 + 0,'Confirmação') = 6
  7.     xalias = Alias()
  8.     xord = Order()
  9.     rec = Iif(!Eof(),Recno(),0)
  10.  
  11.     abre_tabela("produtos", "", "AUX", 1)
  12.     Select produtosAux
  13.     Set Order To pro_descri
  14.     Select csgcdite
  15.     Set Relation To pro_descri Into produtosAUX Additive
  16.  
  17.     Create Cursor X_mapa(fone c(70), isbn c(13),fax c(30),udatac c(30),endere c(50),bairro c(30),cidade c(30),sigla c(17),;
  18.     produto c(50),descont c(6),unit c(12),Total c(12),qtd c(17),devolv c(17), vend c(30),;
  19.     repos c(6), contato c(20), email c(100), cscCli_nome c(50), cscgCli_cgccpf c(50), prPro_custo c(12), prSaldoesto c(10))
  20.  
  21.     Select csgcdite
  22.  
  23.     Set Order To pro_descri
  24.  
  25.     Go Top
  26.  
  27.     xtotal = 0
  28.     xqtd = 0
  29.     xdevolv = 0
  30.     xvend = 0
  31.     xrepos = 0
  32.     xnome = csgcdcab.cli_nome
  33.  
  34.     If  xnome = csgcdcab.cli_nome
  35.  
  36.         For m_i = 1 To 2
  37.             Insert Into X_mapa(cidade,sigla,produto);
  38.             VALUES(Iif(m_i = 1,"Telefone",CLIENTES_CSG.cli_fone), Iif(m_i = 1, "Fax",CLIENTES_CSG.cli_fax),;
  39.             IIF(m_i = 1, "Ult.Acerto:",Dtoc(csgcdcab.csg_udatac)))
  40.         Endfor
  41.  
  42.         For m_i = 1 To 2
  43.             Insert Into X_mapa(fone,fax,udatac,endere, contato, email);
  44.             values(CLIENTES_CSG.cli_endere, CLIENTES_CSG.cli_bairro, CLIENTES_CSG.cli_cidade, CLIENTES_CSG.ufe_sigla, CLIENTES_CSG.cli_contat, CLIENTES_CSG.cli_email)
  45.         Endfor
  46.  
  47.     Endif
  48.     Insert Into X_mapa(fone, isbn,fax,udatac,endere,bairro,cidade,sigla,produto);
  49.     VALUES("PRODUTO", "ISBN", "DESCONTO","$ UNITÁRIO","$ TOTAL","QUANT.","DEVOLV.","VEND.","REPOS.")
  50.  
  51.     Select csgcdcab
  52.     Set Order To CSG_NUMERO
  53.  
  54.     Select csgcdite
  55.     Set Order To CSG_NUMERO
  56.     Go Top
  57.     Seek Alltrim(csgcdcab.CSG_NUMERO)
  58.  
  59.     Do While csgcdite.CSG_NUMERO = csgcdcab.CSG_NUMERO
  60.  
  61.         Insert Into X_mapa (fone, isbn,;
  62.         fax,udatac,endere,;
  63.         bairro, cscCli_nome, cscgCli_cgccpf, prPro_custo, prSaldoesto );
  64.         values (Alltrim(csgcdite.pro_descri), produtosAUX.pro_isbn,;
  65.         Str(csgcdite.csg_dsc,6)+"%", Str(csgcdite.csg_vlu,10,2), ;
  66.         Str(Round(csgcdite.csg_qtd*(csgcdite.csg_vlu-(csgcdite.csg_vlu*csgcdite.csg_dsc/100)),2),12,2),;
  67.         Str(csgcdite.csg_qtd,6),;
  68.         Clientes_csg.Cli_nome,;
  69.         Clientes_csg.Cli_cgccpf,;
  70.         ConverteDados(produtosaux.pro_custo),;
  71.         "99")
  72.  
  73.         xtotal = xtotal + Round(csgcdite.csg_qtd*(csgcdite.csg_vlu-(csgcdite.csg_vlu*csgcdite.csg_dsc/100)),2)
  74.         xqtd = xqtd + csgcdite.csg_qtd
  75.  
  76.         Skip
  77.     Enddo
  78.  
  79.     Insert Into X_mapa(udatac,endere,bairro);
  80.     VALUES ("TOTAL:", Str(xtotal,12,2),Str(xqtd,6))
  81.  
  82.     xtotal = 0
  83.     xqtd = 0
  84.  
  85.     original = Sys(5)+Sys(2003)
  86.     Set Default To Sys(5)+"\sistemas\planilhas"
  87.     drv = Putfile("Gravar", "mapaAcerto", "xls")
  88.     Set Defa To &original
  89.  
  90.     If !Empty(drv)
  91.         Erro = .F.
  92.  
  93.         Select X_mapa
  94.         Export To (drv) For !Eof() Type Xl5
  95.        
  96.         loexcel=Createobject("Excel.application")
  97.  
  98.         With loexcel.Application
  99.             .Visible = .F.
  100.             .workbooks.Open(drv)
  101.  
  102.             lcCliFor = Iif(informacao[1, 21] = 1, 'CLIENTE :', 'FORNECEDOR :')
  103.             .Cells(1,1).Value = 'MAPA DE CONSIGNAÇÕES DO ' + lcCliFor
  104.             For m_i = 2 To 15
  105.                 .Cells(1,m_i).Value = ''
  106.             Endfor
  107.  
  108.             .Cells(3,1).Value = csgcdcab.cli_nome
  109.             For m_i = 2 To 4
  110.                 .Cells(3,m_i).Value = ''
  111.             Endfor
  112.  
  113.             .Rows(6).Insert
  114.             .Cells(6,1).Value = informacao [1,1]
  115.             For m_i = 2 To 15
  116.                 .Cells(6,m_i).Value = ''
  117.             Endfor
  118.  
  119.             .Rows(7).Insert
  120.  
  121.             .Cells(5,7).Value = "Vendedor(a):"
  122.             .Cells(5,8).Value = CLIENTES_CSG.FUN_NOME
  123.  
  124.             .Rows(6).Insert
  125.  
  126.             For m_i = 1 To 10
  127.                 .Cells(4,m_i).Value = ''
  128.             Endfor
  129.  
  130.             .Cells.Select
  131.             .Selection.Columns.AutoFit
  132.             .Selection.Font.Name = "Arial"
  133.             .Selection.Font.Size = 8
  134.  
  135.             letra1 = 'b'
  136.             letra2 = 'b'
  137.             .Range("&LETRA1:&letra2").Select
  138.             .Selection.HorizontalAlignment = 3
  139.  
  140.             letra1 = 'a1'
  141.             letra2 = 'a3'
  142.             .Range("&LETRA1:&letra2").Select
  143.             .Selection.Font.Size = 10
  144.             .Selection.Font.bold = .T.
  145.  
  146.             letra1 = 'c'
  147.             letra2 = 'E'
  148.             .Range("&LETRA1:&letra2").Select
  149.             .Selection.HorizontalAlignment = 4
  150.  
  151.             .Columns("a:a").ColumnWidth = 50.00
  152.             .Columns("h:h").ColumnWidth = 13.71
  153.  
  154.             .Rows(9).HorizontalAlignment = 3
  155.             .Rows(5).HorizontalAlignment = 2
  156.  
  157.             .Rows(2).Font.bold = .T.
  158.  
  159.             Go Top
  160.  
  161.             contador = 1
  162.  
  163.             x_linha = 0
  164.  
  165.             Do While !Eof()
  166.  
  167.                 If Upper(Alltrim(X_mapa.fone)) = "PRODUTO"
  168.                     x_linha = contador
  169.  
  170.                     .Rows(x_linha+2).Font.bold = .T.
  171.                     .Rows(x_linha+2).Font.Size = 10
  172.                     .Rows(x_linha+4).Font.bold = .T.
  173.                     .Rows(x_linha).Font.bold = .T.
  174.  
  175.                     letra1 = 'A'+ Alltrim(Str(contador-4))
  176.                     letra2 = 'i' + Alltrim(Str(x_linha+4))
  177.                     .Range("&LETRA1:&letra2").Select
  178.                     .Selection.BorderS(9).weight = 2
  179.                     .Selection.BorderS(7).weight = 2
  180.                     .Selection.BorderS(10).weight = 2
  181.                     .Selection.BorderS(4).weight = 2
  182.                     .Selection.BorderS(3).weight = 2
  183.  
  184.                     letra1 = 'g'+ Alltrim(Str(contador-3))
  185.                     letra2 = 'H' + Alltrim(Str(x_linha-2))
  186.                     .Range("&LETRA1:&letra2").Select
  187.                     .Selection.BorderS(1).weight = 2
  188.                     .Selection.BorderS(2).weight = 2
  189.  
  190.                     letra1 = 'g'+ Alltrim(Str(contador))
  191.                     letra2 = 'i' + Alltrim(Str(x_linha))
  192.                     .Range("&LETRA1:&letra2").Select
  193.                     .Selection.BorderS(7).weight = 2
  194.  
  195.                 Endif
  196.  
  197.                 If  Empty(X_mapa.fone) .And. !Empty(X_mapa.udatac)
  198.                     xcont = contador
  199.  
  200.                     .Rows(xcont+4).Font.bold = .T.
  201.  
  202.                     letra1 = 'a'+ Alltrim(Str(contador))
  203.                     letra2 = 'i' + Alltrim(Str(xcont+3))
  204.                     .Range("&LETRA1:&LETRA2").Select
  205.                     .Selection.BorderS(9).weight = 2
  206.  
  207.                     letra1 = 'D'+ Alltrim(Str(contador-1))
  208.                     letra2 = 'i' + Alltrim(Str(xcont+4))
  209.                     .Range("&LETRA1:&LETRA2").Select
  210.                     .Selection.BorderS(9).weight = 2
  211.  
  212.                     letra1 = 'D'+ Alltrim(Str(x_linha+5))
  213.                     letra2 = 'i' + Alltrim(Str(xcont+4))
  214.                     .Range("&LETRA1:&LETRA2").Select
  215.                     .Selection.BorderS(1).weight = 2
  216.                     .Selection.BorderS(2).weight = 2
  217.  
  218.                     letra1 = 'A'+ Alltrim(Str(x_linha+5))
  219.                     letra2 = 'B' + Alltrim(Str(xcont+3))
  220.                     .Range("&LETRA1:&LETRA2").Select
  221.                     .Selection.BorderS(1).weight = 2
  222.                     .Selection.BorderS(2).weight = 2
  223.                 Endif
  224.  
  225.                 contador = contador +1
  226.                 Skip
  227.             Enddo
  228.  
  229.             *inicio trabalho Mover Colunas.
  230.  
  231.             .Range("F9:F"+Alltrim(Str(xcont+3))).Select
  232.             .Selection.Cut
  233.  
  234.             .Range("K9:K"+Alltrim(Str(xcont+3))).Select
  235.             .Selection.Insert
  236.  
  237.             .Range("E9:E"+Alltrim(Str(xcont+3))).Select
  238.             .Selection.Cut
  239.  
  240.             .Range("N9:N"+Alltrim(Str(xcont+3))).Select
  241.             .Selection.Insert
  242.  
  243.             .Range("B9:B"+Alltrim(Str(xcont+3))).Select
  244.             .Selection.Cut
  245.  
  246.             .Range("A9:A"+Alltrim(Str(xcont+3))).Select
  247.             .Selection.Insert
  248.  
  249.             .Range("B9:B"+Alltrim(Str(xcont+3))).Select
  250.  
  251.             .Range("S10:S"+Alltrim(Str(xcont+3))).Select
  252.             .Selection.Cut
  253.  
  254.             .Range("C10:C"+Alltrim(Str(xcont+3))).Select
  255.             .Selection.Insert
  256.  
  257.             .Range("T10:T"+Alltrim(Str(xcont+3))).Select
  258.             .Selection.Cut
  259.  
  260.             .Range("D10:D"+Alltrim(Str(xcont+3))).Select
  261.             .Selection.Insert
  262.  
  263.             .Range("F10:F"+Alltrim(Str(xcont+3))).Select
  264.             .Selection.Cut
  265.             .Range("E10:E"+Alltrim(Str(xcont+3))).Select
  266.             .Selection.Insert
  267.  
  268.             .Range("U10:U"+Alltrim(Str(xcont+3))).Select
  269.             .Selection.Cut
  270.  
  271.             .Range("F10:F"+Alltrim(Str(xcont+3))).Select
  272.             .Selection.Insert
  273.  
  274.             .Range("L10:L"+Alltrim(Str(xcont+3))).Select
  275.             .Selection.Cut
  276.             .Range("E10:E"+Alltrim(Str(xcont+3))).Select
  277.             .Selection.Insert
  278.  
  279.             .Range("P10:P"+Alltrim(Str(xcont+3))).Select
  280.             .Selection.Cut
  281.             .Range("G10:G"+Alltrim(Str(xcont+3))).Select
  282.             .Selection.Insert
  283.  
  284.             .Range("H10:H"+Alltrim(Str(xcont+3))).Select
  285.             .Selection.Cut
  286.             .Range("F10:F"+Alltrim(Str(xcont+3))).Select
  287.             .Selection.Insert
  288.  
  289.             .Range("H9:V"+Alltrim(Str(xcont+3))).Select
  290.             .Selection.Delete
  291.             .Selection.ClearContents
  292.  
  293.             .Range("N1:W"+Alltrim(Str(xcont+3))).Select
  294.             .Selection.Delete
  295.             .Selection.ClearContents
  296.             *set step on
  297.  
  298.             .Range("A9:W"+Alltrim(Str(xcont+3))).Select
  299.             .Selection.Columns.AutoFit
  300.  
  301.             *Fim trabalho Mover Colunas.
  302.             *Renomear Cabecalhos.
  303.  
  304.             .Cells(9,1).Value = 'ISBN'
  305.             .Cells(9,2).Value = 'PRODUTO'
  306.             .Cells(9,3).Value = 'CLIENTE'
  307.             .Cells(9,4).Value = 'CNPJ'
  308.             .Cells(9,5).Value = 'QTD CSG'
  309.             .Cells(9,6).Value = 'PREÇO CUSTO'
  310.             .Cells(9,7).Value = 'TOTAL'
  311.  
  312.             .Range("A10:G"+Alltrim(Str(xcont+3))).Select
  313.             .Selection.Font.Name = "Arial"
  314.             .Selection.Font.Size = 8
  315.             .Selection.Font.bold = .F.
  316.             .Selection.BorderS(9).weight = 2
  317.             .Selection.BorderS(7).weight = 2
  318.             .Selection.BorderS(10).weight = 2
  319.             .Selection.BorderS(4).weight = 2
  320.             .Selection.BorderS(3).weight = 2
  321.            
  322.             .ActiveWorkbook.Save
  323.             .workbooks.Close
  324.  
  325.         Endwith
  326.         Rele loexcel
  327.  
  328.         = Messagebox('Planilha gerada com sucesso!', 0 + 32, 'Aviso')
  329.     Endif
  330.  
  331.     fecha_tabela("produtosAUX")
  332.     Select (xalias)
  333.     Set Order To (xord)
  334.     If !Empty(rec)
  335.         Go rec
  336.     Endif
  337. Endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement