<%@Page Language="C#" EnableSessionState=true Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.WEB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="c#" runat="server">
	SqlConnection Source;
	void Page_Load(object sender, EventArgs e){
		if(Session["NowFolder"]==null){
			gData.Visible=true;
			diss.Visible=false;
		}
		else{
			Source = (SqlConnection)Session["NowFolder"];
		}
	}
	void OKClick(object sender,EventArgs e){
		if(SQLServer.Text!=""){
			string f="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服务器名称";
		}
	}
	public string GetFDName(string FID,string fileName){
		string FD =GetFullFDName(FID);
		string m=Request.PhysicalPath;
		m=m.Substring(0,m.Length-12)+"\\";
		return "\\ASPNETData\\Ch14\\14-3\\cs\\" + FD + fileName;
	}
	void Folder_ItemCommand(object sender,DataListCommandEventArgs e){
		if(e.CommandName == "Select" ){
			string h=e.CommandArgument.ToString();
			int x=h.IndexOf("-");//切割处理
			string FID= h.Substring(0,x);
			string NowAllPath =GetFullFDName(FID);//取得完整路径
			Folder.SelectedIndex = e.Item.ItemIndex;
			Folder.EditItemIndex = -1;
			NowPath.Text = NowAllPath;//写入至小抄
			ShowPath.Text = NowAllPath;
			ClickShow(e.CommandArgument.ToString(), e.Item.ItemIndex);
			string SID= h.Substring(x+1,h.Length-x-2);
			int k = GetLevel(SID);
		}
	}
	void ClickShow(string NowCommand,int NowIndex){
		int x=NowCommand.IndexOf("-");
		string SID= NowCommand.Substring(x+1,NowCommand.Length-x-1);
		string FID = NowCommand.Substring(0,x);//切割字符串
		DataSet DS;//第一个DataSet
		DS=(DataSet)Session["NowFolderDS"];
		LabSortID.Text=SID;//写入至小抄
		LabFID.Text=FID;
		DataSet DS1=new DataSet();//第二个DataSet
		int z =DeleteSubFolder(FID);
		Folder.SelectedIndex = NowIndex;
		string j="select * from Folders where ParentID =" + Folder.DataKeys[NowIndex] + " Order by SortID";
		SqlDataAdapter Comm = new SqlDataAdapter(j,Source);
		Comm.Fill(DS1,"Folders");
		if(z==0){
			DS.Merge(DS1.Tables["Folders"]);
		}
		int k=GetLevel(SID);
		NowLevel.Text=k.ToString(); //目前level
		DocumentBind(true);
		DataView dv =DS.Tables["Folders"].DefaultView;
		dv.Sort="SortID";
		Folder.DataSource=dv;
		Folder.DataBind();
		Session["NowFolderDS"]=DS;
		Folder.SelectedIndex = NowIndex;
	}
	int DeleteSubFolder(string FID){
		DataSet DS =(DataSet)Session["NowFolderDS"];
		int p=0;
		try{
		for(int i =DS.Tables["Folders"].Rows.Count-1 ; i >=0;i--){
			if(DS.Tables["Folders"].Rows[i]["ParentID"].ToString()==FID){
				DS.Tables["Folders"].Rows.RemoveAt(i);
				p+=1;
			}
		}
		return p;
		}
		catch(Exception f){
		return -1;
		}
	}
	int GetLevel(string SID){
	    int k=0;
	   int k1=0;
	    k = SID.IndexOf(".");
	    if(k != 0 ){
        	do{
	            k1 += 1;
        	    k = SID.IndexOf(",",k + 1);
        	}while(k>0);
	    }
	    return k1;
	}
	string GetFullFDName(string NowFolderID){
		string FD="";
		int NowCompare=Convert.ToInt32(NowFolderID);
		do{
			SqlCommand re = new SqlCommand();
			re.Connection=Source;
			re.CommandText="Exec GetFDName @NowPID=" + NowCompare;
			re.CommandType = CommandType.Text;
			SqlDataReader kx;
			re.Connection.Open();
			kx=re.ExecuteReader();
			while(kx.Read()){
				FD= kx.GetString(0) + "\\" + FD;
				NowCompare=kx.GetInt32(2);
				break;
			}
			re.Connection.Close();
		}while(NowCompare>0);
		return FD;
	}
	void Folder_CancelCommand(object sender,DataListCommandEventArgs e){
		Folder.EditItemIndex = -1;
		FolderBind(false);
	}
	void Folder_UpdateCommand(object sender,DataListCommandEventArgs e){
		DataList dL = Folder;
		TextBox FDN=(TextBox)e.Item.FindControl("FDName");
		if(FDN.Text == ""){
			Folder.EditItemIndex = -1;
			FolderBind(false);
			return;
		}
		int t1 = dL.SelectedIndex;
		int NowFolder1 = Convert.ToInt32(dL.DataKeys[dL.SelectedIndex].ToString());
		DataSet DS=(DataSet)Session["NowFolderDS"];
		DataRow Row = DS.Tables["Folders"].Rows.Find(NowFolder1);
		string Orgin= Row["FDName"].ToString();
		if(Orgin == FDN.Text){
			dL.EditItemIndex = -1;
			FolderBind(false);
		}
		else{
			string p=NowPath.Text;
			int Leng = p.Length;
			string h = p.Substring(0,Leng-2);
			int pos = p.LastIndexOf(Orgin);//取得最右边\的位置
			if(pos == Leng){
				pos = pos-1;
			}
			string NPath = p.Substring(0,pos-1);//取得去掉目前路径的路径
			string NowFolder =NPath + "\\" + FDN.Text;
			string FDName= FDN.Text;
			Label s2 = (Label)e.Item.FindControl("errSamFolder");
//			string w=Request.PhysicalApplicationPath + "ProjectRoot\\" + NowFolder;
			string m=Request.PhysicalPath;
			m=m.Substring(0,m.Length-12)+"\\";
			Boolean FDExist = Directory.Exists(m);
			if(FDExist == true){
				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;
				DataSet DSx = new DataSet();
				try{
					SqlDataAdapter Comm = new SqlDataAdapter("select * from Folders where FID = " + NowFolder1 ,Source);
					Comm.Fill(DSx,"Folders");
					DSx.Tables["Folders"].Rows[0]["FDName"]=FDName;
					SqlCommandBuilder custCB = new SqlCommandBuilder(Comm);
					Comm.Update(DS,"Folders");
					Row["FDName"]=FDN.Text;
				}
				catch{
					s2.Visible=true;
					s2.Text="Error, fail to update record.";
				}
				DataView dv = DS.Tables["Folders"].DefaultView;
				dv.Sort = "SortID";
				dL.DataSource = dv;
				dL.DataBind();
			}
		}
	}
	void FolderBind(Boolean tag){
		DataView dv;
		if(tag==true){
			DataSet DS = GetDS();
			dv=DS.Tables["Folders"].DefaultView;
		}
		else{
			DataSet DS=(DataSet)Session["NowFolderDS"];
			dv = DS.Tables["Folders"].DefaultView;
		}
		dv.Sort = "SortID";
		Folder.DataSource = dv;
		Folder.DataBind();
	}
	public string custCount(string y){
		int z=Convert.ToInt32(y);
		string d1="";
		for(int i= 0 ; i <= z;i++){
			d1+="　";
		}
		return d1;
	}
	string TestDesNull(string Des){
		if(Des.IndexOf("%")>1){
			return Des.Substring(0,Des.Length-1);
		}
		else{
			return "";
		}
	}
	Boolean ExecActionQuery(string ustring){
		try{
			SqlCommand InCmdExec = new SqlCommand(ustring,Source);
			InCmdExec.Connection.Open();
			InCmdExec.ExecuteNonQuery();
			InCmdExec.Connection.Close();
			return true;
		}
		catch{
			return false;
		}
	}
	void Rename_Click(object sender,EventArgs e){
		Label NowLevel=(Label)Page.FindControl("NowLevel");
			DataList dL = Folder;
			dL.EditItemIndex = dL.SelectedIndex;
			DataSet DS=(DataSet)Session["NowFolderDS"];
			DataView dv = DS.Tables["Folders"].DefaultView;
			dv.Sort="SortID";
			dL.DataSource=dv;
			dL.DataBind();
	}
	void ShowAll_Click(object sender,EventArgs e){
		DataList dl=Folder;
		int FID =0;
		if(dl.SelectedIndex > -1){
			FID = Convert.ToInt32(dl.DataKeys[dl.SelectedIndex].ToString());
		}
		DataSet DS=GetDS();
		string j="select * from Folders where LevelID > 1 Order by SortID";
		SqlDataAdapter Comm = new SqlDataAdapter(j,Source);
		DataSet DS1=new DataSet();
		Comm.Fill(DS1,"Folders");
		DS1.Merge(DS.Tables["Folders"]);
		Session["NowFolderDS"] = DS1;//'data.dataset
		DataView dv = DS1.Tables["Folders"].DefaultView;
		dv.Sort="SortID";
		dl.DataSource=dv;
		dl.DataBind();
	}
	DataSet GetDS(){
		string j="select * from Folders where LevelID =1 Order by SortID";
		SqlDataAdapter Comm = new SqlDataAdapter(j,Source);
		DataSet DS = new DataSet();
		Comm.Fill(DS, "Folders");//以下为建立主键
		DataColumn[] PrimaryKeyColumns=new DataColumn[1];
		PrimaryKeyColumns[0] = DS.Tables["Folders"].Columns["FID"];
		DS.Tables["Folders"].PrimaryKey = PrimaryKeyColumns;
		Session["NowFolderDS"] = DS;
		return DS;
	}
	void CloseAll_Click(object sender,EventArgs e){
		FolderBind(true);
	}
	void Short_Click(object sender,EventArgs e){
		if(NowLevel.Text==""){
			return;
		}
		ShortCutVisible(false);
		NewShortDoc.Text = ShowPath.Text;
		string x=ShowPath.Text;
		string NowPathString = x.Substring(0,x.Length-2);
		int d = NowPathString.LastIndexOf("\\");
		NewShortCut.Text = NowPathString.Substring(d+1,NowPathString.Length-d-2);
	}
	void ShortCutVisible(Boolean tag){
		Short.Visible=tag;
		allShortcut.Visible=tag;
		ReplaceYes.Visible=tag;
		ReplaceNo.Visible=tag;
		if(tag==false){
			GetShortcut.Visible= true;
			CELNewShort.Visible= true;
		}
		else{
			GetShortcut.Visible= false;
			CELNewShort.Visible= false;
		}
		ReplaceQu.Visible=tag;

	}
	void Upload_Click(object sender,EventArgs e){
		if(Folder.SelectedIndex!=-1){
			UploadFile.Visible=true;
			GetShortcut.Visible=false;
		}
	}
	string GetFString(string s,string f){
		try{
			DataSet DS = new DataSet();
			string tbName, strRe;
			SqlDataAdapter Comm = new SqlDataAdapter(s, Source);
	                tbName = "tmpTable";
			Comm.Fill(DS, tbName);
			strRe = DS.Tables[tbName].Rows[0][f].ToString();
			return strRe;
		}
		catch{
			return "";
		}
	}
	void allShortcut_Changed(object sender,EventArgs e){
		string ShortCutFID = allShortcut.SelectedItem.Value;
		string ShortCutPath=GetFullFDName(ShortCutFID);
		string ParentID="";
		int NowLevelID=0;
		int CompareFID = Convert.ToInt32(ShortCutFID);
		DataSet DS = GetDS();
		int p=0;
		string SID = GetFString("Select * from Folders where FID =" + ShortCutFID, "SortID");
		LabSortID.Text = SID;
		LabFID.Text = ShortCutFID;
		string NowAllPath = GetFullFDName(ShortCutFID);
		NowPath.Text = NowAllPath;
		int i=0;
		DataSet DS1 =new DataSet();
		NowLevelID = Convert.ToInt32(GetFString("select * from Folders where FID =" + CompareFID,"LevelID"));
		while(NowLevelID > 0){
			NowLevelID = Convert.ToInt32(GetFString("select * from Folders where FID =" + CompareFID,"LevelID"));
			ParentID = GetFString("select * from Folders where FID =" + CompareFID,"ParentID");
			CompareFID = Convert.ToInt32(ParentID);
			string j="select * from Folders where ParentID =" + ParentID + " Order by SortID";
			SqlDataAdapter Comm = new SqlDataAdapter(j,Source);
			Comm.Fill(DS1,"Folders");
			DS.Merge(DS1.Tables["Folders"]);
			if(ParentID == "0"){
				break;
			}
		}
		Session["NowFolderDS"] = DS;
		NowLevel.Text = GetFString("select * from Folders where FID =" + ShortCutFID,"LevelID");
		DataView dv= DS.Tables["Folders"].DefaultView;
		dv.Sort = "SortID";
		Folder.DataSource = dv;
		Folder.DataBind();
		for(int c=0;c<=dv.Count-1;c++){
			if(dv[c]["LevelID"].ToString() == "1"){
				ShowPath.Text = dv[c]["Description"].ToString();
			}
			else{
				ShowPath.Text += "\\" + dv[c]["Description"].ToString();
			}
			if(dv[c]["FID"].ToString() == ShortCutFID){
				Folder.SelectedIndex = c;
				break;
			}
		}
		Folder.DataBind();
		DocumentBind(true);
		allShortcut.SelectedIndex = 0;
	}
	void allShortcutBind(Boolean tag){
		DropDownList ddL=allShortcut;
		string strComm;
		strComm  = "select * from ProjShortcut where Description = '-- Select a shortcut --' or id > 1 order by id";
		SqlDataAdapter Comm = new SqlDataAdapter(strComm,Source);
		DataSet DS = new DataSet();
		Comm.Fill(DS, "AllShort");
		allShortcut.DataSource=DS.Tables["AllShort"].DefaultView;
		allShortcut.DataValueField="ShortCutFID";
		allShortcut.DataTextField="Description";
		allShortcut.DataBind();
	}
	void ReplaceYesClick(object sender,EventArgs e){
		string ReplaceS ="";
		ReplaceS="Update ProjShortCut Set ShortCutFID=" + Folder.DataKeys[Folder.SelectedIndex].ToString() + " where Description ='" + NewShortCut.Text + "'";
		Boolean x =ExecActionQuery(ReplaceS);
		ShortCutVisible(true);
		allShortcutBind(true);
	}
	void OKNewShortClick(object sender,EventArgs e){
		DataSet DS = new DataSet();
		SqlDataAdapter Comm = new SqlDataAdapter("select * from ProjShortCut where Description = '" + NewShortCut.Text + "'",Source);
		Comm.Fill(DS,"ShortCut");
		if(DS.Tables["ShortCut"].Rows.Count>0){
			ReplaceYesVo(true);
		}
		else{
			string AddNewS="";
			string x=ShowPath.Text;
			x.Substring(0,x.Length-1);
			AddNewS = "Insert Into ProjShortCut (ShortCutFID,Description,ShortCutPath) values (" + Folder.DataKeys[Folder.SelectedIndex].ToString() + ",'" + NewShortCut.Text + "','" + x + "')";
			Boolean y=ExecActionQuery(AddNewS);
			if(y==true){
				ShortCutVisible(true);
				allShortcutBind(true);
			}
		}
	}
	void ReplaceNoClick(object sender ,EventArgs e){
		ReplaceYesVo(false);
	}
	void ReplaceYesVo(Boolean tag){
		if(tag==false){
			CELNewShort.Visible=true;
		}
		else{
			CELNewShort.Visible=false;
		}
		ReplaceYes.Visible=tag;
		ReplaceNo.Visible=tag;
		ReplaceQu.Visible=tag;
	}
	void CELNewShortClick(object sender, EventArgs e){
		ShortCutVisible(true);
	}
	void ExecUpload_Click(object sender,EventArgs e){
		if(UpFile.PostedFile!=null){
			string FN="";
			string m=Request.PhysicalPath;
			m=m.Substring(0,m.Length-12)+"\\";
				string QuString="";
			try{
				string x =UpFile.PostedFile.FileName;
				int y=x.LastIndexOf("\\");
				FN = x.Substring(y+1,x.Length-y-1);
				UpFile.PostedFile.SaveAs(m + NowPath.Text + "\\" + FN);
				Boolean saveRes;
				Boolean ReplaceFile;
				string g=GetFString("select * from ProjDocuments where FID =" + Folder.DataKeys[Folder.SelectedIndex].ToString() + " and DocuName = '" + FN + "'", "DID");
				string strT = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
				if(g!=""){
					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 + "')";
				}
				Boolean SaveToD =ExecActionQuery(QuString);
				if(SaveToD==true){
					Span1.InnerHtml="完成上传至" + ShowPath.Text + FN + "<br>上传大小：" + UpFile.PostedFile.ContentLength + "字节数";
				}
				else{
					Span1.InnerHtml=QuString + "保存失败";
				}
				errLabel1.Visible=true;
				string stID=GetFString("select * from Folders Where FID =" + Folder.DataKeys[Folder.SelectedIndex].ToString(),"SortID");
				ClickShow(Folder.DataKeys[Folder.SelectedIndex].ToString() + "-" + stID, Folder.SelectedIndex);
			}
			catch(Exception j){
				Span1.InnerHtml=j.ToString()+ QuString;//m + ShowPath.Text + FN + "，可能路径不存在或未选择文件<br>";
				errLabel1.Visible=true;
			}
		}
	}
	void CancelUpLoad_Click(object sender,EventArgs e){
		UploadFile.Visible = false;
	}
	void DocumentBind(Boolean tag){
		DataGrid dg=Document;
		if(tag==true){
			DataSet DS=new DataSet();
			SqlDataAdapter Comm = 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{
			DataSet DS=(DataSet)Session["DocuDS"];
			dg.DataSource=DS.Tables["Documents"].DefaultView;
		}
		dg.DataBind();
	}
	void CreateFolder_Click(object sender, EventArgs e){
		if(Folder.SelectedIndex!=-1){
			FolderC.Visible=true;
		}
	}
	void CreateOKClick(object sender,EventArgs e){
		string m=Request.PhysicalPath;
		m=m.Substring(0,m.Length-12)+"\\";
		if(Directory.Exists(m + NowPath.Text + NewFolderName.Text)==true){
			errLabel.Visible=true;
			errLabel.Text="路径已存在";
			return;
		}
		else{
			errLabel.Visible=false;
		}
			Directory.CreateDirectory(m + NowPath.Text + NewFolderName.Text);
			string sid = LabSortID.Text + ".";
			int FolderMaxSortID = GetMaxGroupFDName(Convert.ToInt32(LabFID.Text), sid);
			int ParID = FolderMaxSortID + 1;
			int Nowlevel1 = GetLevel(LabSortID.Text);
			string InCmd1 ,k1,k2;
			InCmd1 = "insert into Folders (FDName,ParentID,SortID,LevelID) Values ('" + NewFolderName.Text + "'," + LabFID.Text + ",'" + LabSortID.Text + "." + (FolderMaxSortID + 1).ToString() + "'," + Convert.ToInt32(Nowlevel1+2) + ")";
			Boolean b=ExecActionQuery(InCmd1);
			if(b==true){
				FolderC.Visible = false;
				string NV = NowLevel.Text;
				string l1 = LabSortID.Text;
				string l2 = LabFID.Text;
				int FolderMaxID=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{

			}
	}
	void CelClick(object sender,EventArgs e){
		FolderC.Visible=false;
	}
	int GetMaxGroupFDName(int PID,string SID){
		int FD = 0;
		SqlCommand re= new SqlCommand();
		re.Connection=Source;
		re.CommandText="Exec GetSortMaxID @NowPID=" + PID + ",@NowSID ='" + SID + "'";
		re.CommandType = CommandType.Text;
		SqlDataReader kx;
		re.Connection.Open();
		kx=re.ExecuteReader();
		while(kx.Read()){
			FD=kx.GetInt32(1);
			break;
		}
		re.Connection.Close();
		return FD;
	}
</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>
