Click here to Skip to main content
13,863,289 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
function bindMemberList() {
    $("#loading").show();
    var from = '01/01/1900';
    var to = '01/01/1900';
    $.ajax({
        type: "Get",
        cache: false,
        url: "/Member/GetMemberData",
        data: { 'pageIndex': $('#NewPageIndex').val(), 'PageSize': $('#PageSize').val(), 'SearchFirstName': '', 'SearchLastName': '', 'Clientid': '', 'Barcode': '', 'hasEmail': '0', 'hasContract': '0', 'hasAccountNo': '0', 'hasPolicyNo': '0', 'hasGroupNo': '0', 'From': from, 'To': to, clublocationid: '0', clublocationName: '', insuranceid: '0', MemberStatus: '0', Sort: 'order by Memberlastname asc', IsVerified: '0' },
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        async: false,
        success: function (response) {
            var curRecords = 0;
            var TotalRecs = 0;
            if (parseInt(response.length) > 0)
            {
                curRecords = parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val()));
                curRecords = curRecords - (50 - parseInt(response.length));
                TotalRecs = parseInt(response[0].TotalRecords);
                $('.FooterRecordCount').show();
            }
            else
            {
                $('.FooterRecordCount').hide();
            }
            $('.RecordCountSpan').text(curRecords);
            $('.TotalCountSpan').text(TotalRecs);

            if (parseInt(response.length) > 0) {
                if (parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val())) > parseInt(response[0].TotalRecords)) {
                    $("#ddlload").hide();
                } else {
                    $("#ddlload").show();
                }
            } else {
                $("#ddlload").hide();
            }
            $("#RawDatas table tbody tr:not(:first)").remove();
            $("#RawDatas table tbody tr:eq(0)").show();
            for (var i = 0; i < response.length; i++) {
                var table = $("#RawDatas table tbody tr:eq(0)").clone(true);
                $(".memname", table).html(response[i].Memberlastname + ', ' + response[i].Memberfirstname);
                $(".email", table).html(response[i].Memberemailid);
                $(".clubname", table).html(response[i].ClublocationidDesc);
                $(".insname", table).html(response[i].InsurancecompanyidDesc);
                $('.memberstatus', table).html(response[i].MemberStatusDesc);
                $("#editdata", table).attr('href', '/Member/Edit?Memberid=' + response[i].Memberid);
                $('#Deletedata', table).attr('href', '/Member/DeleteSadmin?Memberid=' + response[i].Memberid);
                $("#RawDatas table").append(table);
            }
            $("#RawDatas table tbody tr:eq(0)").hide();
            $("#loading").hide();
        },
        failure: function (response) {
        },
        error: function (response) {
        }
    });
}


What I have tried:

How to get data usiing javascript in mvc and wheel scrol time get 50 record
Posted
Updated 11-Feb-19 20:18pm
Comments
Member 11882351 12-Feb-19 1:24am
   
public ActionResult PrakashIndex(string BackFor = "")
{
TempData["BackFor"] = BackFor;
return View();
}
Member 11882351 12-Feb-19 1:24am
   
public JsonResult GetMemberData(int pageIndex, int PageSize, string SearchFirstName, string SearchLastName, string Clientid, string Barcode, string hasEmail, string hasContract, string hasAccountNo, string hasPolicyNo, string hasGroupNo, string From, string To, string clublocationid, string clublocationName, string insuranceid, string MemberStatus, string Sort, string IsVerified)
{
TempData["MemberSearch"] = SearchFirstName;
TempData["MemberLastName"] = SearchLastName;
TempData["Clientid"] = Clientid;
TempData["Barcode"] = Barcode;
TempData["hasEmail"] = hasEmail;
TempData["hasContract"] = hasContract;
TempData["hasAccountNo"] = hasAccountNo;
TempData["hasPolicyNo"] = hasPolicyNo;
TempData["hasGroupNo"] = hasGroupNo;
TempData["Memberclublocationid"] = clublocationid.ToString();
TempData["MemberclublocationName"] = clublocationName.ToString();
TempData["Memberinsuranceid"] = insuranceid.ToString();
TempData["FromDate"] = From.ToString();
TempData["ToDate"] = To.ToString();
TempData["MemberStatus"] = MemberStatus;
TempData["IsVerified"] = IsVerified;
TempData["PageIndex"] = pageIndex;
if (OBMI.GlobalModels.GlobalUtils.UserRole == "Club Manager")
{
clublocationid = OBMI.GlobalModels.GlobalUtils.UserClubLocationId;
}
Int32 totalREcs = 0;
using (MemberCtl db = new MemberCtl())
{
totalREcs = db.GetMemberDataCount(pageIndex, PageSize, SearchFirstName, SearchLastName, Clientid, Barcode, hasEmail, hasContract, hasAccountNo, hasPolicyNo, hasGroupNo, From, To, Convert.ToInt32(clublocationid), Convert.ToInt32(insuranceid), Convert.ToInt32(MemberStatus), Sort, IsVerified);
}
using (MemberCtl db = new MemberCtl())
{
return Json(db.GetMemberData(pageIndex, PageSize, SearchFirstName, SearchLastName, Clientid, Barcode, hasEmail, hasContract, hasAccountNo, hasPolicyNo, hasGroupNo, From, To, Convert.ToInt32(clublocationid), Convert.ToInt32(insuranceid), Convert.ToInt32(MemberStatus), Sort, IsVerified, totalREcs), JsonRequestBehavior.AllowGet);
}
}
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

