数据结构和add页面 就不写了看select救出来了
<VBSCRIPT">%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conn.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_conn_STRING
Recordset1.Source = "SELECT UserID, Username FROM dbo.[User]"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<%
Dim Recordset2
Dim Recordset2_numRows
Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_conn_STRING
Recordset2.Source = "SELECT ProjectID, ProjectName FROM dbo.ProjectID"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()
Recordset2_numRows = 0
%>
<%
Set conninner = Server.CreateObject("ADODB.Connection")
conninner.Open MM_conn_STRING
function haschild(cid)
dim haschildid,sql,rs
haschildid=Cint(cid)
sql="select * from takelist where fid="& haschildid
set rs=Server.CreateObject("ADODB.Recordset")
rs.open sql,conninner,3,3
if not rs.EOF then
haschild=TRUE
else
haschild=FALSE
end if
set rs=nothing
end function
function MenuNub(Maid)
dim sql,rs,Mnub
sql="select fid from takelist where takelistid="& Maid
rs=conninner.execute(sql)
Mnub=0
if not rs.EOF then
Mnub=MenuNub(rs("fid"))+1
else
exit function
end if
set rs=nothing
MenuNub=Cint(Mnub)
end function
Function Get_style(Level)
If Cint(Level)=0 then
Get_style=""
Else
Get_style="style=""display:none"""
End if
End Function
Function get_pid(id)
dim rs,sql
sql="select Fid from takelist where takelistid="&id
Set rs=Conninner.Execute(Sql)
if not rs.EOF and not rs.BOF then
get_pid=rs("Fid")
else
get_pid=0
end if
set rs=nothing
end Function
Function Get_level(id)
dim rs,sql
Sql="Select fid from takelist Where takelistid="&id
Set rs=Conninner.Execute(Sql)
If not rs.Eof and not rs.bof then
Level=Get_level(rs("fid"))+1
Else
Exit Function
End if
Set rs=nothing
Get_level=Cint(Level)
End Function
Function Chk_next(id,Level)
dim rs,sql
dim tempId
tempId=id
aId=id
curLevel=Get_level(tempId)
For i=curLevel to Level step -1
tempId=Get_Pid(tempId)
Next
For i=curLevel to Level+1 step -1
aId=Get_Pid(aId)
Next
Set rs=server.createobject("adodb.recordset")
Sql="Select * from takelist Where fid="&tempId&""
rs.open Sql,Conninner,3,3
wida=0
If Rs.recordcount>1 then
rs.MoveLast
if aid=rs("takelistid") then
Chk_next=false
Else
Chk_next=true
End if
Else
Chk_next=false
End if
Rs.close()
Set rs=nothing
End Function
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>takelist manage</title>
<script language="JavaScript" type="text/JavaScript">
function expandIt(ObjDIV,ObjIMG)
{
if (document.all.DIVs[ObjDIV].style.display=="none")
{document.all.DIVs[ObjDIV].style.display="";
ObjIMG.src="images/sub.gif";
}
else{
document.all.DIVs[ObjDIV].style.display="none";
ObjIMG.src="images/plus.gif";
}
}
var hid=0
function expandall(a,ba)
{
if(hid==0)
{
for(var i=0; i<document.all.DIVs.length;i++)
{
if(document.all.DIVs[i].Fid==ba)
{
document.all.DIVs[i].style.display="block";
for(var j=0;j<document.all.DIVs.length;j++)
{
if(document.all.DIVs[j].md==document.all.DIVs[i].Fid)
{
expandall(j,document.all.DIVs[j].Fid)
}
}
}
}
hid=1
}
else
{
for(var i=0; i<document.all.DIVs.length;i++)
{
if(document.all.DIVs[i].Fid==ba)
{
document.all.DIVs[i].style.display="none";
for(var j=0;j<document.all.DIVs.length;j++)
{
if(document.all.DIVs[j].md==document.all.DIVs[i].Fid)
{
expandall(j,document.all.DIVs[j].Fid)
}
}
}
}
hid=0
}
}
function closeall()
{
for(var i=0; i<document.all.DIVs.length;i++)
{
document.all.DIVs[i].style.display="none"
}
}
function expandalla()
{
for(var i=0; i<document.all.DIVs.length;i++)
{
document.all.DIVs[i].style.display="block"
}
}
function takesubmit()
{
var url="take_add.asp";
var f=document.createElement("form");
f.action = url;
f.method = "post";
f.id= "dosubmit";
f.style.display = "none";
var ct=document.createElement("textarea")
ct.name="cttime"
ct.value=document.all.createtime.value
f.appendChild(ct);
var st=document.createElement("textarea")
st.name="sttime"
st.value=document.all.starttime.value
f.appendChild(st);
var ft=document.createElement("textarea")
ft.name="fttime"
ft.value=document.all.finishtime.value
f.appendChild(ft);
var tde=document.createElement("textarea")
tde.name="tdesc"
tde.value=document.all.takedesc.value
f.appendChild(tde);
var ud=document.createElement("textarea")
ud.name="uid"
ud.value=document.all.userid[0].value
f.appendChild(ud);
var tud=document.createElement("textarea")
tud.name="tuid"
tud.value=document.all.userid[1].value
f.appendChild(tud);
var pd=document.createElement("textarea")
pd.name="projid"
pd.value=document.all.projectid.value
f.appendChild(pd);
var fd=document.createElement("textarea")
fd.name="fid"
fd.value=fidval;
f.appendChild(fd);
var elF = document.body.appendChild(f);
elF.submit()
}
var fidval
function addtake(tid,pid)
{
fidval=tid;
if(tid==0)
{
for(var i=1;i<=loopnub;i++)
{
eval(" var hdin=innercontain"+innerc[i]+"; var inputhd=input"+innerc[i]+";")
hdin.innerHTML="";
inputhd.style.display="none";
}
input0.style.display="block";
innercontain0.innerHTML=tempstr;
projectinner.innerHTML=projstr;
projecthd.style.display="block";
canceldiv.innerHTML="<input type=\"button\" onClick=\"innercontain0.innerHTML=‘’‘’\" value=\"取消\">"
alert(canceldiv.innerHTML)
}
else
{
input0.style.display="none";
innercontain0.innerHTML="";
if(pid!=0)
{
for(var i=1;i<=loopnub;i++)
{
eval(" var hdin=innercontain"+innerc[i]+"; var inputhd=input"+innerc[i]+";")
hdin.innerHTML="";
inputhd.style.display="none";
}
eval("var inputer=input"+tid+";var innercontainer=innercontain"+tid)
inputer.style.display="block"
innercontainer.innerHTML=tempstr
projectinner.innerHTML="<input type=\"text\" name=\"projectid\" value="+pid+">"
projecthd.style.display="none"
canceldiv.innerHTML="<input type=\"button\" onClick=\"innercontain"+tid+".innerHTML=‘’‘’\" value=\"取消\">"
//alert(canceldiv.innerHTML)
}
else
{
for(var i=1;i<=loopnub;i++)
{
eval(" var hdin=innercontain"+innerc[i]+"; var inputhd=input"+innerc[i]+";")
hdin.innerHTML="";
inputhd.style.display="none";
}
eval("var inputer=input"+tid+";var innercontainer=innercontain"+tid)
inputer.style.display="block"
innercontainer.innerHTML=tempstr
//fid.value=tid;
projectinner.innerHTML=projstr
projecthd.style.display="block"
canceldiv.innerHTML="<input type=\"button\" onClick=\"innercontain"+tid+".innerHTML=‘’‘’\" value=\"取消\">"
//alert(canceldiv.innerHTML)
}
}
}
</script>
<style>
a
{
color:#000000;
text-decoration:none;
}
</style>
</head>
<body>
<table id=TABLE border="1" cellspacing="0" cellpadding="0" style="font-size:12px " bordercolordark="#0066CC">
<tr><td width="500" onClick="expandall()"> </td><td width="50" onClick="closeall()">完成与否</td><td width="80">创立时间</td><td width="80">下放时间</td><td width="120" onClick="addtake(0,0)">添加New Takes</td></tr>
<tr id="input0" style="display:none"><td id="innercontain0" colspan="6"></td></tr>
</table>
<%
response.Write("<script language=javascript> var innerc=new Array();"&vbcrlf&"</script>")
innercn=0
divid=0
Call WriteCatalog(0,null) %>
<%
Sub WriteCatalog(id,allcount)
Dim sql
Dim rs
Level=Cint(Get_level(id))
Set rs=server.createobject("adodb.recordset")
Sql="select * from takelist where fid ="&id&" order by takelistid"
rs.open sql,conninner,1,1
Do while not rs.eof
Loopid=0
Loopid=Loopid+1 %>
<table id=TABLE border="1" cellspacing="0" cellpadding="0" style="font-size:12px; border-top-color:#FFFFFF" bordercolordark="#0066CC">
<tr><%For i=1 to Level %>
<% If Chk_next(rs("takelistid"),i) then %>
<td nowrap width=28> </td>
<% Else %>
<td nowrap width=28> </td>
<% End if %>
<% Next %>
<% if Loopid<>rs.recordcount then %>
<td width="28">
<% Else %>
<td width=28>
<% End if %>
<% If hasChild(Cint(rs("takelistid"))) then %><a href="#" onClick="expandall(<%=get_pid(rs("takelistid"))%>,<%=Cint(rs("takelistid"))%>)">展</a><img id=IMG<%= rs("takelistid") %> src="images/sub.gif" width="16" height="16" border="0" align="absmiddle" style="cursor:hand" onclick="expandIt(<%=divid%>,IMG<%= rs("takelistid") %>)">
<%
loopid=loopid+1
Else %><img name="" src="images/sub.gif" width="16" height="16" alt=""><% End if %></td>
<td width="<%=500-30*get_level(Cint(rs("takelistid")))%>"><a href="#"><%=rs("takedesc")%></a></td>
<td width="50"><%
if rs("isfinished")=0 then
response.Write("未")
else
response.write("已")
end if
%></a></td>
<td width="80"><%=rs("createtime")%></td>
<td width="80"><%=rs("starttime")%></td>
<td width="120"><a href="#" onClick="addtake(<%=rs("takelistid")%>,<%=rs("fk_projectid")%>)">添加该类别下Takes</a></td>
</tr>
<tr id="input<%=rs("takelistid")%>" style="display:none"><td id="innercontain<%=rs("takelistid")%>" colspan="<%=6+get_level(rs("takelistid"))%>">
<%
innercn=innercn+1
response.Write("<script language=javascript>"&vbcrlf&"innerc["&innercn&"]="&rs("takelistid")&";"&vbcrlf&"</script>")
%>
</td></tr>
</table>
<%
If hasChild(rs("takelistid")) then
divid=divid+1
%>
<div id=DIVs md=<%=get_pid(rs("takelistid"))%> Fid=<%=rs("takelistid")%> style="display:none">
<% CAll WriteCatalog(rs("takelistid"),rs.recordcount) %>
</div>
<% Else
%>
<% CAll WriteCatalog(rs("takelistid"),rs.recordcount) %>
<% End if %>
<%
rs.movenext
Loop
rs.close
set rs=nothing
End Sub
%>
<div id="addtk" align="center" title="Takes Add" lang="zh" style="position:absolute;left:350;top:290; width: 400px; height: 89px; display:none">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="200" bgcolor="#999999"><tr> <td bgcolor="#CCCCCC" style="padding:4px" colspan="2" align="center">
<table width="400" border="0" cellpadding="2" cellspacing="2" bgcolor="#CCCCCC">
<tr id="projecthd" style="display:block;">
<td align="left"> </td>
<td align="left">Project</td>
<td id="projectinner" align="left"> </td>
<td align="left"> </td>
</tr>
<tr>
<td align="left"> </td>
<td align="left">create user</td>
<td id="createuserinner" align="left"> </td>
<td align="left"> </td>
</tr>
<tr>
<td align="left"> </td>
<td align="left">take user</td>
<td id="takeuserinner" align="left"> </td>
<td align="left"> </td>
</tr>
<tr>
<td align="left"> </td>
<td align="left">create time</td>
<td align="left"><input type="text" size="12" name="createtime" value=""><input type="hidden" name="fid" value=""></td>
<td align="left"> </td>
</tr>
<tr>
<td align="left"> </td>
<td align="left">start time</td>
<td align="left"><input type="text" size="12" name="starttime" value=""></td>
<td align="left"> </td>
</tr>
<tr>
<td align="left"> </td>
<td align="left">finish time</td>
<td align="left"><input type="text" size="12" name="finishtime" value=""></td>
<td align="left"> </td>
</tr>
<tr>
<td align="left" width="68"> </td>
<td align="left" width="121">Take Description</td>
<td align="left"><textarea name="takedesc" rows="6" cols="28" style="border:0; "></textarea></td>
<td align="left"> </td>
</tr>
<tr>
<td align="left" width="68"> </td>
<td align="left" width="121"><input type="button" onClick="takesubmit()" value="提交"></td>
<td align="left" id="canceldiv"></td>
<td align="left"> </td>
</tr>
</table></td>
</tr></table></div>
<div id=projlist style="display:none;">
<%
Response.write("<select name=""projectid"">")
do while not Recordset2.eof
Response.write("<option value="&Recordset2("projectid")&">"&Recordset2("projectname")&"</option>")
Recordset2.MoveNext
loop
Response.write("</select>")
%>
</div>
<div id=userlist style="display:none">
<%
Response.write("<select name=""userid"">")
do while not Recordset1.eof
Response.write("<option value="&Recordset1("userid")&">"&Recordset1("username")&"</option>")
Recordset1.MoveNext
loop
Response.write("</select>")
%>
</div>
<%
response.Write("<script language=javascript> var loopnub="&innercn&"</script>")
%>
<script>
document.getElementById("createuserinner").innerHTML=document.getElementById("userlist").innerHTML
document.getElementById("takeuserinner").innerHTML=document.getElementById("userlist").innerHTML
var tempstr=document.getElementById("addtk").innerHTML
document.getElementById("addtk").innerHTML=""
var projstr=document.getElementById("projlist").innerHTML
document.getElementById("projlist").innerHTML=""
</script>
</body>
</html>