<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Admin_HotelBrand.aspx.vb"
    Inherits="TourEx.Web.Admin_HotelBrand" %>
<%@ 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" width="80" align="right">名称：</td>
                    <td class="subMainRight">
                        <input name="T_Name" type="text" id="T_Name_0" size="20" maxlength="20" class="formTitle"/>
                    </td>
                    <td class="subMainRight" rowspan="3" width="100" id="Preview_0">
                    </td>
                </tr>
                <tr>
                    <td class="subMainLeft" align="right">上传LOGO：</td>
                    <td class="subMainRight">
                        <input id="T_Logo_0" name="T_Logo" type="hidden" />
                        <asp:HiddenField ID="T_RanNum" runat="server" />
                        <iframe src="" id="UpIframe_0" width="300" height="25" scrolling="No" frameborder="0">
                        </iframe>
                    </td>
                </tr>
                <tr>
                    <td class="subMainLeft" align="right">排序：</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>
            </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>
    <div id="alertUp" class="promptWindow" align="center">
        <div class="titleBar">
            <span>上传LOGO</span><span onclick="HideWindow()" style="float: right; margin-right: 10px">×</span></div>
        <div class="mainContent">
            <iframe src="" id="UpIframe" width="300" height="25" scrolling="No" frameborder="0">
            </iframe>
        </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="$('input[name=\'T_ID\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));">全选</a></td>
                <td width="120">Logo</td>
                <td>名称</td>
                <td width="100">排序</td>
                <td width="100">操作</td>
            </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr class="tabTextMain" onmouseout="this.style.background='#FFFFFF';" onmouseover="this.style.background='#F4F7FA';" id="From_<%#Eval("t_id")%>">
            <td>
            <input id="T_RanNum_<%#Eval("t_id")%>" name="T_RanNum_<%#Eval("t_id")%>" type="hidden" value="<%#Eval("t_rannum")%>" />
                <input id="T_Logo_<%#Eval("t_id")%>" name="T_Logo_<%#Eval("t_id")%>" type="hidden" value="<%#Eval("t_logo")%>" ovalue="<%#Eval("t_logo")%>" />
                <input name="T_ID" type="checkbox" id="T_ID_<%#Eval("t_id")%>" value="<%#Eval("t_id")%>" /></td>
            <td id="Preview_<%#Eval("t_id")%>"><img src="<%# UpFolder & Eval("t_logo")%>" width="50" height="40" style="border:1px #eee solid;padding:3px;" /></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")%>" size="16" 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="Up(<%#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_Logo_0').val()==''){alert('请上传Logo！');return false;}
	    return true;
	 }
     $('#UpIframe_0').attr('src','../sys/Upload.aspx?r='+$('#T_RanNum').val())
    function UpReturn(err,msg,id)
    {
	    var M=100;
	    if(id=='')id='0';
	    var Preview = 'Preview_'+id;
	    if(err!=""){
		    alert(err);
	    }else if(msg!=''){
	        $("#T_Logo_"+id).val(msg);
		    $("#"+Preview).html('<img src="<%=UpFolder%>'+msg+'" style="width:'+M+'px"/>');
	        if(id>0)HideWindow();
	    }
    }
    function Up(id)
    {
        ShowWindow('','alertUp');
        $('#UpIframe').attr('src','../sys/Upload.aspx?r='+$('#T_RanNum_'+id).val()+'&id='+id);
    }
	 function Save(ID)
	 {
	 	var T_IDs=ID==0?$('input[name="T_ID"]'):$('#T_ID_'+ID);
		var Name,OrderId,logo;
		$('#BatchSubmit').html('');
		for(var i=0;i<T_IDs.length;i++)
		{
			Name = $.trim($('#T_Name_'+T_IDs[i].value).val());
			$('#T_Name_'+T_IDs[i].value).val(Name);
			if(Name==''){alert('请填写品牌名！');return;}
			OrderId=$('#T_OrderID_'+T_IDs[i].value).val();
			logo=$('#T_Logo_'+T_IDs[i].value).val();
			if(Name!=$('#T_Name_'+T_IDs[i].value).attr('ovalue') || OrderId!=$('#T_OrderID_'+T_IDs[i].value).attr('ovalue') || logo!=$('#T_Logo_'+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(Name);
				$('#T_OrderID_'+T_IDs[i].value,'#BatchSubmit').val(OrderId);
				$('#T_Logo_'+T_IDs[i].value,'#BatchSubmit').val(logo);
			}
		}
	 	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;
	 $('#T_OrderID_0').val(OrderID++);
     //-->
    </script>

</body>
</html>
