<% Option Explicit %> <% dim strpagecode strpagecode= "FAIRG04" session("usertype")="SUS" %> <% dim strinsert dim rs dim nmId dim strName dim strStartDate dim strToDate dim strLastDate Const STRLOGOGPATH = "\fairregistration\admin\logoimages\" dim strCreateUserId dim strCreateDate dim strQry dim nmNextMaxHallId dim EncodedSectionName dim strFileName dim str_StartDateTime nmId = 0 strName = "" strStartDate = "" strToDate = "" strLastDate = "" strCreateUserId = "" strCreateDate = "" strQry = "" nmNextMaxHallId = 0 EncodedSectionName = "" str_StartDateTime = "" EncodedSectionName = " Hall Registration " dim objFUpLoad Set objFUpLoad = Server.CreateObject("SoftArtisans.FileUp") strName = trim(objFUpLoad.Form("fairname")) str_StartDateTime = trim(objFUpLoad.Form("frmdate")) strStartDate = Format_Date_Time(trim(objFUpLoad.Form("frmdate"))) strToDate = Format_Date_Time(trim(objFUpLoad.Form("todate"))) strLastDate = Format_Date_Time(trim(objFUpLoad.Form("lastdate"))) strCreateUserId = trim(Session("userid")) strCreateDate = now() 'code for saving the image into a directory on the server. dim chLogoPath, strExtnsion, item chLogoPath = "" strExtnsion = "" strFileName = "" chLogoPath = server.MapPath(STRLOGOGPATH) set rs = Server.CreateObject("ADODB.RECORDSET") 'Before inserting the record for a Product Category, it has to be checked for duplicate 'Fair Name. In this case, duplicate fair name is allowed but for that the Start from 'date of the fair 'should be greater than the End Date of the Latest fair with the same name. strQry = " Select fairid from fairmaster where Upper(ltrim(rtrim(fairname))) = '" & _ Ucase(strName) & "' and enddate <= '" & str_StartDateTime & "'" on error resume next set rs = ObjConn.Execute(strQry) if err <> 0 then response.Redirect "/inc/admin/error.asp?errortype=err_record§ion="&server.URLEncode("Hall Registration") Response.End end if on error goto 0 if (rs.EOF and rs.BOF ) then 'Fetching the last maxmimum HallId to increment it by one. strQry = " Select Max(fairid) maxid from fairmaster " on error resume next set rs = ObjConn.Execute(strQry) if err <> 0 then response.Redirect "/inc/admin/error.asp?errortype=err_record§ion="&server.URLEncode("Hall Registration") Response.End end if on error goto 0 if not ( rs.EOF and rs.BOF ) then if isNULL(rs("maxid")) then nmNextMaxHallId = 1 else nmNextMaxHallId = Cdbl(rs("maxid")) + 1 end if else nmNextMaxHallId = 1 end if for each item in objFUpLoad.FormEx if IsObject(objFUpLoad.Form(item)) then 'Response.Write objFUpLoad.Form(Item).ContentType & "
" select case LCASE(objFUpLoad.Form(item).ContentType) Case "image/gif" strExtnsion=".gif" Case "image/pjpeg" if lcase(right( objFUpLoad.Form(item).UserFilename,4))="jpeg" then strExtnsion=".jpg" elseif lcase(right(objFUpLoad.Form(item).UserFilename,3))="jpg" then strExtnsion=".jpg" else strExtnsion=".jpg" end if case else if trim(objFUpLoad.Form(item).UserFilename ) <> "" then Response.Redirect "/inc/admin/error.asp?section=" & EncodedSectionName & "&errorno=MF2" end if End select 'Response.Write item & objFUpLoad.Form(item).ContentType & objFUpLoad.Form(item).totalbytes 'response.Write ucase(trim(chLogoPath)) 'response.Write right(Cstr(trim(objFUpLoad.Form(item).UserFilename)), len(Cstr(trim(objFUpLoad.Form(item).UserFilename))) - instrrev(Cstr(trim(objFUpLoad.Form(item).UserFilename)),"\",-1,1)) 'strFileName = right(Cstr(trim(objFUpLoad.Form(item).UserFilename)), len(Cstr(trim(objFUpLoad.Form(item).UserFilename))) - instrrev(Cstr(trim(objFUpLoad.Form(item).UserFilename)),"\",-1,1)) strFileName = nmNextMaxHallId & "_" & "fairlogo" & strExtnsion if ucase(trim(item))="FAIRLOGO" then 'chLogoPath=chLogoPath & "\" & "LogoManufacturer-" & ManufCode & strExtnsion chLogoPath=chLogoPath & "\" & nmNextMaxHallId & "_" & "fairlogo" & strExtnsion if trim(objFUpLoad.Form(item).UserFilename) <> "" then objFUpLoad.Form(item).SaveAs chLogoPath if cint(err.number)=80070005 then Response.Redirect "/inc/admin/error.asp?section=" & EncodedSectionName & "&errorno=MF3" end if 'CompLogoPath="LogoManufacturer-" & ManufCode & strExtnsion else 'CompLogoPath="" end if end if end if next 'Inserting into the Hall Master. strinsert = " Insert into fairmaster (fairid, fairname, " & _ " startdate,enddate, lastdtreceipt, logopath, " & _ " CreateUserId, createDate) values(" & nmNextMaxHallId & ",'" & _ strName & "','" & strStartDate & "','" & strToDate & "','" & strLastDate & _ "','" & strFileName & _ "','" & strCreateUserId & "','" & strCreateDate & "')" on error resume next ObjConn.Execute strinsert if err <> 0 then response.Redirect "/inc/admin/error.asp?errortype=err_record§ion="&server.URLEncode("Hall Registration") Response.End else Response.redirect "/inc/admin/confirm.asp?message=1§ion=" & Server.URLEncode("Hall Registration")& "&path=/fairregistration/admin" end if else response.Redirect "/inc/admin/error.asp?errorno=FMT§ion="&server.URLEncode("Hall Registration") Response.End end if %>