<script src="~/Scripts/jquery1.8.3.min.js"></script>
<script src="~/Scripts/jquery-1.js"></script>
@{   
    string BackFortd = Convert.ToString(TempData["BackFor"]);
}
<script>
    $(document).ready(function () {
        $("#ddlload").hide();
        $('#loading').show();       
        $('#NewPageIndex').val('1');
        bindMemberList();
    });
    function bindMemberList() {
        $("#loading").show();
        var from = '01/01/1900';
        var to = '01/01/1900';       
        $.ajax({
            type: "Get",
            cache: false,
            url: "/Member/GetMemberData",
            data: { 'pageIndex': $('#NewPageIndex').val(), 'PageSize': $('#PageSize').val(), 'SearchFirstName': '', 'SearchLastName': '', 'Clientid': '', 'Barcode': '', 'hasEmail': '0', 'hasContract': '0', 'hasAccountNo': '0', 'hasPolicyNo': '0', 'hasGroupNo': '0', 'From': from, 'To': to, clublocationid: '0', clublocationName: '', insuranceid: '0', MemberStatus: '0', Sort: 'order by Memberlastname asc', IsVerified: '0' },
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            async: false,
            success: function (response) {
                var curRecords = 0;
                var TotalRecs = 0;
                if (parseInt(response.length) > 0)
                {
                    curRecords = parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val()));
                    curRecords = curRecords - (50 - parseInt(response.length));
                    TotalRecs = parseInt(response[0].TotalRecords);
                    $('.FooterRecordCount').show();
                }
                else
                {
                    $('.FooterRecordCount').hide();
                }
                $('.RecordCountSpan').text(curRecords);
                $('.TotalCountSpan').text(TotalRecs);

                if (parseInt(response.length) > 0) {
                    if (parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val())) > parseInt(response[0].TotalRecords)) {
                        $("#ddlload").hide();
                    } else {
                        $("#ddlload").show();
                    }
                } else {
                    $("#ddlload").hide();
                }
                $("#RawDatas table tbody tr:not(:first)").remove();
                $("#RawDatas table tbody tr:eq(0)").show();
                for (var i = 0; i < response.length; i++) {
                    var table = $("#RawDatas table tbody tr:eq(0)").clone(true);
                    $(".memname", table).html(response[i].Memberlastname + ', ' + response[i].Memberfirstname);
                    $(".email", table).html(response[i].Memberemailid);
                    $(".clubname", table).html(response[i].ClublocationidDesc);
                    $(".insname", table).html(response[i].InsurancecompanyidDesc);
                    $('.memberstatus', table).html(response[i].MemberStatusDesc);
                    $("#editdata", table).attr('href', '/Member/Edit?Memberid=' + response[i].Memberid);
                    $('#Deletedata', table).attr('href', '/Member/DeleteSadmin?Memberid=' + response[i].Memberid);
                    $("#RawDatas table").append(table);
                }
                $("#RawDatas table tbody tr:eq(0)").hide();
                $("#loading").hide();
            },
            failure: function (response) {
            },
            error: function (response) {
            }
        });
    }
    function SortingFun(val) {       
        $("#ddlload").hide();
        $('#loading').show();
        if (val == 'name') {
            if ($('#namehdn').val() == 'asc') {
                Sort = 'order by Memberlastname desc';
            }
            else {
                Sort = 'order by Memberlastname asc';
            }
        }        
        if (val == 'club') {
            if ($('#clubhdn').val() == 'asc') {
                Sort = 'order by ClublocationidDesc desc';
            }
            else {
                Sort = 'order by ClublocationidDesc asc';
            }
        }
        if (val == 'insurancecomp') {
            if ($('#insurancecomhdn').val() == 'asc') {
                Sort = 'order by InsurancecompanyidDesc desc';
            }
            else {
                Sort = 'order by InsurancecompanyidDesc asc';
            }
        }
        if (val == 'memberemailid') {
            if ($('#memberemailidhdn').val() == 'asc') {
                Sort = 'order by memberemailid desc';
            }
            else {
                Sort = 'order by memberemailid asc';
            }
        }
        var from = '01/01/1900';
        var to = '01/01/1900';            
        $('#RawDatas table').hide();
        $('#SortValue').val(Sort);
        $('#NewPageIndex').val('1');        
        $.ajax({
            type: "Get",
            cache: false,
            url: "/Member/GetMemberData",
            data: { 'pageIndex': $('#NewPageIndex').val(), 'PageSize': $('#PageSize').val(), 'SearchFirstName': '', 'SearchLastName': '', 'Clientid': '', 'Barcode': '', 'hasEmail': '0', 'hasContract': '0', 'hasAccountNo': '0', 'hasPolicyNo': '0', 'hasGroupNo': '0', 'From': from, 'To': to, clublocationid: '0', clublocationName: '', insuranceid: '0', MemberStatus: '0', Sort: Sort, IsVerified: '0' },
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
                var curRecords = 0;
                var TotalRecs = 0;
                if (parseInt(response.length) > 0) {
                    curRecords = parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val()));
                    curRecords = curRecords - (50 - parseInt(response.length));
                    TotalRecs = parseInt(response[0].TotalRecords);
                    $('.FooterRecordCount').show();
                }
                else {
                    $('.FooterRecordCount').hide();
                }
                $('.RecordCountSpan').text(curRecords);
                $('.TotalCountSpan').text(TotalRecs);
                if (parseInt(response.length) > 0) {
                    if (parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val())) > parseInt(response[0].TotalRecords)) {
                        $("#ddlload").hide();
                    } else {
                        $("#ddlload").show();
                    }
                } else {
                    $("#ddlload").hide();
                }
                if (response.length > 0) {
                    $('#RawDatas table').show();
                    $("#RawDatas table tbody tr:not(:first)").remove();
                    $("#RawDatas table tbody tr:eq(0)").show();
                    for (var i = 0; i < response.length; i++) {
                        var table = $("#RawDatas table tbody tr:eq(0)").clone(true);
                        $(".memname", table).html(response[i].Memberlastname + ', ' + response[i].Memberfirstname);
                        $(".email", table).html(response[i].Memberemailid);
                        $(".clubname", table).html(response[i].ClublocationidDesc);
                        $(".insname", table).html(response[i].InsurancecompanyidDesc);
                        $('.memberstatus', table).html(response[i].MemberStatusDesc);
                        $("#editdata", table).attr('href', '/Member/Edit?Memberid=' + response[i].Memberid);
                        $('#Deletedata', table).attr('href', '/Member/DeleteSadmin?Memberid=' + response[i].Memberid);
                        $("#RawDatas table").append(table);
                    }
                    $("#RawDatas table tbody tr:eq(0)").hide();
                }                
                $('#namei').removeClass('fa-sort-desc');
                $('#namei').addClass('fa-sort-asc');
                $('#clubi').removeClass('fa-sort-desc');
                $('#clubi').addClass('fa-sort-asc');
                $('#insurancecomi').removeClass('fa-sort-desc');
                $('#insurancecomi').addClass('fa-sort-asc');
                $('#memberemailidi').removeClass('fa-sort-desc');
                $('#memberemailidi').addClass('fa-sort-asc');
                if (val == 'name') {
                    if ($('#namehdn').val() == 'asc') {
                        $('#namehdn').val('desc');
                        $('#namei').removeClass('fa-sort-asc');
                        $('#namei').addClass('fa-sort-desc');
                    }
                    else {
                        $('#namehdn').val('asc');
                        $('#namei').removeClass('fa-sort-desc');
                        $('#namei').addClass('fa-sort-asc');
                    }
                }
                if (val == 'club') {
                    if ($('#clubhdn').val() == 'asc') {
                        $('#clubhdn').val('desc');
                        $('#clubi').removeClass('fa-sort-asc');
                        $('#clubi').addClass('fa-sort-desc');
                    }
                    else {

                        $('#clubhdn').val('asc');
                        $('#clubi').removeClass('fa-sort-desc');
                        $('#clubi').addClass('fa-sort-asc');
                    }
                }
                if (val == 'insurancecomp') {
                    if ($('#insurancecomhdn').val() == 'asc') {

                        $('#insurancecomhdn').val('desc');
                        $('#insurancecomi').removeClass('fa-sort-asc');
                        $('#insurancecomi').addClass('fa-sort-desc');
                    }
                    else {

                        $('#insurancecomhdn').val('asc');
                        $('#insurancecomi').removeClass('fa-sort-desc');
                        $('#insurancecomi').addClass('fa-sort-asc');
                    }
                }
                if (val == 'memberemailid') {
                    if ($('#memberemailidhdn').val() == 'asc') {

                        $('#memberemailidhdn').val('desc');
                        $('#memberemailidi').removeClass('fa-sort-asc');
                        $('#memberemailidi').addClass('fa-sort-desc');
                    }
                    else {

                        $('#memberemailidhdn').val('asc');
                        $('#memberemailidi').removeClass('fa-sort-desc');
                        $('#memberemailidi').addClass('fa-sort-asc');
                    }
                }
                $('#loading').hide();
            },
            failure: function (response) {                
            },
            error: function (response) {                
            }
        });
    }
    //$('#verified').change(function () {
    //    $('#Clubnamei').addClass('fa-sort-asc');
    //    $('#addressi').addClass('fa-sort-asc');
    //    $('#clientidi').addClass('fa-sort-asc');
    //    $('#emailidi').addClass('fa-sort-asc');
    //    $('#Insurance').change();
    //});
