<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Admin_HelpCategory.aspx.vb" Inherits="TourEx.Web.Admin_HelpCategory" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题页</title>
<link rel="stylesheet" type="text/css" href="Css/Style.css"/>
<script language="javascript" src="../Sys/Js/jquery.js"></script>
<script language="javascript" src="../Sys/Js/AlertWindow.js"></script>
</head>
<body>
    <div id="messWindow" class="messWindow">
    </div>
    <div id="promptWindow" class="promptWindow" align="center">
        <div class="titleBar">
            <span>添加帮助分类</span><span onclick="HideWindow()" style="float:right;"><img src="Images/popclose.gif" /></span></div>
        <div class="mainContent">
            <form method="post" action="?Act=add">
            <input name="CountRows" id="CountRows" type="hidden" value="0" />
            <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D6DFF7">
                <tr>
                    <td class="subMainLeft">名称</td>
                    <td width="20%" class="subMainRight">排序</td>
                </tr>
                <tr id="Rows_0">
                    <td class="subMainLeft">
                        <input name="Name_0" type="text" id="Name_0" size="20" maxlength="20" class="formTitle"/>
                    </td>
                    <td class="subMainRight">
                        <input name="OrderID_0" type="text" id="OrderID_0" onkeyup="this.value=this.value.replace(/\D/g,'');"
                            size="6" maxlength="6" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))" class="formTitle"/>
                    </td>
                </tr>
                <tr id="Rows" style="display: none">
                    <td class="subMainLeft">
                        <input name="Name_" type="text" id="Name_" size="20" maxlength="20" class="formTitle"/>
                    </td>
                    <td class="subMainRight">
                        <input name="OrderID_" type="text" id="OrderID_" onkeyup="this.value=this.value.replace(/\D/g,'');"
                            size="6" maxlength="6" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/\D/g,''))" class="formTitle"/>
                    </td>
                </tr>
            </table>
			<div class="subMainFoot" style="text-align:center; padding-left:0;"><input name="submit" type="submit" class="formInput01" value="添加" /> <input type="button" class="formInput02" value="增加十行" onclick="PlusRows();" /></div>
            </form>
        </div>
    </div>
    <form id="BatchSubmit" name="BatchSubmit" method="post" action="?act=edit" style="display: none">
    </form>
	<ul class="tools">
		<li class="add"><span><a href="javascript:void(0);" onclick="ShowWindow()">添加</a></span></li>
		<li class="save"><span><a href="javascript:void(0);" onclick="Save(0);return false;">保存</a></span></li>
		<li class="del"><span><a href="javascript:void(0);" onclick="Del(0);return false;">删除</a></span></li>
	</ul>
    <asp:Repeater ID="Repeater" runat="server">
        <HeaderTemplate>
			<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabBox">
                <tr class="tabTitleMain">
                    <td width="35" class="selectAll"><a href="javascript:void(0);" onclick="All();">全选</a></td>
                    <td>名称</td>
                    <td width="80">排序</td>
                    <td width="100">操作</td>
                </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr class="tabTextMain" id="From_<%#Eval("t_id")%>" onmouseout="this.style.background='#FFFFFF';" onmouseover="this.style.background='#F4F7FA';">
                <td>
                    <input name="T_ID" type="checkbox" id="T_ID_<%#Eval("t_id")%>" value="<%#Eval("t_id")%>" />
                </td>
                <td>
                    <input name="T_Name_<%#Eval("t_id")%>" type="text" id="T_Name_<%#Eval("t_id")%>"
                        value="<%#Eval("t_name")%>" ovalue="<%#Eval("t_name")%>" class="formTitle"/>
                </td>
                <td>
                    <input name="T_OrderID_<%#Eval("t_id")%>" id="T_OrderID_<%#Eval("t_id")%>"
                        type="text" value="<%#Eval("t_orderid")%>" ovalue="<%#Eval("t_orderid")%>"
                        onkeyup="this.value=this.value.replace(/\D/g,'');" size="6" maxlength="6" class="formTitle"/>
                </td>
                <td>
                     <a href="javascript:void(0);" onclick="Save(<%#Eval("t_id")%>);return false;">
                        保存</a>
                         <a href="javascript:void(0);" onclick="Del(<%#Eval("t_id")%>);return false;">
                            删除</a>
                </td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table>
            <asp:Label ID="lblEmpty" Text="暂无分类" runat="server" Visible="<%#Boolean.Parse((Repeater.Items.Count = 0).ToString())%>"
                Width="100%" Style="text-align: center">     
            </asp:Label>
        </FooterTemplate>
    </asp:Repeater>
    <br />
    <br />

    <script type="text/javascript">
        	 <!--//
        	 function Save(ID)
        	 {
        	 	var T_IDs=ID==0?$('input[name="T_ID"]'):$('#T_ID_'+ID);
        		var T_Name,T_O;
        		$('#BatchSubmit').html('');
        		for(var i=0;i<T_IDs.length;i++)
        		{
        			T_Name = $.trim($('#T_Name_'+T_IDs[i].value).val());
        			$('#T_Name_'+T_IDs[i].value).val(T_Name);
        			if(T_Name==''){alert('请填写分类名！');return;}
        			T_O=$('#T_OrderID_'+T_IDs[i].value).val();
        			if(T_Name!=$('#T_Name_'+T_IDs[i].value).attr('ovalue') || T_O!=$('#T_OrderID_'+T_IDs[i].value).attr('ovalue'))
        			{
        				T_IDs[i].checked=true;
        				$('#From_'+T_IDs[i].value).clone().prependTo("#BatchSubmit");
        				$('#T_Name_'+T_IDs[i].value,'#BatchSubmit').val(T_Name);
        				$('#T_OrderID_'+T_IDs[i].value,'#BatchSubmit').val(T_O);
        			}
        		}
        	 	if($('#BatchSubmit').html()==''){alert('数据没有改动过，无需保存！');return;}
        		$('input[name="T_ID"]','#BatchSubmit').attr('checked',true);
        		$('#BatchSubmit').submit();
        	 }
        	 var Alls=true;
        	 function All(){$('input[name="T_ID"]').attr('checked',Alls);Alls=!Alls;}
        	 function Del(ID)
        	 {
        	 	var Url='?Act=del&';
        		var T_IDs;
        		if(ID>0)
        		{
        			Url +='T_ID='+ID;
        		}else{
        	 		T_IDs = $("input[name='T_ID']").serialize().replace(/&T_ID=/g,',');
        			if(T_IDs==''){alert('请选择您要删除的分类！');return;}
        			Url +=T_IDs;
        		}
        		if(confirm('删除分类将删除分类下所有数据(信息、模板等)!\n您确定删除吗！')){location=Url;}
        	 }
        	 var OrderID=parseFloat($('input[name^="T_OrderID_"]:last').val()||0) + 1
        	 $('#OrderID_0').val(OrderID++);
        	var r=0;
        	function PlusRows()
        	{
        		for(var i=0;i<10;i++)
        		{
        		    $('#CountRows').val(++r);
        		    $('#Rows').clone().attr('id','Rows_'+r).insertBefore('#Rows').show();
        		    $('#Name_',$('#Rows_'+r)).attr({'id':'Name_'+r,'name':'Name_'+r});
        		    $('#OrderID_',$('#Rows_'+r)).attr({'id':'OrderID_'+r,'name':'OrderID_'+r}).val(OrderID++);
        		}
        		if($('#promptWindow').height()>$('#messWindow').height())
        		{
        			$('#messWindow').height($('#promptWindow').height()+20);
        		}
        	}
         //-->
    </script>
</body>
</html>
