<%@ CodePage=65001 %> <% Const EW_PAGE_ID = "delete" Const EW_TABLE_NAME = "Top_Navigation" %> <% Session.Timeout = 100 %> <% Response.Expires = 0 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate" %> <% ' Open connection to the database Dim conn Set conn = Server.CreateObject("ADODB.Connection") conn.Open EW_DB_CONNECTION_STRING %> <% Dim Security Set Security = New cAdvancedSecurity %> <% If Not Security.IsLoggedIn() Then Call Security.AutoLogin() If Not Security.IsLoggedIn() Then Call Security.SaveLastUrl() Call Page_Terminate("login.asp") End If %> <% ' Common page loading event (in userfn60.asp) Call Page_Loading() %> <% ' Page load event, used in current page Call Page_Load() %> <% Response.Buffer = True Dim sKey, bSingleDelete, arRecKeys, nKeySelected Dim sKeyFld, arKeyFlds Dim i Dim sFilter Dim nRecCount ' Load Key Parameters sKey = "" bSingleDelete = True ' Initialize as single delete nKeySelected = 0 ' Initialize selected key count If Request.QueryString("id").Count > 0 Then Top_Navigation.id.QueryStringValue = Request.QueryString("id") If Not IsNumeric(Top_Navigation.id.QueryStringValue) Then Call Page_Terminate(Top_Navigation.ReturnUrl) ' Prevent sql injection, exit End If sKey = sKey & Top_Navigation.id.QueryStringValue Else bSingleDelete = False End If If bSingleDelete Then nKeySelected = 1 ' Set up key selected count Redim arRecKeys(0) ' Set up key arRecKeys(0) = sKey Else If Request.Form("key_m").Count > 0 Then ' Key in form nKeySelected = Request.Form("key_m").Count ' Set up key selected count Redim arRecKeys(nKeySelected-1) For i = 1 to nKeySelected ' Set up keys arRecKeys(i-1) = Request.Form("key_m")(i) Next End If End If If nKeySelected <= 0 Then Call Page_Terminate(Top_Navigation.ReturnUrl) ' No key specified, exit ' Build filter For i = 0 to nKeySelected - 1 sKey = Trim(arRecKeys(i)) sFilter = sFilter & "(" ' Set up key field sKeyFld = sKey If Not IsNumeric(sKeyFld) Then Call Page_Terminate(Top_Navigation.ReturnUrl) ' Prevent sql injection, exit End If sFilter = sFilter & "[id]=" & ew_AdjustSql(sKeyFld) & " AND " If Right(sFilter, 5) = " AND " Then sFilter = Left(sFilter, Len(sFilter)-5) & ") OR " Next If Right(sFilter, 4) = " OR " Then sFilter = Left(sFilter, Len(sFilter)-4) ' Set up filter (Sql Where Clause) and get Return Sql ' Sql constructor in Top_Navigation class, Top_Navigationinfo.asp Top_Navigation.CurrentFilter = sFilter ' Get action If Request.Form("a_delete").Count > 0 Then Top_Navigation.CurrentAction = Request.Form("a_delete") Else Top_Navigation.CurrentAction = "D" ' Delete record directly End If Select Case Top_Navigation.CurrentAction Case "D" ' Delete Top_Navigation.SendEmail = True ' Send email on delete success If DeleteRows() Then ' delete rows Session(EW_SESSION_MESSAGE) = "Delete Successful" ' Set up success message Call Page_Terminate(Top_Navigation.ReturnUrl) ' Return to caller End If End Select ' Load records for display Dim rs, nTotalRecs Set rs = LoadRecordset() nTotalRecs = rs.RecordCount ' Get record count If nTotalRecs <= 0 Then ' No record found, exit rs.Close Set rs = Nothing Call Page_Terminate(Top_Navigation.ReturnUrl) ' Return to caller End If %>

Delete from TABLE: Top Navigation

Go Back

<% If Session(EW_SESSION_MESSAGE) <> "" Then %>

<%= Session(EW_SESSION_MESSAGE) %>

<% Session(EW_SESSION_MESSAGE) = "" ' Clear message End If %>