</script>
@{   
    <div id="loading">
        <img id="loading-image" src="~/Content/img/loading.gif" alt="Loading..." style="left: 55%;" />
    </div>
    <div class="box-content">
        <input type="hidden" id="namehdn" value="asc" />
        <input type="hidden" id="clubhdn" value="asc" />
        <input type="hidden" id="insurancecomhdn" value="asc" />
        <input type="hidden" id="memberemailidhdn" value="asc" />
        <input type="hidden" id="SortValue" value="order by Memberlastname asc" />
        <div class="clearfix"></div>     
        <div class="clearfix"></div>
        <div class="control-group clearfix">
            <label style="float: right; color: #0088cc;">
                <span class="RecordCountSpan" style="color: #0088cc; font-weight: bold;">
                    0
                </span> out of
                <span class="TotalCountSpan" style="font-weight: bold;">
                    0
                </span>
                records
            </label>
        </div>
        <div id="RawDatas">
            <table class="table table-striped table-bordered bootstrap-datatable">
                <thead>
                    <tr>
                        <th onclick="SortingFun('name');" style="cursor: pointer;">
                            "namei" class="fa fa-sort-asc">
                            Name
                        </th>
                      
                        <th onclick="SortingFun('memberemailid');" style="cursor: pointer;">
                            "memberemailidi" class="fa fa-sort-asc">
                            Email Address
                        </th>
                        @if (OBMI.GlobalModels.GlobalUtils.UserRole != "Club Manager")
                        {
                            <th onclick="SortingFun('club');" style="cursor: pointer;">
                                "clubi" class="fa fa-sort-asc">
                                Club
                            </th>
                        }
                        <th onclick="SortingFun('insurancecomp');" style="cursor: pointer;">
                            "insurancecomi" class="fa fa-sort-asc">
                            Insurance Company
                        </th>
                        <th>
                            Member Status
                        </th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            <span class="memname"></span>
                        </td>

                        <td>
                            <span class="email"></span>
                        </td>
                        @if (OBMI.GlobalModels.GlobalUtils.UserRole != "Club Manager")
                        {
                            <td>
                                <span class="clubname"></span>
                            </td>
                        }
                        <td>
                            <span class="insname"></span>
                        </td>
                        <td>
                            <span class="memberstatus"></span>
                        </td>
                        <td>
                            <a class="btn btn-info" id="editdata" style="padding: 2px 7px; margin: 2px;">"fa fa-edit" title="Edit"></a>
                            <a class="btn btn-danger" id="Deletedata" style="padding: 2px 7px; margin: 2px;" onclick="return confirm('Are you sure you want to delete this record?'); ">"fa fa-trash" title="Delete"></a>
                            @*				 <a class="btn btn-success" style="padding:2px 7px; margin:2px;" href="/Member/Details?Memberid=@item.Memberid ">"halflings-icon white zoom-in"></a>  *@

                        </td>
                    </tr>
                </tbody>
            </table>
            <br />
            <div style="text-align: center" id="ddlload">
                <a href="#" class="btn btn-primary" id="loaddata" onclick="Getdata();">Load more</a>
                @Html.Hidden("hdnload", 0)
            </div>
            <div class="text-center" id="loading1" style="display: none;">
                <img src="~/Images/spiffygif_30x30.gif" />
            </div>
            <div class="control-group clearfix">
                <label style="float: right; color: #0088cc;"><span class="RecordCountSpan" style="color: #0088cc; font-weight: bold;">0 </span> out of <span class="TotalCountSpan" style="font-weight: bold;">0</span> records</label>
            </div>
        </div>
        <div class="pagination" style="display: none;">
            <ul style="padding-left: 10px; float: left; margin: 0px 0px 20px">
                <li class="prev">
                    <a href="#">Previous</a>
                </li>
                <li class="active">
                    <a href="#">
                        <label id="lblPageIndex" style="margin: 0px;"></label>
                    </a>
                </li>
                <li class="next">
                    <a href="#">Next</a>
                </li>
            </ul>
            <input type="hidden" id="NewPageIndex" value='1' />
            <input type="hidden" id="TotalPageRecord" value='0' />
            <input type="hidden" id="StartIndex" value="1" />
            <input type="hidden" id="EndIndex" value="10" />
            <div style="float: right; line-height: 13px; padding: 1px 10px 1px 5px;">
                <select id="PageSize">
                    <option value="10">10</option>
                    <option value="20">20</option>
                    <option selected="selected" value="50">50</option>
                    <option value="100">100</option>
                </select>
                <span style="line-height: 25px; vertical-align: bottom;">Records/Page</span>
            </div>
            <input type="hidden" id="scrollIndex" value="0" />
        </div>
    </div>
}
<script>
    $(function () {
    });
    function Getdata() {
        $("#loading1").show();
        $("#hdnload").val("1");
        $("#ddlload").hide();
        GetRecords();
    }
    $(window).on('mousewheel DOMMouseScroll', function (e) {
        var scroll = $(window).scrollTop();
        var direction = (function () {
            var delta = (e.type === 'DOMMouseScroll' ? e.originalEvent.detail * -40 : e.originalEvent.wheelDelta);
            return delta > 0 ? 0 : 1;
        }());
        if (direction === 1) {
            var maxVal = parseInt((parseInt($(document).height()) * 95) / 100);
            var lowVal = $(window).scrollTop() + $(window).height();
            if (lowVal >= maxVal) {
                //alert("page down!");
                if ($("#NewPageIndex").val() != "1" && $("#loading1").css('display') == 'none') {
                    // console.log('Scroll down' + $('#NewPageIndex').val());
                    $("#ddlload").hide();
                    GetRecords();
                }
            }
        }
    });
    function GetRecords() {
        var CountVal = (parseInt($('#NewPageIndex').val()) + 1);
        $('#NewPageIndex').val(CountVal);
        $("#loading1").show();
        var from = '01/01/1900';
        var to = '01/01/1900';
        $.ajax({
            type: "Get",
            cache: false,
            url: "/Member/GetMemberData",
            data: { 'pageIndex': $('#NewPageIndex').val(), 'PageSize': $('#PageSize').val(), 'SearchFirstName': '', 'SearchLastName': '', 'Clientid': '', 'Barcode': '', 'hasEmail': '0', 'hasContract': '0', 'hasAccountNo': '0', 'hasPolicyNo': '0', 'hasGroupNo': '0', 'From': from, 'To': to, clublocationid: '0', clublocationName: '', insuranceid: '0', MemberStatus: '0', Sort: 'order by Memberlastname asc', IsVerified: '0' },           
            contentType: "application/json; charset=utf-8",
            dataType: "json",           
            async: false,
            success: OnSuccess,
            failure: function (response) {
                //alert(response.d);
            },
            error: function (response) {
                //alert(response.d);
            }
        });
    }

    function OnSuccess(response) {
        var curRecords = 0;
        var TotalRecs = 0;
        if (parseInt(response.length) > 0)
        {
            curRecords = parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val()));
            curRecords = curRecords - (50 - parseInt(response.length));
            TotalRecs = parseInt(response[0].TotalRecords);
            $('.RecordCountSpan').text(curRecords);
            $('.FooterRecordCount').show();
            $('.TotalCountSpan').text(TotalRecs);
        }
        if (parseInt(response.length) > 0)
        {
            if (parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val())) > parseInt(response[0].TotalRecords)) {
                $("#ddlload").hide();
            } else {
                $("#ddlload").show();
            }
        }
        else
        {
            $("#ddlload").hide();
        }
        if (response.length > 0)
        {
            $("#RawDatas table tbody tr:eq(0)").show();
            for (var i = 0; i < response.length; i++)
            {
                var table = $("#RawDatas table tbody tr:eq(0)").clone(true);
                $(".memname", table).html(response[i].Memberlastname + ', ' + response[i].Memberfirstname);
                $(".email", table).html(response[i].Memberemailid);
                $(".clubname", table).html(response[i].ClublocationidDesc);
                $(".insname", table).html(response[i].InsurancecompanyidDesc);
                $('.memberstatus', table).html(response[i].MemberStatusDesc);
                $("#editdata", table).attr('href', '/Member/Edit?Memberid=' + response[i].Memberid);
                $('#Deletedata', table).attr('href', '/Member/DeleteSadmin?Memberid=' + response[i].Memberid);
                $("#RawDatas table").append(table);
                if ('@BackFortd' != '') {
                    if ('@BackFortd' == response[i].Memberid) {
                        $("#editdata", table).focus();
                        $(table).focus();
                    }
                }
            }
            $("#RawDatas table tbody tr:eq(0)").hide();
        }
        else
        {
            $("#loading1").hide();
        }
        $("#loading1").hide();
    }
