﻿
$(function() {
    //预约科室
    $("#ddlCategores").FillOptions("/Resources/Services/GetQuestionCategories.ashx?typeid=A&cspell=0", { datatype: "json", textfield: "name", valuefiled: "spell" });

});

$(document).ready(
        function() {
            //问题提交
            $("#btnPost").click(function() { PostBookings(); });

})
//***********************提交预约***********************
//提交预约
function PostBookings() {
    if (CheckPostBookings()) {
        PostBookingsGo();
    }
}

//验证输入情况
function CheckPostBookings() {
    if ($("#Realname").val() == "") {
        alert("请输入您预约的姓名.");
        $("#Realname").focus();
        return false;
    }
    if ($("#Telephone").val() == "") {
        alert("请输入您预约的联系电话.");
        $("#Telephone").focus();
        return false;
    }
    if ($("#ddlCategores").val() == "0") {
        alert("请选择科室.");
        return false;
    }
    if ($("#PostDate").val() == "") {
        alert("请输入您的预约时间.");
        $("#PostDate").focus();
        return false;
    }
    return true;
}

//提交提问信息
function PostBookingsGo() {
    $.post("/Resources/PutData/PutBookings.aspx", { Action: "post",
        SweetBox2U_textRealname: $("#Realname").val(),
        SweetBox2U_selectGender: $("#Gender").attr("value"),
        SweetBox2U_selectCategores: $("#ddlCategores").val(),
        SweetBox2U_Age: $("#Age").val(),
        SweetBox2U_Address: $("#Address").val(),
        SweetBox2U_Telephone: $("#Telephone").val(),
        SweetBox2U_Email: $("#Email").val(),
        SweetBox2U_qq: $("#qq").val(),
        SweetBox2U_PostDate: $("#PostDate").val(),
        SweetBox2U_Memo: $("#Memo").val()
    },
     function(data, textStatus) {
         if (data.result == "success") {
             ClearText();
             alert("预约请求提交成功,我们将第一时间为您解答.");// location.href = '/bookings/';
         }
         else if (data.result == "fail") {
             alert("预约请求提交失败,请速与管理员联系,谢谢.");
         }
         else {
             alert(data.result);
         }
     }, "json")
 }

 function ClearText() {
     $("#Realname").attr("value", "");
     $("#Age").attr("value", "");
     $("#Address").attr("value", "");
     $("#Telephone").attr("value", "");
     $("#Email").attr("value", "");
     $("#qq").attr("value", "");
     $("#PostDate").attr("value", "");
     $("#Memo").attr("value", "");
 }

//***********************提交预约***********************


