Как сравнить две даты и применить проверку относительно этого - PullRequest
0 голосов
/ 01 октября 2019

Я создал страницу со сводкой заказов в моем проекте. На этой странице я показываю все значения, поступающие из базы данных. Я хочу обновить даты и проверить, что дата доставки не меньше даты получения. Пожалуйста, помогите мне, как я могу сделать это из JQuery. Я поделился с вами кодом. Пожалуйста, проверьте это и помогите мне в этом.

Позвольте мне показать код, который поможет вам в этом.

<div class="form-group">
    <div class="row">
        <div class="col-md-6">
            <strong>PickUp Date:</strong>
            @if (@Model.OrderSummary.PickUpDate != null)
            {
            @Html.DisplayFor(x => x.OrderSummary.PickUpDate, new { id = "PickUp_Date1", @class = "form-control" })
            <a href="#" title="Click to edit" class="orderPickupdate" id="@Model.OrderSummary.ID"><i class="fas fa-pencil-alt"></i></a>
            }
        </div>
        <div class="col-md-6">
            <strong>PickUp Time:</strong>
            @Html.DisplayFor(x => x.OrderSummary.PickUpTime, new { id = "PickUp_Time1", @class = "form-control" })
            <a href="#" title="Click to edit" class="orderPickuptime" id="@Model.OrderSummary.ID"><i class="fas fa-pencil-alt"></i></a>
        </div>
    </div>
</div>'

<div class="form-group">
    <div class="row">
        <div class="col-md-6">
            <strong>Delivery Address:</strong>
            @Html.DisplayFor(x => x.OrderSummary.deliveryAddress, new { id = "Delivery_Address1", @class = "form-control" })
            <a href="#" title="Click to edit" class="orderDeliveryaddress" id="@Model.OrderSummary.ID"><i class="fas fa-pencil-alt"></i></a>
        </div>
        <div class="col-md-6">
            <strong>Delivery At:</strong>
            @Html.DisplayFor(x => x.OrderSummary.DeliveryLocation, new { id = "Delivery_Location1", @class = "form-control" })
            <a href="#" title="Click to edit" class="orderDeliveryat" id="@Model.OrderSummary.ID"><i class="fas fa-pencil-alt"></i></a>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="row">
        <div class="col-md-6">
            <strong>Delivery Date:</strong>
            @Html.DisplayFor(x => x.OrderSummary.DeliveryDate, "{0:dd-MM-yyyy}", new { id = "Delivery_Date1", @class = "form-control" })
            <a href="#" title="Click to edit" class="orderDeliverydate" id="@Model.OrderSummary.ID"><i class="fas fa-pencil-alt"></i></a>
        </div>
        <div class="col-md-6">
            <strong>Delivery Time:</strong>
            @Html.DisplayFor(x => x.OrderSummary.DeliveryTime, new { id = "Delivery_Time1", @class = "form-control ui-timepicker-container" })
            <a href="#" title="Click to edit" class="orderDeliverytime" id="@Model.OrderSummary.ID"><i class="fas fa-pencil-alt"></i></a>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="row">
        <div class="col-md-6">
            <strong>Number Of Shoes:</strong>
            @Html.DisplayFor(x => x.OrderSummary.No_Of_Shoes, new { id = "No_Of_Shoes1", @class = "form-control" })
        </div>
        <div class="col-md-6">
            <strong>Total Payment:</strong>
            @Html.DisplayFor(x => x.OrderSummary.TotalPayment, new { id = "TotalPayment1", @class = "form-control" })
        </div>
    </div>
</div>
<span>
    @Html.ActionLink("Cancel", "DashBoard", "Home", new { id = "Cancel", @class = "btn btn-success", @style = "border-radius:20px" })
    @*@Html.ActionLink("Confirm Now", "Pay", "Home", new { id = "BookNow", @class = "btn btn-success", @style = "border-radius:20px" })*@
    <input type="submit" value="Confirm Now" class="Submit btn btn-success" style="border-radius:20px" />
</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>

    @*#region DELIVERY ADDRESS MODAL*@
