<%@ CodePage="1252" LCID="1046" %> <% Response.Buffer = EW_RESPONSE_BUFFER %> <% Session.Timeout = 20 %> <% Call ew_Header(False, EW_CHARSET) %> <% ' Define page object Dim funcionarios_delete Set funcionarios_delete = New cfuncionarios_delete Set Page = funcionarios_delete ' Page init processing Call funcionarios_delete.Page_Init() ' Page main processing Call funcionarios_delete.Page_Main() %> <% funcionarios_delete.ShowPageHeader() %> <% ' Load records for display Set funcionarios_delete.Recordset = funcionarios_delete.LoadRecordset() funcionarios_delete.TotalRecs = funcionarios_delete.Recordset.RecordCount ' Get record count If funcionarios_delete.TotalRecs <= 0 Then ' No record found, exit funcionarios_delete.Recordset.Close Set funcionarios_delete.Recordset = Nothing Call funcionarios_delete.Page_Terminate("funcionarioslist.asp") ' Return to list End If %>

<%= Language.Phrase("Delete") %> <%= Language.Phrase("TblTypeTABLE") %><%= funcionarios.TableCaption %>

<%= Language.Phrase("GoBack") %>

<% funcionarios_delete.ShowMessage %>

<% For i = 0 to UBound(funcionarios_delete.RecKeys) %> <% Next %>
<%= funcionarios.TableCustomInnerHTML %> <% funcionarios_delete.RecCnt = 0 i = 0 Do While (Not funcionarios_delete.Recordset.Eof) funcionarios_delete.RecCnt = funcionarios_delete.RecCnt + 1 ' Set row properties Call funcionarios.ResetAttrs() funcionarios.RowType = EW_ROWTYPE_VIEW ' view ' Get the field contents Call funcionarios_delete.LoadRowValues(funcionarios_delete.Recordset) ' Render row Call funcionarios_delete.RenderRow() %> > > ><%= funcionarios.ID.ListViewValue %> > ><%= funcionarios.NOME.ListViewValue %> > ><%= funcionarios.zLOGIN.ListViewValue %> > ><%= funcionarios.SENHA.ListViewValue %> <% funcionarios_delete.Recordset.MoveNext Loop funcionarios_delete.Recordset.Close Set funcionarios_delete.Recordset = Nothing %>
<%= funcionarios.ID.FldCaption %> <%= funcionarios.NOME.FldCaption %> <%= funcionarios.zLOGIN.FldCaption %> <%= funcionarios.SENHA.FldCaption %>

">

<% funcionarios_delete.ShowPageFooter() If EW_DEBUG_ENABLED Then Response.Write ew_DebugMsg() %> <% ' Drop page object Set funcionarios_delete = Nothing %> <% ' ----------------------------------------------------------------- ' Page Class ' Class cfuncionarios_delete ' Page ID Public Property Get PageID() PageID = "delete" End Property ' Table Name Public Property Get TableName() TableName = "funcionarios" End Property ' Page Object Name Public Property Get PageObjName() PageObjName = "funcionarios_delete" End Property ' Page Name Public Property Get PageName() PageName = ew_CurrentPage() End Property ' Page Url Public Property Get PageUrl() PageUrl = ew_CurrentPage() & "?" If funcionarios.UseTokenInUrl Then PageUrl = PageUrl & "t=" & funcionarios.TableVar & "&" ' add page token End Property ' Message Public Property Get Message() Message = Session(EW_SESSION_MESSAGE) End Property Public Property Let Message(v) Dim msg msg = Session(EW_SESSION_MESSAGE) Call ew_AddMessage(msg, v) Session(EW_SESSION_MESSAGE) = msg End Property Public Property Get FailureMessage() FailureMessage = Session(EW_SESSION_FAILURE_MESSAGE) End Property Public Property Let FailureMessage(v) Dim msg msg = Session(EW_SESSION_FAILURE_MESSAGE) Call ew_AddMessage(msg, v) Session(EW_SESSION_FAILURE_MESSAGE) = msg End Property Public Property Get SuccessMessage() SuccessMessage = Session(EW_SESSION_SUCCESS_MESSAGE) End Property Public Property Let SuccessMessage(v) Dim msg msg = Session(EW_SESSION_SUCCESS_MESSAGE) Call ew_AddMessage(msg, v) Session(EW_SESSION_SUCCESS_MESSAGE) = msg End Property ' Show Message Public Sub ShowMessage() Dim sMessage sMessage = Message Call Message_Showing(sMessage, "") If sMessage <> "" Then Response.Write "

