<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DispensingForm.aspx.cs" Inherits="Medical.MBusiness.SysDispensing.DispensingForm" %>

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <style>
        #tbInfo th{text-align:right;vertical-align:bottom}
        #tbInfo td{text-align:left; vertical-align:bottom; padding-left:5px; color:#666; height:30px; border-bottom:1px solid #ccc}
        .fixedTable td{border:1px solid #ccc;text-align:center;color:#666; height:30px}
    </style>
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/myLib/helper.js" type="text/javascript"></script>
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" style="display:none" >
        <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0"></embed>
    </object>
    <script src="../../Scripts/LodopFuncs.js" type="text/javascript"></script>
    <script src="../../js/myLib/Print.js" type="text/javascript"></script>
</head>
<body>
    <form id="myFrom" runat="server">
        <fieldset>
            <legend style="text-align:center">处方信息</legend>
            <input type="hidden" id="haveInjection" runat="server" />
            <table id="tbInfo">
                <tr>
                    <th>处方编号</th>
                    <td><span runat="server" id="wNum"></span></td>
                    <th>姓名</th>
                    <td><span runat="server" id="wName"></span></td>
                    <th>开具日期</th>
                    <td><span runat="server" id="wDate"></span></td>
                    <th>医生</th>
                    <td><span runat="server" id="wDoctor"></span></td>
                </tr>
                <tr>
                    <th>诊断</th>
                    <td colspan='7'><span runat="server" id="wDiagnosis"></span></td>
                </tr>
            </table>
        </fieldset>
        <fieldset>
            <legend style="text-align:center">药品信息</legend>
            <asp:Repeater ID="rpDrug" runat="server" EnableViewState="false">
                <HeaderTemplate>
                    <table id="tbDrug" class="fixedTable">
                        <thead>
                            <tr>
                                <td style="width:100px">药品编号</td>
                                <td style="width:100px">药品名称</td>
                                <td style="width:100px">批号</td>
                                <td style="width:100px">有效期</td>
                                <td style="width:100px">规格</td>
                                <td style="width:100px">单位</td>
                                <td style="width:100px">总量</td>
                                <td style="width:100px">用量</td>
                                <td style="width:100px">用法</td>
                                <td style="width:13px"></td>
                            </tr>
                        </thead>
                        <tbody>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td><%#Eval("wCode")%></td>
                        <td><%#Eval("wName")%></td>
                        <td><%#Eval("wBatch")%></td>
                        <td><%#Eval("wValid")%></td>
                        <td><%#Eval("wSpec")%></td>
                        <td><%#Eval("wUnit")%></td>
                        <td><%#Eval("wTotal")%></td>
                        <td><%#Eval("wReal")%></td>
                        <td><%#Eval("wUsage")%></td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                        </tbody>
                    </table> 
                </FooterTemplate>
            </asp:Repeater>
        </fieldset>
        <div class="pt-padding" style="text-align:center">
            <input type="button" id="btnConfirm" class="pt-button active"  value="发药确认" />
            <input type="button" id="btnClose" class="pt-button active" value="关闭" />
        </div>
    </form>
    <script>
        (function() {
            var key = "<%=key %>",
            type = "<%=type %>",
            printModule = new Print({ pageName: "CreateCustomPage", pageSize: [1480, 100] });

            function init() {
                setPage();
                bindEvents();
            }
            function setPage() {
                if (type == "view") {
                    $("#btnConfirm").hide();
                }
                var widths = [];
                $("#tbDrug thead tr td").each(function() {
                    widths.push(getStyle($(this).attr("style"), "width"));
                });
                FixedTableHeader("tbDrug", 370);
                $("#tbDrug tbody tr td").each(function() {
                    $(this).width(widths[$(this).index()]);
                });
            }
            function bindEvents() {
                $("#btnClose").click(function() {
                    top.art.dialog.close("Dispensing_Form");
                });
                $("#btnConfirm").click(function() {
                    $.get("DispensingForm.aspx", { action: "confirm", key: key }, function(data) {
                        if (parseInt(data, 10) > 0) {
                            top.showTipsMsg('发药确认操作成功!', 0, 3000);
                            if ($("#haveInjection").val()=="有") {
                                printInjectionCard();
                            } else {
                                top.art.dialog.close("Dispensing_Form");
                            }
                        } else {
                            top.showTipsMsg("操作失败!", 1, 4000);
                        }
                    });
                });
            }
            function printInjectionCard() {
                $.get("DispensingList.aspx", { action: "print", num: key }, function(data) {
                    printModule.print(data, false);
                })
            }
            init();
        })();
    </script>
</body>
</html>