<div class="modal fade pmodel" id="Delivery_Address" role="dialog" aria-labelledby="Delivery_Address_Label" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content res ml-2" style="width:333px">
            <div class="modal-header">
                <h5 class="modal-title" id="Delivery_Address_Label">Edit Delivery Address</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="clearfix"></div>
            <div class="modal-body">
                <div id="modalContentHolder2">
                </div>
            </div>
            <div class="modal-footer">
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
</div>

    @section scripts{
        @Scripts.Render("~/bundles/jqueryval")

<script>


    $(document).ready(function () {

        google.maps.event.addDomListener(window, 'load', function () {
            var input = document.getElementById('.PickUpAddress');
            var places = new google.maps.places.Autocomplete(input);

        });

        google.maps.event.addDomListener(window, 'load', function () {
            var input = document.getElementById('DeliveryAddress');
            var places = new google.maps.places.Autocomplete(input);

        });
    });

    $(document).on("click", ".pickupAddress", function () {

        var oderDetail = {
            PickUpAddress: $("#PickUpAddress").val(),
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/home/OrderSummaryPickUpAddress",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                $('#PickUp_Address').modal('hide');
                $('#PickUp_Address1').val(response.PickUpAddress);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);
            }
        });
    });

    $(".orderPickupaddress").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();

        $.ajax({
            type: "Get",
            url: "/home/OrderSummaryPickUpAddress",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {

                $('#modalContentHolder1').html(response);
                $('#PickUp_Address').modal('show');
            }
        });
    });

    $(document).on("click", ".pickupat", function () {

        var radioValue = $("input[name='pickuplocation']:checked").val();
        $('#PickUpLocation').val(radioValue);
        var oderDetail = {
            PickUpLocation: radioValue,
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/Home/OrderSummaryPickUp",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                $('#PickUp_At').modal('hide');
                $('#PickUp_Location1').val(response.PickUpLocation);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);
            }
        });
    });

    $(".orderPickupat").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();
        $.ajax({
            type: "Get",
            url: "/Home/OrderSummaryPickUp",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {
                $('#pickupmodalContentHolder1').html(response);
                $('#PickUp_At').modal('show');
            }
        });
    })

    $(document).on("click", ".pickupdate", function () {

        var oderDetail = {
            Pickupdate: $("#PickUpDate2").val(),
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/Home/OrderSummaryPickUpDate",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                $('#PickUp_Date').modal('hide');
                $('#PickUp_Date1').val(response.PickUpDate);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);
            }
        });
    });

    $(".orderPickupdate").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();
        $.ajax({
            type: "Get",
            url: "/Home/OrderSummaryPickUpDate",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {

                $('#modalContentHolder10').html(response);
                $("#PickUpDate2").datepicker({
                    dateFormat: 'mm/dd/yy',
                    prevText: '<i class="fa fa-chevron-left"></i>',
                    nextText: '<i class="fa fa-chevron-right"></i>',
                });
                $('#PickUp_Date').modal('show');

            }
        });

    })

    $(document).on("click", ".pickuptime", function () {

        var oderDetail = {
            PickUpTime: $("#PickUpTime").val(),
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/Home/OrderSummaryPickUpTime",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                $('#PickUp_Time').modal('hide');
                $('#PickUp_Time1').val(response.PickUpTime);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);
            }
        });
    });

    $(".orderPickuptime").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();
        $.ajax({
            type: "Get",
            url: "/Home/OrderSummaryPickUpTime",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {
                $('#modalContentHolder5').html(response);
                $('#PickUp_Time').modal('show');
            }
        });
    })

    $(document).on("click", ".deliveryaddress", function () {

        var oderDetail = {
            DeliveryAddress: $("#DeliveryAddress").val(),
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/Home/OrderSummaryDeliveryAddress",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                $('#Delivery_Address').modal('hide');
                $('#Delivery_Address1').val(response.DeliveryAddress);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);
            }
        });
    });

    $(".orderDeliveryaddress").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();
        $.ajax({
            type: "Get",
            url: "/Home/OrderSummaryDeliveryAddress",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {

                $('#modalContentHolder2').html(response);
                $('#Delivery_Address').modal('show');

            }
        });
    })

    $(document).on("click", ".deliveryat", function () {

        var radioValue = $("input[name='deliverylocation']:checked").val();
        $('#DeliveryLocation').val(radioValue);
        var oderDetail = {
            DeliveryLocation: radioValue,
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/Home/OrderSummaryDelivery",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                alert("hi");
                $('#Delivery_At').modal('hide');
                $('#Delivery_Location1').val(response.DeliveryLocation);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);
            }
        });
    });

    $(".orderDeliveryat").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();
        $.ajax({
            type: "Get",
            url: "/Home/OrderSummaryDelivery",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {
                $('#modalContentHolder3').html(response);
                $('#Delivery_At').modal('show');
            }
        });
    })

    $(document).on("click", ".deliverydate", function () {

        var oderDetail = {
            DeliveryDate: $("#EditDelivery_Date1").val(),
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/Home/OrderSummaryDeliveryDate",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                $('#Delivery_Date').modal('hide');
                $('#Delivery_Date1').val(response.DeliveryDate);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);

            }

        });


    });

    $(".orderDeliverydate").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();
        $.ajax({
            type: "Get",
            url: "/Home/OrderSummaryDeliveryDate",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {
                $('#modalContentHolder6').html(response);
                $("#EditDelivery_Date1").datepicker({
                    dateFormat: 'mm/dd/yy',
                    prevText: '<i class="fa fa-chevron-left"></i>',
                    nextText: '<i class="fa fa-chevron-right"></i>',
                    onSelect: function (selectedDate) {
                        $('#EditDelivery_Date1').datepicker('option', 'minDate', selectedDate);
                    }
                });
                $('#Delivery_Date').modal('show');
            }
        });
    })

    $(document).on("click", ".deliverytime", function () {

        var oderDetail = {
            DeliveryTime: $("#DeliveryTime").val(),
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/Home/OrderSummaryDeliveryTime",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                $('#Delivery_Time').modal('hide');
                $('#Delivery_Time1').val(response.DeliveryTime);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);
            }
        });
    });

    $(".orderDeliverytime").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();
        $.ajax({
            type: "Get",
            url: "/Home/OrderSummaryDeliveryTime",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {
                $('#modalContentHolder7').html(response);
                $('#Delivery_Time').modal('show');
            }
        });
    });

    $(document).on("click", ".Submit", function () {

        var oderDetail = {
            DeliveryAddress: $("#DeliveryAddress").val(),
            ID: $("#ID").val(),
            OrderCount: $("#No_Of_Shoes").val(),
            TotalAmount: $("#TotalAmount").val(),
        }
        $.ajax({
            type: "POST",
            url: "/Home/OrderSummaryDeliveryAddress",
            data: oderDetail,
            dataType: JSON,
            traditional: true,
            success: function (response) {

                $('#Delivery_Address').modal('hide');
                $('#Delivery_Address1').val(response.DeliveryAddress);
                $('#TotalPayment1').val(response.tb_Amount);
                $('#No_Of_Shoes1').val(response.ShoesCount);
            }
        });
    });

    $(".orderDeliveryaddress").click(function (evt) {

        var id = $(this).attr("id")
        var No_Of_Shoes = $('#No_Of_Shoes').val();
        var TotalAmount = $('#TotalAmount').val();
        $.ajax({
            type: "Get",
            url: "/Home/OrderSummaryDeliveryAddress",
            data: { id: id, No_Of_Shoes: No_Of_Shoes, TotalAmount: TotalAmount },
            success: function (response) {

                $('#modalContentHolder2').html(response);
                $('#Delivery_Address').modal('show');

            }
        });
    })

