Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have a table as shown in image bellow i get a popup on click event from a button in the table
CLICK HERE FOR TABLE IMG

After clicking on that complain button the following popup appears by following code:

the Code is as bellow:

the view for above table as shown in img as follows:

HTML
@model List<NomzyMVC.Models.MyRechargesModel>
@{
    ViewBag.Title = "My Recharges";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
          if (Model != null)
                        {
                        <table id="MyRechargesexample" class="table table-bordered table-hover">
                            <thead>
                                <tr id="0">
                                    <th>Sr No
                                    </th>
                                    <th>TransNo
                                    </th>
                                    <th>Type
                                    </th>
                                    <th>Category
                                    </th>
                                    <th>Company
                                    </th>
                                    <th>Product
                                    </th>
                                    <th>A/C
                                    </th>
                                    <th>Amount
                                    </th>
                                    <th>Discount
                                    </th>
                                    <th>LastBalance
                                    </th>
                                    <th>Description
                                    </th>
                                    <th>Date
                                    </th>
                                    <th></th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach (var item in Model)
                                {  
                                    <tr>
                                        <td>@Html.DisplayFor(modelItem => item.Userid)</td>
                                        <td>@Html.DisplayFor(modelItem => item.TransNo)</td>
                                        <td>@Html.DisplayFor(modelItem => item.RechargeType)</td>
                                        <td>@Html.DisplayFor(modelItem => item.RechargeCategory)</td>
                                        <td>@Html.DisplayFor(modelItem => item.CompanyName)</td>
                                        <td>@Html.DisplayFor(modelItem => item.ProductCode)</td>
                                        <td>@Html.DisplayFor(modelItem => item.Account)</td>
                                        <td>@Html.DisplayFor(modelItem => item.Value)</td>
                                        <td>@Html.DisplayFor(modelItem => item.Rcommission)</td>
                                        <td>@Html.DisplayFor(modelItem => item.RLastbalance)</td>
                                        <td>@Html.DisplayFor(modelItem => item.NomadicDescription)</td>
                                        <td>@Html.DisplayFor(modelItem => item.DT)</td>
                                        <td>
                                            @{
                                    decimal disc = Convert.ToDecimal(item.Rcommission);
                                    int calltransno = Convert.ToInt32(item.CallTransNo);
                                    if (calltransno == 0)
                                    {
                                        if (disc > 0)
                                        {
                                                <a id="btnRetailerComplain" title="@Html.DisplayFor(modelItem => item.TransNo)" class="complain">Complain</a>                                               
                                        }
                                        else
                                        {

                                        }
                                        // <button id="btnRetailerComplain"  title="@Html.DisplayFor(modelItem => item.TransNo)" type="button" class="btn btn-block btn-danger"> Complain</button>
                                    }
                                    else
                                    {
                                                <a id="btnRetaiComplain" title="@Html.DisplayFor(modelItem => item.TransNo)" class="showcomplain">ShowComp</a>
                                        // <button id="btnRetaiComplain"  title="@Html.DisplayFor(modelItem => item.TransNo)" type="button" class="btn btn-block btn-warning" style="font-size:small;padding-left:3px;">^__i class="fa fa-check-square-o"> Show Complain</button>
                                    }
                                            }

                                        </td>

                                    </tr>
                          
                            
                                }
                            </tbody>
                        </table>
                        }


And the View For POPUP is as shown Bellow:

JavaScript
$("#MyRechargesexample tbody tr td a").click(function () {
    var transno = $(this).attr('title');
    var buttontype = $(this).attr('class');
    var datefrom = $("#DateFrom").val();
    var dateto = $("#DateTo").val();
    alert(buttontype);
    if (buttontype == "complain") {
        $.ajax({
            url: "/Retailer/_GetComplain",
            type: "GET",
            data: { TransNo: transno, Type: buttontype, DateFrom: datefrom, DateTo: dateto },
            success: function (data) {
                // alert(data);
                var dialog = new BootstrapDialog({
                    type: 'type-primary',
                    title: '<h4></h4>',
                    message: data
});
                dialog.realize();
                dialog.getModalDialog().css("width", "500px");
                dialog.getModalDialog().css("height", "400px");
                dialog.open();
            }
        });
    }
    else {
        $.ajax({
            url: "/Retailer/_GetComplain",
            type: "GET",
            data: { TransNo: transno, Type: buttontype, DateFrom: datefrom, DateTo: dateto },
            success: function (data) {
                // alert(data);
                var dialog = new BootstrapDialog({
                    type: 'type-primary',
                    title: '<h4>^__i class="fa fa-warning text-yellow">  ^__b>Complain Details</h4>',
                    message: data
                });
                dialog.realize();
                dialog.getModalFooter().hide();
                dialog.getModalDialog().css("width", "500px");
                dialog.getModalDialog().css("height", "400px");
                dialog.open();
            }
        });
    }
});


and the controller is as follows:

C#
[HttpGet]
        public PartialViewResult _GetComplain(string TransNo, string Type)
        {
            if (Type == "complain")
            {
                TempData["type"] = "WriteComplain";
                var query = (from c in NMSDC.DataSends
                             where c.DSID == Convert.ToInt32(TransNo)
                             select c).SingleOrDefault();

                GetComplainModel gt = new GetComplainModel();
                gt.UserID = query.UserID;
                gt.Number = query.account;
                gt.Amount = query.value.ToString();
                gt.Company = query.CompanyName;
                gt.Transno = query.DSID.ToString();
                gt.DT = query.DT;

                return PartialView(gt);
            }
            else
            {
                TempData["type"] = "ShowComplain";
                var query = (from CL in NMSDC.CallCenterLogs
                             join SC in NMSDC.SubCategories on CL.SCID equals SC.SCID
                             where CL.IsDeleted == false && CL.Status == false && CL.TransactionNo == TransNo
                             orderby CL.DT descending
                             select new
                             {
                                 CL.QID,
                                 CL.Status,
                                 CL.Note,
                                 CL.CustID,
                                 CL.UserID,
                                 CL.TransactionNo,
                                 CL.Amount,
                                 CL.CompanyName,
                                 CL.account,
                                 CL.AddNote,
                                 CL.DT,
                                 CL.PDID,
                                 SC.SubType,
                             }).SingleOrDefault();

                GetComplainModel gt = new GetComplainModel();
                gt.UserID = query.UserID;
                gt.Number = query.account.ToString();
                gt.Amount = query.Amount.ToString();
                gt.Company = query.CompanyName;
                gt.Transno = query.TransactionNo.ToString();
                gt.Category = query.SubType;
                gt.Note = query.Note;
                gt.DT = (DateTime)query.DT;
                gt.ComplainNo = query.QID.ToString();
                gt.CallCenterAC = query.CustID;
                return PartialView(gt);
            }

        }


and the popup appears as such :

Click HERE FOR POUP IMG

i took the partial view as its easy to handle GET and POST methods so please look at it in the question and the view for getcomplain is as follows:

HTML
@model NomzyMVC.Models.GetComplainModel
@using (Html.BeginForm())
{
    if (TempData["type"] == "WriteComplain")
    {
    <div id="test" class="row" style="margin-removed -50px !important; margin-removed -50px !important">
        <div class="col-md-12">
            Retailer :       <span>@Html.DisplayFor(model => model.UserID) </span>

            Amount :        <span>@Html.DisplayFor(model => model.Amount) </span>
            @Html.TextBox("Amount", null, new { @style = "display:none" })
            Transno :        <span>@Html.DisplayFor(model => model.Transno) </span>
            @Html.TextBox("Transno", null, new { @style = "display:none" })
            Number :        <span>@Html.DisplayFor(model => model.Number) </span>
            @Html.TextBox("Number", null, new { @style = "display:none" })
            Company :       <span>@Html.DisplayFor(model => model.Company)</span>
            @Html.TextBox("Company", null, new { @style = "display:none" })
            Category :       @Html.DropDownList("Category", new List<SelectListItem> {
                                   new SelectListItem{Text="Bal Deduct",Value="7"},
                                   new SelectListItem{Text="Balance Not Received",Value="13"}
                                   }, new { @style = "width:50%" })

            Note :              @Html.TextBox("Note", null, new { @style = "width:50%", placeholder = "Enter Your Note" })
            @Html.TextBox("DT", null, new { @style = "display:none" })
        </div>
        <div class="col-md-12">
            <div class="col-md-5">
                <button type="submit" id="btnWriteComplain" class="btn btn-block btn-warning" value="WriteComplain" name="Command" style="width: 100%;">Submit</button>
            </div>
            @*<div class="col-md-5" style="margin-removed -20px;">
                <button type="button" id="btnComplaincancel" class="btn btn-block btn-default" value="Clear" style="width: 100%;">Cancel</button>
            </div>*@
        </div>
    </div>
    }
    else
    {
    <div id="showcomp" class="row" style="margin-removed -50px !important; margin-removed -50px !important">
        <div class="col-md-12">
            Complain No  :      <span>@Html.DisplayFor(model => model.ComplainNo)</span>

            UserID               :      <span>@Html.DisplayFor(model => model.UserID) </span>

            Amount            :       <span>@Html.DisplayFor(model => model.Amount) </span>

            Transno            :      <span>@Html.DisplayFor(model => model.Transno) </span>

            Number            :      <span>@Html.DisplayFor(model => model.Number) </span>

            Company         :     <span>@Html.DisplayFor(model => model.Company)</span>

            Complain By  :      <span>@Html.DisplayFor(model => model.CallCenterAC) </span>

            Category          :     @Html.DisplayFor(model => model.Category)

            Note                   :    @Html.DisplayFor(model => model.Note)

        </div>
    </div>
    }
}


and after clicking on that submit button of popup the following code executes :

the controller code is as follows:

C#
[HttpPost]
        public PartialViewResult _GetComplain(string Command, string Number, string Amount, string TransNo, string Company, string Category, string Note, DateTime DT)
        {
            if (Command == "WriteComplain")
            {
                var result = (from c in NMSDC.CallCenterLogs
                              where c.TransactionNo == TransNo
                              //&& c.PDID == 3 && c.SCID == Category
                              select new
                              {
                                  c.TransactionNo,
                                  c.PDID,
                                  c.SCID
                              }).ToList();
                if (result.Count == 0)
                {
                    if (DT >= System.DateTime.Now.AddDays(-7))
                    {
                        // NMSDC.USP_Insert_CallCenterLog(Session["UserID"].ToString(), Session["UserID"].ToString(), Number, Convert.ToString(Amount), Convert.ToString(TransNo), Company, 3, SCID, Note, null, "Retailer");
                        //Response.RedirectToRoute("Select", "Search", TempData["Dt1"].ToString(), TempData["Dt2"].ToString());
//---THE PROBLEM IS HERE I AM REDIRECTING IT THE PAGE BUT IT WONT REDIRECT AND I MIGHT BE SHOWING POPUP using WRONG METHOD------------------- //  
                         RetailerController rec = new RetailerController();
                        rec.MyRecharges("Select", "Search", TempData["Dt1"].ToString(), TempData["Dt2"].ToString());
                        ComplainRedirct();
                        this.MyRecharges("Select", "Search", TempData["Dt1"].ToString(), TempData["Dt2"].ToString());
                    }
                    else
                    {
                        // string msg = "You can not write complain 1 week old.";
                        ComplainRedirct();
                    }
                }
                else
                {
                    string msg = "You have already registered complain for this transaction.";
                    ComplainRedirct();
                }
            }
            return PartialView();
        }


THE PROBLEM IS AFTER THIS I WANT THE POPUP TO CLOSE AND THE BEHIND SEARCH SHOULD REMAIN INTACT BUT IT ISN'T THE CASE , I THink that my showing of popup method is wrong pls help me on this, bcz after clicking on submit the popup closes but i redirect to the same page i.e MyRecharge but all the search is gone and i have to search all to gather pls pls help on this.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900