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

<!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/jquery.easyui.min.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 id="divTab" class="easyui-tabs" data-options="" style="margin-top: 10px; margin: 2px;
        overflow: hidden;">
        <div title="问题审核" style="padding: 2px;" id="00">
            <div id="divQuestionAudit" class="easyui-panel" title="" data-options="border:false,fit:true"
                style="overflow-x: hidden; overflow-y: auto">
                <div id="QuestionAudit" style="overflow-y: auto; overflow-x: hiddne">
                </div>
            </div>
        </div>
        <div title="答案审核"  style="padding: 2px;" id="11">
            <div id="divAnswerAudit" class="easyui-panel" title="" data-options="border:false,fit:true"
                style="overflow-x: hidden; overflow-y: auto">
                <div id="AnswerAudit" style="overflow-y: auto; overflow-x: hiddne">
                </div>
            </div>
        </div>
    </div>
    </form>
</body>
</html>
<script type="text/javascript">

    $("#divQuestionAudit").css("height", common.PageHeight());
    $("#divAnswerAudit").css("height", common.PageHeight());

    //问题审核部分
    $('#QuestionAudit').datagrid({
        title: '',
        loadMsg: "数据加载中，请稍后……",
        nowrap: false,
        striped: true,
        collapsible: true,
        rownumbers: true,
        showFooter: true,
        striped: true,
        url: 'AdminQuestionHandler.ashx?cmd=edit',
        pageList: [10, 15, 20, 25, 30, 40, 50],
        pageSize: 20,
        sortName: 'Question',
        sortOrder: 'asc',
        remoteSort: false,
        idField: 'ID',
        columns: [[
            { field: 'ID', checkbox: 'true', align: 'center', width: '30' },
            { field: 'Question', title: '问题', align: 'left', width: 600, fixed: true, sortable: true },
            { field: 'QuestionUser', title: '提问者', width: 120, align: 'center', sortable: true },
            { field: 'QuestionDateTime', title: '提问时间', width: 200, align: 'center', sortable: true },
            { field: 'IsAudit', title: '是否已审核', width: 120, align: 'center', sortable: true,
                formatter: function (value, row, index) {
                    if (value =="0")
                        return "否";
                    else if (value =="1")
                        return "是";
                    else return "否";
                }
             }
        ]],
        pagination: true,
        rownumbers: true,
        onLoadSuccess: function () {
        },
        toolbar: [
                 {
                     id: 'btnadd',
                     text: '审核问题',
                     iconCls: 'icon-add',
                     handler: function () {
                         var ids = getSelections();
                         if (ids == '') {
                             $.messager.alert('提示消息', '请选择要审核的数据！', 'info');
                         } else {
                             $.messager.confirm('提示消息', '确定要审核所选数据吗？', function (r) {
                                 if (r) {
                                     $.ajax({
                                         url: 'AdminQuestionHandler.ashx?cmd=QuestionAudit&ids=' + ids,
                                         type: 'post',
                                         datatype: 'text',
                                         success: function (returnValue) {
                                             if (returnValue) {
                                                 $('#QuestionAudit').datagrid('reload');
                                                 $('#QuestionAudit').datagrid('clearSelections');
                                                 ids.length = 0;
                                             }
                                         }
                                     });
                                 }
                             });
                         }
                     }
                 }, {
                     id: 'btncut',
                     text: '取消审核',
                     iconCls: 'icon-cut',
                     handler: function () {
                         var ids = getSelections();
                         if (ids == '') {
                             $.messager.alert('提示消息', '请选择要取消审核的数据！', 'info');
                         } else {
                             $.messager.confirm('提示消息', '确定要取消审核所选数据吗？', function (r) {
                                 if (r) {
                                     $.ajax({
                                         url: 'AdminQuestionHandler.ashx?cmd=CancelQuestionAudit&ids=' + ids,
                                         type: 'post',
                                         datatype: 'text',
                                         success: function (returnValue) {
                                             if (returnValue) {
                                                 $('#QuestionAudit').datagrid('reload');
                                                 $('#QuestionAudit').datagrid('clearSelections');
                                                 ids.length = 0;
                                             }
                                         }
                                     });
                                 }
                             });
                         }
                     }
                 }
                ]

    });
    $("#QuestionAudit").datagrid("getPager").pagination({
        beforePageText: '第', //页数文本框前显示的汉字  
        afterPageText: '页    共 {pages} 页',
        displayMsg: '当前显示从第{from}条到{to}条 共{total}条记录',
        onBeforeRefresh: function (pageNumber, pageSize) {
            $(this).pagination('loading');
        }
    });

    function getSelections() {
        var ids = [];
        var rows = $("#QuestionAudit").datagrid("getSelections");
        for (var i = 0; i < rows.length; i++) {
            ids.push(rows[i].ID);
        }
        return ids.join(',');
    }

    //答案部分
    $('#AnswerAudit').datagrid({
        title: '',
        loadMsg: "数据加载中，请稍后……",
        nowrap: false,
        striped: true,
        collapsible: true,
        rownumbers: true,
        showFooter: true,
        striped: true,
        url: 'AdminQuestionHandler.ashx?cmd=LoadAnswerData',
        pageList: [10, 15, 20, 25, 30, 40, 50],
        pageSize: 20,
        sortName: 'AnswerDateTime',
        sortOrder: 'desc',
        remoteSort: false,
        idField: 'ID',
        columns: [[
            { field: 'ID', checkbox: 'true', align: 'center', width: '30' },
            { field: 'Answer', title: '答案', align: 'left', width: 600, fixed: true, sortable: true },
            { field: 'AnswerUser', title: '回答者', width: 120, align: 'center', sortable: true },
            { field: 'AnswerDateTime', title: '回答时间', width: 200, align: 'center', sortable: true },
            { field: 'IsAudit', title: '是否已审核', width: 120, align: 'center', sortable: true,
                formatter: function (value, row, index) {
                    if (value == "0")
                        return "否";
                    else if (value == "1")
                        return "是";
                    else return "否";
                }
             }
        ]],
        pagination: true,
        rownumbers: true,
        onLoadSuccess: function () {
        },
        toolbar: [
                 {
                     id: 'btnadd',
                     text: '审核问题',
                     iconCls: 'icon-add',
                     handler: function () {
                         var ids = getAnswerSelections();
                         if (ids == '') {
                             $.messager.alert('提示消息', '请选择要审核的数据！', 'info');
                         } else {
                             $.messager.confirm('提示消息', '确定要审核所选数据吗？', function (r) {
                                 if (r) {
                                     $.ajax({
                                         url: 'AdminQuestionHandler.ashx?cmd=AnswerAudit&ids=' + ids,
                                         type: 'post',
                                         datatype: 'text',
                                         success: function (returnValue) {
                                             if (returnValue) {
                                                 $('#AnswerAudit').datagrid('reload');
                                                 $('#AnswerAudit').datagrid('clearSelections');
                                                 ids.length = 0;
                                             }
                                         }
                                     });
                                 }
                             });
                         }
                     }
                 }, {
                     id: 'btncut',
                     text: '取消审核',
                     iconCls: 'icon-cut',
                     handler: function () {
                         var ids = getAnswerSelections();
                         if (ids == '') {
                             $.messager.alert('提示消息', '请选择要取消审核的数据！', 'info');
                         } else {
                             $.messager.confirm('提示消息', '确定要取消审核所选数据吗？', function (r) {
                                 if (r) {
                                     $.ajax({
                                         url: 'AdminQuestionHandler.ashx?cmd=CancelAnswerAudit&ids=' + ids,
                                         type: 'post',
                                         datatype: 'text',
                                         success: function (returnValue) {
                                             if (returnValue) {
                                                 $('#AnswerAudit').datagrid('reload');
                                                 $('#AnswerAudit').datagrid('clearSelections');
                                                 ids.length = 0;
                                             }
                                         }
                                     });
                                 }
                             });
                         }
                     }
                 }
                ]

    });
        $("#AnswerAudit").datagrid("getPager").pagination({
        beforePageText: '第', //页数文本框前显示的汉字  
        afterPageText: '页    共 {pages} 页',
        displayMsg: '当前显示从第{from}条到{to}条 共{total}条记录',
        onBeforeRefresh: function (pageNumber, pageSize) {
            $(this).pagination('loading');
        }
    });

    function getAnswerSelections() {
        var ids = [];
        var rows = $("#AnswerAudit").datagrid("getSelections");
        for (var i = 0; i < rows.length; i++) {
            ids.push(rows[i].ID);
        }
        return ids.join(',');
    }
</script>
