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

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/My97DatePicker/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/myLib/jsHelper_Form.js" type="text/javascript"></script>
    <style type="text/css">
        #pt-edit th{text-align:right;vertical-align:bottom; color:#666; font-weight:normal}
        #pt-edit td{text-align:left; vertical-align:bottom; padding-left:5px; color:#666; height:30px; border-bottom:1px solid #ccc}
        #pt-edit input{border:none;width:97%}
    </style>
</head>
<body>
    <form id="form1" name="fEdit" style="padding:20px" >
    <table class="pt-edit">
        <tr>
            <th>姓名</th>
            <td><input type="text" id="pName" name="pName" runat="server"/></td>
            <th>性别</th>
            <td>
                <input type="radio" name="pSex" id="pSex0" value="0" checked="true" runat="server"/>男
                <input type="radio" name="pSex" id="pSex1" value="1" runat="server"/>女
            </td>
        </tr>
        <tr>
            <th>出生日期</th>
            <td><input type="text" id="pBirth" name="pBirth" onclick="WdatePicker()" error="收款日期" runat="server"/></td>
            <th>电话</th>
            <td><input type="text" id="pTelephone" name="pTelephone" runat="server"/></td>
        </tr>
        <tr>
            <th>住址</th>
            <td colspan='3'><input type="text" id="pAddress" name="pAddress" style="width: 98%"  runat="server"/></td>
         </tr>
        <tr>
            <th>过敏史</th>
            <td colspan='3'><input type="text" id="pAllergy" name="pAllergy" style="width: 98%"  runat="server"/></td>
        </tr>
        <tr>
            <th>备注</th>
            <td colspan='3'><input type="text" id="pRemark" name="pRemark" style="width: 240px" runat="server"/></td>
        </tr>
    </table>
    <div class="pt-padding" style="text-align:center">
        <input type="button" id="btnSave" class="pt-button active" value="保存" />
        <%--<asp:Button ID="btnSave" class="pt-button active" runat="server" Text="保存" OnClientClick="return Patient.validate() " onclick="btnSave_Click" />--%>
        <input type="button" class="pt-button active" onclick="top.OpenClose('Patient_Form')" value="关闭" />
    </div>
    </form>
    <script type="text/javascript">
        (function() {
            var dataSplit = 'Θ ☺ ☻'.split(' '),
            url = "PatientForm.aspx",
            key = "<%=key %>",
            type = "<%=type %>";

            function init() {
                if (type != "") {//处方调用
                    top.art.dialog.data('PatientValue', ""); // 清空数据
                }
                $("#btnSave").click(function() {
                    Save();
                });
            }
            function Save() {
                if (!validate()) return;
                $.post(url, $.parseJSON(form2JsonString(fEdit, { action: "save", key: key })), function(data) {
                    data = parseInt(data, 10);
                    if (data == 100) {
                        var errorMsg = "操作失败:您输入的姓名[" + $("#pName").val() + "]和住址[" + $("#pAddress").val() + "]已存在!";
                        top.showTipsMsg(errorMsg, 1, 3000);
                    } else if (data == 200) {
                        if (type == "") { //不是处方调用就刷新界面
                            top.main.location.reload();
                            top.showTipsMsg('操作成功!', 0, 3000);
                        }
                        else {
                            top.art.dialog.data('PatientValue', $("#pName").val() + dataSplit[0] + $("#pAddress").val()); // 存储数据
                        }
                        top.OpenClose('Patient_Form');
                    } else {
                        top.showTipsMsg(data, 1, 3000);
                    }
                });
            }
            function validate() {
                //!(/^1[3-8|0-9][0-9]\d{7,8}$/.test($("#pTelephone").val())) var mobile = /^1[3|5|8]\d{9}$/ , phone = /^0\d{2,3}-?\d{7,8}$/;//(!(/^1[3|5][0-9]\d{4,8}$/.test(sMobile))){ 
                if ($("#pName").val() == "") {
                    top.showTipsMsg('您未输入姓名!无法保存!', 1, 3000);
                    return false;
                }
//                if ($("#pTelephone").val() == "") {
//                    top.showTipsMsg('您未输入联系电话!无法保存!', 1, 3000);
//                    return false;
//                }
//                if (isNaN($("#pTelephone").val())) {
//                    top.showTipsMsg('您输入的联系电话格式错误，请重新输入!', 1, 3000);
//                    return false;
//                }
                if ($("#pBirth").val() == "") {
                    top.showTipsMsg('您未选择出生日期!无法保存!', 1, 3000);
                    return false;
                }
                if ($("#pAddress").val() == "") {
                    top.showTipsMsg('您未输入住址，无法保存!', 1, 3000);
                    return false;
                }
                return true;
            }
            init();
        })();
    </script>
</body>
</html>


