<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Admin_HotelPicList.aspx.vb"
    Inherits="TourEx.Web.Admin_HotelPicList" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ 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 type="text/javascript" src="../Sys/Js/jquery.js"></script>
    <script type="text/javascript" src="../sys/js/AlertWindow.js"></script>
    <script type="text/javascript" src="../sys/js/jquery-ui-1.8.2.custom.js"></script>
</head>
<body>
    <ul class="tools">
        <li class="selectAll" p="15"><span><a href="javascript:void(0);" onclick="All();">全选</a></span></li>
        <li class="add" p="13"><span><a href="Admin_HotelPic.aspx?id=<%=HID %>">添加</a></span></li>
        <li class="del" p="15"><span><a href="javascript:void(0);" onclick="Del(0);return false;">删除</a></span></li>
        <li class="cover"><span><a href="javascript:void(0);" onclick="Default();return false;">设置封面图片</a></span></li>
        <li class="name"><span><%=HotelName %></span></li>
    </ul>
    <div class="pics">
    <input type="hidden" name="OrderList" id="OrderList" value="" />
        <asp:Repeater ID="Repeater" runat="server">
            <ItemTemplate>
                <div class="list" id="Pic_<%#Eval("P_ID")%>">
                    <div class="listTit"><%#Eval("P_Title")%></div>
                    <div class="listText"><img src="<%# UpFolder & FormatPic(Eval("P_Pic"),"a")%>" title="<%#Eval("P_Title")%>" /></div>
                    <div class="listTools">
                        <span><a href="javascript:;" onclick="Edit(<%#Eval("P_ID")%>);" p="14">编辑</a> <a
                            href="javascript:;" onclick="Del(<%#Eval("P_ID")%>);return false;" p="15">删除</a></span>
                        <input name="P_ID" id="P_ID_<%#Eval("P_ID")%>" type="checkbox" value="<%#Eval("P_ID")%>"/>
                        <input type="hidden" name="P_Default" id="P_Default_<%#Eval("P_ID")%>" value="<%#Eval("P_Default")%>"/>
                        <input type="hidden" name="P_OrderId" id="P_OrderId_<%#Eval("P_ID")%>" value="<%#Eval("P_OrderId")%>" />
                        <input type="hidden" name="P_Title" id="P_Title_<%#Eval("P_ID")%>" value="<%#Eval("P_Title")%>" />
                    </div>
                </div>
            </ItemTemplate>
            <FooterTemplate>
                <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>
    </div>
<webdiyer:AspNetPager ID="TourExPage" runat="server" UrlPaging="true" ShowPageIndexBox="Never"
    PageIndexBoxType="DropDownList" TextBeforePageIndexBox=""
    PageSize="30" OnPageChanged="BindData" EnableTheming="true" FirstPageText="首页"
    LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" CssClass="page" 
        PagingButtonSpacing="" CurrentPageButtonClass="current" 
    CurrentPageButtonStyle="">
</webdiyer:AspNetPager>
    <div id="promptWindow" class="promptWindow" style="display:none">
		<div class="titleBar">
			<span>编辑图片</span><span onclick="HideWindow()" style="float:right;"><img src="Images/popclose.gif" /></span></div>
		<div class="mainContent">
			<form id="BatchSubmit" name="BatchSubmit" method="post" action="?act=edit&HID=<%=HID%>" onsubmit="return checkform();">
			<table width="96%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D6DFF7" align="center">
				<tr>
					<td class="subMainLeft" width="80">图片描述：</td>
					<td class="subMainRight"><input type="hidden" name="P_ID" id="P_ID" /><input type="text" name="P_Title" id="P_Title" size="50" class="formTitle"/></td>
				</tr>
				<tr>
					<td class="subMainLeft">排序：</td>
					<td class="subMainRight"><input type="text" name="P_OrderId" id="P_OrderId" class="formTitle"/></td>
				</tr>
			</table>
			<div class="subMainFoot"><input type="submit" class="formInput01" value="确定" /> <input type="button" class="formInput02" value="取消" onclick="HideWindow()"/></div>
			</form>
		</div>
    </div>
	<div class="popSuccess" id="show"><span>更新成功！</span></div>
<script type="text/javascript">
<!--//
 var AP='<%=TourEx.BLL.GetSession("AdminPermissions") %>';
 if(AP!='')
 {
    if(AP.indexOf(',13,')==-1)$('*[p="13"]').remove();
    if(AP.indexOf(',14,')==-1)$('*[p="14"]').remove();
    if(AP.indexOf(',15,')==-1)$('*[p="15"]').remove();
 }
 var DefaultId=0;
 var A=false;
 var oldid = []; 
 function All(){A=!A;$('input[id^="P_ID_"]').attr('checked',A);}
 function Edit(ID){$('#P_ID').val($('#P_ID_'+ID).val());$('#P_Title').val($('#P_Title_'+ID).val());$('#P_OrderId').val($('#P_OrderId_'+ID).val());ShowWindow();}
 function checkform()
 {
    if($('#P_Title').val()==''){alert('请填写图片名称！');return false;}
    var o = parseInt($('#P_OrderId').val());
    if(isNaN(o)||0<1){alert('请填写排序！');return false;}
 }
 function Del(ID)
 {
    var Url='?Act=del&HID=<%=HID%>&',IDs;
	if(ID>0)
	{
		IDs ='P_ID='+ID;
	}else{
		IDs = $("input[id^='P_ID_']").serialize().replace(/&P_ID=/g,',');
		if(IDs==''){alert('请选择您要删除的图片！');return;}
	}
	if((','+IDs.substring(5)+',').indexOf(','+DefaultId+',')!=-1)
	{
	    alert('封面图片不能删除！');
	}else if(confirm('您确定删除吗！')){location=Url+IDs;}
 }
 function Default()
 {
    var c=$("input[id^='P_ID_']:checked");
    if(c.length!=1)
    {
        alert('请选择一张图片！');
    }else{
        location='?act=Default&HID=<%=HID%>&P_ID='+c.val();
    }
 }
$(function() {
 $('input[id^="P_ID_"]').each(function(){
     oldid.push($(this).val());
     if($('#P_Default_'+$(this).val()).val()==1)
     {
        DefaultId=$(this).val();
        $('#Pic_'+DefaultId).css('border','red 1px solid');
     }
 });
 $('#OrderList').val(oldid.join(','));
 if(AP==''||AP.indexOf(',14,')!=-1)
 {
	$( ".pics" ).disableSelection().sortable({cursor: 'move',
    update: function(){
         var oid=0,id=0,orderid=0,title;
         var newid = [];
         oldid=$('#OrderList').val().split(',');
         $('input[id^="P_ID_"]').each(function(i) { 
            newid.push($(this).val());
            if(oldid[i]!=$(this).val() && id==0)
            {
                id=$(this).val();
                oid=oldid[i];
                orderid=$('#P_OrderId_'+oid).val();
                title=$('#P_Title_'+id).val();
            }
         });
        $('#OrderList').val(newid.join(','));
        $('#P_OrderId_'+oid).val($('#P_OrderId_'+id).val());
        $('#P_OrderId_'+id).val(orderid);
         $.ajax({ 
            type: "post",url: "?act=edit&HID=<%=HID%>", //服务端处理程序 
            data: {'P_ID':id,'P_Orderid':orderid,'P_Title':title},   //id:新的排列对应的ID,order：原排列顺序 
            beforeSend: function() { 
                 ShowWindow('','show','','#ffffff');
            }, 
            success: function(msg) { 
                HideWindow();
            } 
         }); 
      }
	});
 }
});
//-->
</script>
</body>
</html>
