<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Admin_HotelCategory.aspx.vb"
    Inherits="TourEx.Web.Admin_HotelCategory" %>

<%@ Import Namespace="TourEx.BLL" %>
<!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" runat="server" onsubmit="return checkadd();">
            <input name="CountRows" id="CountRows" type="hidden" value="0" />
            <table width="96%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D6DFF7">
                <tr>
                    <td class="subMainLeft">
                        名称
                    </td>
                    <td width="20%" class="subMainRight">
                        <input name="T_Name" type="text" id="T_Name_0" size="20" maxlength="20" class="formTitle" />
                    </td>
                </tr>
                <tr>
                    <td class="subMainLeft">
                        排序
                    </td>
                    <td class="subMainRight">
                        <input name="T_OrderID" type="text" id="T_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>
                    <td class="subMainLeft" align="right">
                        图片：
                    </td>
                    <td class="subMainRight">
                        <input id="T_Pic_0" name="T_Pic" type="text" />
                    </td>
                </tr>
            </table>
            <div class="subMainFoot">
                <asp:Button ID="Button1" runat="server" Text="添加" CssClass="formInput01" />
                <input type="button" class="formInput02" value="取消" onclick="HideWindow()" /></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>
    <div style="display: none">
        <asp:Label ID="navIgation" runat="server" Text=""></asp:Label></div>
    <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>图片</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" class="formTitle" id="T_Name_<%#Eval("t_id")%>"
                        value="<%#Eval("t_name")%>" ovalue="<%#Eval("t_name")%>" />
                </td>
                <td id="Preview_<%#Eval("t_id")%>">
                    <input name="T_Pic_<%#Eval("t_id")%>" type="text" id="T_Pic_<%#Eval("t_id")%>" value="<%#Eval("t_pic")%>"
                        ovalue="<%#Eval("t_pic")%>" />
                </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 checkadd()
	 {
	    var Name = $.trim($('#T_Name_0').val());
		$('#T_Name_0').val(Name);
		if(Name==''){alert('请填写名称！');return false;}
		if($('#T_Pic_0').val()==''){alert('请图片填写图片路径！');return false;}
	    return true;
	 }
	 function Save(ID)
	 {
	 	var T_IDs=ID==0?$('input[name="T_ID"]'):$('#T_ID_'+ID);
		var T_Name,T_O,Pic;
		$('#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();
			Pic=$('#T_Pic_'+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') || Pic!=$('#T_Pic_'+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);
				$('#T_Pic_'+T_IDs[i].value,'#BatchSubmit').val(Pic);
			}
		}
	 	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++);
 //-->
    </script>

</body>
</html>