" & sMessage & "

" Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session ' Success message Dim sSuccessMessage sSuccessMessage = SuccessMessage Call Message_Showing(sSuccessMessage, "success") If sSuccessMessage <> "" Then Response.Write "

" & sSuccessMessage & "

" Session(EW_SESSION_SUCCESS_MESSAGE) = "" ' Clear message in Session ' Failure message Dim sErrorMessage sErrorMessage = FailureMessage Call Message_Showing(sErrorMessage, "failure") If sErrorMessage <> "" Then Response.Write "

" & sErrorMessage & "

" Session(EW_SESSION_FAILURE_MESSAGE) = "" ' Clear message in Session End Sub Dim PageHeader Dim PageFooter ' Show Page Header Public Sub ShowPageHeader() Dim sHeader sHeader = PageHeader Call Page_DataRendering(sHeader) If sHeader <> "" Then ' Header exists, display Response.Write "

" & sHeader & "

" End If End Sub ' Show Page Footer Public Sub ShowPageFooter() Dim sFooter sFooter = PageFooter Call Page_DataRendered(sFooter) If sFooter <> "" Then ' Footer exists, display Response.Write "

" & sFooter & "

" End If End Sub ' ----------------------- ' Validate Page request ' Public Function IsPageRequest() If funcionarios.UseTokenInUrl Then IsPageRequest = False If Not (ObjForm Is Nothing) Then IsPageRequest = (funcionarios.TableVar = ObjForm.GetValue("t")) End If If Request.QueryString("t").Count > 0 Then IsPageRequest = (funcionarios.TableVar = Request.QueryString("t")) End If Else IsPageRequest = True End If End Function ' ----------------------------------------------------------------- ' Class initialize ' - init objects ' - open ADO connection ' Private Sub Class_Initialize() If IsEmpty(StartTimer) Then StartTimer = Timer ' Init start time ' Initialize language object If IsEmpty(Language) Then Set Language = New cLanguage Call Language.LoadPhrases() End If ' Initialize table object If IsEmpty(funcionarios) Then Set funcionarios = New cfuncionarios Set Table = funcionarios ' Initialize urls ' Initialize form object Set ObjForm = Nothing ' Intialize page id (for backward compatibility) EW_PAGE_ID = "delete" ' Initialize table name (for backward compatibility) EW_TABLE_NAME = "funcionarios" ' Open connection to the database If IsEmpty(Conn) Then Call ew_Connect() End Sub ' ----------------------------------------------------------------- ' Subroutine Page_Init ' - called before page main ' - check Security ' - set up response header ' - call page load events ' Sub Page_Init() ' Global page loading event (in userfn7.asp) Call Page_Loading() ' Page load event, used in current page Call Page_Load() End Sub ' ----------------------------------------------------------------- ' Class terminate ' - clean up page object ' Private Sub Class_Terminate() Call Page_Terminate("") End Sub ' ----------------------------------------------------------------- ' Subroutine Page_Terminate ' - called when exit page ' - clean up ADO connection and objects ' - if url specified, redirect to url ' Sub Page_Terminate(url) ' Page unload event, used in current page Call Page_Unload() ' Global page unloaded event (in userfn60.asp) Call Page_Unloaded() Dim sRedirectUrl sReDirectUrl = url Call Page_Redirecting(sReDirectUrl) If Not (Conn Is Nothing) Then Conn.Close ' Close Connection Set Conn = Nothing Set funcionarios = Nothing Set ObjForm = Nothing ' Go to url if specified If sReDirectUrl <> "" Then If Response.Buffer Then Response.Clear Response.Redirect sReDirectUrl End If End Sub ' ' Subroutine Page_Terminate (End) ' ---------------------------------------- Dim TotalRecs Dim RecCnt Dim RecKeys Dim Recordset ' Page main processing Sub Page_Main() Dim sFilter ' Load Key Parameters RecKeys = funcionarios.GetRecordKeys() ' Load record keys sFilter = funcionarios.GetKeyFilter() If sFilter = "" Then Call Page_Terminate("funcionarioslist.asp") ' Prevent SQL injection, return to list End If ' Set up filter (Sql Where Clause) and get Return Sql ' Sql constructor in funcionarios class, funcionariosinfo.asp funcionarios.CurrentFilter = sFilter ' Get action If Request.Form("a_delete").Count > 0 Then funcionarios.CurrentAction = Request.Form("a_delete") Else funcionarios.CurrentAction = "D" ' Delete record directly End If Select Case funcionarios.CurrentAction Case "D" ' Delete funcionarios.SendEmail = True ' Send email on delete success If DeleteRows() Then ' delete rows SuccessMessage = Language.Phrase("DeleteSuccess") ' Set up success message Call Page_Terminate(funcionarios.ReturnUrl) ' Return to caller End If End Select End Sub ' ----------------------------------------------------------------- ' Load recordset ' Function LoadRecordset() ' Call Recordset Selecting event Dim sFilter sFilter = funcionarios.CurrentFilter Call funcionarios.Recordset_Selecting(sFilter) funcionarios.CurrentFilter = sFilter ' Load list page sql Dim sSql sSql = funcionarios.ListSQL Call ew_SetDebugMsg("LoadRecordset: " & sSql) ' Show SQL for debugging ' Load recordset Dim RsRecordset Set RsRecordset = ew_LoadRecordset(sSql) ' Call Recordset Selected event Call funcionarios.Recordset_Selected(RsRecordset) Set LoadRecordset = RsRecordset End Function ' ----------------------------------------------------------------- ' Load row based on key values ' Function LoadRow() Dim RsRow, sSql, sFilter sFilter = funcionarios.KeyFilter ' Call Row Selecting event Call funcionarios.Row_Selecting(sFilter) ' Load sql based on filter funcionarios.CurrentFilter = sFilter sSql = funcionarios.SQL Call ew_SetDebugMsg("LoadRow: " & sSql) ' Show SQL for debugging Set RsRow = ew_LoadRow(sSql) If RsRow.Eof Then LoadRow = False Else LoadRow = True RsRow.MoveFirst Call LoadRowValues(RsRow) ' Load row values End If RsRow.Close Set RsRow = Nothing End Function ' ----------------------------------------------------------------- ' Load row values from recordset ' Sub LoadRowValues(RsRow) Dim sDetailFilter If RsRow.Eof Then Exit Sub ' Call Row Selected event Call funcionarios.Row_Selected(RsRow) funcionarios.ID.DbValue = RsRow("ID") funcionarios.NOME.DbValue = RsRow("NOME") funcionarios.zLOGIN.DbValue = RsRow("LOGIN") funcionarios.SENHA.DbValue = RsRow("SENHA") End Sub ' ----------------------------------------------------------------- ' Render row values based on field settings ' Sub RenderRow() ' Initialize urls ' Call Row Rendering event Call funcionarios.Row_Rendering() ' --------------------------------------- ' Common render codes for all row types ' --------------------------------------- ' ID ' NOME ' LOGIN ' SENHA ' ----------- ' View Row ' ----------- If funcionarios.RowType = EW_ROWTYPE_VIEW Then ' View row ' ID funcionarios.ID.ViewValue = funcionarios.ID.CurrentValue funcionarios.ID.CssStyle = "text-align:center;" funcionarios.ID.ViewCustomAttributes = "" ' NOME funcionarios.NOME.ViewValue = funcionarios.NOME.CurrentValue funcionarios.NOME.CssStyle = "text-align:center;" funcionarios.NOME.ViewCustomAttributes = "" ' LOGIN funcionarios.zLOGIN.ViewValue = funcionarios.zLOGIN.CurrentValue funcionarios.zLOGIN.CssStyle = "text-align:center;" funcionarios.zLOGIN.ViewCustomAttributes = "" ' SENHA funcionarios.SENHA.ViewValue = funcionarios.SENHA.CurrentValue funcionarios.SENHA.CssStyle = "text-align:center;" funcionarios.SENHA.ViewCustomAttributes = "" ' View refer script ' ID funcionarios.ID.LinkCustomAttributes = "" funcionarios.ID.HrefValue = "" funcionarios.ID.TooltipValue = "" ' NOME funcionarios.NOME.LinkCustomAttributes = "" funcionarios.NOME.HrefValue = "" funcionarios.NOME.TooltipValue = "" ' LOGIN funcionarios.zLOGIN.LinkCustomAttributes = "" funcionarios.zLOGIN.HrefValue = "" funcionarios.zLOGIN.TooltipValue = "" ' SENHA funcionarios.SENHA.LinkCustomAttributes = "" funcionarios.SENHA.HrefValue = "" funcionarios.SENHA.TooltipValue = "" End If ' Call Row Rendered event If funcionarios.RowType <> EW_ROWTYPE_AGGREGATEINIT Then Call funcionarios.Row_Rendered() End If End Sub ' ' Delete records based on current filter ' Function DeleteRows() If Not EW_DEBUG_ENABLED Then On Error Resume Next Dim sKey, sThisKey, sKeyFld, arKeyFlds Dim sSql, RsDelete Dim RsOld DeleteRows = True sSql = funcionarios.SQL Set RsDelete = Server.CreateObject("ADODB.Recordset") RsDelete.CursorLocation = EW_CURSORLOCATION RsDelete.Open sSql, Conn, 1, EW_RECORDSET_LOCKTYPE If Err.Number <> 0 Then FailureMessage = Err.Description RsDelete.Close Set RsDelete = Nothing DeleteRows = False Exit Function ElseIf RsDelete.Eof Then FailureMessage = Language.Phrase("NoRecord") ' No record found RsDelete.Close Set RsDelete = Nothing DeleteRows = False Exit Function End If Conn.BeginTrans ' Clone old recordset object Set RsOld = ew_CloneRs(RsDelete) ' Call row deleting event If DeleteRows Then RsDelete.MoveFirst Do While Not RsDelete.Eof DeleteRows = funcionarios.Row_Deleting(RsDelete) If Not DeleteRows Then Exit Do RsDelete.MoveNext Loop RsDelete.MoveFirst End If If DeleteRows Then sKey = "" RsDelete.MoveFirst Do While Not RsDelete.Eof sThisKey = "" If sThisKey <> "" Then sThisKey = sThisKey & EW_COMPOSITE_KEY_SEPARATOR sThisKey = sThisKey & RsDelete("ID") RsDelete.Delete If Err.Number <> 0 Then FailureMessage = Err.Description ' Set up error message DeleteRows = False Exit Do End If If sKey <> "" Then sKey = sKey & ", " sKey = sKey & sThisKey RsDelete.MoveNext Loop Else ' Set up error message If funcionarios.CancelMessage <> "" Then FailureMessage = funcionarios.CancelMessage funcionarios.CancelMessage = "" Else FailureMessage = Language.Phrase("DeleteCancelled") End If End If If DeleteRows Then Conn.CommitTrans ' Commit the changes If Err.Number <> 0 Then FailureMessage = Err.Description DeleteRows = False ' Delete failed End If Else Conn.RollbackTrans ' Rollback changes End If RsDelete.Close Set RsDelete = Nothing ' Call row deleting event If DeleteRows Then If Not RsOld.Eof Then RsOld.MoveFirst Do While Not RsOld.Eof Call funcionarios.Row_Deleted(RsOld) RsOld.MoveNext Loop End If RsOld.Close Set RsOld = Nothing End Function ' Page Load event Sub Page_Load() 'Response.Write "Page Load" End Sub ' Page Unload event Sub Page_Unload() 'Response.Write "Page Unload" End Sub ' Page Redirecting event Sub Page_Redirecting(url) 'url = newurl End Sub ' Message Showing event ' typ = ""|"success"|"failure" Sub Message_Showing(msg, typ) ' Example: 'If typ = "success" Then msg = "your success message" End Sub ' Page Data Rendering event Sub Page_DataRendering(header) ' Example: 'header = "your header" End Sub ' Page Data Rendered event Sub Page_DataRendered(footer) ' Example: 'footer = "your footer" End Sub End Class %>