按钮类型按钮发布数据未保存在DB中

时间:2018-01-04 07:01:03

标签: javascript jquery c#-4.0 asp.net-mvc-5.2

我添加了消息框,我发布了该数据但没有添加到我的数据库中。

当我尝试点击“确认”按钮时,它不会保存在数据库中如何保存到数据库中,请您帮助我。

reindex

var leaveManagement= {
    leaveData: null,
    showModal: function(data) {
        leaveManagement.leaveData = data;
        $('#adminComment').val("");
        $('#IsPaidLeave').prop('checked', false);
        if ($(data).val() === "Reject") {
            $(".form-check").hide();
        } else {
            var leaveTypeId = $(leaveManagement.leaveData).attr('data-leaveTypeId');
            var userId = $(leaveManagement.leaveData).attr('data-employeeId');

            if (leaveTypeId !== "" && leaveTypeId !== null && userId !== "" && userId !== null) {
                $.ajax({
                    url: "/PayRoll/Leave/GetEmployeeLeaveTypeCount?employeeId=" +userId+"&leaveTypeId=" +leaveTypeId,
                    type: 'GET',
                    async: false,
                    contentType: 'application/json; charset=utf-8',
                    success: function (data) {
                     $('#leaveCount').html('<span class="badge badge-outline badge-primary">Remaining Leave : '+data+'</span>');
                    },
                    error: function (e) {

                    }
                });
            }
            $(".form-check").show();
        }
        $('#showCommentModal').modal('show');
    },
    changeRequest: function () {
        if (leaveManagement.leaveData !== null) {
        debugger;
            var leaveId;
            if ($(leaveManagement.leaveData).val() === "Approve") {
                leaveId = $(leaveManagement.leaveData).attr('data-id');
                leaveManagement.processRequest(leaveId, true, false);
            } else if ($(leaveManagement.leaveData).val() === "Reject") {
                leaveId = $(leaveManagement.leaveData).attr('data-id');
                leaveManagement.processRequest(leaveId, false, true);
            }

        }
    },
    processRequest: function(leaveId, isApproved, isRejected) {
        var comment = $('#adminComment').val();
        var isPaidLeave = $('#IsPaidLeave').prop('checked');
        $.ajax({
            url: "/PayRoll/Leave/RespondToLeaveRequest/?leaveId=" +
                leaveId +
                "&isApproved=" +
                isApproved +
                "&IsRejected=" +
                isRejected +
                "&comment=" +
                comment +
                "&isPaidLeave=" +
                isPaidLeave,
            type: "POST",
            async: false,
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                if (!data.success) {
                    $.notify(data.ResponseText, { position: "top right", className: "success" });
                } else {
                    $.notify('Updated', { position: "top right", className: "success" });
                }
                $("#OpenLeaveRequestGrid").data('kendoGrid').dataSource.read();
                $("#ClosedLeaveRequestGrid").data('kendoGrid').dataSource.read();
                $('#adminComment').val("");
                $('#IsPaidLeave').prop('checked', false);
                $('#IsPaid').prop('checked', false);
            },
            error: function(data) {
                console.log(data);
                $.notify('Error', { position: "top right", className: "error" });
            }
        });
    },

这是按钮,如果我点击此按钮,它应该保存我的评论数据。

div class="modal-footer">
                <button type="button" class="btn btn-warning" onclick="leaveManagement.changeRequest(this);" data-dismiss="modal" value="Confirm" id="bntconfirm">Confirm</button>@*<span class="fa fa-check"> Confirm</span>*@
            </div>

这是写评论的方框。

0 个答案:

没有答案