</script>
   
Comments
Member 14146669 12-Feb-19 1:25am
   
model
Member 11882351 12-Feb-19 1:26am
   
public Int32 GetMemberDataCount(int pageIndex, int PageSize, string Search, string SearchLastname, string Clientid, string Barcode, string hasEmail, string hasContract, string hasAccountNo, string hasPolicyNo, string hasGroupNo, string From, string To, Int32 clublocationid, Int32 insuaranceid, Int32 memberstatusid, string Sort, string IsVerified)
{
try
{
DateTime FromNew = Convert.ToDateTime(From);
DateTime ToNew = Convert.ToDateTime(To);
//Int32 changeid = Convert.ToInt32(OBMI.GlobalModels.GlobalUtils.UserClubChainId);
obj_con.clearParameter();
obj_con.addParameter("@PageIndex", pageIndex);
obj_con.addParameter("@PageSize", PageSize);
obj_con.addParameter("@Search", Search.Trim());
obj_con.addParameter("@SearchLastName", SearchLastname.Trim());
obj_con.addParameter("@clientid", Convert.ToString(Clientid).Trim());
obj_con.addParameter("@barcode", Barcode.Trim());
obj_con.addParameter("@hasEmail", hasEmail);
obj_con.addParameter("@hasContract", hasContract);
obj_con.addParameter("@hasAccount", hasAccountNo);
obj_con.addParameter("@hasPolicy", hasPolicyNo);
obj_con.addParameter("@hasGroup", hasGroupNo);
obj_con.addParameter("@FromDate", FromNew);
obj_con.addParameter("@ToDate", ToNew);
obj_con.addParameter("@clublocationid", clublocationid);
obj_con.addParameter("@insuaranceid", insuaranceid);
//obj_con.addParameter("@ClubId", changeid);
//obj_con.addParameter("@userid", Convert.ToInt64(OBMI.GlobalModels.GlobalUtils.UserId));
obj_con.addParameter("@memberstatusid", memberstatusid);
obj_con.addParameter("@Sort", Sort);
obj_con.addParameter("@IsVerified", IsVerified);
// obj_con.addParameter("@PageCount", 4, DBTrans.Update);
DataTable dt = ConvertDatareadertoDataTable(obj_con.ExecuteReader("sp_Member_selectIndexPagingNew2Count", CommandType.StoredProcedure));
obj_con.CommitTransaction();
obj_con.closeConnection();
return Convert.ToInt32(dt.Rows[0][0]);
}
catch (Exception ex)
{
return 0;
//throw new Exception("sp_Member_selectIndexPagingNew2Count");
}

}
Member 14146669 12-Feb-19 1:27am
   
