<%@ Page Language="C#" %>
<%@ Register TagPrefix="aspxform" Namespace="XFormDesigner.Framework.Web.UI" Assembly="XFormDesigner.Framework" %>
<script runat="server">

    // Insert page code here
    //

</script>
<html xmlns:xform="xmlns:xform">
<head runat="server">
    <link href="/Oimec/Styles/css/StyleSheet.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <title>车辆预约</title> 
    <style>
        BODY {
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        TABLE {
            border-collapse: collapse;
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        P {
            PADDING-RIGHT: 0px;
            PADDING-LEFT: 0px;
            PADDING-BOTTOM: 0px;
            MARGIN: 0px;
            PADDING-TOP: 0px;
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        TD {
            PADDING-RIGHT: 0px;
            PADDING-LEFT: 2px;
            PADDING-BOTTOM: 0px;
        }

            TD.NoPadding {
                PADDING-RIGHT: 0px;
                PADDING-LEFT: 0px;
                PADDING-BOTTOM: 0px;
                PADDING-TOP: 0px;
            }

        INPUT {
            HEIGHT: 20px;
        }

            INPUT.UL {
                BORDER-RIGHT: medium none;
                BORDER-TOP: medium none;
                BORDER-LEFT: medium none;
                BORDER-BOTTOM: #33ff33 1px solid;
            }

        TEXTAREA {
            FONT-SIZE: 12px;
        }

        .yz-inp-cnt {
            display: inline;
        }

        DIV.datetimepicker-date-hour-minutes DIV.time {
            width: 150px;
        }
        #td1 {
        border-right:#b2bcc6 1px solid;
        }
    </style>
    <script type="text/javascript">
        //获取对应控件的值
        function getValue(id) {
            return agent.Eles[document.getElementById(id).getAttribute("xform_xele_index")].getValue();
        }

        //对应控件赋值
        function setValue(id, value) {
            return agent.Eles[document.getElementById(id).getAttribute("xform_xele_index")].setValue(value);
        }


        agent.on('beforeSubmit', function (post, acname) {

            var subscribeID = getValue("XTextBox1");
            var subscribePerson = getValue("subscribePerson");
            var CarNumber = getValue("CarNumber");
            var PostName = getValue("PostName");
            var subscribeDepart = getValue("subscribeDepart");
            var TimeSlot = getValue("XDropDownList1");
            var Route = getValue("Route");

            var DrivingTime = getValue("XDateTimePicker5");
            var endtime = new Date(DrivingTime);

            var endtime1 = endtime.getFullYear() + "-" + (endtime.getMonth() + 1) + "-" + endtime.getDate();

            var nowtime = new Date();
            var nowtime1 = nowtime.getFullYear() + "-" + (nowtime.getMonth() + 1) + "-" + nowtime.getDate();



            if (subscribeID != '') {

                var code = MVehicleJudgment();
                var number = MCarNumberJudgment();
                var JTwo = MVehicleJudgmentTWO();
                var MJTwo = MCarNumberJudgmentTwo();

                if (JTwo > 0) {

                    if (getValue("CarNumber") != "") {
                        if (MJTwo > 0) {
                            if (code > 0) {
                                alert(subscribePerson + "已在" + endtime1 + TimeSlot + "预约车辆，不能重复预约！");
                                return false;
                            }
                            else {
                                if (number > 0) {
                                    alert(CarNumber + "已在" + endtime1 + TimeSlot + "已被预约！");
                                    return false;
                                }
                                else {
                                    var num = (endtime.getMonth() + 1) - (nowtime.getMonth() + 1);
                                    var nowDate = new Date();
                                    var fullYear = nowDate.getFullYear();
                                    var month = nowDate.getMonth() + 1; // getMonth 方法返回 0-11，代表1-12月
                                    var endOfMonth = new Date(fullYear, month, 0).getDate(); // 获取本月最后一天
                                    if (endtime.getFullYear() == nowtime.getFullYear() && ((endtime.getMonth() + 1) == (nowtime.getMonth() + 1) || num == 1)) {

                                        if (endtime.getDate() - nowtime.getDate() == 0) {

                                            if (nowtime.getHours() < 14 && TimeSlot == "下午") {
                                                if (TimeSlot == "") {
                                                    alert("请选择用车时间段！");
                                                    return false;
                                                }
                                                else {
                                                    if (getValue("XLabel2") != "") {

                                                        if (getValue("XLabel2") == "星期六" || getValue("XLabel2") == "星期日") {
                                                            alert("周末无法预约车辆");
                                                            return false;
                                                        }
                                                        else {
                                                            if (getValue("CarNumber") == "京NDF082") {
                                                                if (subscribePerson == "张天容" || subscribePerson == "韦月") {

                                                                    if (Route != "") {
                                                                        if (getValue("SubjectMatter") == "") {
                                                                            alert("请填写用车事由！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            var num = MSubjectMatterJudgment();
                                                                            if (num > 0) {
                                                                                alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                                return false;
                                                                            } else {
                                                                                var SMS = MSendSMS();
                                                                                if (SMS != 1) {
                                                                                    alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                    return false;
                                                                                }
                                                                                else {
                                                                                    return true;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    else {
                                                                        alert("请填写行车路线！");
                                                                        return false;
                                                                    }
                                                                }
                                                                else {
                                                                    alert(subscribePerson + "不能预约" + CarNumber);
                                                                    return false;
                                                                }
                                                            }
                                                            else {
                                                                if (getValue("CarNumber") == "京PVL217" || getValue("CarNumber") == "京PVL223") {

                                                                    if (PostName.indexOf("销售") != -1 || subscribeDepart.indexOf("销售") != -1 || PostName.indexOf("行政") != -1 || subscribeDepart.indexOf("行政") != -1) {

                                                                        if (Route != "") {
                                                                            if (getValue("SubjectMatter") == "") {
                                                                                alert("请填写用车事由！");
                                                                                return false;
                                                                            }
                                                                            else {
                                                                                var num = MSubjectMatterJudgment();
                                                                                if (num > 0) {
                                                                                    alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                                    return false;
                                                                                } else {
                                                                                    var SMS = MSendSMS();
                                                                                    if (SMS != 1) {
                                                                                        alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                        return false;
                                                                                    }
                                                                                    else {
                                                                                        return true;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else {
                                                                            alert("请填写行车路线！");
                                                                            return false;
                                                                        }
                                                                    }

                                                                    else {
                                                                        alert(subscribePerson + "不能预约" + CarNumber);
                                                                        return false;
                                                                    }
                                                                }
                                                                else {

                                                                    if (Route != "") {
                                                                        if (getValue("SubjectMatter") == "") {
                                                                            alert("请填写用车事由！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            var num = MSubjectMatterJudgment();
                                                                            if (num > 0) {
                                                                                alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                                return false;
                                                                            } else {
                                                                                var SMS = MSendSMS();
                                                                                if (SMS != 1) {
                                                                                    alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                    return false;
                                                                                }
                                                                                else {
                                                                                    return true;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    else {
                                                                        alert("请填写行车路线！");
                                                                        return false;
                                                                    }
                                                                }

                                                            }
                                                        }
                                                    }
                                                    else {
                                                        return false;
                                                    }
                                                }
                                            }
                                            else if (nowtime.getHours() < 10 && TimeSlot == "上午") {
                                                if (TimeSlot == "") {
                                                    alert("请选择用车时间段！");
                                                    return false;
                                                }
                                                else {
                                                    if (getValue("XLabel2") != "") {

                                                        if (getValue("XLabel2") == "星期六" || getValue("XLabel2") == "星期日") {
                                                            alert("周末无法预约车辆");
                                                            return false;
                                                        }
                                                        else {
                                                            if (getValue("CarNumber") == "京NDF082") {
                                                                if (subscribePerson == "张天容" || subscribePerson == "韦月") {

                                                                    if (Route != "") {
                                                                        if (getValue("SubjectMatter") == "") {
                                                                            alert("请填写用车事由！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            var num = MSubjectMatterJudgment();
                                                                            if (num > 0) {
                                                                                alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                                return false;
                                                                            } else {
                                                                                var SMS = MSendSMS();
                                                                                if (SMS != 1) {
                                                                                    alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                    return false;
                                                                                }
                                                                                else {
                                                                                    return true;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    else {
                                                                        alert("请填写行车路线！");
                                                                        return false;
                                                                    }
                                                                }
                                                                else {
                                                                    alert(subscribePerson + "不能预约" + CarNumber);
                                                                    return false;
                                                                }
                                                            }
                                                            else {
                                                                if (getValue("CarNumber") == "京PVL217" || getValue("CarNumber") == "京PVL223") {

                                                                    if (PostName.indexOf("销售") != -1 || subscribeDepart.indexOf("销售") != -1 || PostName.indexOf("行政") != -1 || subscribeDepart.indexOf("行政") != -1) {

                                                                        if (Route != "") {
                                                                            if (getValue("SubjectMatter") == "") {
                                                                                alert("请填写用车事由！");
                                                                                return false;
                                                                            }
                                                                            else {
                                                                                var num = MSubjectMatterJudgment();
                                                                                if (num > 0) {
                                                                                    alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                                    return false;
                                                                                } else {
                                                                                    var SMS = MSendSMS();
                                                                                    if (SMS != 1) {
                                                                                        alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                        return false;
                                                                                    }
                                                                                    else {
                                                                                        return true;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                        else {
                                                                            alert("请填写行车路线！");
                                                                            return false;
                                                                        }
                                                                    }

                                                                    else {
                                                                        alert(subscribePerson + "不能预约" + CarNumber);
                                                                        return false;
                                                                    }
                                                                }
                                                                else {

                                                                    if (Route != "") {
                                                                        if (getValue("SubjectMatter") == "") {
                                                                            alert("请填写用车事由！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            var num = MSubjectMatterJudgment();
                                                                            if (num > 0) {
                                                                                alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                                return false;
                                                                            } else {
                                                                                var SMS = MSendSMS();
                                                                                if (SMS != 1) {
                                                                                    alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                    return false;
                                                                                }
                                                                                else {
                                                                                    return true;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    else {
                                                                        alert("请填写行车路线！");
                                                                        return false;
                                                                    }
                                                                }

                                                            }
                                                        }
                                                    }
                                                    else {
                                                        return false;
                                                    }
                                                }
                                            }
                                            else {
                                                alert("已过了预约时间！");
                                                return false;
                                            }

                                        }
                                        else if (endtime.getDate() - nowtime.getDate() == 1 || (endOfMonth == nowtime.getDate() &&  endtime.getDate()==1)) {
                                            if (TimeSlot == "") {
                                                alert("请选择用车时间段！");
                                                return false;
                                            }
                                            else {
                                                if (getValue("XLabel2") != "") {

                                                    if (getValue("XLabel2") == "星期六" || getValue("XLabel2") == "星期日") {
                                                        alert("周末无法预约车辆");
                                                        return false;
                                                    }
                                                    else {
                                                        if (getValue("CarNumber") == "京NDF082") {
                                                            if (subscribePerson == "张天容" || subscribePerson == "韦月") {

                                                                if (Route != "") {
                                                                    if (getValue("SubjectMatter") == "") {
                                                                        alert("请填写用车事由！");
                                                                        return false;
                                                                    }
                                                                    else {
                                                                        var num = MSubjectMatterJudgment();
                                                                        if (num > 0) {
                                                                            alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                            return false;
                                                                        } else {
                                                                            var SMS = MSendSMS();
                                                                            if (SMS != 1) {
                                                                                alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                return false;
                                                                            }
                                                                            else {
                                                                                return true;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else {
                                                                    alert("请填写行车路线！");
                                                                    return false;
                                                                }
                                                            }
                                                            else {
                                                                alert(subscribePerson + "不能预约" + CarNumber);
                                                                return false;
                                                            }
                                                        } else {
                                                            if (getValue("CarNumber") == "京PVL217" || getValue("CarNumber") == "京PVL223") {

                                                                if (PostName.indexOf("销售") != -1 || subscribeDepart.indexOf("销售") != -1 || PostName.indexOf("行政") != -1 || subscribeDepart.indexOf("行政") != -1) {

                                                                    if (Route != "") {
                                                                        if (getValue("SubjectMatter") == "") {
                                                                            alert("请填写用车事由！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            var num = MSubjectMatterJudgment();
                                                                            if (num > 0) {
                                                                                alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                                return false;
                                                                            } else {
                                                                                var SMS = MSendSMS();
                                                                                if (SMS != 1) {
                                                                                    alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                    return false;
                                                                                }
                                                                                else {
                                                                                    return true;
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    else {
                                                                        alert("请填写行车路线！");
                                                                        return false;
                                                                    }
                                                                }
                                                                else {
                                                                    alert(subscribePerson + "不能预约" + CarNumber);
                                                                    return false;
                                                                }
                                                            }
                                                            else {

                                                                if (Route != "") {
                                                                    if (getValue("SubjectMatter") == "") {
                                                                        alert("请填写用车事由！");
                                                                        return false;
                                                                    }
                                                                    else {
                                                                        var num = MSubjectMatterJudgment();
                                                                        if (num > 0) {
                                                                            alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                            return false;
                                                                        } else {
                                                                            var SMS = MSendSMS();
                                                                            if (SMS != 1) {
                                                                                alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                return false;
                                                                            }
                                                                            else {
                                                                                return true;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else {
                                                                    alert("请填写行车路线！");
                                                                    return false;
                                                                }
                                                            }

                                                        }
                                                    }
                                                }
                                                else {
                                                    return false;
                                                }
                                            }
                                        }
                                        else {
                                            alert("预约车时间只能是当天和前一天！");
                                            return false;
                                        }
                                    }
                                    else {
                                        alert("预约车时间只能是当天和前一天！");
                                        return false;
                                    }

                                }
                            }
                        }
                        else {
                            alert("预约人当天只能约一辆车！");
                            return false;
                        }
                    }
                    else {
                        alert("请选择车牌号！");
                        return false;

                    }


                }
                else {
                    if (code > 0) {
                        alert(subscribePerson + "已在" + endtime1 + TimeSlot + "预约车辆，不能重复预约！");
                        return false;
                    }
                    else {
                        if (number > 0) {
                            alert(CarNumber + "已在" + endtime1 + TimeSlot + "已被预约！");
                            return false;
                        }
                        else {
                            var num = (endtime.getMonth() + 1) - (nowtime.getMonth() + 1);
                            var nowDate = new Date();
                            var fullYear = nowDate.getFullYear();
                            var month = nowDate.getMonth() + 1; // getMonth 方法返回 0-11，代表1-12月
                            var endOfMonth = new Date(fullYear, month, 0).getDate(); // 获取本月最后一天
                            if (endtime.getFullYear() == nowtime.getFullYear() && ((endtime.getMonth() + 1) == (nowtime.getMonth() + 1) || num == "1")) {

                                if (endtime.getDate() - nowtime.getDate() == 0) {

                                    if (nowtime.getHours() < 14 && TimeSlot == "下午") {
                                        if (TimeSlot == "") {
                                            alert("请选择用车时间段！");
                                            return false;
                                        }
                                        else {
                                            if (getValue("XLabel2") != "") {

                                                if (getValue("XLabel2") == "星期六" || getValue("XLabel2") == "星期日") {
                                                    alert("周末无法预约车辆");
                                                    return false;
                                                }
                                                else {
                                                    if (getValue("CarNumber") == "京NDF082") {
                                                        if (subscribePerson == "张天容" || subscribePerson == "韦月") {

                                                            if (Route != "") {
                                                                if (getValue("SubjectMatter") == "") {
                                                                    alert("请填写用车事由！");
                                                                    return false;
                                                                }
                                                                else {
                                                                    var num = MSubjectMatterJudgment();
                                                                    if (num > 0) {
                                                                        alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                        return false;
                                                                    } else {
                                                                        var SMS = MSendSMS();
                                                                        if (SMS != 1) {
                                                                            alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            return true;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else {
                                                                alert("请填写行车路线！");
                                                                return false;
                                                            }
                                                        }
                                                        else {
                                                            alert(subscribePerson + "不能预约" + CarNumber);
                                                            return false;
                                                        }
                                                    }
                                                    else {
                                                        if (getValue("CarNumber") == "京PVL217" || getValue("CarNumber") == "京PVL223") {

                                                            if (PostName.indexOf("销售") != -1 || subscribeDepart.indexOf("销售") != -1 || PostName.indexOf("行政") != -1 || subscribeDepart.indexOf("行政") != -1) {

                                                                if (Route != "") {
                                                                    if (getValue("SubjectMatter") == "") {
                                                                        alert("请填写用车事由！");
                                                                        return false;
                                                                    }
                                                                    else {
                                                                        var num = MSubjectMatterJudgment();
                                                                        if (num > 0) {
                                                                            alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                            return false;
                                                                        } else {
                                                                            var SMS = MSendSMS();
                                                                            if (SMS != 1) {
                                                                                alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                return false;
                                                                            }
                                                                            else {
                                                                                return true;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else {
                                                                    alert("请填写行车路线！");
                                                                    return false;
                                                                }
                                                            }

                                                            else {
                                                                alert(subscribePerson + "不能预约" + CarNumber);
                                                                return false;
                                                            }
                                                        }
                                                        else {

                                                            if (Route != "") {
                                                                if (getValue("SubjectMatter") == "") {
                                                                    alert("请填写用车事由！");
                                                                    return false;
                                                                }
                                                                else {
                                                                    var num = MSubjectMatterJudgment();
                                                                    if (num > 0) {
                                                                        alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                        return false;
                                                                    } else {
                                                                        var SMS = MSendSMS();
                                                                        if (SMS != 1) {
                                                                            alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            return true;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else {
                                                                alert("请填写行车路线！");
                                                                return false;
                                                            }
                                                        }

                                                    }
                                                }
                                            }
                                            else {
                                                return false;
                                            }
                                        }
                                    }
                                    else if (nowtime.getHours() < 10 && TimeSlot == "上午") {
                                        if (TimeSlot == "") {
                                            alert("请选择用车时间段！");
                                            return false;
                                        }
                                        else {
                                            if (getValue("XLabel2") != "") {

                                                if (getValue("XLabel2") == "星期六" || getValue("XLabel2") == "星期日") {
                                                    alert("周末无法预约车辆");
                                                    return false;
                                                }
                                                else {
                                                    if (getValue("CarNumber") == "京NDF082") {
                                                        if (subscribePerson == "张天容" || subscribePerson == "韦月") {

                                                            if (Route != "") {
                                                                if (getValue("SubjectMatter") == "") {
                                                                    alert("请填写用车事由！");
                                                                    return false;
                                                                }
                                                                else {
                                                                    var num = MSubjectMatterJudgment();
                                                                    if (num > 0) {
                                                                        alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                        return false;
                                                                    } else {
                                                                        var SMS = MSendSMS();
                                                                        if (SMS != 1) {
                                                                            alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            return true;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else {
                                                                alert("请填写行车路线！");
                                                                return false;
                                                            }
                                                        }
                                                        else {
                                                            alert(subscribePerson + "不能预约" + CarNumber);
                                                            return false;
                                                        }
                                                    }
                                                    else {
                                                        if (getValue("CarNumber") == "京PVL217" || getValue("CarNumber") == "京PVL223") {

                                                            if (PostName.indexOf("销售") != -1 || subscribeDepart.indexOf("销售") != -1 || PostName.indexOf("行政") != -1 || subscribeDepart.indexOf("行政") != -1) {

                                                                if (Route != "") {
                                                                    if (getValue("SubjectMatter") == "") {
                                                                        alert("请填写用车事由！");
                                                                        return false;
                                                                    }
                                                                    else {
                                                                        var num = MSubjectMatterJudgment();
                                                                        if (num > 0) {
                                                                            alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                            return false;
                                                                        } else {
                                                                            var SMS = MSendSMS();
                                                                            if (SMS != 1) {
                                                                                alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                return false;
                                                                            }
                                                                            else {
                                                                                return true;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else {
                                                                    alert("请填写行车路线！");
                                                                    return false;
                                                                }
                                                            }

                                                            else {
                                                                alert(subscribePerson + "不能预约" + CarNumber);
                                                                return false;
                                                            }
                                                        }
                                                        else {

                                                            if (Route != "") {
                                                                if (getValue("SubjectMatter") == "") {
                                                                    alert("请填写用车事由！");
                                                                    return false;
                                                                }
                                                                else {
                                                                    var num = MSubjectMatterJudgment();
                                                                    if (num > 0) {
                                                                        alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                        return false;
                                                                    } else {
                                                                        var SMS = MSendSMS();
                                                                        if (SMS != 1) {
                                                                            alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            return true;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else {
                                                                alert("请填写行车路线！");
                                                                return false;
                                                            }
                                                        }

                                                    }
                                                }
                                            }
                                            else {
                                                return false;
                                            }
                                        }
                                    }
                                    else {
                                        alert("已过了预约时间！");
                                        return false;
                                    }
                                }
                                else if (endtime.getDate() - nowtime.getDate() == 1 || (endOfMonth == nowtime.getDate() && endtime.getDate()==1)) {
                                    if (TimeSlot == "") {
                                        alert("请选择用车时间段！");
                                        return false;
                                    }
                                    else {
                                        if (getValue("XLabel2") != "") {

                                            if (getValue("XLabel2") == "星期六" || getValue("XLabel2") == "星期日") {
                                                alert("周末无法预约车辆");
                                                return false;
                                            }
                                            else {
                                                if (getValue("CarNumber") == "京NDF082") {
                                                    if (subscribePerson == "张天容" || subscribePerson == "韦月") {
                                                        if (getValue("CarNumber") != "") {
                                                            if (Route != "") {
                                                                if (getValue("SubjectMatter") == "") {
                                                                    alert("请填写用车事由！");
                                                                    return false;
                                                                }
                                                                else {
                                                                    var num = MSubjectMatterJudgment();
                                                                    if (num > 0) {
                                                                        alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                        return false;
                                                                    } else {
                                                                        var SMS = MSendSMS();
                                                                        if (SMS != 1) {
                                                                            alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            return true;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else {
                                                                alert("请填写行车路线！");
                                                                return false;
                                                            }
                                                        }
                                                        else {
                                                            alert("请选择车牌号！");
                                                            return false;

                                                        }
                                                    }
                                                    else {
                                                        alert(subscribePerson + "不能预约" + CarNumber);
                                                        return false;
                                                    }
                                                } else {
                                                    if (getValue("CarNumber") == "京PVL217" || getValue("CarNumber") == "京PVL223") {

                                                        if (PostName.indexOf("销售") != -1 || subscribeDepart.indexOf("销售") != -1 || PostName.indexOf("行政") != -1 || subscribeDepart.indexOf("行政") != -1) {
                                                            if (getValue("CarNumber") != "") {
                                                                if (Route != "") {
                                                                    if (getValue("SubjectMatter") == "") {
                                                                        alert("请填写用车事由！");
                                                                        return false;
                                                                    }
                                                                    else {
                                                                        var num = MSubjectMatterJudgment();
                                                                        if (num > 0) {
                                                                            alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                            return false;
                                                                        } else {
                                                                            var SMS = MSendSMS();
                                                                            if (SMS != 1) {
                                                                                alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                                return false;
                                                                            }
                                                                            else {
                                                                                return true;
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                else {
                                                                    alert("请填写行车路线！");
                                                                    return false;
                                                                }
                                                            }
                                                            else {
                                                                alert("请选择车牌号！");
                                                                return false;

                                                            }
                                                        }
                                                        else {
                                                            alert(subscribePerson + "不能预约" + CarNumber);
                                                            return false;
                                                        }
                                                    }
                                                    else {
                                                        if (getValue("CarNumber") != "") {
                                                            if (Route != "") {
                                                                if (getValue("SubjectMatter") == "") {
                                                                    alert("请填写用车事由！");
                                                                    return false;
                                                                }
                                                                else {
                                                                    var num = MSubjectMatterJudgment();
                                                                    if (num > 0) {
                                                                        alert(subscribePerson + "已预约车辆" + CarNumber + "成功！送货车辆只能预约半天。");
                                                                        return false;
                                                                    } else {
                                                                        var SMS = MSendSMS();
                                                                        if (SMS != 1) {
                                                                            alert(subscribePerson + "预约车失败，请查看司机手机是否正确！");
                                                                            return false;
                                                                        }
                                                                        else {
                                                                            return true;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else {
                                                                alert("请填写行车路线！");
                                                                return false;
                                                            }
                                                        }
                                                        else {
                                                            alert("请选择车牌号！");
                                                            return false;

                                                        }
                                                    }

                                                }
                                            }
                                        }
                                        else {
                                            return false;
                                        }
                                    }
                                }
                                else {
                                    alert("预约车时间只能是当天和前一天！");
                                    return false;
                                }
                            }
                            else {
                                alert("预约车时间只能是当天和前一天！");
                                return false;
                            }

                        }
                    }
                }


            }
            else {
                alert("请选择预约人！");
                return false;
            }
        });

        function MVehicleJudgmentTWO() {
            var subscribeID = getValue("XTextBox1");
            var DrivingTime = getValue("XDateTimePicker5");

            var url = YZSoft.$url('Oimec/OA/Services/VehicleHandler.ashx');
            var parm = {
                method: "VehicleJudgmentTWO",
                subscribeID: subscribeID,
                DrivingTime: DrivingTime
            };

            var res;
            AjaxParm(url, false, parm, function (action) {

                var result = action.result;
                var data = action.result.Value;
                var num = data.length;

                res = num;
            });
            return res;
        };

        function MCarNumberJudgmentTwo() {
            var subscribeID = getValue("XTextBox1");
            var CarNumber = getValue("CarNumber");
            var DrivingTime = getValue("XDateTimePicker5");
            var url = YZSoft.$url('Oimec/OA/Services/VehicleHandler.ashx');
            var parm = {
                method: "CarNumberJudgmentTWO",
                subscribeID: subscribeID,
                CarNumber: CarNumber,
                DrivingTime: DrivingTime
            };
            var res;
            AjaxParm(url, false, parm, function (action) {

                var result = action.result;
                var data = action.result.Value;
                var num = data.length;

                res = num;

            });
            return res;
        };

        function MVehicleJudgment() {
            var subscribeID = getValue("XTextBox1");
            var DrivingTime = getValue("XDateTimePicker5");
            var TimeSlot = getValue("XDropDownList1");

            var url = YZSoft.$url('Oimec/OA/Services/VehicleHandler.ashx');
            var parm = {
                method: "VehicleJudgment",
                subscribeID: subscribeID,
                DrivingTime: DrivingTime,
                TimeSlot: TimeSlot
            };

            var res;
            AjaxParm(url, false, parm, function (action) {

                var result = action.result;
                var data = action.result.Value;
                var num = data.length;

                res = num;
            });
            return res;
        };

        function MCarNumberJudgment() {
            var CarNumber = getValue("CarNumber");
            var DrivingTime = getValue("XDateTimePicker5");
            var TimeSlot = getValue("XDropDownList1");
            var url = YZSoft.$url('Oimec/OA/Services/VehicleHandler.ashx');
            var parm = {
                method: "CarNumberJudgment",
                CarNumber: CarNumber,
                DrivingTime: DrivingTime,
                TimeSlot: TimeSlot
            };
            var res;
            AjaxParm(url, false, parm, function (action) {

                var result = action.result;
                var data = action.result.Value;
                var num = data.length;

                res = num;

            });
            return res;
        };

        function MSubjectMatterJudgment() {
            var subscribeID = getValue("XTextBox1");
            var CarNumber = getValue("CarNumber");
            var DrivingTime = getValue("XDateTimePicker5");
            var url = YZSoft.$url('Oimec/OA/Services/VehicleHandler.ashx');
            var parm = {
                method: "MSubjectMatterJudgment",
                subscribeID: subscribeID,
                CarNumber: CarNumber,
                DrivingTime: DrivingTime
            };
            var res;
            AjaxParm(url, false, parm, function (action) {

                var result = action.result;
                var data = action.result.Value;
                var num = data.length;

                res = num;

            });
            return res;
        };

        function MSendSMS() {
            var DriverName = getValue("DriverName");
            var DriverPhone = getValue("DriverPhone");
            var subscribePerson = getValue("subscribePerson");
            var DrivingTime = getValue("XDateTimePicker5");
            var TimeSlot = getValue("XDropDownList1");
            var Route = getValue("Route");

            var url = YZSoft.$url('Oimec/OA/Services/VehicleHandler.ashx');
            var parm = {
                method: "VehicleMSendSMS",
                DriverName: DriverName,
                DriverPhone: DriverPhone,
                subscribePerson: subscribePerson,
                DrivingTime: DrivingTime,
                TimeSlot: TimeSlot,
                Route: Route
            };

            var res;
            AjaxParm(url, false, parm, function (action) {

                var result = action.result;
                res = result;
            });
            return res;
        };

        function AjaxParm(url, async, parm, fun) {

            YZSoft.Ajax.request({
                async: async,
                url: url,
                params: parm,
                success: fun
            });
        };

        function getWeek(startTime) {

            if (startTime != "") {
                var reserveDate = getValue("XDateTimePicker5");

                var reserveDate = reserveDate.substring(0, 10);
                var dtArr = reserveDate.split("-");
                var dt = new Date(dtArr[0], dtArr[1] - 1, dtArr[2]);
                var week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
                setValue("XLabel2", week[dt.getDay()]);

            }
        }

        function getFullDate(targetDate) {
            var D, y, m, d;
            if (targetDate) {
                D = new Date(targetDate);
                y = D.getFullYear();
                m = D.getMonth() + 1;
                d = D.getDate();
            } else {
                y = fullYear;
                m = month;
                d = date;
            }
            m = m > 9 ? m : '0' + m;
            d = d > 9 ? d : '0' + d;
            return y + '-' + m + '-' + d;
        };
    </script>
</head>
<body>
    <form runat="server">
        <!-- Insert content here -->
        <table width="1200" align="center" class="head" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td class="logo">
                    </td>
                    <td class="biaoti" style="PADDING-LEFT: 30px">
                        <asp:Label id="XLabel1" runat="server" text="车辆预约"></asp:Label></td>
                    <td class="formno">
                    </td>
                </tr>
            </tbody>
        </table>
        <br />
        <table width="1200" align="center" class="table" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                 <tr>
                    <td height="22" class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="Label4" runat="server" text="申请人"></asp:Label></td>
                    <td class="tsbottomtext" style="WIDTH: 35%">
                        <aspxform:XTextBox id="XTextBox3" runat="server" XDataBind="DF_OA_VehicleBookin.ApplicantID" BackColor="#E6F1F8" BorderWidth="1" Width="70%" DisableBehavior="ReadOnly" BorderColor="#DCDCDC" CssClass="text" ReadOnly="True" HiddenExpress="1"  ValueToDisplayText="TableName:V_DF_HR_BasicInfo;FilterColumn:AttendanceKakaNO;DisplayColumn:AttendanceKakaNO" DataMap="AttendanceKakaNO->DF_OA_VehicleBookin.subscribeID;Name->DF_OA_VehicleBookin.subscribePerson;Department->DF_OA_VehicleBookin.subscribeDepart;PostName->PostName" ></aspxform:XTextBox>
                        <aspxform:XTextBox id="XTextBox4" runat="server" Width="50%" BorderWidth="1" BorderColor="#DCDCDC" XDataBind="DF_OA_VehicleBookin.Applicant"></aspxform:XTextBox>
                    </td>
                    <td class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="Label5" runat="server" text="申请时间"></asp:Label></td>
                    <td class="tsbottomtext" style="WIDTH: 35%">
                        <aspxform:XDateTimePicker id="XDateTimePicker6" runat="server" BackColor="#e6f1f8" XDataBind="DF_OA_VehicleBookin.ApplicationTime" BorderWidth="1" BorderColor="#DCDCDC" DisableBehavior="ReadOnly" Width="60%" CssClass="text" DisplayOnly="True"></aspxform:XDateTimePicker>
                    </td>
                </tr>
                <tr>
                    <td class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="XLabel4" runat="server" text="预约人"></asp:Label>
                         <aspxform:XTextBox id="XTextBox1" runat="server" Width="50%" BorderWidth="1" BorderColor="#DCDCDC" XDataBind="DF_OA_VehicleBookin.subscribeID" HiddenInput="true"></aspxform:XTextBox>
                        <aspxform:XTextBox id="PostName" runat="server" Width="50%" BorderWidth="1" BorderColor="#DCDCDC" XDataBind="PostName" HiddenInput="true"></aspxform:XTextBox>
                    </td>
                    <td class="tsbottomtext" style="WIDTH: 35%">
                        <aspxform:XTextBox id="subscribePerson" runat="server" XDataBind="DF_OA_VehicleBookin.subscribePerson" BackColor="#E6F1F8" BorderWidth="1" Width="50%" DisableBehavior="ReadOnly" BorderColor="#DCDCDC" CssClass="text" ReadOnly="True"></aspxform:XTextBox>
                        <aspxform:XDataBrowserButton id="XDataBrowserButton4" runat="server" Text="查询" Width="35px" DataMap="AttendanceKakaNO->DF_OA_VehicleBookin.subscribeID;Name->DF_OA_VehicleBookin.subscribePerson;Department->DF_OA_VehicleBookin.subscribeDepart;PostName->PostName" Height="25px" DisplayColumns="AttendanceKakaNO:BPM账号;Name:员工姓名;Department:部门" XDataSource="TableName:V_DF_HR_BasicInfo"></aspxform:XDataBrowserButton>
                    </td>
                    <td class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="XLabel5" runat="server" text="预约部门"></asp:Label></td>
                    <td class="tsbottomtext" style="WIDTH: 35%">
                        <aspxform:XTextBox id="subscribeDepart" runat="server" XDataBind="DF_OA_VehicleBookin.subscribeDepart" BackColor="#E6F1F8" BorderWidth="1" Width="50%" DisableBehavior="ReadOnly" BorderColor="#DCDCDC" CssClass="text" ReadOnly="True"></aspxform:XTextBox>
                    </td>
                </tr>
                <tr>
                    <td height="22" class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="XLabel42" runat="server" text="车牌号"></asp:Label>
                        <aspxform:XTextBox id="XTextBox5" runat="server" XDataBind="DF_OA_VehicleBookin.VMID" BackColor="#E6F1F8" BorderWidth="1" Width="50%" DisableBehavior="ReadOnly" BorderColor="#DCDCDC" CssClass="text" ReadOnly="True" HiddenInput="true"></aspxform:XTextBox>
                        <aspxform:XTextBox id="DriverName" runat="server" XDataBind="DriverName" BackColor="#E6F1F8" BorderWidth="1" Width="50%" DisableBehavior="ReadOnly" BorderColor="#DCDCDC" CssClass="text" ReadOnly="True" HiddenInput="true"></aspxform:XTextBox>
                         <aspxform:XTextBox id="DriverPhone" runat="server" XDataBind="DriverPhone" BackColor="#E6F1F8" BorderWidth="1" Width="50%" DisableBehavior="ReadOnly" BorderColor="#DCDCDC" CssClass="text" ReadOnly="True" HiddenInput="true"></aspxform:XTextBox>
                    </td>
                    <td class="tsbottomtext" style="WIDTH: 35%">
                       <aspxform:XTextBox id="CarNumber" runat="server" XDataBind="DF_OA_VehicleBookin.CarNumber" BackColor="#E6F1F8" BorderWidth="1" Width="50%" DisableBehavior="ReadOnly" BorderColor="#DCDCDC" CssClass="text" ReadOnly="True"></aspxform:XTextBox>
                        <aspxform:XDataBrowserButton id="XDataBrowserButton8" runat="server" Width="35px" Text="查询" XDataSource="TableName:DF_OA_VehicleManagement;Filter:Enabled->'0'"  DisplayColumns="CarNumber:车牌号;Model:车型;Describe:描述"  Height="25px" DataMap="ID->DF_OA_VehicleBookin.VMID;CarNumber->DF_OA_VehicleBookin.CarNumber;Model->DF_OA_VehicleBookin.Model;DriverPhone->DriverPhone;DriverName->DriverName;" ></aspxform:XDataBrowserButton>  
                    </td>
                    <td class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="Label3" runat="server" text="车型"></asp:Label></td>
                    <td class="tsbottomtext" style="WIDTH: 35%">
                          <aspxform:XTextBox id="Model" runat="server" XDataBind="DF_OA_VehicleBookin.Model" BackColor="#E6F1F8" BorderWidth="1" Width="50%" DisableBehavior="ReadOnly" BorderColor="#DCDCDC" CssClass="text" ReadOnly="True"></aspxform:XTextBox>
                    </td>
                </tr>
                <tr>
                    <td class="tsbottomlabel" style="WIDTH: 10%">用车时间</td>
                   <td class="tsbottomtext" style="WIDTH: 35%">
                       <aspxform:XDateTimePicker id="XDateTimePicker5" style="WIDTH: 50%" runat="server" XDataBind="DF_OA_VehicleBookin.DrivingTime" BorderColor="#DCDCDC"  BorderWidth="1" ></aspxform:XDateTimePicker>
                        &nbsp;&nbsp;<aspxform:XLabel id="XLabel2" runat="server" BackColor="#d4e4fe"></aspxform:XLabel>
                        <aspxform:XTextBox id="XTextBox14" runat="server" Width="54px" BorderWidth="1px" BorderColor="Gainsboro" ValueToDisplayText Max="0" Min="0" HiddenInput="True" Express="javascript('getWeek',DF_OA_VehicleBookin.DrivingTime)"></aspxform:XTextBox>
                   </td>
                    <td height="22" class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="Label1" runat="server" text="时间段"></asp:Label></td>
                    <td class="tsbottomtext" style="WIDTH: 35%">
                        <aspxform:XDropDownList id="XDropDownList1" runat="server" XDataBind="DF_OA_VehicleBookin.TimeSlot" PromptText="--请选择--">
                            <asp:ListItem Value="上午">上午</asp:ListItem>
                            <asp:ListItem Value="下午">下午</asp:ListItem>
                        </aspxform:XDropDownList>
                    </td>
                    
                </tr>
                <tr>
                     <td class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="Label2" runat="server" text="行车路线"></asp:Label>
                    </td>
                    <td class="tsbottomtext" colspan="3">
                        <aspxform:XTextBox id="Route" runat="server" Width="78%" BorderWidth="1" BorderColor="#DCDCDC" XDataBind="DF_OA_VehicleBookin.Route"></aspxform:XTextBox>
                    </td>
                </tr>
                <tr>
                     <td class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="Label6" runat="server" text="用车事由"></asp:Label>
                    </td>
                    <td class="tsbottomtext" colspan="3">
                        <aspxform:XTextBox id="SubjectMatter" runat="server" Width="78%" BorderWidth="1" BorderColor="#DCDCDC" XDataBind="DF_OA_VehicleBookin.SubjectMatter"></aspxform:XTextBox>
                    </td>
                </tr>
            </tbody>
        </table>
         <br />
        <table width="1200" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td>
                        <asp:Label id="Label11" runat="server" text="提示一：预约人可以当天约车，也可提前一天预约车辆，车辆预约时间分为上午和下午，如果需要全天用车，请同时预约上下午的时间。" forecolor="Red" font-bold="True"></asp:Label></td>
                </tr>
                <tr>
                    <td>
                        <asp:Label id="Label7" runat="server" text="提示二：预约人约车时必须清楚地注明行车路线。" forecolor="Red" font-bold="True"></asp:Label></td>
                </tr>
                <tr>
                    <td>
                        <asp:Label id="Label8" runat="server" text="提示三：预约人当天只能约一辆车。" forecolor="Red" font-bold="True"></asp:Label></td>
                </tr>
                <tr>
                    <td>
                        <asp:Label id="Label9" runat="server" text="提示四：预约人用车事由为“送货”只能约上午或者下午。" forecolor="Red" font-bold="True"></asp:Label></td>
                </tr>
                 <tr>
                    <td>
                        <asp:Label id="Label10" runat="server" text="提示五：当天约车，10点之前可约上午，14点之前可约下午。" forecolor="Red" font-bold="True"></asp:Label></td>
                </tr>
                 <tr>
                    <td>
                        <asp:Label id="Label12" runat="server" text="提示六：周六日不能约车，也不能在周六日提前约车。" forecolor="Red" font-bold="True"></asp:Label></td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
</html>

