<%@Page Language="vb" EnableSessionState=true Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.WEB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
	Dim Source as SqlConnection
	sub Page_Load(sender as object, e as EventArgs)
		if Session("NowFolder")is nothing then
			gData.Visible=true
			diss.Visible=false
		else
			Source = Ctype(Session("NowFolder"),SqlConnection)
		end if
	end sub
	sub OKClick(sender as object,e as EventArgs)
		if SQLServer.Text<>"" then
			dim f as string ="server=" + SQLServer.Text + ";uid=" + uid.Text + ";pwd=" + Password.Text + ";database=EmploySQL"
			Source = new SqlConnection(f)
			Session("NowFolder")=Source
			gData.Visible=false
			diss.Visible=true
			allShortcutBind(true)
			FolderBind(true)
		else
			err.Text="未输入SQL服务器名称"
		end if
	end sub
	public Function GetFDName(FID as string ,fileName as string) as string
		dim FD as string  =GetFullFDName(FID)
		dim m as string=Request.PhysicalPath
		m=m.Substring(0,m.Length-12) & "\"
		return "\ASPNETData\Ch14\14-3\vb\" & FD & fileName
	end function
	sub Folder_ItemCommand(sender as object,e as DataListCommandEventArgs)
		if e.CommandName = "Select"  then
			dim h as string =e.CommandArgument.ToString()
			dim x as integer =h.IndexOf("-")'切割处理
			dim FID as string= h.Substring(0,x)
			dim NowAllPath as string =GetFullFDName(FID)'取得完整路径
			Folder.SelectedIndex = e.Item.ItemIndex
			Folder.EditItemIndex = -1
			NowPath.Text = NowAllPath'写入至小抄
			ShowPath.Text = NowAllPath
			ClickShow(e.CommandArgument.ToString(), e.Item.ItemIndex)
