<% option explicit %> <% dim strpagecode strpagecode ="FAIRG05" session("usertype")="SUS" %> <% dim strinsert dim rs dim nmId dim strName dim nmMinbooksp dim strCategoryCodes dim strIsAvailable dim strCreateUserId dim strCreateDate dim strQry dim nmNextMaxHallId dim nmMaxbooksp nmId = 0 strName = "" nmMinbooksp = 0 strCategoryCodes = "" strIsAvailable = "" strCreateUserId = "" strCreateDate = "" strQry = "" nmNextMaxHallId = 0 nmMaxbooksp = 0 strName = trim(request.Form("spacename")) nmMinbooksp = trim(request.Form("minbookspace")) strCategoryCodes = trim(request.Form("cboCategory")) strIsAvailable = trim(request.Form("cboAvailable")) if trim(request.Form("maxbookspace")) = "" then nmMaxbooksp = 0 else nmMaxbooksp = trim(request.Form("maxbookspace")) end if strCreateUserId = trim(Session("userid")) strCreateDate = now() 'dim strName strName = "" strName = trim(request.Form("spacename")) dim objrs, nextval,objrssql set objrs = server.createobject("ADODB.RecordSet") 'First of all, check for the existance of the Description in the table, if it already 'exists then disallow the addition. 'objrssql = " select categoryid from SpaceMaster where " & _ ' " Upper(ltrim(rtrim(spacename))) = '" & Ucase(strName) & "'" dim arrCatgs arrCatgs = split(strCategoryCodes,",",-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(description))) = '" & 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.Write " select space id " Response.End end if on error goto 0 if (rs.EOF and rs.BOF ) then dim rs1 'Fetching the last maxmimum HallId to increment it by one. set rs1 = Server.CreateObject("adodb.recordset") strQry = " Select Max(spaceid) maxid from spaceMaster " on error resume next rs1.Open strQry,ObjConn if err <> 0 then response.Redirect "/inc/admin/error.asp?errortype=err_record§ion="&server.URLEncode("Hall Registration") 'response.Write " select max(space) id " Response.End end if on error goto 0 dim nmNextMaxSpaceId if not ( rs1.EOF and rs1.BOF ) then if isNULL(rs1("maxid")) then nmNextMaxSpaceId = 1 else nmNextMaxSpaceId = Cdbl(rs1("maxid")) + 1 end if else nmNextMaxSpaceId = 1 end if 'rs.close 'rs1.close 'ObjConn.BeginTrans 'Inserting into the Space Master. if nmMaxbooksp = 0 then strinsert = " Insert into SpaceMaster (SpaceId, description, " & _ " MinBookSpace, AvailforBook, " & _ " CreateUserId, createDate,MaxBookSpace) values(" & nmNextMaxSpaceId & ",'" & _ strName & "'," & nmMinbooksp &""&_ ",'" & strIsAvailable & _ "','" & strCreateUserId & "','" & strCreateDate & "',NULL)" else strinsert = " Insert into SpaceMaster (SpaceId, description, " & _ " MinBookSpace, AvailforBook, " & _ " CreateUserId, createDate,MaxBookSpace) values(" & nmNextMaxSpaceId & ",'" & _ strName & "'," & nmMinbooksp &""&_ ",'" & strIsAvailable & _ "','" & strCreateUserId & "','" & strCreateDate & "'," & nmMaxbooksp & ")" end if Response.Write strinsert on error resume next ObjConn.Execute strinsert if err <> 0 then 'response.Write " insert in to space master " 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 SpaceCategDetails for i = 0 to ubound(arrCatgs) strinsert = " Insert into SpaceAvailToDetails (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.Write " insert into space aval rollback " response.Redirect "/inc/admin/error.asp?errortype=err_record§ion="&server.URLEncode("Hall Registration") Response.End end if on error goto 0 next if err <> 0 then 'objconn.RollbackTrans 'response.Write " complete roolback " response.Redirect "/inc/admin/error.asp?errortype=err_record§ion="&server.URLEncode("Hall Registration") Response.End else 'objconn.CommitTrans 'response.Write " complete commit " Response.redirect "/inc/admin/confirm.asp?message=1§ion=" & Server.URLEncode("Hall Registration")& "&path=/fairregistration/admin" end if on error goto 0 else 'response.Write " already exists " response.Redirect "/inc/admin/error.asp?errorno=SAD§ion="&server.URLEncode("Hall Registration") Response.End end if %>