<% For i = 0 to nKeySelected - 1 %> <% Next %> <% nRecCount = 0 i = 0 Do While (Not rs.Eof) nRecCount = nRecCount + 1 ' Set row class and style Top_Navigation.CssClass = "ewTableRow" Top_Navigation.CssStyle = "" ' Display alternate color for rows If nRecCount Mod 2 <> 1 Then Top_Navigation.CssClass = "ewTableAltRow" End If ' Get the field contents Call LoadRowValues(rs) ' Render row value Top_Navigation.RowType = EW_ROWTYPE_VIEW ' view Call RenderRow() %> > > ><%= Top_Navigation.id.ViewValue %> > ><%= Top_Navigation.Navigation_Name.ViewValue %> > ><%= Top_Navigation.language_id.ViewValue %> > ><%= Top_Navigation.Page_Type.ViewValue %> > ><%= Top_Navigation.Player_Position.ViewValue %> > ><%= Top_Navigation.View_Order.ViewValue %> > <% If Top_Navigation.Hide.CurrentValue&"" = "1" Then %> <% Else %> <% End If %> <% rs.MoveNext Loop rs.Close Set rs = Nothing %>
id Navigation Name Language Page Type Player Position View Order Hide

<% ' If control is passed here, simply terminate the page without redirect Call Page_Terminate("") ' ----------------------------------------------------------------- ' Subroutine Page_Terminate ' - called when exit page ' - clean up ADO connection and objects ' - if url specified, redirect to url, otherwise end response ' Sub Page_Terminate(url) ' Page unload event, used in current page Call Page_Unload() ' Global page unloaded event (in userfn60.asp) Call Page_Unloaded() conn.Close ' Close Connection Set conn = Nothing Set Security = Nothing Set Top_Navigation = Nothing ' Go to url if specified If url <> "" Then Response.Clear Response.Redirect url End If ' Terminate response Response.End End Sub ' ' Subroutine Page_Terminate (End) ' ---------------------------------------- %> <% ' ------------------------------------------------ ' Function DeleteRows ' - Delete Records based on current filter ' Function DeleteRows() On Error Resume Next Dim sKey, sThisKey, sKeyFld, arKeyFlds Dim rs, sSql, sWrkFilter Dim rsold DeleteRows = True sWrkFilter = Top_Navigation.CurrentFilter ' Set up filter (Sql Where Clause) and get Return Sql ' Sql constructor in Top_Navigation class, Top_Navigationinfo.asp Top_Navigation.CurrentFilter = sWrkFilter sSql = Top_Navigation.SQL Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = EW_CURSORLOCATION rs.Open sSql, conn, 1, 2 If Err.Number <> 0 Then Session(EW_SESSION_MESSAGE) = Err.Description rs.Close Set rs = Nothing DeleteRows = False Exit Function ElseIf rs.Eof Then Session(EW_SESSION_MESSAGE) = "No records found" ' No record found rs.Close Set rs = Nothing DeleteRows = False Exit Function End If conn.BeginTrans ' Clone old rs object Set rsold = ew_CloneRs(rs) ' Call recordset deleting event If DeleteRows Then DeleteRows = Top_Navigation.Recordset_Deleting(rs) If DeleteRows Then sKey = "" If Not rs.Eof Then rs.MoveFirst Do While Not rs.Eof sThisKey = "" If sThisKey <> "" Then sThisKey = sThisKey & EW_COMPOSITE_KEY_SEPARATOR sThisKey = sThisKey & rs("id") ew_DeleteFile ew_UploadPathEx(True, EW_UPLOAD_DEST_PATH) & rs("Thumb_Image") ew_DeleteFile ew_UploadPathEx(True, EW_UPLOAD_DEST_PATH) & rs("Image") rs.Delete If Err.Number <> 0 Then Session(EW_SESSION_MESSAGE) = Err.Description ' Set up error message DeleteRows = False Exit Do End If If sKey <> "" Then sKey = sKey & ", " sKey = sKey & sThisKey rs.MoveNext Loop Else ' Set up error message If Top_Navigation.CancelMessage <> "" Then Session(EW_SESSION_MESSAGE) = Top_Navigation.CancelMessage Top_Navigation.CancelMessage = "" Else Session(EW_SESSION_MESSAGE) = "Delete cancelled" End If End If If DeleteRows Then conn.CommitTrans ' Commit the changes If Err.Number <> 0 Then Session(EW_SESSION_MESSAGE) = Err.Description DeleteRows = False ' Delet failed Else End If Else conn.RollbackTrans ' Rollback changes End If rs.Close Set rs = Nothing ' Call recordset deleted event If DeleteRows Then Call Top_Navigation.Recordset_Deleted(rsold) rsold.Close Set rsold = Nothing End Function %> <% ' Load recordset Function LoadRecordset() ' Call Recordset Selecting event Call Top_Navigation.Recordset_Selecting(Top_Navigation.CurrentFilter) ' Load list page sql Dim sSql sSql = Top_Navigation.ListSQL ' Response.Write sSql ' Uncomment to show SQL for debugging ' Load recordset Dim rs Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = EW_CURSORLOCATION rs.Open sSql, conn, 1, 2 ' Call Recordset Selected event Call Top_Navigation.Recordset_Selected(rs) Set LoadRecordset = rs End Function %> <% ' Load row based on key values Function LoadRow() Dim rs, sSql, sFilter sFilter = Top_Navigation.SqlKeyFilter If Not IsNumeric(Top_Navigation.id.CurrentValue) Then LoadRow = False ' Invalid key, exit Exit Function End If sFilter = Replace(sFilter, "@id@", ew_AdjustSql(Top_Navigation.id.CurrentValue)) ' Replace key value ' Call Row Selecting event Call Top_Navigation.Row_Selecting(sFilter) ' Load sql based on filter Top_Navigation.CurrentFilter = sFilter sSql = Top_Navigation.SQL Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSql, conn If rs.Eof Then LoadRow = False Else LoadRow = True rs.MoveFirst Call LoadRowValues(rs) ' Load row values ' Call Row Selected event Call Top_Navigation.Row_Selected(rs) End If rs.Close Set rs = Nothing End Function ' Load row values from recordset Sub LoadRowValues(rs) Top_Navigation.id.DbValue = rs("id") Top_Navigation.Navigation_Name.DbValue = rs("Navigation_Name") Top_Navigation.language_id.DbValue = rs("language_id") Top_Navigation.Page_Type.DbValue = rs("Page_Type") Top_Navigation.Player_Position.DbValue = rs("Player_Position") Top_Navigation.Content.DbValue = rs("Content") Top_Navigation.View_Order.DbValue = rs("View_Order") Top_Navigation.Show_Center_Images.DbValue = ew_IIf(rs("Show_Center_Images"), "1", "0") Top_Navigation.Show_Rotating_Images.DbValue = ew_IIf(rs("Show_Rotating_Images"), "1", "0") Top_Navigation.Show_Wallpaper.DbValue = ew_IIf(rs("Show_Wallpaper"), "1", "0") Top_Navigation.Hide.DbValue = ew_IIf(rs("Hide"), "1", "0") Top_Navigation.Thumb_Image.Upload.DbValue = rs("Thumb_Image") Top_Navigation.Image.Upload.DbValue = rs("Image") Top_Navigation.isHomePage.DbValue = ew_IIf(rs("isHomePage"), "1", "0") End Sub %> <% ' Render row values based on field settings Sub RenderRow() ' Call Row Rendering event Call Top_Navigation.Row_Rendering() ' Common render codes for all row types ' id Top_Navigation.id.CellCssStyle = "" Top_Navigation.id.CellCssClass = "" ' Navigation_Name Top_Navigation.Navigation_Name.CellCssStyle = "" Top_Navigation.Navigation_Name.CellCssClass = "" ' language_id Top_Navigation.language_id.CellCssStyle = "" Top_Navigation.language_id.CellCssClass = "" ' Page_Type Top_Navigation.Page_Type.CellCssStyle = "" Top_Navigation.Page_Type.CellCssClass = "" ' Player_Position Top_Navigation.Player_Position.CellCssStyle = "" Top_Navigation.Player_Position.CellCssClass = "" ' View_Order Top_Navigation.View_Order.CellCssStyle = "" Top_Navigation.View_Order.CellCssClass = "" ' Hide Top_Navigation.Hide.CellCssStyle = "" Top_Navigation.Hide.CellCssClass = "" If Top_Navigation.RowType = EW_ROWTYPE_VIEW Then ' View row ' id Top_Navigation.id.ViewValue = Top_Navigation.id.CurrentValue Top_Navigation.id.CssStyle = "" Top_Navigation.id.CssClass = "" Top_Navigation.id.ViewCustomAttributes = "" ' Navigation_Name Top_Navigation.Navigation_Name.ViewValue = Top_Navigation.Navigation_Name.CurrentValue Top_Navigation.Navigation_Name.CssStyle = "" Top_Navigation.Navigation_Name.CssClass = "" Top_Navigation.Navigation_Name.ViewCustomAttributes = "" ' language_id If Not IsNull(Top_Navigation.language_id.CurrentValue) And Top_Navigation.language_id.CurrentValue <> "" Then sSqlWrk = "SELECT [Language_Name] FROM [Languages] WHERE [id] = " & ew_AdjustSql(Top_Navigation.language_id.CurrentValue) & "" sSqlWrk = sSqlWrk & " ORDER BY [Language_Name] Asc" Set rswrk = conn.Execute(sSqlWrk) If Not rswrk.Eof Then Top_Navigation.language_id.ViewValue = rswrk("Language_Name") Else Top_Navigation.language_id.ViewValue = Top_Navigation.language_id.CurrentValue End If rswrk.Close Set rswrk = Nothing Else Top_Navigation.language_id.ViewValue = Null End If Top_Navigation.language_id.CssStyle = "" Top_Navigation.language_id.CssClass = "" Top_Navigation.language_id.ViewCustomAttributes = "" ' Page_Type If Not IsNull(Top_Navigation.Page_Type.CurrentValue) Then Select Case Top_Navigation.Page_Type.CurrentValue Case "1" Top_Navigation.Page_Type.ViewValue = "General" Case "2" Top_Navigation.Page_Type.ViewValue = "Players" Case "3" Top_Navigation.Page_Type.ViewValue = "Coaches" Case Else Top_Navigation.Page_Type.ViewValue = Top_Navigation.Page_Type.CurrentValue End Select Else Top_Navigation.Page_Type.ViewValue = Null End If Top_Navigation.Page_Type.CssStyle = "" Top_Navigation.Page_Type.CssClass = "" Top_Navigation.Page_Type.ViewCustomAttributes = "" ' Player_Position If Not IsNull(Top_Navigation.Player_Position.CurrentValue) And Top_Navigation.Player_Position.CurrentValue <> "" Then sSqlWrk = "SELECT [Position] FROM [positions] WHERE [ID] = " & ew_AdjustSql(Top_Navigation.Player_Position.CurrentValue) & "" sSqlWrk = sSqlWrk & " ORDER BY [Position] Asc" Set rswrk = conn.Execute(sSqlWrk) If Not rswrk.Eof Then Top_Navigation.Player_Position.ViewValue = rswrk("Position") Else Top_Navigation.Player_Position.ViewValue = Top_Navigation.Player_Position.CurrentValue End If rswrk.Close Set rswrk = Nothing Else Top_Navigation.Player_Position.ViewValue = Null End If Top_Navigation.Player_Position.CssStyle = "" Top_Navigation.Player_Position.CssClass = "" Top_Navigation.Player_Position.ViewCustomAttributes = "" ' View_Order Top_Navigation.View_Order.ViewValue = Top_Navigation.View_Order.CurrentValue Top_Navigation.View_Order.CssStyle = "" Top_Navigation.View_Order.CssClass = "" Top_Navigation.View_Order.ViewCustomAttributes = "" ' Hide If Top_Navigation.Hide.CurrentValue = "1" Then Top_Navigation.Hide.ViewValue = "Yes" Else Top_Navigation.Hide.ViewValue = "No" End If Top_Navigation.Hide.CssStyle = "" Top_Navigation.Hide.CssClass = "" Top_Navigation.Hide.ViewCustomAttributes = "" ' id ' *** view refer script Top_Navigation.id.HrefValue = "" ' Navigation_Name ' *** view refer script Top_Navigation.Navigation_Name.HrefValue = "" ' language_id ' *** view refer script Top_Navigation.language_id.HrefValue = "" ' Page_Type ' *** view refer script Top_Navigation.Page_Type.HrefValue = "" ' Player_Position ' *** view refer script Top_Navigation.Player_Position.HrefValue = "" ' View_Order ' *** view refer script Top_Navigation.View_Order.HrefValue = "" ' Hide ' *** view refer script Top_Navigation.Hide.HrefValue = "" ElseIf Top_Navigation.RowType = EW_ROWTYPE_ADD Then ' Add row ElseIf Top_Navigation.RowType = EW_ROWTYPE_EDIT Then ' Edit row ElseIf Top_Navigation.RowType = EW_ROWTYPE_SEARCH Then ' Search row End If ' Call Row Rendered event Call Top_Navigation.Row_Rendered() End Sub %> <% ' Page Load event Sub Page_Load() '***Response.Write "Page Load" End Sub ' Page Unload event Sub Page_Unload() '***Response.Write "Page Unload" End Sub %>