<%
Server.ScriptTimeOut =270
'on Error response.redirect("inputclient.asp?time=" +cstr(time()) )
if request("upd")<>"" then
colname=0 'Inicializa variable para registro denombres de Columna
nocol=20 'Numero de COlumnas del Archivo
idfld=1 'COlumna con el ID del Archivo o KEY
response.write("
")
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f,colas(20),Tits(20)
total=0
Set fs = CreateObject("Scripting.FileSystemObject")
'/home/sites/site5/data/PROMAD/enter/
'/home/sites/site5/data/PROMAD/enter/PEDIDOS.TXT
'
Set f = fs.OpenTextFile("c:\xnet\PROMAD\enter\data\PEDIDOS.TXT" , ForReading,TristateFalse)
'Lectura de Archivo Cargado
do while (not f.AtEndOfStream) and (ist<2000)
if (colname=1) and (total=0) then
if request("RESTART")<>"" THEN
for i=1 to Cint(request("RESTART"))
IF NOT F.AtEndOfStream then f.SkipLine
next
total=Cint(request("RESTART"))
end if
ist=0
end if
lleg=cstr(f.ReadLine)
'Registra longitud de primera linea
largo=len(linea)
if colname=1 then 'Si ya resgitro Nombres de Columnas Registra Valores del Renglon
for m=1 to nocol-1
ccs=InStr(lleg,chr(9))+1 'Contador de TABS
val=InStr(lleg,chr(9))-1
if val<0 then
'response.write("*")
if m=1 then val=7 else val=1
end if
while InStr(lleg,",")>0 'Elimina Commas
coma=InStr(lleg,",")
resto=mid(lleg,coma+1,len(lleg))
lleg=left(lleg,coma-1)+resto
wend
if InStr(lleg,"$")>0 then 'Elimina Pesos
coma=InStr(lleg,"$")
resto=mid(lleg,coma+1,len(lleg))
lleg=left(lleg,coma-1)+resto
end if
colas(m)=Replace(left(lleg,val),"$"," ") 'eliminar pesos
colas(m)=Replace(colas(m),""""," ")
colas(m)=Replace(colas(m),"'","""")
'colas(m)=Replace(colas(m),"-","0") 'Elimna Guiones
colas(m)=trim(colas(m)) 'Quita espacios
if len(colas(m))<=1 and m<>1 then colas(m)=""
'response.write(colas(m)+"-")
lleg=mid(lleg,ccs,len(lleg)) 'Corta la columna actual del String
next
while InStr(lleg,",")>0 'Elimina Commas
coma=InStr(lleg,",")
resto=mid(lleg,coma+1,len(lleg))
lleg=left(lleg,coma-1)+resto
wend
if InStr(lleg,"$")>0 then 'Elimina Pesos
coma=InStr(lleg,"$")
resto=mid(lleg,coma+1,len(lleg))
lleg=left(lleg,coma-1)+resto
end if
colas(nocol)=Replace(colas(nocol),""""," ")
colas(nocol)=Replace(colas(nocol),"'","""")
colas(nocol)=trim(colas(nocol)) 'Agrega la ultima columna
if len(colas(nocol))<=1 then colas(nocol)=""
'response.write(colas(nocol))
'response.write(" ")
ist=ist+1
total=total+1
end if
if colname=1 then
dl="'"
sqlmins="INSERT INTO ENTRADAS (" + Tits(1)
for i=2 to nocol-1
sqlmins = sqlmins + "," + Tits(i)
next
sqlmins=sqlmins + ") values (" + dl+ cstr(colas(1)) + dl
for i=2 to nocol-1
'if i>7 then dl=""
sqlmins = sqlmins + "," + dl + colas(i) + dl
next
sqlmins = sqlmins + " )"
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_entradas_STRING
MM_editCmd.CommandText = sqlmins
'response.redirect("escribes.asp?cmd=" +sqlmins )
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
end if
if colname=0 then 'Regsitro de Nombres de columna en Variables
'if request("RESTART")="" then
' Set MM_editCmd = Server.CreateObject("ADODB.Command")
' MM_editCmd.ActiveConnection = MM_entradas_STRING
' MM_editCmd.CommandText = "DELETE FROM CLIENTES WHERE ID>0"
' 'response.redirect("escribes.asp?cmd=" +sqlmins )
' MM_editCmd.Execute
' MM_editCmd.ActiveConnection.Close
'end if
Tits(1)="PEDIDO"
Tits(2)="FECHA"
Tits(3)="DESCRIPCION"
Tits(4)="MODELO"
Tits(5)="SERIE"
Tits(6)="CLIENTE"
Tits(7)="PROVEEDOR"
Tits(8)="F_PEDIDO"
Tits(9)="FACTURA_PROMAD"
Tits(10)="SUCSOLICITANTE"
Tits(11)="CODIGO"
Tits(12)="ENTREGA"
Tits(13)="FECHA_ENTREGA"
Tits(14)="FACTURA"
Tits(15)="F_DE_FACTURA"
Tits(16)="TOTAL_DE_FACT"
Tits(17)="DE_PEDIMENTO"
Tits(18)="FACC_ARANCEL"
Tits(19)="ORSERVACIONES"
colname=1
end if
loop
if f.AtEndOfStream then total=""
f.Close
Server.ScriptTimeOut =90
response.redirect("inputpeds.asp?success=Archivo Registrado Satisfactoriamente&parcial="+ cstr(total)+"&totales=" + cstr(ist))
end if
%>