'			Dim SID as string = h.Substring(x+1,h.Length-x-2)
		end if
	end sub
	sub ClickShow(NowCommand as string,NowIndex as integer)
		dim x as integer =NowCommand.IndexOf("-")
		dim SID as string= NowCommand.Substring(x+1,Len(NowCommand)-x-1)
		dim FID as string = NowCommand.Substring(0,x)'切割字串
		Dim DS as DataSet '第一个DataSet
		DS=Ctype(Session("NowFolderDSvb"),DataSet)
		LabSortID.Text=SID'写入至小抄
		LabFID.Text=FID
		Dim DS1 as DataSet=new DataSet()'第二个DataSet
		dim z as integer =DeleteSubFolder(FID)
		Folder.SelectedIndex = NowIndex
		dim j as string="select * from Folders where ParentID =" & Folder.DataKeys(NowIndex) & " Order by SortID"
		dim Comm as SqlDataAdapter = new SqlDataAdapter(j,Source)
		Comm.Fill(DS1,"Folders")
		if z=0 then
			DS.Merge(DS1.Tables("Folders"))
		end if
		dim k as integer =GetLevel(SID)
		NowLevel.Text=k.ToString() '目前level
		DocumentBind(true)
		Dim dv as DataView =DS.Tables("Folders").DefaultView
		dv.Sort="SortID"
		Folder.DataSource=dv
		Folder.DataBind()
		Session("NowFolderDSvb")=DS
		Folder.SelectedIndex = NowIndex
	end sub
	Function DeleteSubFolder(FID as string) as integer
		Dim DS as DataSet =Ctype(Session("NowFolderDSvb"),DataSet)
		Dim p as integer=0
		Dim i as integer=0
		try
		for i =DS.Tables("Folders").Rows.Count-1 to 0 step -1
			if DS.Tables("Folders").Rows(i)("ParentID").ToString()=FID then
				DS.Tables("Folders").Rows.RemoveAt(i)
				p+=1
			end if
		next
		return p
		catch
		return -1
		end try
	end function
	Function GetLevel(SID as string) as integer
		dim k as integer=0
		dim k1 as integer=0
		k = SID.IndexOf(".")
		if k <> 0  then
        		do 
				k1 += 1
				k = SID.IndexOf(",",k + 1)
				if k<=0 then exit do
 			loop
		end if
		return k1
	end function
	function GetFullFDName(NowFolderID as string) as string
		Dim FD as string =""
		dim NowCompare as integer=Convert.ToInt32(NowFolderID)
		do
			dim re as SqlCommand = new SqlCommand()
			re.Connection=Source
			re.CommandText="Exec GetFDName @NowPID=" & NowCompare
			re.CommandType = CommandType.Text
			dim kx as SqlDataReader
			re.Connection.Open()
			kx=re.ExecuteReader()
			do until kx.Read()=false
				FD= kx.GetString(0) & "\" & FD
				NowCompare=kx.GetInt32(2)
				exit do
			loop
			re.Connection.Close()
			if NowCompare=0 then exit do
		loop
		return FD
	end function
	sub Folder_CancelCommand(sender as object,e as DataListCommandEventArgs)
		Folder.EditItemIndex = -1
		FolderBind(false)
	end sub
	sub Folder_UpdateCommand(sender as object,e as DataListCommandEventArgs)
		Dim dL as DataList = Folder
		Dim FDN as TextBox =Ctype(e.Item.FindControl("FDName"),TextBox)
		if FDN.Text = "" then
			Folder.EditItemIndex = -1
			FolderBind(false)
			exit sub
		end if
		dim t1 as integer = dL.SelectedIndex
		dim NowFolder1 as integer = Convert.ToInt32(dL.DataKeys(dL.SelectedIndex).ToString())
		Dim DS as DataSet =Ctype(Session("NowFolderDSvb"),DataSet)
		Dim Row as DataRow = DS.Tables("Folders").Rows.Find(NowFolder1)
		Dim Orgin as string= Row("FDName").ToString()
		if Orgin = FDN.Text then
			dL.EditItemIndex = -1
			FolderBind(false)
		else
			dim p as string=NowPath.Text
			dim Leng as integer = p.Length
			dim h as string = p.Substring(0,Leng-2)
			dim pos as integer = p.LastIndexOf(Orgin)'取得最右边\的位置
			if pos = Leng then
				pos = pos-1
			end if
			dim NPath as string = p.Substring(0,pos-1)'取得去掉目前路径的路径
			dim NowFolder as string=NPath & "\" & FDN.Text
			dim FDName as string= FDN.Text
			dim s2 as Label = Ctype(e.Item.FindControl("errSamFolder"),Label)
			dim m as string=Request.PhysicalPath
			m=m.Substring(0,m.Length-12) & "\"
			Dim FDExist as Boolean= Directory.Exists(m)
			if FDExist = true then
				s2.Visible = true
				s2.Text="Error, target path already exists."
			else
				Directory.Move(m + NowPath.Text,m + NowFolder)
				NowPath.Text = NowFolder
				ShowPath.Text = NowFolder
				s2.Visible = false
				dL.EditItemIndex = -1
				Dim DSx as DataSet = new DataSet()
				try
					Dim COmm as SqlDataAdapter = new SqlDataAdapter("select * from Folders where FID = " + NowFolder1 ,Source)
					Comm.Fill(DSx,"Folders")
					DSx.Tables("Folders").Rows(0)("FDName")=FDName
					dim custCB as SqlCommandBuilder = new SqlCommandBuilder(Comm)
					Comm.Update(DS,"Folders")
					Row("FDName")=FDN.Text
				catch
					s2.Visible=true
					s2.Text="Error, fail to update record."
				end try
				dim dv as DataView = DS.Tables("Folders").DefaultView
				dv.Sort = "SortID"
				dL.DataSource = dv
				dL.DataBind()
			end if
		end if
	end sub
	sub FolderBind(tag as Boolean)
		dim dv as DataView
		if tag=true then
			dim DS as DataSet = GetDS()
			dv=DS.Tables("Folders").DefaultView
		else
			Dim DS as DataSet =Ctype(Session("NowFolderDSvb"),DataSet)
			dv = DS.Tables("Folders").DefaultView
		end if
		dv.Sort = "SortID"
		Folder.DataSource = dv
		Folder.DataBind()
	end sub
	public function custCount(y as string) as string
		dim z as integer =Convert.ToInt32(y)
		dim d1 as string =""
		dim i as integer=0
		for i= 0 to z
			d1+="　"
		next
		return d1
	end function
	function TestDesNull(Des as string) as string
		if Des.IndexOf("%")>1 then
			return Des.Substring(0,Des.Length-1)
		else
			return ""
		end if
	end function
	Function ExecActionQuery(ustring as string) as Boolean
		try
			Dim InCmdExec as SqlCommand = new SqlCommand(ustring,Source)
			InCmdExec.Connection.Open()
			InCmdExec.ExecuteNonQuery()
			InCmdExec.Connection.Close()
			return true
		catch
			return false
		end try
	end function
	sub Rename_Click(sender as object,e as EventArgs)
		dim NowLevel as Label=Ctype(Page.FindControl("NowLevel"),Label)
			Dim dL as DataList = Folder
			dL.EditItemIndex = dL.SelectedIndex
			dim DS as DataSet=Ctype(Session("NowFolderDSvb"),DataSet)
			dim dv as DataView = DS.Tables("Folders").DefaultView
			dv.Sort="SortID"
			dL.DataSource=dv
			dL.DataBind()
	end sub
	sub ShowAll_Click(sender as object,e as EventArgs)
		dim dL as DataList =Folder
		dim FID as integer=0
		if dl.SelectedIndex > -1 then
			FID = Convert.ToInt32(dl.DataKeys(dl.SelectedIndex).ToString())
		end if
		dim DS as DataSet =GetDS()
		dim j as string ="select * from Folders where LevelID > 1 Order by SortID"
		Dim Comm as SqlDataAdapter= new SqlDataAdapter(j,Source)
		Dim DS1 as DataSet =new DataSet()
		Comm.Fill(DS1,"Folders")
		DS1.Merge(DS.Tables("Folders"))
		Session("NowFolderDSvb") = DS1''data.dataset
		Dim dv as DataView = DS1.Tables("Folders").DefaultView
		dv.Sort="SortID"
		dl.DataSource=dv
		dl.DataBind()
	end sub
	Function GetDS() as DataSet 
		dim j as string="select * from Folders where LevelID =1 Order by SortID"
		dim Comm as SqlDataAdapter = new SqlDataAdapter(j,Source)
		Dim DS as DataSet= new DataSet()
		Comm.Fill(DS, "Folders")'以下为建立主索引
		Dim PrimaryKeyColumns(1) as DataColumn'=new DataColumn(0)
		PrimaryKeyColumns(0) = DS.Tables("Folders").Columns("FID")
		DS.Tables("Folders").PrimaryKey = PrimaryKeyColumns
		Session("NowFolderDSvb") = DS
		return DS
	end function
	sub CloseAll_Click(sender as object,e as EventArgs)
		FolderBind(true)
	end sub
	sub Short_Click(sender as object,e as EventArgs)
		if NowLevel.Text="" then
			return
		end if
		ShortCutVisible(false)
		NewShortDoc.Text = ShowPath.Text
		dim x as string =ShowPath.Text
		dim NowPathString as string= x.Substring(0,x.Length-2)
		dim d as integer = NowPathString.LastIndexOf("\")
		NewShortCut.Text = NowPathString.Substring(d+1,NowPathString.Length-d-2)
	end sub
	sub ShortCutVisible(tag as Boolean)
'		Short.Visible=tag
		allShortcut.Visible=tag
		ReplaceYes.Visible=tag
		ReplaceNo.Visible=tag
		if tag=false then
			GetShortcut.Visible= true
			CELNewShort.Visible= true
		else
			GetShortcut.Visible= false
			CELNewShort.Visible= false
		end if
		ReplaceQu.Visible=tag
	end sub
	sub Upload_Click(sender as object,e as EventArgs)
		if Folder.SelectedIndex<>-1 then
			UploadFile.Visible=true
			GetShortcut.Visible=false
		end if
	end sub
	function GetFString(s as string,f as string) as string
		try
			dim DS as DataSet = new DataSet()
			dim tbName, strRe as string
			dim Comm as SqlDataAdapter = new SqlDataAdapter(s, Source)
	                tbName = "tmpTable"
			Comm.Fill(DS, tbName)
			strRe = DS.Tables(tbName).Rows(0)(f).ToString()
			return strRe
		catch
			return ""
		end try
	end function
	sub allShortcut_Changed(sender as object,e as EventArgs)
		dim ShortCutFID as string= allShortcut.SelectedItem.Value
		dim ShortCutPath as string=GetFullFDName(ShortCutFID)
		dim ParentID as string=""
		dim NowLevelID as integer=0
		dim CompareFID as integer= Convert.ToInt32(ShortCutFID)
		Dim DS as DataSet = GetDS()
		dim p as integer=0
		dim SID as string = GetFString("Select * from Folders where FID =" & ShortCutFID, "SortID")
		LabSortID.Text = SID
		LabFID.Text = ShortCutFID
		dim NowAllPath as string= GetFullFDName(ShortCutFID)
		NowPath.Text = NowAllPath
		dim i as integer =0
		dim DS1 as DataSet =new DataSet()
		NowLevelID = Convert.ToInt32(GetFString("select * from Folders where FID =" & CompareFID,"LevelID"))
		do
			NowLevelID = Convert.ToInt32(GetFString("select * from Folders where FID =" & CompareFID,"LevelID"))
			ParentID = GetFString("select * from Folders where FID =" + CompareFID,"ParentID")
			CompareFID = Convert.ToInt32(ParentID)
			dim j as string ="select * from Folders where ParentID =" & ParentID & " Order by SortID"
			dim Comm as SqlDataAdapter = new SqlDataAdapter(j,Source)
			Comm.Fill(DS1,"Folders")
			DS.Merge(DS1.Tables("Folders"))
			if ParentID = "0" then
				exit do
			end if
		loop
		Session("NowFolderDSvb") = DS
		NowLevel.Text = GetFString("select * from Folders where FID =" & ShortCutFID,"LevelID")
		dim dv as DataView = DS.Tables("Folders").DefaultView
		dv.Sort = "SortID"
		Folder.DataSource = dv
		Folder.DataBind()
		dim c as integer=0
		for c=0 to dv.Count-1
			if dv(c)("LevelID").ToString() = "1" then
				ShowPath.Text = dv(c)("Description").ToString()
			else
				ShowPath.Text += "\" & dv(c)("Description").ToString()
			end if
			if dv(c)("FID").ToString() = ShortCutFID then
				Folder.SelectedIndex = c
				exit for
			end if
		next
		Folder.DataBind()
		DocumentBind(true)
		allShortcut.SelectedIndex = 0
	end sub
	sub allShortcutBind(tag as Boolean)
		dim ddL as DropDownList =allShortcut
		dim strComm as string  = "select * from ProjShortcut where Description = '-- Select a shortcut --' or id > 1 order by id"
		dim Comm as SqlDataAdapter = new SqlDataAdapter(strComm,Source)
		dim DS as DataSet = new DataSet()
		Comm.Fill(DS, "AllShort")
		allShortcut.DataSource=DS.Tables("AllShort").DefaultView
		allShortcut.DataValueField="ShortCutFID"
		allShortcut.DataTextField="Description"
		allShortcut.DataBind()
	end sub
	sub ReplaceYesClick(sender as object,e as EventArgs)
		dim ReplaceS as string=""
		ReplaceS="Update ProjShortCut Set ShortCutFID=" & Folder.DataKeys(Folder.SelectedIndex).ToString() & " where Description ='" & NewShortCut.Text & "'"
		dim x as Boolean =ExecActionQuery(ReplaceS)
		ShortCutVisible(true)
		allShortcutBind(true)
	end sub
	sub OKNewShortClick(sender as object,e as EventArgs)
		dim DS as DataSet = new DataSet()
		dim Comm as SqlDataAdapter = new SqlDataAdapter("select * from ProjShortCut where Description = '" + NewShortCut.Text + "'",Source)
		Comm.Fill(DS,"ShortCut")
		if DS.Tables("ShortCut").Rows.Count>0 then
			ReplaceYesVo(true)
		else
			dim AddNewS as string=""
			dim x as string =ShowPath.Text
			x.Substring(0,x.Length-1)
			AddNewS = "Insert Into ProjShortCut (ShortCutFID,Description,ShortCutPath) values (" & Folder.DataKeys(Folder.SelectedIndex).ToString() & ",'" & NewShortCut.Text & "','" & x & "')"
			dim y as Boolean =ExecActionQuery(AddNewS)
			if y=true then
				ShortCutVisible(true)
				allShortcutBind(true)
			end if
		end if
	end sub
	sub ReplaceNoClick(sender as object ,e as EventArgs)
		ReplaceYesVo(false)
	end sub
	sub ReplaceYesVo(tag as Boolean)
		if tag=false then
			CELNewShort.Visible=true
		else
			CELNewShort.Visible=false
		end if
		ReplaceYes.Visible=tag
		ReplaceNo.Visible=tag
		ReplaceQu.Visible=tag
	end sub
	sub CELNewShortClick(sender as object, e as EventArgs)
		ShortCutVisible(true)
	end sub
	sub ExecUpload_Click(sender as object,e as EventArgs)
		if UpFile.PostedFile is nothing then
		else
			dim FN as string =""
			dim m as string=Request.PhysicalPath
			m=m.Substring(0,m.Length-12) & "\"
				dim QuString as string=""
			try
				dim x as string =UpFile.PostedFile.FileName
				dim y as integer=x.LastIndexOf("\")
				FN = x.Substring(y+1,x.Length-y-1)
				UpFile.PostedFile.SaveAs(m & NowPath.Text & "\" & FN)
				dim saveRes as Boolean
				dim ReplaceFile as Boolean
				dim g as string=GetFString("select * from ProjDocuments where FID =" & Folder.DataKeys(Folder.SelectedIndex).ToString() & " and DocuName = '" & FN & "'", "DID")
				dim strT as string = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
				if g <> "" then
					QuString = "Update ProjDocuments Set Description = '" & Filedes.Text & "', Size = " & UpFile.PostedFile.ContentLength & ", UploadDate = '" & strT & "' Where FID = " & LabFID.Text & " and DocuName = '" & FN & "'"
				else
					QuString = "Insert into ProjDocuments (DocuName,FID,Size,Description,UploadDate,Location) values ( '" & FN & "'," & LabFID.Text & "," & UpFile.PostedFile.ContentLength & ",'" & Filedes.Text & "','" & strT & "','" & ShowPath.Text & "')"
				end if
				dim SaveToD as Boolean =ExecActionQuery(QuString)
				if SaveToD=true then
					Span1.InnerHtml="完成上传至" & ShowPath.Text & FN & "<br>上传大小：" & UpFile.PostedFile.ContentLength & "字节数"
				else
					Span1.InnerHtml=QuString & "保存失败"
				end if
				errLabel1.Visible=true
				dim stID as string =GetFString("select * from Folders Where FID =" & Folder.DataKeys(Folder.SelectedIndex).ToString(),"SortID")
				ClickShow(Folder.DataKeys(Folder.SelectedIndex).ToString() & "-" & stID, Folder.SelectedIndex)
			catch j as Exception
				Span1.InnerHtml=j.ToString()+ QuString'm + ShowPath.Text + FN + "，可能路径不存在或未选择文件<br>"
				errLabel1.Visible=true
			end try
		end if
	end sub
	sub CancelUpLoad_Click(sender as object,e as EventArgs)
		UploadFile.Visible = false
	end sub
	sub DocumentBind(tag as Boolean)
		dim dg as DataGrid =Document
		if tag=true then
			dim DS as DataSet =new DataSet()
			dim Comm as SqlDataAdapter = new SqlDataAdapter("select * from ProjDocuments where FID =" & Folder.DataKeys(Folder.SelectedIndex).ToString(),Source)
			Comm.Fill(DS,"Documents")
			dg.DataSource=DS.Tables("Documents").DefaultView
			Session("DocuDS")=DS
		else
			dim DS as DataSet=Ctype(Session("DocuDS"),DataSet)
			dg.DataSource=DS.Tables("Documents").DefaultView
		end if
		dg.DataBind()
	end sub
	sub CreateFolder_Click(sender as object, e as EventArgs)
		if Folder.SelectedIndex<>-1 then
			FolderC.Visible=true
		end if
	end sub
	sub CreateOKClick(sender as object,e as EventArgs)
		dim m as string=Request.PhysicalPath
		m=m.Substring(0,m.Length-12) & "\"
		if Directory.Exists(m & NowPath.Text & NewFolderName.Text)=true then
			errLabel.Visible=true
			errLabel.Text="路径已存在"
			return
		else
			errLabel.Visible=false
		end if
			Directory.CreateDirectory(m & NowPath.Text & NewFolderName.Text)
			dim sid as string = LabSortID.Text & "."
			dim FolderMaxSortID as integer= GetMaxGroupFDName(Convert.ToInt32(LabFID.Text), sid)
			dim ParID as integer= FolderMaxSortID + 1
			dim Nowlevel1 as integer= GetLevel(LabSortID.Text)
			dim InCmd1 ,k1,k2 as string
			InCmd1 = "insert into Folders (FDName,ParentID,SortID,LevelID) Values ('" & NewFolderName.Text & "'," & LabFID.Text & ",'" & LabSortID.Text & "." & (FolderMaxSortID + 1).ToString() & "'," & Convert.ToInt32(Nowlevel1+2) & ")"
			dim b as Boolean =ExecActionQuery(InCmd1)
			if b=true then
				FolderC.Visible = false
				dim NV as string = NowLevel.Text
				dim l1 as string = LabSortID.Text
				dim l2 as string = LabFID.Text
				dim FolderMaxID as integer=Convert.ToInt32(GetFString("select Max(FID) as fd from Folders","fd"))
				ClickShow((FolderMaxID + 1).ToString() & "-" & LabSortID.Text,Folder.SelectedIndex)
				NowLevel.Text = NV
				LabSortID.Text = l1
				LabFID.Text = l2
				NewFolderName.Text = ""
			else

			end if
	end sub
	sub CelClick(sender as object,e as EventArgs)
		FolderC.Visible=false
	end sub
	function GetMaxGroupFDName(PID as integer,SID as string) as integer
		dim FD as integer= 0
		dim re as SqlCommand= new SqlCommand()
		re.Connection=Source
		re.CommandText="Exec GetSortMaxID @NowPID=" & PID & ",@NowSID ='" & SID & "'"
		re.CommandType = CommandType.Text
		dim kx as SqlDataReader
		re.Connection.Open()
		kx=re.ExecuteReader()
		do until kx.Read()=false
			FD=kx.GetInt32(1)
			exit do
		loop
		re.Connection.Close()
		return FD
	end function
</script>
<link rel=stylesheet type="Text/css" href="style.css">
<body background="../../../images/winback.gif">
<form id="doc" enctype="multipart/form-data" runat="server">
<ASP:label ID="err" Runat="Server" Visible=false />
<asp:panel id="gData" runat="server" >
SQL服务器名称：<ASP:TextBOX Text="Localhost" runat="server" id="SQLServer" /><br>
登录ID：<ASP:TextBOX Text="sa" runat="server" id="uid" /><br>
密码：<ASP:TextBOX Runat="server" TextMode="Password" id="Password" /><ASP:button Text="OK" Runat="server" onclick="OKClick" /><br>
</asp:panel>
<asp:panel id="diss" visible="false" runat="server" >
	<ASP:label ID="rr" Runat="Server" Visible=false />
	<ASP:label ID="NowPath" Runat="Server" Visible=false />
	<ASP:label ID="ShowPath"  Runat="Server" Visible=false />
	<asp:label id="NowLevel" runat="server" visible=false />
	<asp:Label id=LabFID runat="server" Visible=false ></asp:Label>
	<asp:Label id=LabSortID runat="server" Visible=false ></asp:Label><br>
	<asp:Linkbutton cssclass="Tab_Btn_1" Runat="server" id="ShowAll" Text="ShowAll" OnClick="ShowAll_Click" />
	<asp:Linkbutton cssclass="Tab_Btn_1" Runat="server" id="CloseAll" Text="CloseAll" OnClick="CloseAll_Click" />
	<asp:Linkbutton cssclass="Tab_Btn_1" Runat="server" id="Rename" Text="更名" OnClick="Rename_Click" />
<asp:Linkbutton cssclass="Tab_Btn_1" Runat="server" id="CreateFolder" Onclick="CreateFolder_Click" Text="添加文件夹" /> 
	<asp:Linkbutton cssclass="Tab_Btn_1" Runat="server" id="Upload" Text="上传" OnClick="Upload_Click" />
	<asp:Linkbutton cssclass="Tab_Btn_1" Runat="server" id="Short" Text="建立快捷方式" OnClick="Short_Click" />
	<asp:Dropdownlist id="allShortcut" onselectedindexchanged="allShortcut_Changed" autopostback="True" runat="server" />
<asp:Panel  id="FolderC" runat="server"  visible="false" >
										<table cellspacing="1" cellpadding="5"  border=0 >
			 							   <tr>
		    								    <td align="left" class="Tab_IP8_4">
													<asp:label id="ShowPathInFolderC" runat="Server" />
　													<br><b><asp:Label id=LabEnterNewFolderName runat="server" />输入新文件夹名称：</b>
　													<asp:Textbox columns="25" ID="NewFolderName" Runat="server" /><br>
		    								    </td>
		   								   </tr>
			 							   <tr>
		    								    <td align="center" class="Tab_IP8_2">						
　													<asp:Button Width="50px" height="18" ID="OK" Text="Save" cssclass="Tab_Btn_0" Onclick="CreateOKClick" Runat="server" />
													<asp:Button Width="50px" height="18" Text="Cancel" cssclass="Tab_Btn_0" Onclick="CelClick" ID="cel" Runat="server" />
													<br><asp:Label id=errLabel visible=false runat="server"></asp:Label>
		    								    </td>
		   								   </tr>
										</table>　 				
</asp:Panel>
<asp:Panel id="UploadFile" runat="server" visible="false">
										<table cellspacing="1" cellpadding="5"  border=0 >
			 							   <tr>
		    								    <td align="left" class="Tab_IP8_4">
													<ASP:label ID="ShowPathInUploadFile" Runat="Server" />
　													<br><b><asp:Label id=LabFileDirectory1 runat="server" />指定文件：</b>
　													<input id="UpFile" type=file runat="server" size="25">
		    								    </td>
		   								   </tr>
			 							   <tr>
		    								    <td align="left" class="Tab_IP8_4">	
													<b><asp:Label id=LabDescription runat="server" />摘要：</b>
													<asp:Textbox id="Filedes" runat="server" size="30" />
		    								    </td>
		   								   </tr>
			 							   <tr>
		    								    <td align="left" class="Tab_IP8_2">
													<asp:Button cssclass="Tab_Btn_0" Width="80px" height="20" id="Button1" Text="Upload" OnClick="ExecUpload_Click" Runat="server" />
													<asp:Button cssclass="Tab_Btn_0" Width="50px" height="20" Onclick="CancelUpLoad_Click" Text="Cancel" ID="cel1" Runat="server" /><br>
													<span id=Span1 style="font: 9pt verdana" runat="server" />
													<asp:Label id=errLabel1 visible=False runat="server"></asp:Label>
		    								    </td>
		   								   </tr>
										</table>　
</asp:Panel>
	<asp:panel id="GetShortcut" runat="server" Width="400px" cssclass="Tab_IP3_4" font-size="10" BorderWidth="0" visible="false">
					<table cellspacing="1" CellPadding="5" border=0 class="Tab_IP3_4" width="100%">
			 					<tr>
			    					<td align="center" class="Tab_IP8_2">
										<asp:Label id="LabAddShortCut" runat="server" />
			    					</td>  			 
			 					</tr>
			  					<tr>
			    					<td align="left" class="Tab_IP8_4"> 
										<asp:Label id="LabCurrentFolder" runat="server" />：<asp:label id="NewShortDoc" runat="server" /><br>
										<asp:Label id="LabEnterShortCutName" runat=server />：<asp:Textbox id="NewShortCut" runat="server" />
			    					</td>  			 
			 					</tr>
			  					<tr>
			    					<td align="center" class="Tab_IP8_2"> 
										<asp:linkbutton cssclass="Tab_Btn_2" id="OKNewShort" runat="server" onclick="OKNewShortClick"  Text="Save" />
										<asp:label Text="输入之捷径名称已存在，是否要取代?" id="ReplaceQu" runat="server" visible="False" />
										<asp:linkbutton cssclass="Tab_Btn_2" id="ReplaceYes" runat="server" onclick="ReplaceYesClick" Text="Yes" Visible="False"  />
										<asp:linkbutton cssclass="Tab_Btn_3" id="ReplaceNo" runat="server" onclick="ReplaceNoClick" Text="No(重新输入)" Visible="False" />
										<asp:linkbutton cssclass="Tab_Btn_3" id="CELNewShort" runat="server" onclick="CELNewShortClick" Text="Cancel" />

									</td>
								</tr>
							</table>

	</asp:Panel>

	<asp:datalist id=Folder runat="server" 
		datakeyfield="FID"
		ForeColor="white"	
		CellPadding="1"
		CellSpacing="1"
		Font-Size="11pt"
		HeaderStyle-font-bold="True"
		OnItemCommand="Folder_ItemCommand"
		OnUpdateCommand="Folder_UpdateCommand"
		OnCancelCommand="Folder_CancelCommand"
	>
		<itemtemplate>
			<%# custCount(DataBinder.Eval(Container.DataItem,"LevelID").ToString()) %>
			<asp:linkbutton cssclass="Lnk_IP3_1" id=Linkbutton1  runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FDName", "{0}") %>' 
    			CommandArgument='<%# DataBinder.Eval(Container.DataItem,"FID") & "-" & DataBinder.Eval(Container.DataItem,"SortID")%>'  CommandName="Select" >
		</asp:linkbutton>
		<span id="en" runat="server" />
		</itemTEMPLATE>
		<selecteditemtemplate>
			<%# custCount(DataBinder.Eval(Container.DataItem,"LevelID").ToString()) %>
			<asp:linkbutton Font-Bold  cssclass="Lnk_IP3_3" id=Linkbutton2  runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FDName", "{0}") %>' 
	    			CommandArgument='<%# DataBinder.Eval(Container.DataItem,"FID") & "-" & DataBinder.Eval(Container.DataItem,"SortID")%>' CommandName="Select" >
			</asp:linkbutton>
			</selecteditemTEMPLATE>
		<EditItemTemplate>
			<%# custCount(DataBinder.Eval(Container.DataItem,"LevelID").ToString()) %>
			<asp:Label BackColor="lightyellow" cssclass="Lnk_IP3_1" runat="server" Text='<%# "原始名称：" + DataBinder.Eval(Container.DataItem,"FDName") %>' /><br>
			<%# custCount(DataBinder.Eval(Container.DataItem,"LevelID").ToString()) %>
			<asp:Textbox BackColor="lightyellow" id="FDName" columns="10" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"FDName") %>' /><br>
			<%# custCount(DataBinder.Eval(Container.DataItem,"LevelID").ToString()) %>
			<asp:label id="errSamFolder" foreColor="red" runat="server" />
			<asp:LinkButton cssclass="Tab_Btn_2" id="button2" runat="server" Text="Save" CommandName="Update" />
			<asp:LinkButton cssclass="Tab_Btn_3" id="button3" runat="server" Text="Cancel" CommandName="Cancel" /><br>
			</EditItemtemplate>　
	</asp:datalist>
<hr>
									<ASP:DataGrid id="Document" runat="server"
										width="100%"
									    	BorderColor="white"
									   	BorderWidth="0"
									   	GridLines="Both"
										datakeyfield="DID"
									   	CellPadding="0"
										itemstyle-height="8"
									   	CellSpacing="0"
									   	Font-Name="Verdana"
									   	Font-Size="10pt"
										AlternatingItemStyle-BackColor="lightyellow"
										ShowHeader="true"
										HeaderStyle-font-bold="True"
										HeaderStyle-BackColor="#dcdcdc"
										AutoGenerateColumns="false"
									>
										<Columns>
											<asp:TemplateColumn ItemStyle-Width="3%">
											</asp:TemplateColumn>
											<asp:TemplateColumn ItemStyle-Width="40%">
												<HeaderTemplate>
													文件名
												</Headertemplate>
												<ItemTemplate>
													<asp:HyperLink Text='<%# DataBinder.Eval(Container.DataItem, "DocuName") %>' 
														NavigateUrl='<%# GetFDName(DataBinder.Eval(Container.DataItem, "FID").ToString(),DataBinder.Eval(Container.DataItem, "DocuName").ToString())%>'
														Target="_blank" Runat="server" />
												</Itemtemplate>
											</asp:TemplateColumn>

　											<asp:TemplateColumn ItemStyle-Width="12%">
												<HeaderTemplate>
													大小
												</Headertemplate>
												<ItemTemplate>
													<%# DataBinder.Eval(Container.DataItem,"Size","{0}") %>
												</Itemtemplate>
											</asp:TemplateColumn>

											<asp:TemplateColumn ItemStyle-Width="20%">
												<HeaderTemplate>
													建立日期
												</Headertemplate>
												<ItemTemplate>
													<%# DataBinder.Eval(Container.DataItem,"UploadDate","{0:yy/MM/dd HH:mm}") %>
												</Itemtemplate>
											</asp:TemplateColumn>
				        				</Columns>　
									</ASP:DataGrid>
</asp:panel>
</form>
</body>
