최초등록
This commit is contained in:
@@ -0,0 +1,360 @@
|
||||
<!--#include virtual="/common/lib/dbcon.asp"-->
|
||||
<%
|
||||
'******************* Information ***********************
|
||||
' Program Title :
|
||||
' File Name :
|
||||
' Company :
|
||||
' Creator :
|
||||
'*********************************************************
|
||||
Server.ScriptTimeout=10000'-엑셀데이터의 원활한 처리를 위해 타임아웃 설정
|
||||
Set objApp = nothing
|
||||
|
||||
Set uploadform = Server.CreateObject("DEXT.FileUpload")
|
||||
uploadform.DefaultPath = server.MapPath("./")
|
||||
'--업로드컴포넌트를 이용해 엑셀파일을 받아오는 부분
|
||||
|
||||
|
||||
strPath = server.MapPath("./")&"\excel\"
|
||||
'response.write strPath
|
||||
strName = uploadform("excelFile").FileName
|
||||
mimetype = uploadform("excelFile").MimeType
|
||||
sType = uploadform("sType")
|
||||
'response.write mimetype
|
||||
|
||||
'--실제로 엑셀파일인지 알아보는 부분
|
||||
If mimetype="application/vnd.ms-excel" or mimetype="application/octet-stream" Then
|
||||
|
||||
excelFile_str = wfile("excelFile",10,strPath)
|
||||
|
||||
Else
|
||||
|
||||
Set uploadform = Nothing
|
||||
dbcon.Close
|
||||
set dbcon=nothing
|
||||
response.write "<script language='javascript'>"
|
||||
response.write "alert('\n엑셀파일만 등록가능합니다.');"
|
||||
response.write "history.back();"
|
||||
response.write "</script>"
|
||||
|
||||
End If
|
||||
|
||||
Set uploadform = Nothing
|
||||
|
||||
|
||||
'set xlsConn= Server.createobject("Adodb.connection")
|
||||
'set AdoRs= createobject("Adodb.recordset")
|
||||
'StrFilename=strPath&excelFile_str
|
||||
'StrFilename= server.MapPath("/code.xls")
|
||||
'StrDir = "Driver={Microsoft Excel Driver (*.xls)}; DBQ=" + StrFileName
|
||||
'xlsConn.Open Strdir
|
||||
|
||||
|
||||
'Set xlsConn =Server.CreateObject("ADODB.Connection")
|
||||
'xlsConnection = "Driver={Microsoft Excel Driver (*.xls)}; DBQ="&strPath&excelFile_str&"; DriverID=278"
|
||||
'xlsConn.open xlsConnection
|
||||
|
||||
|
||||
Set xlsConn =Server.CreateObject("ADODB.Connection")
|
||||
xlsConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPath&excelFile_str + "; Extended Properties=Excel 8.0;"
|
||||
xlsConn.Open xlsConnection '연결합니다
|
||||
|
||||
'response.write xlsConn.WorkSheets.Count
|
||||
'response.end
|
||||
|
||||
|
||||
|
||||
sql = "select * from [Sheet1$]"
|
||||
set rs_xls = xlsConn.execute(sql)
|
||||
xls_data = rs_xls.getrows
|
||||
Set rs_xls = Nothing
|
||||
xlsConn.close
|
||||
Set xlsConn = Nothing
|
||||
|
||||
|
||||
|
||||
ON ERROR RESUME NEXT
|
||||
Dbcon.BeginTrans
|
||||
|
||||
|
||||
If Not(IsNull(xls_data)) then
|
||||
For i = 0 To UBound(xls_data, 2)
|
||||
adr_mobile = Array("","","")
|
||||
adr_c_fax = Array("","","")
|
||||
adr_email = ""
|
||||
bdm_menuname = ""
|
||||
adr_c_memo = ""
|
||||
If sType = "1" Then '형식 1(이름,폰번호,그룹명,메모)
|
||||
adr_name = xls_data(0,i)
|
||||
adr_mobile = Split(phoneValue( xls_data(1,i) ), "-")
|
||||
bdm_menuname = xls_data(2,i)
|
||||
adr_c_memo = xls_data(3,i)
|
||||
Else '형식 2(이름,폰번호1,폰2,폰3,그룹명,메모)
|
||||
adr_name = xls_data(0,i)
|
||||
adr_mobile = array(xls_data(1,i), xls_data(2,i), xls_data(3,i))
|
||||
bdm_menuname = xls_data(4,i)
|
||||
adr_c_memo = xls_data(5,i)
|
||||
End if
|
||||
|
||||
'==================그룹번호가져오기====================
|
||||
sql_1 = "select bdm_idx from bd_address where bdm_id = '"&SESSION("ss_m_id")&"' and bdm_menuname = '"&bdm_menuname&"'"
|
||||
Set bdm_idxRs = dbcon.execute(sql_1)
|
||||
|
||||
If bdm_idxRs.bof Or bdm_idxRs.eof Then '해당 그룹이 없다면 생성하고 번호가져온다.
|
||||
bdm_idx = makeGroup(bdm_menuname)
|
||||
Else
|
||||
bdm_idx = bdm_idxRs(0)
|
||||
End If
|
||||
Set bdm_idxRs = Nothing
|
||||
'==================그룹번호 가져오기끝=================
|
||||
|
||||
sql = "insert into bd_address_page(bdm_idx, adr_m_id, adr_name, adr_mobile1, adr_mobile2, adr_mobile3, adr_c_fax1, adr_c_fax2, adr_c_fax3, adr_email, adr_c_memo)values("
|
||||
sql = sql & bdm_idx & ", '"
|
||||
sql = sql & SESSION("ss_m_id") & "', '"
|
||||
sql = sql & adr_name & "', '"
|
||||
sql = sql & adr_mobile(0) & "','"
|
||||
sql = sql & adr_mobile(1) & "', '"
|
||||
sql = sql & adr_mobile(2) & "','"
|
||||
sql = sql & adr_c_fax(0) & "','"
|
||||
sql = sql & adr_c_fax(1) & "','"
|
||||
sql = sql & adr_c_fax(2) & "','"
|
||||
sql = sql & adr_email & "','"
|
||||
sql = sql & adr_c_memo & "')"
|
||||
|
||||
'response.write sql & "<br>"
|
||||
'response.write adr_name & ":" & phoneValue(adr_mobile(0)&"-"&adr_mobile(1)&"-"&adr_mobile(2)) & "<br>"
|
||||
If phoneValue(adr_mobile(0)&"-"&adr_mobile(1)&"-"&adr_mobile(2)) <> "--" then '필수사항 핸드폰 번호 정규화거침
|
||||
dbcon.execute(sql)
|
||||
End if
|
||||
'response.end
|
||||
|
||||
if dbcon.Errors.Count > 0 then '실패
|
||||
Dbcon.RollBackTrans
|
||||
|
||||
response.write "<script language='javascript'>"
|
||||
response.write "alert('오류발생\n\n" & Err.Description & "');"
|
||||
response.write "location.href='excel_input.asp';"
|
||||
response.write "</script>"
|
||||
|
||||
else '성공
|
||||
Dbcon.CommitTrans
|
||||
end if
|
||||
|
||||
Next
|
||||
End if
|
||||
|
||||
|
||||
set dbcon = Nothing
|
||||
|
||||
response.write "<script language='javascript'>"
|
||||
response.write "alert('\n등록되었습니다.');"
|
||||
response.write "opener.location.reload();"
|
||||
response.write "location.href='excelinput.asp';"
|
||||
response.write "</script>"
|
||||
|
||||
|
||||
|
||||
'************** Information ****************************************
|
||||
' Program Title : 업로드파일저장하기(dext버젼)
|
||||
' Company : (주)나우아이텍 (053)955-9055
|
||||
' Creator : 윤 종 우 2004. 05
|
||||
'*********************************************************************
|
||||
function wfile(filedname, maxMbyte, strDirectory)
|
||||
|
||||
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
if Len(UploadForm(filedname)) > 0 then
|
||||
|
||||
'strDirectory = server.MapPath("./")&"\data\"&a_tablename&"\"
|
||||
|
||||
If FSO.FolderExists(strDirectory) = False Then '폴더가 없으면 새로 생성한다..
|
||||
FSO.CreateFolder(strDirectory)
|
||||
End if
|
||||
|
||||
|
||||
'--파일 정보추출
|
||||
fileName = UploadForm(filedname).FileName '파일이름..
|
||||
filePath = UploadForm(filedname).FilePath '절대경로..
|
||||
fileSize = UploadForm(filedname).FileLen '파일사이즈..
|
||||
|
||||
|
||||
saveFileName = strDirectory & fileName '실제 저장되 경로에 파일...
|
||||
|
||||
'--확장장와 파일 이름 분리
|
||||
strfile = split(fileName,".")
|
||||
strName = strfile(0) '파일명
|
||||
strExt = strfile(1) '확장자
|
||||
|
||||
|
||||
'-- 파일크기가 검사
|
||||
'1MByte = 1048576Byte
|
||||
|
||||
if Round(fileSize) > Round(1048576 * maxMbyte) then
|
||||
|
||||
response.write "<SCRIPT LANGUAGE='JavaScript'>" & VbCrLf
|
||||
response.write "alert('파일크기가"& maxMbyte &"MByte 이하여만 합니다.');" & VbCrLf
|
||||
response.write "history.back();" & VbCrLf
|
||||
response.write "</SCRIPT>" & VbCrLf
|
||||
Set UploadForm = nothing
|
||||
Set FSO = nothing
|
||||
response.end
|
||||
|
||||
end if
|
||||
|
||||
|
||||
'같은 파일 이 존재할경우 --> _1,_2 이런식으로 파일명 변경..ㅡㅡv
|
||||
bExist = True
|
||||
count= 0
|
||||
Do While bExist
|
||||
If (FSO.FileExists(saveFileName)) Then
|
||||
count = count + 1
|
||||
FileName = strName & "_" & count & "." & strExt
|
||||
saveFileName = strDirectory & FileName
|
||||
Else
|
||||
|
||||
Exit Do '없으며 빠져나간당..
|
||||
|
||||
End If
|
||||
Loop
|
||||
'파일 저장
|
||||
UploadForm(filedname).SaveAs saveFileName
|
||||
end if
|
||||
|
||||
|
||||
|
||||
'Set UploadForm = nothing
|
||||
Set FSO = nothing
|
||||
|
||||
|
||||
wfile = FileName
|
||||
|
||||
end function
|
||||
|
||||
|
||||
|
||||
'************** Information ****************************************
|
||||
' Program Title : file삭제
|
||||
' Company : (주)나우아이텍 (053)955-9055
|
||||
' Creator : 윤 종 우 2004. 05.
|
||||
'*********************************************************************
|
||||
function dfile(strpath)
|
||||
|
||||
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
|
||||
If FSO.fileExists(strpath) = true Then '파일이 있으면 지운다.
|
||||
FSO.DeleteFile(strpath)
|
||||
End if
|
||||
|
||||
Set FSO = nothing
|
||||
|
||||
end Function
|
||||
'************** Information ****************************************
|
||||
' Program Title : 그룹생성
|
||||
' Company : (주)나우아이텍 (053)955-9055
|
||||
' Creator : 최 경 수 2006. 04.
|
||||
'*********************************************************************
|
||||
Function makeGroup(menuName)
|
||||
'받아오는 파라미터
|
||||
info_url = "" 'InputValue(request("info_url"))
|
||||
bdm_depth = "1" 'InputValue(request("bdm_depth"))
|
||||
bdm_ref = "0" 'InputValue(request("bdm_ref"))
|
||||
bdm_menuname = menuName 'InputValue(request("bdm_menuname"))
|
||||
bdm_t_clr = "#ffffff"
|
||||
bdm_ro_clr = "#f4f4f4"
|
||||
bdm_chk = "Y"
|
||||
|
||||
|
||||
sql = "select max(bdm_code) from bd_address where bdm_id='"&SESSION("ss_m_id")&"' and info_url='"&info_url&"' and bdm_depth ="&bdm_depth
|
||||
set rs = dbcon.execute(sql)
|
||||
|
||||
bdm_code = rs(0)
|
||||
|
||||
rs.close
|
||||
set rs = nothing
|
||||
|
||||
|
||||
if isnull(bdm_code) then
|
||||
bdm_code = 1
|
||||
else
|
||||
bdm_code = bdm_code + 1
|
||||
end if
|
||||
|
||||
|
||||
SQL = "INSERT INTO bd_address "& _
|
||||
"(info_url, bdm_depth, bdm_code, bdm_ref, bdm_menuname, bdm_t_clr, bdm_ro_clr, bdm_chk,bdm_id) " & _
|
||||
"values(" & _
|
||||
" '"&info_url&"'" & _
|
||||
", "&bdm_depth&"" & _
|
||||
", "&bdm_code&"" & _
|
||||
", "&bdm_ref&"" & _
|
||||
",'"&bdm_menuname&"'" & _
|
||||
",'"&bdm_t_clr&"'" & _
|
||||
",'"&bdm_ro_clr&"'" & _
|
||||
",'"&bdm_chk&"'" & _
|
||||
",'"&SESSION("ss_m_id")&"')"
|
||||
'response.write sql
|
||||
Dbcon.Execute SQL
|
||||
|
||||
sql = "select max(bdm_idx) from bd_address where bdm_id = '"&SESSION("ss_m_id")&"'"
|
||||
Set rs = Dbcon.Execute( sql )
|
||||
|
||||
makeGroup = rs(0)
|
||||
|
||||
Set rs = nothing
|
||||
End Function
|
||||
|
||||
|
||||
'---전화번호필터-----
|
||||
Function phoneValue(value)
|
||||
Dim phone_arr_temp, phone_arr_temp_len, i
|
||||
|
||||
If IsNull( value ) Then value = ""
|
||||
phone_arr_temp = Trim(value)
|
||||
|
||||
'---------------불필요한 문자열 제거------------------
|
||||
phone_arr_temp = Replace(phone_arr_temp,")","")
|
||||
phone_arr_temp = Replace(phone_arr_temp,"(","")
|
||||
phone_arr_temp = Replace(phone_arr_temp,"-","")
|
||||
phone_arr_temp = Replace(phone_arr_temp," ","")
|
||||
|
||||
phone_arr_temp = Replace(phone_arr_temp,"ㅡ","")
|
||||
phone_arr_temp = Replace(phone_arr_temp,"*","")
|
||||
'---------------불필요한 문자열 제거------------------
|
||||
phone_arr_temp_len = Len(phone_arr_temp)
|
||||
|
||||
'phone_arr_temp = Split(mem_list(4, i), "-")
|
||||
|
||||
If Left(phone_arr_temp, 2) = "00" Then '지역번호에 0이 2개 들어갔을 경우
|
||||
phone_arr_temp = Mid(phone_arr_temp, 2)
|
||||
End if
|
||||
'response.write "["& mem_list(4, i) &"], "
|
||||
|
||||
'---------------전화번호를 정규화------------------
|
||||
Select Case phone_arr_temp_len
|
||||
Case 7
|
||||
phone_arr = Array("054",Left(phone_arr_temp,3),right(phone_arr_temp,4))
|
||||
Case 8
|
||||
phone_arr = Array("054",Left(phone_arr_temp,4),right(phone_arr_temp,4))
|
||||
Case 10
|
||||
phone_arr = Array(Left(phone_arr_temp,3),mid(phone_arr_temp,4,3),right(phone_arr_temp,4))
|
||||
Case 11
|
||||
phone_arr = Array(Left(phone_arr_temp,3),mid(phone_arr_temp,4,4),right(phone_arr_temp,4))
|
||||
Case 12
|
||||
phone_arr = Array(Left(phone_arr_temp,4),mid(phone_arr_temp,5,4),right(phone_arr_temp,4))
|
||||
Case Else
|
||||
phone_arr = Array("","","")
|
||||
End select
|
||||
'---------------전화번호를 정규화끝------------------
|
||||
'---------------마지막필터 숫자냐---------------
|
||||
If IsNumeric(phone_arr(0)) And IsNumeric(phone_arr(1)) And IsNumeric(phone_arr(2)) Then
|
||||
M_phone = phone_arr(0) & "-" & phone_arr(1) & "-" & phone_arr(2)
|
||||
Else
|
||||
M_phone = "--"
|
||||
End If
|
||||
'---------------마지막필터 숫자냐---------------
|
||||
phoneValue = M_phone
|
||||
End Function
|
||||
|
||||
|
||||
%>
|
||||
|
||||
Reference in New Issue
Block a user