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 pathstructure.asp
More file actions
345 lines (335 loc) · 12.9 KB
/
Copy pathstructure.asp
File metadata and controls
345 lines (335 loc) · 12.9 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<%@ 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">
<title>DBA:<%=langCaptionTableStructure%></title>
<script type="text/javascript" language="javascript" src="scripts/common.js" defer></script>
<script language="javascript" type="text/javascript">
//<!--
function deleteColumn(name){
var str = '<%=Replace(langAreYouSureToDelete, """", "\""")%>';
str = str.replace("\$name", name);
if(confirm(str)){
document.location.replace('structure.asp?table=<%=Server.URLEncode(Request("table"))%>&field=' + name + '&action=delete_field');
}
}
function onFieldTypeChange(newType){
var isText = newType == "TEXT" || newType == "MEMO" ? true : false;
document.getElementById('trZeroLength').style.display = isText ? "" : "none";
document.getElementById('trCompress').style.display = isText ? "" : "none";
}
//-->
</script>
</head>
<body>
<% call DBA_WriteNavigation%>
<%
if not DBAE_DEBUG Then On Error Resume Next
dim dba, dic, strTable, item, action, sClass, sPrimaryIndexName, oTable
dim ADOXAvail
strTable = CStr(Request("table"))
action = CStr(Request("action"))
ADOXAvail = StpProfile.ComponentAvailable("ADOX")
set dba = new DBAdmin
dba.Connect Session(DBA_cfgSessionDBPathName), Session(DBA_cfgSessionDBPassword)
DBA_BeginNewTable strTable & langTableStructure, "", "90%", ""
If not dba.IsOpen then Response.Redirect "database.asp"
if dba.HasError then DBA_WriteError dba.LastError
set oTable = dba.Tables.Item(strTable)
'perform requested actions first
Select Case action
Case "create_field"
set item = new DBAField
item.Name = Request.Form("fname").Item
item.FieldType = Request.Form("type").Item
item.DefaultValue = Request.Form("default").Item
item.IsNullable = Request.Form("nullable").Item
item.MaxLength = Request.Form("length").Item
item.Description = Request.Form("description").Item
item.AllowZeroLength = Request.Form("zero_length").Item
item.Compressed = Request.Form("compress").Item
oTable.CreateField item, Request.Form("indexed").Item
set item = nothing
if dba.HasError then DBA_WriteError dba.LastError
Case "delete_field"
oTable.DeleteField Request.QueryString("field").Item
if dba.HasError then DBA_WriteError dba.LastError
Case "key"
oTable.CreateIndex "", Request.QueryString("field").Item, True, True
if dba.HasError then DBA_WriteError dba.LastError
Case "delete_index"
oTable.DeleteIndex Request.QueryString("index").Item, Request.QueryString("field").Item
if dba.HasError then DBA_WriteError dba.LastError
Case "create_index"
oTable.CreateIndex Request.Form("index").Item, Request.Form("field").Item, Request.Form("unique").Item, False
if dba.HasError then DBA_WriteError dba.LastError
Case "update_field"
set item = oTable.Fields.Item(Request.Form("oldname").Item)
item.Name = Request.Form("fname").Item
item.FieldType = Request.Form("type").Item
item.MaxLength = Request.Form("length").Item
item.DefaultValue = Request.Form("default").Item
item.Description = Request.Form("description").Item
item.AllowZeroLength = Request.Form("zero_length").Item
item.IsNullable = Request.Form("nullable").Item
item.UpdateBatch
if dba.HasError then DBA_WriteError dba.LastError
End Select
'find out primary index name
sPrimaryIndexName = ""
set dic = dba.Tables.Item(strTable).Indexes
for each item in dic.Items
if item.IsPrimary then
sPrimaryIndexName = item.Name
Exit For
end if
next
set dic = dba.Tables.Item(strTable).Fields
%>
<!--FIELDS-->
<table align="center" width="90%" border="0" cellpadding="3" cellspacing="1">
<tr>
<th><%=langOrdinal%></th>
<th><%=langName%></th>
<th><%=langDataType%></th>
<th><%=langNullable%></th>
<th><%=langMaxLength%></th>
<th><%=langDefaultValue2%></th>
<th><%=langDescription%></th>
<th><%=langActions%></th>
</tr>
<%
for each item in dic.Items
WriteFieldTR item
next
%>
</table>
<%
call DBA_EndNewTable
if action = "edit" then
call WriteFieldEditForm(dic.Item(Request.QueryString("field").Item))
else
set item = new DBAField
item.Ordinal = dic.Count + 1
call WriteFieldEditForm(item)
set item = nothing
end if
%>
<!--INDEXES-->
<%
DBA_BeginNewTable strTable & langTableIndexes, "", "90%", ""
%>
<form action="structure.asp" method="post">
<table align="center" width="90%" border="0" cellpadding="3" cellspacing="1">
<tr>
<th><%=langIndexName%></th>
<th><%=langColumn%></th>
<th><%=langUnique%></th>
<th><%=langActions%></th>
</tr>
<%
set dic = dba.Tables.Item(strTable).Indexes
sClass = ""
for each item in dic.Items
if sClass = "oddrow" then sClass = "evenrow" else sClass = "oddrow"
%>
<tr class="<%=sClass%>" onmouseover="style.backgroundColor='#ffdfbf'" onmouseout="style.backgroundColor=''">
<td>
<% if item.IsPrimary then%>
<img src="images/key.gif" border="0" width="16" height="16" alt="<%=langPrimaryColumnAlt%>">
<% end if%>
<%=item.Name%>
</td>
<td><%=item.TargetField%></td>
<td align="center">
<%if item.IsUnique then%>
<img src="images/check.gif" border="0" width="16" height="16" alt="<%=langUniqueIndexAlt%>">
<%end if%>
</td>
<td align="center">
<a href="structure.asp?table=<%=Server.URLEncode(strTable)%>&action=delete_index&index=<%=Server.URLEncode(item.Name)%>&field=<%=Server.URLEncode(item.TargetField)%>"><img src="images/delete.gif" alt="<%=langDeleteIndexAlt%>" border="0" width="16" height="16"></a>
</td>
</tr>
<% next%>
<tr>
<th align="left"><input type="text" name="index" size="10"></th>
<th align="left">
<select name="field">
<% for each item in dba.Tables.Item(strTable).Fields.Items%>
<option value="<%=item.Name%>"><%=item.Name%></option>
<% next%>
</select>
</th>
<th align="center"><input type="checkbox" name="unique" value="1"></th>
<th align="right"><input type="submit" name="submit" value="<%=langCreateIndex%>" class="button"></th>
</TR>
</table>
<input type="hidden" name="table" value="<%=strTable%>">
<input type="hidden" name="action" value="create_index">
</form>
<!--GENERATED SQL QUERY-->
<%
call DBA_EndNewTable
DBA_BeginNewTable strTable & langCreateTableQuery, langCreateTableQueryAlt, "75%", ""
%>
<div id="divSQL" align="left"><%=HighlightSQL(dba.Tables.Item(strTable).SQL)%></div>
<% if InStr(1, Request.ServerVariables("HTTP_USER_AGENT"), "MSIE") > 0 then%>
<p> </p>
<div align="center"><input type="button" value="<%=langCopyToClipboard%>" onclick="javascript:copyToClipboard(document.getElementById('divSQL'));" class="button"></div>
<% end if%>
<%
call DBA_EndNewTable
set dba = Nothing
%>
<!--#include file=scripts\inc_footer.inc -->
</body>
</html>
<%
Sub WriteFieldTR(byref fld)
if sClass = "oddrow" then sClass = "evenrow" else sClass = "oddrow"
%>
<tr class="<%=sClass%>" onmouseover="style.backgroundColor='#ffdfbf'" onmouseout="style.backgroundColor=''">
<td align=center><%=fld.Ordinal%></td>
<td>
<%if fld.IsPrimaryKey then%>
<img src="images/key.gif" border="0" width="16" height="16" alt="<%=langPrimaryColumnAlt%>">
<%end if%>
<%=fld.Name%>
</td>
<td><%=fld.GetTypeName%></td>
<td align="center">
<%if fld.IsNullable then%>
<img src="images/check.gif" border="0" width="16" height="16">
<%end if%>
</td>
<td><%if fld.MaxLength > 0 then Response.Write fld.MaxLength else Response.Write " "%></td>
<td><%=fld.DefaultValue%> </td>
<td><%=fld.Description%> </td>
<td align="center">
<a href="structure.asp?table=<%=Server.URLEncode(strTable)%>&field=<%=Server.URLEncode(fld.Name)%>&action=edit#editForm"><img src="images/edit.gif" alt="<%=langEditField%>" border="0" width="16" height="16"></a>
<%if fld.IsPrimaryKey then%>
<a href="structure.asp?table=<%=Server.URLEncode(strTable)%>&field=<%=Server.URLEncode(fld.Name)%>&index=<%=Server.URLEncode(sPrimaryIndexName)%>&action=delete_index"><img src="images/un_key.gif" alt="<%=langRemovePK%>" border="0" width="16" height="16"></a>
<%else%>
<a href="structure.asp?table=<%=Server.URLEncode(strTable)%>&field=<%=Server.URLEncode(fld.Name)%>&action=key"><img src="images/key.gif" alt="<%=langSetAsPK%>" border="0" width="16" height="16"></a>
<%end if%>
<a href="javascript:deleteColumn('<%=Server.URLEncode(fld.Name)%>')"><img src="images/delete.gif" alt="<%=langDeleteField%>" border="0" width="16" height="16"></a>
</td>
</tr>
<% End Sub%>
<%
Sub WriteFieldEditForm(byref fld)
On Error Resume Next
dim isText, isNewField, strNullable, strCompress
Response.Write "<a name=""editForm""></a>"
if Len(fld.Name) = 0 then
DBA_BeginNewTable strTable & " : " & langAddNewColumn, "", "50%" , ""
action = "create_field"
isNewField = True
strNullable = "<input type=""checkbox"" name=""nullable"" value=""-1"">"
strCompress = "<input type=""checkbox"" name=""compress"" value=""-1"">"
else
DBA_BeginNewTable strTable & " : " & langEditField, "", "50%", ""
action = "update_field"
isNewField = False
strNullable = "<input type=""hidden"" name=""nullable"" value=""" & CInt(fld.IsNullable) & """>" & CStr(fld.IsNullable)
strCompress = CStr(fld.Compressed)
end if
if fld.GetSQLTypeName = "TEXT" or fld.getSQLTypeName = "MEMO" then isText = True else IsText = False
%>
<!--Field editing form -->
<form action="structure.asp" method="post">
<input type="hidden" name="oldname" value="<%=fld.Name%>">
<input type="hidden" name="table" value="<%=strTable%>">
<input type="hidden" name="action" value="<%=action%>">
<table align="center" border="0" cellpadding="3" cellspacing="1">
<tr>
<td><%=langOrdinal%></td>
<td><%=fld.Ordinal%></td>
</tr>
<tr>
<td><%=langName%></td>
<td>
<% if ADOXAvail Then%>
<input type="text" name="fname" value="<%=fld.Name%>">
<% Else%>
<input type="hidden" name="fname" value="<%=fld.Name%>"><%=fld.Name%>
<% End If%>
</td>
</tr>
<tr>
<td><%=langDataType%></td>
<td><select name="type" onchange="javascript:onFieldTypeChange(this.options[this.selectedIndex].value);">
<option value="<%=fld.GetSQLTypeName%>"><%=fld.GetTypeName%></option>
<option value="DATETIME">Date/Time</option>
<option value="LONG">Long Integer</option>
<option value="TEXT">Text</option>
<option value="COUNTER">AutoNumber</option>
<option value="MEMO">Memo</option>
<option value="MONEY">Currency</option>
<option value="BINARY">Binary</option>
<option value="TINYINT">Byte</option>
<option value="DECIMAL">Decimal</option>
<option value="FLOAT">Double</option>
<option value="INTEGER">Integer</option>
<option value="REAL">Single</option>
<option value="BIT">Boolean</option>
<option value="UNIQUEIDENTIFIER">Replication ID</option>
</select></td>
</tr>
<tr>
<td><%=langNullable%></td>
<td><%=strNullable%></td>
</tr>
<tr>
<td><%=langMaxLength%></td>
<td><input type="text" name="length" size="5" value="<%=fld.MaxLength%>"></td>
</tr>
<tr>
<td><%=langDefaultValue2%></td>
<td><input type="text" name="default" size="20" value="<%=Server.HTMLEncode(fld.DefaultValue)%>" id="Text1"></td>
</tr>
<% if ADOXAvail Then%>
<tr>
<td><%=langDescription%></td>
<td><input type="text" name="description" value="<%=fld.Description%>"></td>
</tr>
<tr id="trZeroLength" style="<%if not isText then Response.Write "display:none"%>">
<td><%=langAllowZeroLength%></td>
<td><input type="checkbox" name="zero_length" value="-1" <%if fld.AllowZeroLength then Response.Write " checked "%>></td>
</tr>
<tr id="trCompress" style="<%if not isText then Response.Write "display:none"%>">
<td><%=langUnicodeCompress%></td>
<td><%=strCompress%></td>
</tr>
<% End If%>
<% if isNewField then%>
<tr>
<td><%=langIndexed%></td>
<td><select name="indexed">
<option value="0"><%=langNo%></option>
<option value="1"><%=langIndxedDuplicates%></option>
<option value="2"><%=langIndexedUnique%></option>
</select></td>
</tr>
<% end if%>
<tr>
<td align="center" colspan="2">
<input type="submit" name="submit" value="<%=langUpdate%>" class="button">
<%if Len(fld.Name) > 0 then%>
<input type="button" value="<%=langCancel%>" class="button" onclick="javascript:window.location.replace('structure.asp?table=<%=Server.URLEncode(strTable)%>');">
<%end if%>
</td>
</tr>
</table>
</form>
<!--End of form-->
<%
DBA_EndNewTable
End Sub
%>