<% Response.Expires = 0 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate" %> <% If Not IsLoggedIn And Request.Cookies(ewProjectName)("autologin") = "autologin" And Request.Cookies(ewProjectName)("password") <> "" Then Response.Redirect "login.asp" Call LoadUserLevel() If IsLoggedIn Then ewCurSec = CurrentUserLevelPriv("Cuentas") Else ewCurSec = GetAnonymousPriv("Cuentas") End If If (ewCurSec And ewAllowDelete) <> ewAllowDelete Then Response.Redirect "Cuentaslist.asp" %> <% ' Initialize common variables x_ID = Null: ox_ID = Null: z_ID = Null x_Vendedora = Null: ox_Vendedora = Null: z_Vendedora = Null x_Empresa = Null: ox_Empresa = Null: z_Empresa = Null x_RazonSocial = Null: ox_RazonSocial = Null: z_RazonSocial = Null %> <% Response.Buffer = True ' Load Key Parameters sKey = "": bSingleDelete = True x_ID = Request.QueryString("ID") If x_ID <> "" Then If Not IsNumeric(x_ID) Then Response.Redirect "Cuentaslist.asp" ' prevent sql injection End If If sKey <> "" Then sKey = sKey & "," sKey = sKey & x_ID Else bSingleDelete = False End If If Not bSingleDelete Then sKey = Request.Form("key_d") End If If sKey = "" Or IsNull(sKey) Then Response.Redirect "Cuentaslist.asp" arRecKey = Split(sKey&"", ",") i = 0 Do While i <= UBound(arRecKey) sDbWhere = sDbWhere & "(" ' Remove spaces sRecKey = Trim(arRecKey(i+0)) If Not IsNumeric(sRecKey) Then Response.Redirect "Cuentaslist.asp" ' prevent sql injection End If ' Build the SQL sDbWhere = sDbWhere & "[ID]=" & AdjustSql(sRecKey) & " AND " If Right(sDbWhere, 5) = " AND " Then sDbWhere = Left(sDbWhere, Len(sDbWhere)-5) & ") OR " i = i + 1 Loop If Right(sDbWhere, 4) = " OR " Then sDbWhere = Left(sDbWhere, Len(sDbWhere)-4) ' Get action sAction = Request.Form("a_delete") If sAction = "" Or IsNull(sAction) Then sAction = "I" ' Display record End If ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "I": ' Display If LoadRecordCount(sDbWhere) <= 0 Then conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "Cuentaslist.asp" End If Case "D": ' Delete If DeleteData(sDbWhere) Then Session(ewSessionMessage) = "Delete Successful" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "Cuentaslist.asp" End If End Select %>

Delete from TABLE: Cuentas

Back to List

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

<%= Session(ewSessionMessage) %>

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

<% nRecCount = 0 i = 0 Do While i <= UBound(arRecKey) nRecCount = nRecCount + 1 ' Set row color sItemRowClass = " class=""ewTableRow""" ' Display alternate color for rows If nRecCount Mod 2 <> 0 Then sItemRowClass = " class=""ewTableAltRow""" End If sRecKey = Trim(arRecKey(i+0)) x_ID = sRecKey If LoadData() Then %> > <% End If i = i + 1 Loop %>
ID Vendedora Empresa Razon Social
<% Response.Write x_ID %> <% Response.Write x_Vendedora %> <% Response.Write x_Empresa %> <% Response.Write x_RazonSocial %>

<% conn.Close ' Close Connection Set conn = Nothing %> <% '------------------------------------------------------------------------------- ' Function LoadData ' - Load Data based on Key Value ' - Variables setup: field variables Function LoadData() Dim rs, sSql, sFilter sFilter = ewSqlKeyWhere If Not IsNumeric(x_ID) Then LoadData = False Exit Function End If sFilter = Replace(sFilter, "@ID", AdjustSql(x_ID)) ' Replace key value sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSql, conn If rs.Eof Then LoadData = False Else LoadData = True rs.MoveFirst ' Get the field contents x_ID = rs("ID") x_Vendedora = rs("Vendedora") x_Empresa = rs("Empresa") x_RazonSocial = rs("RazonSocial") End If rs.Close Set rs = Nothing End Function %> <% '------------------------------------------------------------------------------- ' Function LoadRecordCount ' - Load Record Count based on input sql criteria sqlKey Function LoadRecordCount(sqlKey) On Error Resume Next Dim rs, sSql, sFilter sFilter = sqlKey sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 2 rs.Open sSql, conn, 1, 2 LoadRecordCount = rs.RecordCount rs.Close Set rs = Nothing If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description End If End Function %> <% '------------------------------------------------------------------------------- ' Function DeleteData ' - Delete Records based on input sql criteria sqlKey Function DeleteData(sqlKey) On Error Resume Next Dim rs, sSql, sFilter Dim rsold sFilter = sqlKey sSql = ewBuildSql(ewSqlSelect, ewSqlWhere, ewSqlGroupBy, ewSqlHaving, ewSqlOrderBy, sFilter, "") Set rs = Server.CreateObject("ADODB.Recordset") rs.CursorLocation = 2 rs.Open sSql, conn, 1, 2 If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description rs.Close Set rs = Nothing DeleteData = False Exit Function End If ' Clone old rs object Set rsold = CloneRs(rs) ' Call recordset deleting event DeleteData = Recordset_Deleting(rs) If DeleteData Then Do While Not rs.Eof rs.Delete If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description DeleteData = False Exit Do End If rs.MoveNext Loop End If rs.Close Set rs = Nothing ' Call recordset deleted event If DeleteData Then Call Recordset_Deleted(rsold) End If rsold.Close Set rsold = Nothing End Function '------------------------------------------------------------------------------- ' Recordset deleting event Function Recordset_Deleting(rsold) On Error Resume Next ' Please enter your customized codes here Recordset_Deleting = True End Function '------------------------------------------------------------------------------- ' Recordset deleted event Sub Recordset_Deleted(rsold) On Error Resume Next Dim table table = "Cuentas" End Sub %>