</script>

    _EditPickUpAddressPartial.cshtml

    @model ShoeShinerService.BAL.ViewModel.LocationViewModel
<div class="container">
    <form method="post">
        <div class="row">
            @Html.HiddenFor(x => x.ID)
            @Html.HiddenFor(x => x.No_Of_Shoes)
            @Html.HiddenFor(x => x.TotalAmount)
            <div class="col-md-12">
                <div class="form-row">
                    <div class="col-md-12">
                        <label>Address:</label>
                        @Html.TextBoxFor(x => x.PickUpAddress, new { @class = "form-control", Placeholder = "Enter the PickUp Address" })
                    </div>
                </div>
            </div>
        </div><br />
        <footer>
            <input type="submit" class="btn btn-success pickupAddress" style="border-radius:20px" value="Submit" />
        </footer>
    </form>
</div>


    @model ShoeShinerService.BAL.ViewModel.LocationViewModel
<div class="container">
    <form method="post">
        <div class="row">
            @Html.HiddenFor(x => x.ID)
            @Html.HiddenFor(x => x.No_Of_Shoes)
            @Html.HiddenFor(x => x.TotalAmount)
            <div class="col-md-12">
                <div class="form-row">
                    <div class="col-md-12">
                        <label>Address:</label>
                        @Html.TextAreaFor(x => x.DeliveryAddress, new { @class = "form-control", Placeholder = "Enter the Delivery Address" })
                    </div>
                </div>
            </div>
        </div><br />
        <footer>
            <input type="submit" class="btn btn-success deliveryaddress" style="border-radius:20px" value="Submit" />
        </footer>
    </form>
</div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...