<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DiagnosisList.aspx.cs" Inherits="Medical.MBase.SysDiagnosis.DiagnosisList" %>

<%@ Register src="../../Controls/LoadButton.ascx" tagname="LoadButton" tagprefix="ucLoadButton" %>
<%@ Register src="../../Controls/Pager.ascx" tagname="Pager" tagprefix="ucPager" %>

<!DOCTYPE html>

<html>
<head>
    <title></title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/myLib/jsHelper_Form.js" type="text/javascript"></script>
    <script src="../../js/myLib/Pager.js" type="text/javascript"></script>
    <script src="../../js/myLib/Grid.js" type="text/javascript"></script>
</head>
<body>
    <div class="pt-panel">
        <strong></strong>
        <form id="fCondition" runat="server">
            <ucLoadButton:LoadButton ID="LoadButton1" runat="server" />
            <dl>
                <dt>诊断结果</dt>
                <dd><input type="text" name="diagnosis"/></dd>
            </dl>
        </form>
    </div>
    <div class="pt-panel pt-below">
        <strong>查询一览</strong>
        <div class="pt-grid_frame">
            <table class="pt-grid" id="grid">
                <thead>
                    <tr>
                        <th style="width:130px">操作</th>
                        <th>临时诊断</th>
                        <th>拼音简码</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>        
        <ucPager:Pager ID="gridPager" runat="server" />
    </div>
    <script type="text/javascript">
        (function() {
        var url = "DiagnosisList.aspx",
        dialogUrl = "/MBase/SysDiagnosis/DiagnosisForm.aspx",
        dialogFormName = "Diagnosis_Form",
        listbutton = '<%=Medical.MCommon.PageHelper.GetListButton() %>',
        grid = new Grid({ id: "grid", url: url, pager: new Pager("gridPager"), bindFun: bindData }),
        title = '<%=ModuleName %>';

            function init() {
                grid.search();
                bindEvents();
            }
            function bindEvents() {
                $('input[type="text"]').keydown(function(e) {
                    if (e.keyCode == 13) {
                        grid.search(true);
                    }
                });
                $("#btnAdd").click(function() {
                    top.openDialog(dialogUrl, dialogFormName, title + ' - 添加', 700, 100, 50, 50);
                });
                $("#btnQuery").click(function() {
                    grid.search(true);
                });
                grid.control.click(function(e) {
                    var target = $(e.target);
                    if (target.is("input") && !target.is(":disabled")) {
                        var data = target.parent().parent().data("data");
                        switch (target.val()) {
                            case "修改":
                                top.openDialog(dialogUrl + "?key=" + data.dID, dialogFormName, title + ' - 编辑', 700, 100, 50, 50);
                                break;
                            case "删除":
                                remove(data);
                                break;
                        }
                    }
                });
            }
            function remove(data) {
                top.showConfirmMsg("确定要删除[诊断结果]为[" + data.dDiagnosis + "]的临时信息吗?", function(r) {
                    if (r) {
                        $.get(url, { action: "remove", id: data.dID }, function(data) {
                            if (data == "success") {
                                top.showTipsMsg('删除成功!', 0, 5000);
                                grid.search();
                            } else {
                                top.showTipsMsg('删除失败!', 1, 5000);
                            }
                        });
                    }
                });
            }
            function bindData(tr, data) {
                tr.append($("<td>").html(listbutton))
                .append($("<td>").html(data.dDiagnosis))
                .append($("<td>").html(data.dSimpleCode));
            }
            init();

        })();
    </script>
</body>
</html>