other model?
Member 11882351 12-Feb-19 1:28am
   
public List<memberclass> GetMemberData(int pageIndex, int PageSize, string Search, string SearchLastname, string Clientid, string Barcode, string hasEmail, string hasContract, string hasAccountNo, string hasPolicyNo, string hasGroupNo, string From, string To, Int32 clublocationid, Int32 insuaranceid, Int32 MemberstatusId, string Sort, string IsVerified, Int32 TotalRecs)
{
try
{
DateTime FromNew = Convert.ToDateTime(From);
DateTime ToNew = Convert.ToDateTime(To);
//Int32 changeid = Convert.ToInt32(OBMI.GlobalModels.GlobalUtils.UserClubChainId);
obj_con.clearParameter();
obj_con.addParameter("@PageIndex", pageIndex);
obj_con.addParameter("@PageSize", PageSize);
obj_con.addParameter("@Search", Search);
obj_con.addParameter("@SearchLastName", SearchLastname.Trim());
obj_con.addParameter("@clientid", Convert.ToString(Clientid).Trim());
obj_con.addParameter("@barcode", Barcode.Trim());
obj_con.addParameter("@hasEmail", hasEmail);
obj_con.addParameter("@hasContract", hasContract);
obj_con.addParameter("@hasAccount", hasAccountNo);
obj_con.addParameter("@hasPolicy", hasPolicyNo);
obj_con.addParameter("@hasGroup", hasGroupNo);
obj_con.addParameter("@FromDate", FromNew);
obj_con.addParameter("@ToDate", ToNew);
obj_con.addParameter("@clublocationid", clublocationid);
obj_con.addParameter("@insuaranceid", insuaranceid);
//obj_con.addParameter("@ClubId", changeid);
//obj_con.addParameter("@userid", Convert.ToInt64(OBMI.GlobalModels.GlobalUtils.UserId));
obj_con.addParameter("@memberstatusid", MemberstatusId);
obj_con.addParameter("@Sort", Sort);
obj_con.addParameter("@IsVerified", IsVerified);
// obj_con.addParameter("@PageCount", 4, DBTrans.Update);
DataTable dt = ConvertDatareadertoDataTable(obj_con.ExecuteReader("sp_Member_selectIndexPagingNew2", CommandType.StoredProcedure));
obj_con.CommitTransaction();
obj_con.closeConnection();
return ConvertToList1MemberData(dt, TotalRecs);
}
catch (Exception ex)
{
throw new Exception("sp_Member_selectIndexPagingNew2");
}
}
Member 14146669 12-Feb-19 1:31am
   
