不从编辑保存按钮调用HttpPost Action方法

时间:2014-03-06 07:22:36

标签: c# jquery asp.net-mvc

这是我的行动方法

 [HttpPost]
        [AuthorizePrivileges(Privileges = "Manage Waiting Room")]
        public ActionResult EditBillingCharges(int Id, BillingChargesModel billingChargeModel, string hdnGlobalPostVar, string hdnBillingChargesDetailsId)
        {
            if (!isActive)
                return LogOut();
            ViewData["CurrentPage"] = "Edit Billing Charge Sheet";
            BillingCharges billing = new BillingCharges();
            billing = BillingChargesBo.FindById(Id);
            if (hdnGlobalPostVar.ToLower().ToString() == "edit")
            {
                if (billingChargeModel != null)
                {
                    billing.Name = billingChargeModel.BillingCharges.Name;
                    billing.ModifiedBy = User.Identity.Name;
                    billing.DateCreated = DateTime.Now;
                    billing.DateModified = DateTime.Now;

                    BillingChargesBo.SaveOrUpdate(billing);
                    string[] schedulingDetailId = null;
                    if (hdnBillingChargesDetailsId != "" && hdnBillingChargesDetailsId.Contains(';'))
                    {
                        schedulingDetailId = hdnBillingChargesDetailsId.Split(';');
                        for (int i = 0; i < schedulingDetailId.Length - 1; i++)
                        {
                            BillingChargeDetails billingDetails = BillingChargesDetailsBo.FindById(Convert.ToInt16(schedulingDetailId[i].Trim()));
                            billingDetails.BillingCharges = billing;
                            BillingChargesDetailsBo.SaveOrUpdate(billingDetails);

                        }
                    }




                }
            }



            BillingChargesModel modelbillingModel = new BillingChargesModel();
            modelbillingModel.BillingCharges = BillingChargesBo.FindById(billing.Id);
            modelbillingModel.BillingDetailsModel = BillingChargesDetailsBo.LoadAllDetailsByBillingChargeId(billing.Id);
            IList<BillingChargeDetails> billingchargeDetails = new List<BillingChargeDetails>();
            billingchargeDetails = BillingChargesDetailsBo.LoadAllDetailsByBillingId();
            for (int i = 0; i < billingchargeDetails.Count; i++)
            {
                modelbillingModel.BillingDetailsModel.Add(billingchargeDetails[i]);

            }


            return View(modelbillingModel);

        }

查看代码

