<!--METADATA TYPE= "typelib" NAME= "ADODB Type Library" FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" -->
<!--#include file="Getcookies.asp"-->
<!--#include file="function.asp"-->
<!--#include file="dbopen.asp"-->
<%
set uploadform = server.createobject("DEXT.FileUpload")
uploadform.defaultPath = "D:\Data\sps.synopex.com\upload_file"
board_file=uploadform("board_file")
board_file_name=uploadform("board_file").FileName
data_kind=uploadform("data_kind")
years=uploadform("years")
'response.write board_file
uploadform.DefaultPath = "D:\Data\sps.synopex.com\upload_file"
uploadform("board_file").Save
Set uploadform = Nothing
board_file_kind = "Y"
SQL="insert into p_board (board_kind,title,contents,name,buseo,board_file,board_file_kind,board_write_day)VALUES "
SQL = SQL & "('" & board_kind & "'"
SQL = SQL & ",'" & title & "'"
SQL = SQL & ",'" & contents & "'"
SQL = SQL & ",'" & name & "'"
SQL = SQL & ",'" & buseo & "'"
SQL = SQL & ",'" & board_file_name & "'"
SQL = SQL & ",'" & board_file_kind & "'"
SQL = SQL & ",'" & board_write_day & "')"
set Rs = Dbs.execute(sql)
'텍스트 파일의 크기가 다르기 때문에 만약에 대비해서 스크립트 타임아웃 설정
server.ScriptTimeOut=1200000
'디비에 입력할 텍스트 파일의 위치
Dim strDocUrl : strDocUrl = "D:\Data\sps.synopex.com\upload_file\"&board_file_name
'FSO세팅
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'1번째줄부터 파일을 오픈
set obj_txt = fso.OpenTextFile(strDocUrl, 1)
'반복문부분...여기에서 텍스트파일을 한줄씩 읽어서 한줄마다의 데이터를 디비에 입력
'텍스트의 끝까지 반복문 돌림.
if data_kind = "생산수량" then
SQL = "delete product_qty"
Dbs.Execute(SQL)
Do While obj_txt.AtEndOfStream <> True
'::::::아래부분은 생각을 잘못해서 텍스트 중간에 빈줄이 있을경우 뛰어넘도록 넣었던 구문이지만 잘못됐다.
'왜냐하면 ReadLine은 액션을 취하고 다음줄로 포인터를 옮기므로 하나 더 들어가면 그만큼 건너뛰게 된다.
'따라서 아래의 주석부분을 이용할 것이 아니라, 아래의 UBound(TempLineData)를 이용한다.
'If Len(Trim(obj_txt.ReadLine))>0 Then
'먼저 스플릿으로 데이터를 잘라내서 한줄마다의 데이터를 배열로 만든다.
'"여기에서는 윗꺽쇠로 구분자를 만든 데이터
TempLineData = split(obj_txt.ReadLine," ")
'배열로 반환한 값의 배열갯수가 0보다 작으면(-1) 그줄은 비어있다는 의미다.
'배열갯수가 0보다 크거나 같을 경우에만 데이터 입력작업을 해준다.
If UBound(TempLineData)>=0 Then
product_year = cstr(trim(TempLineData(0)))
company_kind = cstr(trim(TempLineData(1)))
model_code = cstr(trim(TempLineData(2)))
product_qty_1mon = cstr(trim(TempLineData(3)))
product_qty_2mon = cstr(trim(TempLineData(4)))
product_qty_3mon = cstr(trim(TempLineData(5)))
product_qty_4mon = cstr(trim(TempLineData(6)))
product_qty_5mon = cstr(trim(TempLineData(7)))
product_qty_6mon = cstr(trim(TempLineData(8)))
product_qty_7mon = cstr(trim(TempLineData(9)))
product_qty_8mon = cstr(trim(TempLineData(10)))
product_qty_9mon = cstr(trim(TempLineData(11)))
product_qty_10mon = cstr(trim(TempLineData(12)))
product_qty_11mon = cstr(trim(TempLineData(13)))
product_qty_12mon = cstr(trim(TempLineData(14)))
i = i + 1
product_year = years
SQL = "insert into product_qty (product_year,company_kind,model_code,product_qty_1mon,product_qty_2mon,product_qty_3mon,product_qty_4mon,product_qty_5mon,product_qty_6mon,product_qty_7mon,product_qty_8mon,product_qty_9mon,product_qty_10mon,product_qty_11mon,product_qty_12mon)"
SQL = SQL & " values ('"&product_year&"','"&company_kind&"','"&model_code&"','"&product_qty_1mon&"','"&product_qty_2mon&"','"&product_qty_3mon&"','"&product_qty_4mon&"','"&product_qty_5mon&"','"&product_qty_6mon&"','"&product_qty_7mon&"','"&product_qty_8mon&"','"&product_qty_9mon&"','"&product_qty_10mon&"','"&product_qty_11mon&"','"&product_qty_12mon&"') "
Dbs.Execute(SQL)
End If
Loop
else if data_kind = "BOM" then
SQL = "delete bom"
Dbs.Execute(SQL)
Do While obj_txt.AtEndOfStream <> True
TempLineData = split(obj_txt.ReadLine," ")
If UBound(TempLineData)>=0 Then
aa = cstr(trim(TempLineData(0)))
bb = cstr(trim(TempLineData(1)))
cc = cstr(trim(TempLineData(2)))
dd = cstr(trim(TempLineData(3)))
i = i + 1
product_year = years
SQL = "insert into BOM (company_kind,model_code,product_code,need_qty)values ('"&aa&"','"&bb&"','"&cc&"','"&dd&"')"
Dbs.Execute(SQL)
End If
Loop
else if data_kind = "환율" then
SQL = "delete exchange_rate"
Dbs.Execute(SQL)
Do While obj_txt.AtEndOfStream <> True
TempLineData = split(obj_txt.ReadLine," ")
If UBound(TempLineData)>=0 Then
ex_year = cstr(trim(TempLineData(0)))
ex_type = cstr(trim(TempLineData(1)))
ex_basic_rate = CDbl(TempLineData(2))
ex_1mon = CDbl(TempLineData(3))
ex_2mon = CDbl(TempLineData(4))
ex_3mon = CDbl(TempLineData(5))
ex_4mon = CDbl(TempLineData(6))
ex_5mon = CDbl(TempLineData(7))
ex_6mon = CDbl(TempLineData(8))
ex_7mon = CDbl(TempLineData(9))
ex_8mon = CDbl(TempLineData(10))
ex_9mon = CDbl(TempLineData(11))
ex_10mon = CDbl(TempLineData(12))
ex_11mon = CDbl(TempLineData(13))
ex_12mon = CDbl(TempLineData(14))
i = i + 1
ex_year = years
SQL = "insert into exchange_rate (ex_year,ex_type,ex_basic_rate,ex_1mon,ex_2mon,ex_3mon,ex_4mon,ex_5mon,ex_6mon,ex_7mon,ex_8mon,ex_9mon,ex_10mon,ex_11mon,ex_12mon)"
SQL = SQL & " values ('"&ex_year&"','"&ex_type&"','"&ex_basic_rate&"','"&ex_1mon&"','"&ex_2mon&"','"&ex_3mon&"','"&ex_4mon&"','"&ex_5mon&"','"&ex_6mon&"','"&ex_7mon&"','"&ex_8mon&"','"&ex_9mon&"','"&ex_10mon&"','"&ex_11mon&"','"&ex_12mon&"') "
Dbs.Execute(SQL)
End If
Loop
else if data_kind = "품목단가" then
SQL = "delete product_unitprice"
Dbs.Execute(SQL)
Do While obj_txt.AtEndOfStream <> True
TempLineData = split(obj_txt.ReadLine," ")
If UBound(TempLineData)>=0 Then
ProductPrice_Year = cstr(trim(TempLineData(0)))
Company_Kind = cstr(trim(TempLineData(1)))
Product_Code = cstr(trim(TempLineData(2)))
Product_Name = cstr(trim(TempLineData(3)))
Basic_Moneytype = cstr(trim(TempLineData(4)))
BasicUnit_price = CDbl(TempLineData(5))
MoneyType_1Mon = cstr(trim(TempLineData(6)))
UnitPrice_1Mon = CDbl(TempLineData(7))
MoneyType_2Mon = cstr(trim(TempLineData(8)))
UnitPrice_2Mon = CDbl(TempLineData(9))
MoneyType_3Mon = cstr(trim(TempLineData(10)))
UnitPrice_3Mon = CDbl(TempLineData(11))
MoneyType_4Mon = cstr(trim(TempLineData(12)))
UnitPrice_4Mon = CDbl(TempLineData(13))
MoneyType_5Mon = cstr(trim(TempLineData(14)))
UnitPrice_5Mon = CDbl(TempLineData(15))
MoneyType_6Mon = cstr(trim(TempLineData(16)))
UnitPrice_6Mon = CDbl(TempLineData(17))
MoneyType_7Mon = cstr(trim(TempLineData(18)))
UnitPrice_7Mon = CDbl(TempLineData(19))
MoneyType_8Mon = cstr(trim(TempLineData(20)))
UnitPrice_8Mon = CDbl(TempLineData(21))
MoneyType_9Mon = cstr(trim(TempLineData(22)))
UnitPrice_9Mon = CDbl(TempLineData(23))
MoneyType_10Mon = cstr(trim(TempLineData(24)))
UnitPrice_10Mon = CDbl(TempLineData(25))
MoneyType_11Mon = cstr(trim(TempLineData(26)))
UnitPrice_11Mon = CDbl(TempLineData(27))
MoneyType_12Mon = cstr(trim(TempLineData(28)))
UnitPrice_12Mon = CDbl(TempLineData(29))
Item1 = cstr(trim(TempLineData(30)))
Item2 = cstr(trim(TempLineData(31)))
Item3 = cstr(trim(TempLineData(32)))
Item4 = cstr(trim(TempLineData(33)))
Item5 = cstr(trim(TempLineData(34)))
Item6 = cstr(trim(TempLineData(35)))
Item7 = cstr(trim(TempLineData(36)))
Item8 = cstr(trim(TempLineData(37)))
Item9 = cstr(trim(TempLineData(38)))
Item10 = cstr(trim(TempLineData(39)))
i = i + 1
ProductPrice_Year = years
SQL = "insert into product_unitprice (ProductPrice_Year,Company_Kind,Product_Code,Product_Name,Basic_Moneytype,BasicUnit_price,MoneyType_1Mon,UnitPrice_1Mon,MoneyType_2Mon,UnitPrice_2Mon,MoneyType_3Mon,UnitPrice_3Mon,MoneyType_4Mon,UnitPrice_4Mon,MoneyType_5Mon,UnitPrice_5Mon,MoneyType_6Mon,UnitPrice_6Mon,MoneyType_7Mon,UnitPrice_7Mon,MoneyType_8Mon,UnitPrice_8Mon,MoneyType_9Mon,UnitPrice_9Mon,MoneyType_10Mon,UnitPrice_10Mon,MoneyType_11Mon,UnitPrice_11Mon,MoneyType_12Mon,UnitPrice_12Mon,item1,item2,item3,item4,item5,item6,item7,item8,item9,item10 )"
SQL = SQL & " values ('"&ProductPrice_Year&"','"&Company_Kind&"','"&Product_Code&"','"&Product_Name&"','"&Basic_Moneytype&"','"&BasicUnit_price&"','"&MoneyType_1Mon&"','"&UnitPrice_1Mon&"','"&MoneyType_2Mon&"','"&UnitPrice_2Mon&"','"&MoneyType_3Mon&"','"&UnitPrice_3Mon&"','"&MoneyType_4Mon&"','"&UnitPrice_4Mon&"','"&MoneyType_5Mon&"','"&UnitPrice_5Mon&"','"&MoneyType_6Mon&"','"&UnitPrice_6Mon&"','"&MoneyType_7Mon&"','"&UnitPrice_7Mon&"','"&MoneyType_8Mon&"','"&UnitPrice_8Mon&"','"&MoneyType_9Mon&"','"&UnitPrice_9Mon&"','"&MoneyType_10Mon&"','"&UnitPrice_10Mon&"','"&MoneyType_11Mon&"','"&UnitPrice_11Mon&"','"&MoneyType_12Mon&"','"&UnitPrice_12Mon&"','"&item1&"','"&item2&"','"&item3&"','"&item4&"','"&item5&"','"&item6&"','"&item7&"','"&item8&"','"&item9&"','"&item10&"') "
Dbs.Execute(SQL)
End If
Loop
else if data_kind = "모델판가" then
SQL = "delete model_salemoney"
Dbs.Execute(SQL)
Do While obj_txt.AtEndOfStream <> True
TempLineData = split(obj_txt.ReadLine," ")
If UBound(TempLineData)>=0 Then
Company_Kind = cstr(trim(TempLineData(0)))
Model_Name = cstr(trim(TempLineData(1)))
Sale_MoneyType = cstr(trim(TempLineData(2)))
sale_1Mon = CDbl(TempLineData(3))
sale_2mon = CDbl(TempLineData(4))
sale_3mon = CDbl(TempLineData(5))
sale_4mon = CDbl(TempLineData(6))
sale_5mon = CDbl(TempLineData(7))
sale_6mon = CDbl(TempLineData(8))
sale_7mon = CDbl(TempLineData(9))
sale_8mon = CDbl(TempLineData(10))
sale_9mon = CDbl(TempLineData(11))
sale_10mon = CDbl(TempLineData(12))
sale_11mon = CDbl(TempLineData(13))
sale_12mon = CDbl(TempLineData(14))
Model1 = cstr(trim(TempLineData(15)))
Model2 = cstr(trim(TempLineData(16)))
Model3 = cstr(trim(TempLineData(17)))
Model4 = cstr(trim(TempLineData(18)))
Model5 = cstr(trim(TempLineData(19)))
Model6 = cstr(trim(TempLineData(20)))
Model7 = cstr(trim(TempLineData(21)))
Model8 = cstr(trim(TempLineData(22)))
Model9 = cstr(trim(TempLineData(23)))
Model10 = cstr(trim(TempLineData(24)))
i = i + 1
ex_year = years
SQL = "insert into model_salemoney (Company_Kind,Model_Name,Sale_MoneyType,sale_1Mon,sale_2Mon,sale_3mon,sale_4mon,sale_5mon,sale_6mon,sale_7mon,sale_8mon,sale_9mon,sale_10mon,sale_11mon,sale_12mon,Model1,Model2,Model3,Model4,Model5,Model6,Model7,Model8,Model9,Model10)"
SQL = SQL & " values ('"&Company_Kind&"','"&Model_Name&"','"&Sale_MoneyType&"','"&sale_1Mon&"','"&sale_2Mon&"','"&sale_3mon&"','"&sale_4mon&"','"&sale_5mon&"','"&sale_6mon&"','"&sale_7mon&"','"&sale_8mon&"','"&sale_9mon&"','"&sale_10mon&"','"&sale_11mon&"','"&sale_12mon&"','"&Model1&"','"&Model2&"','"&Model3&"','"&Model4&"','"&Model5&"','"&Model6&"','"&Model7&"','"&Model8&"','"&Model9&"','"&Model10&"') "
Dbs.Execute(SQL)
End If
Loop
End If
End If
End If
End If
End If
obj_txt.Close
set fso = nothing
set obj_txt = Nothing
Dbs.Close
Set Dbs = Nothing
'response.write i&"개 작업 완료"
'response.redirect "upload.asp?part="&part&"&search="&title
%>
<script>
alert("등록이완료되었습니다.");
location.href="upload.asp";
</script>
'공책' 카테고리의 다른 글
캐드 뷰어 설치 (0) | 2010.11.11 |
---|---|
SQL 값 옆으로 뿌리기. (0) | 2010.11.08 |
NTFS.SYS - xp 복구 (0) | 2010.10.28 |
IP 배치 파일 만들기. (0) | 2010.06.30 |
메일 반송 메시지 유형 (0) | 2010.03.17 |