data table?
Member 11882351 12-Feb-19 1:31am
   
USE [NihcaNov18]
GO

/****** Object: Table [dbo].[Member] Script Date: 2/12/2019 12:00:14 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Member](
[MemberId] [int] IDENTITY(1,1) NOT NULL,
[MemberFirstName] [nvarchar](50) NULL,
[MemberLastName] [nvarchar](50) NULL,
[MemberMiddleInitial] [nvarchar](50) NULL,
[MemberAddressLine1] [nvarchar](100) NULL,
[MemberAddressLine2] [nvarchar](100) NULL,
[MemberAddressCity] [nvarchar](100) NULL,
[MemberAddressState] [nvarchar](100) NULL,
[MemberAddressZip] [varchar](10) NULL,
[MemberDateOfBirth] [datetime] NULL,
[MemberEmailId] [nvarchar](100) NULL,
[MemberPassword] [nvarchar](500) NULL,
[MemberRegisteredOn] [datetime] NULL,
[ClubLocationId] [int] NULL,
[IsActive] [bit] NULL,
[IsVerified] [bit] NULL,
[ForcePasswordChange] [bit] NULL,
[BankAccountName] [nvarchar](100) NULL,
[BankAccountNumber] [varchar](50) NULL,
[MaskedAccountNumber] [varchar](max) NULL,
[AccountType] [varchar](10) NULL,
[BankId] [int] NULL,
[SubmitCreditToClub] [bit] NULL,
[IsActiveAccount] [bit] NULL,
[AccountErrorDate] [datetime] NULL,
[AccountErrorDescription] [nvarchar](500) NULL,
[AccountInformationLastChangedOn] [datetime] NULL,
[policyno] [nvarchar](max) NULL,
[GroupNumber] [nvarchar](max) NULL,
[InsuranceCompanyID] [int] NULL,
[InsuranceInformationChangeDate] [datetime] NULL,
[MemberStatusID] [int] NULL,
[PhoneNumber] [nvarchar](50) NULL,
[CellNumber] [nvarchar](50) NULL,
[DependentId] [nvarchar](max) NULL,
[maskedpolicyno] [nvarchar](max) NULL,
[IsDeleted] [bit] NULL,
[LastAddedBy] [int] NULL,
[LastUpdatedOn] [datetime] NULL,
[CancelReason] [nvarchar](max) NULL,
[GuidId] [nvarchar](200) NULL,
[GuidUsed] [bit] NULL,
[GuidGenerated] [datetime] NULL,
[GuidIsUsed] [datetime] NULL,
[UpdatedBy] [int] NULL,
[DuesAmount] [money] NULL,
[AddedOn] [datetime] NULL,
[RewardsEnrollmentDate] [datetime] NULL,
[TempBSMemberID] [int] NULL,
[UpdateFrom] [nvarchar](max) NULL,
[Notes] [nvarchar](max) NULL,
[ResubmittedEffectiveDate] [datetime] NULL,
[PastClaims] [bit] NULL,
CONSTRAINT [PK_Member] PRIMARY KEY CLUSTERED
(
[MemberId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[Member] WITH CHECK ADD CONSTRAINT [FK_Member_BankInformation1] FOREIGN KEY([BankId])
REFERENCES [dbo].[BankInformation] ([BankId])
GO

ALTER TABLE [dbo].[Member] CHECK CONSTRAINT [FK_Member_BankInformation1]
GO

ALTER TABLE [dbo].[Member] WITH CHECK ADD CONSTRAINT [FK_Member_InsuranceCompany] FOREIGN KEY([InsuranceCompanyID])
REFERENCES [dbo].[InsuranceCompany] ([InsuranceCompanyId])
GO

ALTER TABLE [dbo].[Member] CHECK CONSTRAINT [FK_Member_InsuranceCompany]
GO

ALTER TABLE [dbo].[Member] WITH CHECK ADD CONSTRAINT [FK_Member_MemberStatus] FOREIGN KEY([MemberStatusID])
REFERENCES [dbo].[MemberStatus] ([MemberStatusId])
GO

ALTER TABLE [dbo].[Member] CHECK CONSTRAINT [FK_Member_MemberStatus]
GO


Member 14146669 12-Feb-19 1:33am
   
sp_Member_selectIndexPagingNew2
Member 11882351 12-Feb-19 1:34am
   
USE [NihcaNov18]
GO
/****** Object: StoredProcedure [dbo].[sp_Member_selectIndexPagingNew2] Script Date: 2/12/2019 12:03:29 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- sp_Member_selectIndexPagingNew2 1,50,'arabe','','','','0','0','0','0','0','01/01/1900', '01/01/1900',0,0,0, 'order by Memberlastname asc','-1'
ALTER PROCEDURE [dbo].[sp_Member_selectIndexPagingNew2]
@PageIndex INT = 1,
@PageSize INT = 10,
@Search nvarchar(max),
@SearchLastName nvarchar(max),
@clientid nvarchar(max),
@barcode nvarchar(max),
@hasEmail nvarchar(max),
@hasContract nvarchar(max),
@hasAccount nvarchar(max),
@hasPolicy nvarchar(max),
@hasGroup nvarchar(max),
@FromDate date,
@ToDate date,
@clublocationid int,
@insuaranceid int,
@memberstatusid int,
@Sort nvarchar(max),
@IsVerified int

AS
BEGIN
SET NOCOUNT ON;

declare @recordCount nvarchar(max) set @recordCount = '0'
declare @qry1 nvarchar(max)

--select @recordCount = count(1) from Member
--where
--(memberfirstname like @barcode or memberlastname like '%'+@Search+'%' or memberemailid like ''%'+@Search+'%'' or @Search = '')
--and (memberid in (select mclo.memberid from memberclublocation mclo
-- where isnull(mclo.isdeleted,0) = 0 and (mclo.barcode = @barcode or @barcode = '') and mclo.clublocationid in
-- (select cl.clublocationid from clublocation cl where isnull(cl.isdeleted,0) = 0 and (cl.clientid = @clientid or @clientid = '') and (cl.clublocationid = @clublocationid or @clublocationid = 0) )
-- and mclo.clublocationid in (select ic.clubid from insuranceclub ic where (ic.insuranceid = @insuaranceid or @insuaranceid = 0) and isnull(ic.isdeleted,0) = 0)
-- ) )
--and (
--(isnull(MemberEmailid,'') <> '' and '1' = @hasEmail)
-- or (isnull(MemberEmailid,'') = '' and '2' = @hasEmail)
-- or '0' = @hasEmail
-- )
-- and(
-- ( member.memberid in (select ma.memberid from MemberAgreement ma) and @hasContract = '1' )
-- or ( member.memberid not in (select ma.memberid from MemberAgreement ma) and @hasContract = '2' )
-- or @hasContract = '0'
Member 14146669 12-Feb-19 1:35am
   
sp_Member_selectIndexPagingNew2Count
Member 11882351 12-Feb-19 1:35am
   
USE [NihcaNov18]
GO
/****** Object: StoredProcedure [dbo].[sp_Member_selectIndexPagingNew2Count] Script Date: 2/12/2019 12:04:28 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- [sp_Member_selectIndexPagingNew2Count] 1,50,'arabe','','','','0','0','0','0','0','01/01/1900', '01/01/1900',0,0,0, 'order by Memberlastname asc','-1'
ALTER PROCEDURE [dbo].[sp_Member_selectIndexPagingNew2Count]
@PageIndex INT = 1,
@PageSize INT = 10,
@Search nvarchar(max),
@SearchLastName nvarchar(max),
@clientid nvarchar(max),
@barcode nvarchar(max),
@hasEmail nvarchar(max),
@hasContract nvarchar(max),
@hasAccount nvarchar(max),
@hasPolicy nvarchar(max),
@hasGroup nvarchar(max),
@FromDate date,
@ToDate date,
@clublocationid int,
@insuaranceid int,
@memberstatusid int,
@Sort nvarchar(max),
@IsVerified int


AS
BEGIN
SET NOCOUNT ON;


declare @recordCount nvarchar(max) set @recordCount = '0'
declare @qry1 nvarchar(max)

set @qry1 = ' select count(*)
from Member m
where
(m.memberstatusid = ' + Convert(varchar,@memberstatusid) + ' or ' + Convert(varchar,@memberstatusid) + ' = 0) and
(m.memberfirstname like ''%'+@Search+'%'' or m.memberemailid like ''%'+@Search+'%'' or '''+@Search+''' = '''')
and (m.MemberLastName like ''%'+@SearchLastName+'%'' or '''+@SearchLastName+''' = '''')
and (m.memberid in
(select mcl.memberid from memberclublocation mcl where isnull(mcl.isdeleted,0)=0 and (mcl.clublocationid = '''+Convert(varchar,@Clublocationid)+''' or '''+Convert(varchar,@Clublocationid)+'''=''0'') and
(mcl.barcode like ''%'+@barcode+'%'' or '''+@barcode+''' = '''')
and mcl.clublocationid in (select cl.clublocationid from clublocation cl where cl.clientid = '''+@clientid+''' or '''+@clientid+''' = ''''))
or ('''+Convert(varchar,@Clublocationid)+'''=''0'' and '''+@barcode+''' = '''' and '''+@clientid+''' = ''''))
and (
((MemberEmailid <> '''' and MemberEmailid is not null) and ''1'' = '+@hasEmail+')
or ((MemberEmailid = '''' or MemberEmailid is null) and ''2'' = '+@hasEmail+')
or ''0'' = '+@hasEmail+') and(
( m.memberid in (select ma.memberid from MemberAgreement ma) and '+@hasContract+' = ''1'')
or ( m.memberid not in (select ma.memberid from MemberAgreement ma) and '+@hasContract+' = ''2'')
or '+@hasContract+' = ''0''
) and (
((m.MaskedAccountNumber <> '''' and m.MaskedAccountNumber is not null) and '+@hasAccount+' = ''1'')
or ((m.MaskedAccountNumber = '''' or m.MaskedAccountNumber is null) and '+@hasAccount+' = ''2'')
or '+@hasAccount+' = ''0''
) and (((m.PolicyNo <> '''' and m.PolicyNo is not null) and '+@hasPolicy+' = ''1'')
or ((m.PolicyNo = '''' or m.PolicyNo is null) and '+@hasPolicy+' = ''2'') or '+@hasPolicy+' = ''0'')
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

@{
string BackFortd = Convert.ToString(TempData["BackFor"]);
}

$(document).ready(function () {
$("#ddlload").hide();
$('#loading').show();
$('#NewPageIndex').val('1');
bindMemberList();
});
function bindMemberList() {
$("#loading").show();
var from = '01/01/1900';
var to = '01/01/1900';
$.ajax({
type: "Get",
cache: false,
url: "/Member/GetMemberData",
data: { 'pageIndex': $('#NewPageIndex').val(), 'PageSize': $('#PageSize').val(), 'SearchFirstName': '', 'SearchLastName': '', 'Clientid': '', 'Barcode': '', 'hasEmail': '0', 'hasContract': '0', 'hasAccountNo': '0', 'hasPolicyNo': '0', 'hasGroupNo': '0', 'From': from, 'To': to, clublocationid: '0', clublocationName: '', insuranceid: '0', MemberStatus: '0', Sort: 'order by Memberlastname asc', IsVerified: '0' },
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function (response) {
var curRecords = 0;
var TotalRecs = 0;
if (parseInt(response.length) > 0)
{
curRecords = parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val()));
curRecords = curRecords - (50 - parseInt(response.length));
TotalRecs = parseInt(response[0].TotalRecords);
$('.FooterRecordCount').show();
}
else
{
$('.FooterRecordCount').hide();
}
$('.RecordCountSpan').text(curRecords);
$('.TotalCountSpan').text(TotalRecs);

if (parseInt(response.length) > 0) {
if (parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val())) > parseInt(response[0].TotalRecords)) {
$("#ddlload").hide();
} else {
$("#ddlload").show();
}
} else {
$("#ddlload").hide();
}
$("#RawDatas table tbody tr:not(:first)").remove();
$("#RawDatas table tbody tr:eq(0)").show();
for (var i = 0; i 0) {
curRecords = parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val()));
curRecords = curRecords - (50 - parseInt(response.length));
TotalRecs = parseInt(response[0].TotalRecords);
$('.FooterRecordCount').show();
}
else {
$('.FooterRecordCount').hide();
}
$('.RecordCountSpan').text(curRecords);
$('.TotalCountSpan').text(TotalRecs);
if (parseInt(response.length) > 0) {
if (parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val())) > parseInt(response[0].TotalRecords)) {
$("#ddlload").hide();
} else {
$("#ddlload").show();
}
} else {
$("#ddlload").hide();
}
if (response.length > 0) {
$('#RawDatas table').show();
$("#RawDatas table tbody tr:not(:first)").remove();
$("#RawDatas table tbody tr:eq(0)").show();
for (var i = 0; i
@{














0
out of

0

records








Name




Email Address

@if (OBMI.GlobalModels.GlobalUtils.UserRole != "Club Manager")
{


Club

}


Insurance Company


Member Status

Action











@if (OBMI.GlobalModels.GlobalUtils.UserRole != "Club Manager")
{



}









@* *@







Load more
@Html.Hidden("hdnload", 0)





0 out of 0 records





Previous







Next








10
20
50
100

Records/Page




}

$(function () {
});
function Getdata() {
$("#loading1").show();
$("#hdnload").val("1");
$("#ddlload").hide();
GetRecords();
}
$(window).on('mousewheel DOMMouseScroll', function (e) {
var scroll = $(window).scrollTop();
var direction = (function () {
var delta = (e.type === 'DOMMouseScroll' ? e.originalEvent.detail * -40 : e.originalEvent.wheelDelta);
return delta > 0 ? 0 : 1;
}());
if (direction === 1) {
var maxVal = parseInt((parseInt($(document).height()) * 95) / 100);
var lowVal = $(window).scrollTop() + $(window).height();
if (lowVal >= maxVal) {
//alert("page down!");
if ($("#NewPageIndex").val() != "1" && $("#loading1").css('display') == 'none') {
// console.log('Scroll down' + $('#NewPageIndex').val());
$("#ddlload").hide();
GetRecords();
}
}
}
});
function GetRecords() {
var CountVal = (parseInt($('#NewPageIndex').val()) + 1);
$('#NewPageIndex').val(CountVal);
$("#loading1").show();
var from = '01/01/1900';
var to = '01/01/1900';
$.ajax({
type: "Get",
cache: false,
url: "/Member/GetMemberData",
data: { 'pageIndex': $('#NewPageIndex').val(), 'PageSize': $('#PageSize').val(), 'SearchFirstName': '', 'SearchLastName': '', 'Clientid': '', 'Barcode': '', 'hasEmail': '0', 'hasContract': '0', 'hasAccountNo': '0', 'hasPolicyNo': '0', 'hasGroupNo': '0', 'From': from, 'To': to, clublocationid: '0', clublocationName: '', insuranceid: '0', MemberStatus: '0', Sort: 'order by Memberlastname asc', IsVerified: '0' },
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: OnSuccess,
failure: function (response) {
//alert(response.d);
},
error: function (response) {
//alert(response.d);
}
});
}

function OnSuccess(response) {
var curRecords = 0;
var TotalRecs = 0;
if (parseInt(response.length) > 0)
{
curRecords = parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val()));
curRecords = curRecords - (50 - parseInt(response.length));
TotalRecs = parseInt(response[0].TotalRecords);
$('.RecordCountSpan').text(curRecords);
$('.FooterRecordCount').show();
$('.TotalCountSpan').text(TotalRecs);
}
if (parseInt(response.length) > 0)
{
if (parseInt(($('#NewPageIndex').val()) * parseInt($('#PageSize').val())) > parseInt(response[0].TotalRecords)) {
$("#ddlload").hide();
} else {
$("#ddlload").show();
}
}
else
{
$("#ddlload").hide();
}
if (response.length > 0)
{
$("#RawDatas table tbody tr:eq(0)").show();
for (var i = 0; i
   

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.190214.1 | Last Updated 12 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100