<% Option Explicit %> <% dim strpagecode strpagecode= "FAIRG02" session("usertype")="SUS" %> <% dim strinsert dim rs dim nmId dim strName dim strType dim nmMinbkbaresp dim nmMinbkshellsp dim strProductCodes dim strCategoryCodes dim strIsAvailable dim strCreateUserId dim strCreateDate dim strQry dim nmNextMaxHallId dim nmMaxBareSpace dim nmMaxShellSpace nmId = 0 strName = "" strType = "" nmMinbkbaresp = 0 nmMinbkshellsp = 0 strProductCodes = "" strCategoryCodes = "" strIsAvailable = "" strCreateUserId = "" strCreateDate = "" strQry = "" nmNextMaxHallId = 0 nmMaxBareSpace = 0 nmMaxShellSpace = 0 strName = trim(request.Form("halldesc")) strType = trim(request.Form("cboType")) nmMinbkbaresp = trim(request.Form("minbkbaresp")) nmMinbkshellsp = trim(request.Form("minbkshellsp")) strProductCodes = trim(request.Form("cboProducts")) strCategoryCodes = trim(request.Form("cboCategory")) strIsAvailable = trim(request.Form("cboAvailable")) if trim(request.Form("maxbkbaresp")) = "" then nmMaxBareSpace = 0 else nmMaxBareSpace = trim(request.Form("maxbkbaresp")) end if if trim(request.Form("maxbkshellsp")) = "" then nmMaxShellSpace = 0 else nmMaxShellSpace = trim(request.Form("maxbkshellsp")) end if strCreateUserId = trim(Session("userid")) strCreateDate = now() dim arrCatgs dim arrProds arrCatgs = split(strCategoryCodes,",",-1,1) 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 hallid from hallMaster 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.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(hallid) maxid from hallMaster " 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 'ObjConn.BeginTrans 'Inserting into the Hall Master. if nmMaxBareSpace = 0 and nmMaxShellSpace = 0 then strinsert = " Insert into HallMaster (HallId, Description,TypeCode, " & _ " MinBookBareSpaceId,MinBookShellSpaceId, AvailforBook, " & _ " CreateUserId, createDate,MaxBookBareSpaceId,MaxBookShellSpaceId) values(" & nmNextMaxHallId & ",'" & _ strName & "','" & strType & "'," & nmMinbkbaresp & "," & nmMinbkshellsp & _ ",'" & strIsAvailable & _ "','" & strCreateUserId & "','" & strCreateDate & "',NULL,NULL)" elseif nmMaxBareSpace = 0 and nmMaxShellSpace <> 0 then strinsert = " Insert into HallMaster (HallId, Description,TypeCode, " & _ " MinBookBareSpaceId,MinBookShellSpaceId, AvailforBook, " & _ " CreateUserId, createDate,MaxBookBareSpaceId,MaxBookShellSpaceId) values(" & nmNextMaxHallId & ",'" & _ strName & "','" & strType & "'," & nmMinbkbaresp & "," & nmMinbkshellsp & _ ",'" & strIsAvailable & _ "','" & strCreateUserId & "','" & strCreateDate & "',NULL," & nmMaxShellSpace & ")" elseif nmMaxBareSpace <> 0 and nmMaxShellSpace = 0 then strinsert = " Insert into HallMaster (HallId, Description,TypeCode, " & _ " MinBookBareSpaceId,MinBookShellSpaceId, AvailforBook, " & _ " CreateUserId, createDate,MaxBookBareSpaceId,MaxBookShellSpaceId) values(" & nmNextMaxHallId & ",'" & _ strName & "','" & strType & "'," & nmMinbkbaresp & "," & nmMinbkshellsp & _ ",'" & strIsAvailable & _ "','" & strCreateUserId & "','" & strCreateDate & "'," & nmMaxBareSpace & ",NULL)" elseif nmMaxBareSpace <> 0 and nmMaxShellSpace <> 0 then strinsert = " Insert into HallMaster (HallId, Description,TypeCode, " & _ " MinBookBareSpaceId,MinBookShellSpaceId, AvailforBook, " & _ " CreateUserId, createDate,MaxBookBareSpaceId,MaxBookShellSpaceId) values(" & nmNextMaxHallId & ",'" & _ strName & "','" & strType & "'," & nmMinbkbaresp & "," & nmMinbkshellsp & _ ",'" & strIsAvailable & _ "','" & strCreateUserId & "','" & strCreateDate & "'," & nmMaxBareSpace & "," & nmMaxShellSpace & ")" end if 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 'Inserting into HallAvailToCatgDetails dim i i = 0 for i = 0 to ubound(arrCatgs) strinsert = " Insert into HallAvailToCatgDetails (HallId, categoryid, " & _ " CreateUserId, createDate) values(" & nmNextMaxHallId & "," & _ trim(arrCatgs(i)) & ",'" & 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 next 'Inserting into HallProdCatgDetails for i = 0 to ubound(arrProds) strinsert = " Insert into HallProdCatgDetails (HallId, ProdID, " & _ " CreateUserId, createDate) values(" & nmNextMaxHallId & "," & _ trim(arrProds(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 on error goto 0 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 %>