@model WCG.Web.Models.BillingChargesModel
@using WCG.Web.Utils
@using WCG.Data.BusinessObjects
@using MvcContrib.UI.Grid
@using MvcContrib.UI.Pager
@using MvcContrib.Pagination
@using MvcContrib.UI.Grid.ActionSyntax
@{
    ViewBag.Title = "Edit Billing Charge Sheet";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<link href="@Url.Content("~/Content/jquery.multiSelect.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/dd.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/jquery-ui.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" type="text/css" rel="stylesheet" />
<link href="@Url.Content("~/Content/Grid/demo_page.css")" type="text/css" rel="stylesheet" />
<link href="@Url.Content("~/Content/Grid/demo_table_jui.css")" type="text/css" rel="stylesheet" />
<link href="@Url.Content("~/Content/Grid/jquery-ui-1.8.4.custom.css")" type="text/css" rel="stylesheet" />
<script  src="@Url.Content("~/Scripts/jquery.min.js")" type='text/javascript' ></script>
<script  src="@Url.Content("~/Scripts/jquery-ui.min.js")" type='text/javascript' ></script>
<script src="@Url.Content("~/Content/Grid/jquery.dataTables.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/CommonScript.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Grid.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/GridSorting.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.dd.js")" type="text/javascript"></script>
<link href="@Url.Content("~/Content/themes/FixHeaderGrid.css")" type="text/css" rel="stylesheet" />
<script src="@Url.Content("~/Scripts/FixHeaderGrid.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/BindBillingChargeSheet.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.blockUI.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.multiselectBillingCPT.js")" type="text/javascript"></script>

<script type="text/javascript">
    var rootUrl = '@Url.Content("~")';
</script>

<style type="text/css">
    #content_wrapper
    {
        width: 100%;
        float: left;
        min-height: 300px;
        margin-bottom: 1px;
    }
    #main_content_area
    {
        width: 72%;
        float: left;
        background: #ffffff;
        padding: 0 1%;
        margin: 0 12%;
    }
    .search
    {
        width: 98%;
        float: left;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    .ui-slider-horizontal .ui-slider-handle
    {
        top: -.3em;
        margin-left: -1.6em;
    }
</style>
@using (Html.BeginForm())
{
    Int32 iCount = 1;    
    <div id="content_area">
        <!--main content area start here-->
        <div id="main_content_area">
            <div id="content_wrapper">
                <table width="99%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            @Html.ValidationSummary(true)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div id="dvBilling">
                                <fieldset>
                                    <legend><span class="pint_heading">Billing Charge Sheet Details</span></legend>
                                    <div class="search">
                                        <div>
                                            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td height="5" colspan="4">
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 20%" class="black_label ">
                                                        @Html.LabelFor(m => m.BillingCharges.Name):<span class="star">*</span>
                                                    </td>
                                                    <td style="width: 20%">
                                                        @Html.TextBoxFor(m => m.BillingCharges.Name, new { style = "width:250px", maxlength = 150 })
                                                    </td>
                                                      <td > 
                                                            @if (ViewData["pat_id"] != null)
                                                            {
                                                                    @Html.Hidden("hdnId", ViewData["pat_id"])                                                                                                                                   

                                                            }
                                                            else
                                                            {
                                                                    @Html.Hidden("hdnId", "0")                                                                  

                                                            }                                                     
                                                        </td>

                                                    <td style="width: 20%" class="black_label ">
                                                        @Html.Hidden("hdnGlobalPostVar", "0")
                                                        @Html.Hidden("hdnBillingChargesDetailsId", "0")
                                                        @Html.Hidden("hdnCPT", ViewData["hdnCPT"])
                                                        @Html.Hidden("hdnPaging", "0")
                                                        @Html.Hidden("hdnPageSize", "100")
                                                        @Html.Hidden("hdnSortIndex", "0")
                                                        @Html.Hidden("hdnSortOrder", "asc")
                                                        @Html.Hidden("hdnAllPaging", "0")
                                                        @Html.Hidden("hdnAllPageSize", "100")
                                                        @Html.Hidden("hdnAllSortIndex", "0")
                                                        @Html.Hidden("hdnAllSortOrder", "asc")
                                                        @Html.Hidden("hdnRedirect", "0")
                                                        @Html.Hidden("hdnBillingId", "0")
                                                        @Html.Hidden("hdnSortColumnID", "patId")

                                                    </td>
                                                     <td>
                                                       <div >
                                                      <a href="#" class="newComment" onclick="bindAddBillingCharge()">Add Details</a></div>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                    </td>
                                                    <td colspan="2">
                                                        <label for="lblSchedulingName" id="lblSchedulingName" class="field-validation-error"
                                                            style="display: none">
                                                            Billing Charge Sheet Name is required.</label>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td height="10" colspan="4" class="black_label">
                                                    </td>
                                                </tr>

                                            </table>
                                        </div>
                                    </div>                                 

                                </fieldset>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>

                     <tr>
                                                                                <td height="10">
                                                                                </td>
                                                                                <td colspan="2">
                                                                                </td>
                                                                            </tr>



            <tr>
                <td>
                    <div id="dvGridCPT">
                        <fieldset>
                            <legend><span class="pint_heading">Amount Details</span></legend>
                            <table width="100%">
                                <tr>
                                    <td>
                                        @Html.Grid(@Model.BillingDetailsModel).Columns(column =>
                                   {
                                       column.For(m => m.Id).Attributes(@class => "HideColumn").HeaderAttributes(@class => "HideHeader");
                                       column.Custom(@<div>@(iCount++)</div>).Named("S.No").Attributes(@style => "width:60px;", @class => "HideColumn").HeaderAttributes(@class => "HideHeader");
                                       column.For(m => m.CPT).Named("Visit Type").Sortable(false).Attributes(@style => "width:150px;").HeaderAttributes(@class => "no-sorting");
                                       column.For(m => m.CodeUsed).Named("NP").Sortable(false).Attributes(@style => "width:150px;").HeaderAttributes(@class => "no-sorting");
                                       column.For(m => m.Amount).Named("NS").Sortable(false).Attributes(@style => "width:150px;").HeaderAttributes(@class => "no-sorting");


                                       column.Custom(@<div>
                                                                   <img src="@Url.Content("~/images/edit_small.png")" class="edit_billingdetails" style="float: left;margin-left: 3px;" title="Edit Working Hours" alt="" />
                                                                   <img src="@Url.Content("~/images/delete_icon.png")" class="delete" title="Delete" style="margin-left: 16px;" alt="" />
                                                               </div>
                                        ).Sortable(false).Named("").Attributes(@style => "width:150px;").HeaderAttributes(@class => "no-sorting");
                                   }).Empty("<div class=\"noRecordDiv\">No record found.</div>").Attributes(new Dictionary<string, object>() { { "cellspacing", "0px" } }).Attributes(@class => "display", id => "jtable")
                                    </td>
                                </tr>
                            </table>
                        </fieldset>
                    </div>
                    <br />
                    <br />
                </td>
            </tr>
                      <tr>
                        <td>
                            @* <input type="button" class="reset_ico" value="" style="float: right; margin-left: 5px;"
                                onclick="return ShowHideControls();" />*@
                            <input type="submit" class="save_bt" id="save_bt" value="" onclick="return BindEditBillingChargeValidations()"
                                style="float: right; margin-left: 5px;" />
                            @Html.ActionLink(" ", "AllBillingCharges", new { action = "AllBillingCharges", controller = "BillingCharges", status = "back" }, new { @class = "back_bt" })
                        </td>
                    </tr>

                    <tr>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
   <div id="dvBillingCharges" style="display: none">
        @Html.ValidationSummary(true)
        <table width="100%">
            <tr>
                <td class="black_label">
                    @Html.HiddenFor(m => m.BillingChargeDetails.Id)
                    @Html.Label("Code To Be Used"):<span class="star">*</span>
                </td>
                <td style="font-size: 12px;">
                    @Html.RadioButton("rbCodeUSed", true,new { id = "rbScheduledbypatient_ICD9", @style = "font-size:12px;" })
                    ICD-9
                    @Html.RadioButton("rbCodeUSed",false,new { id = "rbScheduledbypatient_ICD10", @style = "font-size:12px;" })
                    ICD-10
                </td>
            </tr>
            <tr>
                <td height="5">
                </td>
            </tr>


            <tr>
                <td class="black_label">
                    @Html.Label("Billing CPT"):<span class="star">*</span>
                </td>
                <td style="font-size: 12px;">
                    @Html.DropDownList("ddBillingCPT",new SelectList(BillingCodesBo.LoadAll().OrderBy(x => x.Id),"CPTCodes","CPTCodes"),new { @style = "width:150px;color:black" })
                </td>
            </tr>
             <tr>
                <td height="25">
                </td>
            </tr>
             <tr>
                 <td width="45%" class="black_label">
                    @Html.Label("Amount"):<span class="star">*</span>
                </td>
                <td width="55%" style="font-size: 12px;">

                    @Html.TextBoxFor(m=>m.BillingChargeDetails.Amount, new { @style = "width:150px; ", maxlength = 150 })
                </td>
            </tr>

            <tr>
                <td height="5">
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td align="right">
                    <input type="button" value="" class="save_bt" onclick="return SaveAmounts()" />
                </td>
            </tr>
        </table>
    </div>


  <div id="dvEditBillingCharges" style="display: none">
          @Html.ValidationSummary(true)
        <table width="100%">
            <tr>
                <td class="black_label">
                    @Html.Hidden("edit")
                    @Html.Label("Code To Be Used"):<span class="star">*</span>
                </td>
                <td style="font-size: 12px;">
                    @Html.RadioButton("rbCodeUsedEdit", true,new { id = "rbScheduledbypatient_ICD9", @style = "font-size:12px;" })
                    ICD-9
                    @Html.RadioButton("rbCodeUsedEdit",false,new { id = "rbScheduledbypatient_ICD10", @style = "font-size:12px;" })
                    ICD-10
                </td>
            </tr>
            <tr>
                <td height="5">
                </td>
            </tr>


            <tr>
                <td class="black_label">
                    @Html.Label("Billing CPT"):<span class="star">*</span>
                </td>
                <td style="font-size: 12px;">
                    @Html.DropDownList("ddEditBillingCPT",new SelectList(BillingCodesBo.LoadAll().OrderBy(x => x.Id),"CPTCodes","CPTCodes"),new { @style = "width:150px;color:black" })
                </td>
            </tr>
             <tr>
                <td height="25">
                </td>
            </tr>
             <tr>
                 <td width="45%" class="black_label">
                    @Html.Label("Amount"):<span class="star">*</span>
                </td>
                <td width="55%" style="font-size: 12px;">

                    @Html.TextBox("EditAmount",null, new { @style = "width:150px; ", maxlength = 150 })
                </td>
            </tr>

            <tr>
                <td height="5">
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td align="right">
                    <input type="button" value="" class="save_bt" onclick="return SaveEditAmounts()" />
                </td>
            </tr>
        </table>
    </div>

}

点击保存时,调用的jquery方法是

function BindEditBillingChargeValidations() {
    debugger;
    var txtchargesheetName = $("#BillingCharges_Name");

    var table = "";
    var allRows = "";
    var gridRows = "";
    var LocationsDetailsCount = "";
    table = $("#jtable");
    allRows = $(table).find("tbody>tr");
    gridRows = allRows.filter(".gridrow_alternate, .gridrow");
    var isValid = true;
    var isFirst = false;
    if ($.trim(txtchargesheetName.val()) == "") {

        $("#lblSchedulingName").show();
        isvalid = false;
    }

    else {
        $("#lblSchedulingName").hide();
    }

    gridRows.find(".HideColumn").hide();
    gridRows.each(function (index) {
        LocationsDetailsCount += gridRows[index].cells[0].innerHTML + ";";
    });

    if (LocationsDetailsCount == "") {
        alert("Please Select CPT Code For Charge Sheet and Add Amounts.")
        isvalid = false;
    }



    if (isValid == true) {
        if (confirm("Are you sure you want to proceed?")) {


            $("#dvBilling").find("#hdnGlobalPostVar").val($.trim("edit"))

            var LocationsDetailsID = "";
            table = $("#jtable");
            allRows = $(table).find("tbody>tr");
            gridRows = allRows.filter(".gridrow_alternate, .gridrow");
            gridRows.find(".HideColumn").hide();
            gridRows.each(function (index) {
                LocationsDetailsID += gridRows[index].cells[0].innerHTML + ";";
            });
            $("#dvBilling").find("#hdnBillingChargesDetailsId").val(LocationsDetailsID);

            $("#dvGridCPT").show();


            return ("Billing Charge Updated Successfully");
        }
        else {
            return false;
        }
    }
    else
        return false;
}

这里的问题是当我点击保存整个jquery被执行但是[HttpPost]方法没有被调用。我有人想要我也可以发布生成的html.Plz帮助我。

0 个答案:

没有答案