<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RelevanceMng.aspx.cs" Inherits="Webdisk.RelevanceMng" %>

<!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 runat="server">
    <title>关联文件</title>
    <link rel="stylesheet" type="text/css" href="themes/icon.css" />
    <link href="themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="js/easyloader.js" type="text/javascript"></script>
    <link href="css/demo.css" rel="stylesheet" type="text/css" />
    <script src="js/Common.js" type="text/javascript"></script>
</head>
<body style="overflow-x:hidden; overflow-y:hidden; padding:0px">
    <form id="form1" runat="server">
    <div  style="margin-left:30px; font-size:large; font-weight:bold; margin-top:20px;"><asp:Label ID="lblFileName"  runat="server" Text=""></asp:Label></div>
    <hr  style="width:98%"/>
    <div  class="easyui-panel" title="" data-options="border:false"  style="width:500px;padding:5px; margin-left:20px">
        <div style="float:left;">
            <div>所属用户：<asp:Label ID="lblUser" runat="server" Text=""></asp:Label></div>
            <div>文件类型：<asp:Label ID="lblFileType" runat="server" Text=""></asp:Label></div>
        </div>
        <div style="float:right;">
            <div>文件大小：<asp:Label ID="lblFileSize" runat="server" Text=""></asp:Label></div>
            <div>上传时间：<asp:Label ID="lblUploaddate" runat="server" Text=""></asp:Label></div>
        </div>
    </div>
	
	<div id="divTab" class="easyui-tabs" data-options="" style="margin-top:10px; margin:2px; overflow:hidden;">
		<div title="关联" style="padding:2px;" id="00" >
             <div id="divRelevanceFile" class="easyui-panel" title="" data-options="border:false,fit:true"  style="overflow-x:hidden; overflow-y:auto">
                <div id="RelevanceFile" style="overflow-y:auto; overflow-x:hiddne"></div>
              
            </div>
            <div id="dd"></div>
		</div>
		
		</div>
    <input id="H_fileid" type="hidden"  runat="server"/>

    </form>
</body>
</html>
<script type="text/javascript">
	
    var fileid = $("#H_fileid").val();
    $(function () {
        $("#divRelevanceFile").css("height", common.PageHeight() - 140);
        $("#RelevanceFile").css("height", common.PageHeight() - 140);
        var divheight = common.PageHeight() - 140;
        var href = "<iframe src='RelevanceBeMng.aspx?id=" + fileid + "'  scrolling='no' frameborder='0' marginheight='0' marginwidth='0' style='margin:0px'  width='100%' height='" + divheight + "' ></iframe>";
        var RelevanceDetail = "<iframe src='RelevanceSearch.aspx?id=" + fileid + "'  scrolling='no' frameborder='0'  style='margin:0px'  width='100%' height='" + divheight + "' ></iframe>";
        
        using(['datagrid', 'tabs', 'messager', 'window', 'pagination', 'linkbutton', 'resizable', 'panel'], function () {
            //被关联
            $('#divTab').tabs('add', {
                title: '被关联',
                fit: true,
                selected: false,
                content: href
            });

            //关联文件
            $('#RelevanceFile').datagrid({
                title: '',
                loadMsg: "数据加载中，请稍后……",
                nowrap: false,
                striped: true,
                collapsible: true,
                rownumbers: true,
                showFooter: true,
                striped: true,
                url: 'RelevanceHandler.ashx?cmd=LoadGrid&id=' + fileid,
                pageList: [10, 15, 20, 25, 30, 40, 50],
                pageSize: 20,
                sortName: 'FileName',
                sortOrder: 'asc',
                remoteSort: false,
                idField: 'fileID',
                columns: [[
                    { field: 'ck', checkbox: 'true', align: 'center', width: '30' },
                    { field: 'FileName', title: '文件名', align: 'left', width: 400, fixed: true, sortable: true },
                    {
                        field: 'FileSize', title: '大小', width: 80, align: 'center', sortable: true,
                        formatter: function (value, row, index) {
                            if (value > 1073741824)
                                return Math.round(value / 1073741824, 2) + "GB";
                            else if (value > 1048576)
                                return Math.round(value / 1048576, 2) + "MB";
                            else if (value > 1024)
                                return Math.round(value / 1024) + " KB";
                            else return "0 KB";
                        }
                    },
                    { field: 'FileExt', title: '文件类型', width: 80, align: 'center', sortable: true },
                    { field: 'UserName', title: '所属用户', width: 80, align: 'center', sortable: true }
                ]],
                pagination: true,
                rownumbers: true,
                onLoadSuccess: function () {
                },
                toolbar: [
                 {
                     id: 'btnadd',
                     text: '添加',
                     iconCls: 'icon-add',
                     handler: function () {
                         $('#divTab').tabs('add', {
                             title: '添加关联文件',
                             content: RelevanceDetail,
                             id: 'newtab',
                             closable: true
                         });
                     }
                 }, {
                     id: 'btncut',
                     text: '删除',
                     iconCls: 'icon-cut',
                     handler: function () {
                         var ids = getSelections();
                         var sourid = fileid;
                         if (ids == '') {
                             $.messager.alert('提示消息', '请选择要删除的数据！', 'info');
                         } else {
                             $.messager.confirm('提示消息', '确定要删除所选数据吗？', function (r) {
                                 if (r) {
                                     $('#processWindow').window('open', 'aadasdsads');
                                     $.ajax({
                                         url: 'RelevanceHandler.ashx?cmd=del&sourid=' + sourid + '&id=' + ids,
                                         type: 'post',
										 cache:false,
                                         datatype: 'text',
                                         success: function (returnValue) {
                                             if (returnValue) {
                                                 $('#processWindow').window('close');
                                                 $('#RelevanceFile').datagrid('reload');
                                                 $('#RelevanceFile').datagrid('clearSelections');
                                                 ids.length = 0;
                                             }
                                         }
                                     });
                                 }
                             });
                         }
                     }
                 }
                ]
            });
            $("#RelevanceFile").datagrid("getPager").pagination({
                beforePageText: '第', //页数文本框前显示的汉字  
                afterPageText: '页    共 {pages} 页',
                displayMsg: '当前显示从第{from}条到{to}条 共{total}条记录',
                onBeforeRefresh: function (pageNumber, pageSize) {
                    $(this).pagination('loading');
                }
            });
        });


    });
    function reloadFile (){
        $("#divTab .tabs li:first-child").trigger("click");
        $('#RelevanceFile').datagrid('reload');
    }
    function getSelections() {
        var ids = [];
        var rows = $("#RelevanceFile").datagrid("getSelections");
        for (var i = 0; i < rows.length; i++) {
            ids.push(rows[i].fileID);
        }
        return ids.join(',');
    }

    
    </script>
