<% 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 ewAllowEdit) <> ewAllowEdit 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 from QueryString x_ID = Request.QueryString("ID") ' Get action sAction = Request.Form("a_edit") If sAction = "" Or IsNull(sAction) Then sAction = "I" ' Display with input box Else ' Get fields from form x_ID = Request.Form("x_ID") x_Vendedora = Request.Form("x_Vendedora") x_Empresa = Request.Form("x_Empresa") x_RazonSocial = Request.Form("x_RazonSocial") End If ' Check if valid key If x_ID = "" Or IsNull(x_ID) Then Response.Redirect "Cuentaslist.asp" ' Open connection to the database Set conn = Server.CreateObject("ADODB.Connection") conn.Open xDb_Conn_Str Select Case sAction Case "I": ' Get a record to display If Not LoadData() Then ' Load Record based on key Session(ewSessionMessage) = "No records found" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "Cuentaslist.asp" End If Case "U": ' Update If EditData() Then ' Update Record based on key Session(ewSessionMessage) = "Update Record Successful" conn.Close ' Close Connection Set conn = Nothing Response.Clear Response.Redirect "Cuentaslist.asp" End If End Select %>

Edit TABLE: Cuentas

Back to List

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

<%= Session(ewSessionMessage) %>

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

ID <% Response.Write x_ID %>
Vendedora ">
Empresa ">
Razon Social ">

<% 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 EditData ' - Edit Data based on Key Value ' - Variables used: field variables Function EditData() On Error Resume Next Dim rs, sSql, sFilter Dim rsold, rsnew sFilter = ewSqlKeyWhere If Not IsNumeric(x_ID) Then EditData = 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.CursorLocation = 2 rs.Open sSql, conn, 1, 2 If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description rs.Close Set rs = Nothing EditData = False Exit Function End If ' clone old rs object Set rsold = CloneRs(rs) If rs.Eof Then EditData = False ' Update Failed Else ' Field ID ' Field Vendedora sTmp = Trim(x_Vendedora) If Trim(sTmp) = "" Then sTmp = Null rs("Vendedora") = sTmp ' Field Empresa sTmp = Trim(x_Empresa) If Trim(sTmp) = "" Then sTmp = Null rs("Empresa") = sTmp ' Field RazonSocial sTmp = Trim(x_RazonSocial) If Trim(sTmp) = "" Then sTmp = Null rs("RazonSocial") = sTmp ' Call updating event If Recordset_Updating(rsold, rs) Then ' clone new rs object Set rsnew = CloneRs(rs) rs.Update If Err.Number <> 0 Then Session(ewSessionMessage) = Err.Description EditData = False Else EditData = True End If Else rs.CancelUpdate EditData = False End If End If ' Call updated event If EditData Then Call Recordset_Updated(rsold, rsnew) End If rs.Close Set rs = Nothing rsold.Close Set rsold = Nothing rsnew.Close Set rsnew = Nothing End Function '------------------------------------------------------------------------------- ' Recordset updating event Function Recordset_Updating(rsold, rsnew) On Error Resume Next ' Please enter your customized codes here Recordset_Updating = True End Function '------------------------------------------------------------------------------- ' Recordset updated event Sub Recordset_Updated(rsold, rsnew) On Error Resume Next Dim table table = "Cuentas" End Sub %>