This repository was archived by the owner on Nov 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.asp
More file actions
222 lines (205 loc) · 8.68 KB
/
data.asp
File metadata and controls
222 lines (205 loc) · 8.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<%@ Language=VBScript %>
<!--#include file=scripts\inc_common.asp -->
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
<head>
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<link href="default.css" rel="stylesheet" type="text/css">
<title>DBA:<%=langCaptionData%></title>
<script type="text/javascript" language="javascript" src="scripts/common.js" defer></script>
</head>
<body>
<%
On Error Resume Next
Dim Separator : Separator = vbTab
dim rec, sTableName, fld, abspage, i, pk, sSQL, key, dba, item
dim pagesize, action, page, PrimaryKeys, sClass, arrTemp, strFilter
pk = ""
PrimaryKeys = ""
sTableName = Request("table").Item
action = CStr(Request("action").Item)
pagesize = 10
page = 1
if IsNumeric(Request("pagesize").Item) then pagesize = CInt(Request("pagesize").Item)
if IsNumeric(Request("page").Item) then page = CInt(Request("page").Item)
if pagesize < 1 then pagesize = StpProfile.GetProfileNumber("settings", "page_size", 10)
if page < 1 then page = 1
call DBA_WriteNavigation
set dba = new DBAdmin
dba.Connect Session(DBA_cfgSessionDBPathName), Session(DBA_cfgSessionDBPassword)
If not dba.IsOpen then Response.Redirect "database.asp"
DBA_BeginNewTable sTableName & langDataForTable, "", "90%", ""
if dba.HasError then DBA_WriteError dba.LastError
'delete record
if Request.QueryString("action") = "delete" then
sSQL = "DELETE FROM [" & sTableName & "] WHERE"
fld = ""
pk = Split(Request.QueryString("pk"), Separator)
key = Split(Request.QueryString("key"), Separator)
for i=0 to UBound(pk)
if Len(pk(i)) > 0 and Len(key(i)) > 0 then
sSQL = sSQL & fld & " [" & pk(i) & "]=" & key(i)
fld = " AND"
end if
Next
call dba.RunScript(sSQL, False, False, null)
if dba.HasError then DBA_WriteError dba.LastError
end if
sSQL = "SELECT * FROM [" & sTableName & "]"
if Len(Request.QueryString("order")) > 0 then sSQL = sSQL & " ORDER BY " & Request.QueryString("order")
set rec = dba.RunScript(sSQL, False, False, null)
rec.CacheSize = pagesize
rec.PageSize = pagesize
if dba.HasError then DBA_WriteError dba.LastError
if rec.PageCount > 0 then rec.AbsolutePage = page
abspage = rec.AbsolutePage
'retrieve string with primary keys names
If dba.Tables.Exists(sTableName) Then
for each item in dba.Tables.Item(sTableName).Indexes.Items
if item.IsPrimary then PrimaryKeys = PrimaryKeys & item.TargetField & Separator
next
End If
if Right(PrimaryKeys, 1) = Separator then PrimaryKeys = Left(PrimaryKeys, Len(PrimaryKeys)-1)
%>
<div style="border: 1px #006699 solid; padding-left: 15px">
<p align="left">
<%if Len(PrimaryKeys) > 0 then%>
* <img src="images/add.gif" border="0" WIDTH="16" HEIGHT="16"><a href="recedit.asp?table=<%=Server.URLEncode(sTableName)%>&pk=<%=Server.URLEncode(PrimaryKeys)%>&page=<%=page%>&pagesize=<%=pagesize%>"><%=langAddRecord%></a>
<%end if%>
* <img src="images/refresh.gif" border="0" WIDTH="16" HEIGHT="16"><a href="data.asp?table=<%=Server.URLEncode(sTableName)%>"><%=langRefreshTable%></a>
* <img src="images/xml.gif" border="0" WIDTH="16" HEIGHT="16"><a href="export_xml.asp?sql=<%=Server.URLEncode(sSQL)%>" alt="<%=langXMLExportAlt%>"><%=langXMLExport%></a>
* <img src="images/excel.gif" border="0" WIDTH="16" HEIGHT="16"><a href="export_csv.asp?sql=<%=Server.URLEncode(sSQL)%>" alt="<%=langExcelExportAlt%>"><%=langExcelExport%></a> *
</p>
<%if Len(PrimaryKeys) = 0 then DBA_WriteError langNoPrimaryKey%>
<form action="data.asp" method="get">
<p align="left">
<%=langFilter%>
<select name="filter_field">
<option value=""></option>
<% For Each item In dba.Tables.Item(sTableName).Fields.Items%>
<option value="<%=item.Name%>"><%=item.Name%></option>
<% Next%>
</select>
<select name="filter_cmp">
<option value="=">=</option>
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
<option value="<>"><></option>
<option value="LIKE">LIKE</option>
</select>
<input type="text" name="filter_criteria" size="10">
<%=langPageSize%>
<select name="pagesize">
<%=DBA_GetComboOptions(5, 50, 5, pagesize)%>
</select>
<input type=hidden name="table" value="<%=sTableName%>">
<input type=submit value="<%=langSubmit%>" class="button">
</p>
</form>
</div>
<%=getPagingControl(rec.RecordCount, abspage, pagesize, "&table=" & Server.URLEncode(sTableName) & "&order=" & Server.URLEncode(Request.QueryString("order")))%>
<table align="center" border="1" class="DataTable">
<tr>
<th>*</th>
<%for each fld in rec.Fields%>
<th>
<%if dba.Tables.Item(sTableName).Fields.Item(fld.Name).IsPrimaryKey then%>
<img src="images/key.gif" border="0" WIDTH="16" HEIGHT="16">
<%end if%>
<A href="data.asp?table=<%=Server.URLEncode(sTableName)%>&order=<%=Server.URLEncode("[" & fld.Name & "] ASC")%>" title="<%=langSortAscending%>"><font color=white><%=fld.Name%></font></A> <A href="data.asp?table=<%=Server.URLEncode(sTableName)%>&order=<%=Server.URLEncode("[" & fld.Name & "] DESC")%>" title="<%=langSortDescending%>"><font color=white>↓</font></A>
</th>
<%next%>
</tr>
<%
if rec.State <> adStateClosed then
strFilter = BuildFilter()
if Len(strFilter) > 0 then rec.Filter = strFilter
do while not rec.EOF and i < rec.PageSize
if sClass = "oddrow" then sClass = "evenrow" else sClass = "oddrow"
%>
<tr class="<%=sClass%>" onmouseover="style.backgroundColor='#ffdfbf'" onmouseout="style.backgroundColor=''">
<td valign="top">
<% if Len(PrimaryKeys) > 0 then
sSQL = ""
arrTemp = Split(PrimaryKeys, Separator)
for each item in arrTemp
set fld = dba.Tables.Item(sTableName).Fields.Item(item)
Select Case fld.FieldType
Case adBSTR,adChar,adLongVarChar,adLongVarWChar,adVarChar,adVarWChar,adWChar
sSQL = sSQL & "'" & Replace(rec(fld.Name), "'", "''") & "'"
Case adDate,adDBDate, adDBTime, adDBTimeStamp,adFileTime
sSQL = sSQL & "CDate('" & DBA_FormatDateTime(rec(fld.Name).Value) & "')"
Case Else
sSQL = sSQL & rec(fld.Name)
End Select
sSQL = sSQL & Separator
Next
%>
<a href="recedit.asp?action=edit&pk=<%=Server.URLEncode(PrimaryKeys)%>&key=<%=Server.URLEncode(sSQL)%>&table=<%=Server.URLEncode(sTableName)%>&page=<%=page%>&pagesize=<%=pagesize%>"><img src="images/edit.gif" alt="<%=langEditRecord%>" border="0" WIDTH="16" HEIGHT="16"></a>
<a href="javascript:deleteRecord('<%=Server.URLEncode(Replace(PrimaryKeys, "'", "\'"))%>','<%=Server.URLEncode(Replace(sSQL, "'", "\'"))%>')"><img src="images/delete.gif" alt="<%=langDeleteRecord%>" border="0" WIDTH="16" HEIGHT="16"></a>
<% end if%>
</td>
<% for each fld in rec.Fields%>
<td valign="top" align="center" class="DataTD">
<% if fld.Type <> adBinary and fld.Type <> adVarBinary then%>
<% if Len(fld.Value) > 0 then
Response.Write Server.HTMLEncode(fld.Value)
else
Response.Write " "
end if
else
Response.Write "<" & langBinaryData & ">"
end if%>
</td>
<% next%>
</tr>
<% rec.MoveNext
i = i + 1
loop
end if%>
</table>
<%=getPagingControl(rec.RecordCount, abspage, pagesize, "&table=" & Server.URLEncode(sTableName) & "&order=" & Server.URLEncode(Request.QueryString("order")))%>
<%
rec.Close
call DBA_EndNewTable
set dba = Nothing
%>
<!--#include file=scripts\inc_footer.inc -->
</body>
<script LANGUAGE="javascript">
<!--
function deleteRecord(pk,key){
if(confirm("<%=langSureToDeleteRecord%> " + key + "?")){
document.location.replace("data.asp?action=delete&key=" + escape(key) + "&pk=" + escape(pk) + "&table=<%=sTableName%>&page=<%=page%>&pagesize=<%=pagesize%>");
}
}
//-->
</script>
</html>
<%
Function BuildFilter
dim filter, field, cmp, criteria, fldType
filter = ""
field = Request.QueryString("filter_field").Item
cmp = Request.QueryString("filter_cmp").Item
criteria = Request.QueryString("filter_criteria").Item
If Len(field) > 0 and Len(criteria) > 0 then
fldType = dba.Tables.Item(sTableName).Fields.Item(field).GetSQLTypeName()
If fldType = "TEXT" or fldType = "MEMO" Then
'remove asterics if only at beginning
If Left(criteria, 1) = "*" and Right(criteria, 1) <> "*" Then criteria = Mid(criteria, 2)
criteria = "'" & Replace(criteria, "'", "''") & "'"
ElseIf fldType = "DATETIME" Then
criteria = "#" & criteria & "#"
Else
If cmp = "LIKE" Then cmp = "="
End If
filter = field & " " & cmp & " " & criteria
End If
BuildFilter = filter
End Function
%>