<%@Page Language="C#" Inherits="IWMS.Admin.TemplateMan" MasterPageFile="admin.master"%>
<asp:Content ContentPlaceHolderId="cphHead" runat="server">
	<script type="text/javascript">
	<!--
	function Export(id){
		var ifm = document.getElementById("ifm_export");
		if (id>0){
			ifm.src = "admin_export.aspx?id="+id+"&w=template";
		}
		return false;
	}
	function openAdd(id){
		var con = "<iframe src='admin_popTemplateAdd.aspx"+(id==null?"":"?id="+id)+"' height='100%' width='100%'  frameborder='0'></iframe>";
		var b=boxys.template;
		if (b){
			if(b.isVisible){
				b.show();
			}
			b.setContent(con);
		}else{
			b=new Boxy(con,{title:'添加/修改模板',afterHide:function(){top.location.reload()}});
			boxys.template=b;
		}
		b.resize(380,230);
		b.center();
	}
	-->
	</script>
</asp:Content>
<asp:Content ContentPlaceHolderId="cphMain" runat="server">

	<form id="myForm" runat="server">
	<div class="mframe">
	<div class="tl"></div>
	<div class="rt"></div>
	<div class="tm">
		<span class="tt">模板管理</span>&nbsp; <a href="javascript:openAdd()">添加模板</a>
	</div>
	<div class="wrapper">
	<div class="ml"></div>
	<div class="mr"></div>
	<div class="mm">
		<asp:Label id="myLabel" class="msgBar" EnableViewState="false" runat="server"/>
		<ASP:DataGrid id="MyDataGrid" runat="server"
				Width="100%"
				align="center"
				ShowHeader="true"
				ShowFooter="false"
				AutoGenerateColumns="false"
				DataKeyField="templateid"
				OnDeleteCommand="MyDataGrid_Delete"
				OnItemDataBound="MyDataGrid_ItemDataBound"
				CssClass="grid"
				BorderColor="#cccccc"
				HeaderStyle-CssClass="gridHead"
				ItemStyle-CssClass="tdbg"
				CellPadding="6"
				CellSpacing="0" >
			<EditItemStyle CssClass="tdbg-dark" />
			
			<Columns>
				<asp:TemplateColumn
					>
					<ItemTemplate>
						<a href="javascript:openAdd(<%#Eval("templateid")%>)">修改</a>
					</ItemTemplate>
					<ItemStyle HorizontalAlign="center" />
					<HeaderStyle Width="40"/>
				</asp:TemplateColumn>
				<asp:TemplateColumn
					HeaderText="模板名">
					<ItemTemplate>
						<%#Eval("tname")%>
					</ItemTemplate>
					<EditItemTemplate>
						<asp:TextBox  runat="server"
							id="tName"
							Text=<%#Eval("tname")%>
							Columns="10"
							 />
						<asp:RequiredFieldValidator
							ControlToValidate="tName"
							ErrorMessage="*"
							runat="server" >
						</asp:RequiredFieldValidator>
					</EditItemTemplate>
				</asp:TemplateColumn>
				<asp:TemplateColumn
					HeaderText="类别">
					<ItemTemplate>
						<%#GetSortName(Eval("tSort").ToString())%>
					</ItemTemplate>
					<ItemStyle HorizontalAlign="center" />
					<HeaderStyle Width="60"/>
				</asp:TemplateColumn>
				<asp:TemplateColumn
					HeaderText="适用类型">
					<ItemTemplate>
						<%#Eval("ctype").ToString()=="1" ? "软件" : ""%>
					</ItemTemplate>
					<ItemStyle HorizontalAlign="center"/>
					<HeaderStyle Width="60"/>
				</asp:TemplateColumn>
				<asp:TemplateColumn
					HeaderText="文件地址">
					<ItemTemplate>
						<%#Eval("tFile")%>
					</ItemTemplate>
				</asp:TemplateColumn>
				<asp:TemplateColumn
					HeaderText="默认"
					>
					<ItemTemplate>
						<%#(bool)Eval("tDefault") ? "Yes" : ""%>
					</ItemTemplate>
					<ItemStyle HorizontalAlign="center"/>
					<HeaderStyle Width="30"/>
				</asp:TemplateColumn>
				<asp:TemplateColumn
					>
					<ItemTemplate>
						<a href="admin_fileEdit.aspx?file=<%#Eval("tFile")%>&amp;html=1">编辑</a>
						<a href="###" onclick="Export(<%#Eval("templateId")%>)">导出</a>
					</ItemTemplate>
					<ItemStyle HorizontalAlign="center" />
					<HeaderStyle Width="70"/>
				</asp:TemplateColumn>
				<asp:ButtonColumn
					ButtonType="LinkButton"
					CommandName="Delete"
					Text="删除" >
					<ItemStyle HorizontalAlign="center" />
					<HeaderStyle Width="40"/>
				</asp:ButtonColumn>
				
			</Columns>
		</ASP:DataGrid>
		<br/><br/>
		导入模板 <input type="file" id="upTemplate" size="20" runat="server"/> 
		<asp:Button id="import" Text="导入" onclick="import_Onclick" runat="server"/>&nbsp; 
	
	</div>
	</div>
	<div class="bl"></div>
	<div class="br"></div>
	<div class="bm"></div>
	</div>
	
	</form>
	<iframe id="ifm_export" src="about:blank" height="0" width="0" style="visibility: hidden"></iframe>

</asp:Content>