<% option explicit %> <% dim strpagecode str pagecode = %> <% dim strinsert dim rs dim nmId dim strName dim nmMinbkshellsp dim strCategoryCodes dim strIsAvailable dim strCreateUserId dim strCreateDate dim strQry dim nmNextMaxHallId nmId = 0 strName = "" nmMinbkshellsp = 0 strCategoryCodes = "" strIsAvailable = "" strCreateUserId = "" strCreateDate = "" strQry = "" nmNextMaxHallId = 0 strName = trim(request.Form("spacename")) nmMinbkshellsp = trim(request.Form("minbkshellsp")) strCategoryCodes = trim(request.Form("cboCategory")) strIsAvailable = trim(request.Form("cboAvailable")) strCreateUserId = trim(Session("userid")) strCreateDate = now() dim arrProds arrProds = split(strProductCodes,",",-1,1) set rs = Server.CreateObject("ADODB.RECORDSET") 'Before inserting the record for a Product Category, it has to be checked for duplicate 'Product Id / code. strQry = " Select spaceid from spaceMaster where Upper(ltrim(rtrim(spacename))) = '" & Ucase(strName) & "'" 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(spaceid) maxid from spaceMaster " 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 nmNextMaxSpaceId = 1 else nmNextMaxSpaceId = Cdbl(rs("maxid")) + 1 end if else nmNextMaxSpaceId = 1 end if ObjConn.BeginTrans 'Inserting into the Hall Master. strinsert = " Insert into SpaceMaster (SpaceId, Spacename, " & _ " MinBookShellSpaceId, AvailforBook, " & _ " CreateUserId, createDate) values(" & nmNextMaxSpaceId & ",'" & _ strName & "'," & nmMinbkshellsp & _ ",'" & strIsAvailable & _ "','" & 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 end if on error goto 0 dim i i = 0 'Inserting into HallAvailToCatgDetails for i = 0 to ubound(arrCatgs) strinsert = " Insert into SpaceAvailToCatgDetails (SpaceId, categoryid, " & _ " CreateUserId, createDate) values(" & nmNextMaxSpaceId & "," & _ trim(arrCatgs(i)) & ",'" & strCreateUserId & "','" & strCreateDate & "')" on error resume next ObjConn.Execute strinsert if err <> 0 then objconn.RollbackTrans response.Redirect "/inc/admin/error.asp?errortype=err_record§ion="&server.URLEncode("Hall Registration") Response.End end if next if err <> 0 then objconn.RollbackTrans response.Redirect "/inc/admin/error.asp?errortype=err_record§ion="&server.URLEncode("Hall Registration") Response.End else objconn.CommitTrans 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=AHD§ion="&server.URLEncode("Hall Registration") Response.End end if %>