Пример #1
0
        /// <summary>
        /// Gets the list of data for use by the jqgrid plug-in
        /// </summary>
        public IActionResult OnGetGridData(string sidx, string sord, int _page, int rows, bool isforJqGrid = true)
        {
            int            totalRecords  = Enquiry.GetRecordCount();
            int            startRowIndex = ((_page * rows) - rows);
            List <Enquiry> objEnquiryCol = Enquiry.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);
            int            totalPages    = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (objEnquiryCol is null)
            {
                return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }"));
            }

            var jsonData = new
            {
                total = totalPages,
                _page,
                records = totalRecords,
                rows    = (
                    from objEnquiry in objEnquiryCol
                    select new
                {
                    id = objEnquiry.EnquiryId,
                    cell = new string[] {
                        objEnquiry.EnquiryId.ToString(),
                        objEnquiry.CourseId.ToString(),
                        objEnquiry.StudentName,
                        objEnquiry.ContactNo.ToString(),
                        objEnquiry.Comments
                    }
                }).ToArray()
            };

            return(new JsonResult(jsonData));
        }
Пример #2
0
        public void GetData(string sidx, string sord, int?_page)
        {
            int            rows = Functions.GetGridNumberOfRows();
            int            numberOfPagesToShow = Functions.GetGridNumberOfPagesToShow();
            int            currentPage         = _page is null ? 1 : Convert.ToInt32(_page);
            int            startRowIndex       = ((currentPage * rows) - rows);
            int            totalRecords        = Enquiry.GetRecordCount();
            int            totalPages          = (int)Math.Ceiling((float)totalRecords / (float)rows);
            List <Enquiry> objEnquiryCol       = Enquiry.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);

            // fields and titles
            string[,] fieldNames = new string[, ] {
                { "EnquiryId", "Enquiry Id" },
                { "CourseId", "Course Id" },
                { "StudentName", "Student Name" },
                { "ContactNo", "Contact No" },
                { "Comments", "Comments" }
            };

            // assign properties
            EnquiryData          = objEnquiryCol;
            EnquiryFieldNames    = fieldNames;
            TotalPages           = totalPages;
            CurrentPage          = currentPage;
            FieldToSort          = String.IsNullOrEmpty(sidx) ? "EnquiryId" : sidx;
            FieldSortOrder       = String.IsNullOrEmpty(sord) ? "asc" : sord;
            FieldToSortWithOrder = String.IsNullOrEmpty(sidx) ? "EnquiryId" : (sidx + " " + sord).Trim();
            NumberOfPagesToShow  = numberOfPagesToShow;
            StartPage            = Functions.GetPagerStartPage(currentPage, numberOfPagesToShow, totalPages);
            EndPage = Functions.GetPagerEndPage(StartPage, currentPage, numberOfPagesToShow, totalPages);
        }
        /// <summary>
        /// Gets the list of data for use by the jqgrid plug-in
        /// </summary>
        public IActionResult OnGetGridDataGroupedByEnquiryId(string sidx, string sord, int _page, int rows)
        {
            // using a groupField in the jqgrid passes that field
            // along with the field to sort, remove the groupField
            string groupBy = "StudentName asc, ";

            sidx = sidx.Replace(groupBy, "");

            int totalRecords  = Enquiry.GetRecordCount();
            int startRowIndex = ((_page * rows) - rows);

            List <Enquiry> objEnquiryCol = Enquiry.SelectSkipAndTake(rows, startRowIndex, sidx + " " + sord);
            int            totalPages    = (int)Math.Ceiling((float)totalRecords / (float)rows);

            if (objEnquiryCol is null)
            {
                return(new JsonResult("{ total = 0, page = 0, records = 0, rows = null }"));
            }

            var jsonData = new
            {
                total = totalPages,
                _page,
                records = totalRecords,
                rows    = (
                    from objEnquiry in objEnquiryCol
                    select new
                {
                    id = objEnquiry.EnquiryId,
                    cell = new string[] {
                        objEnquiry.EnquiryId.ToString(),
                        objEnquiry.CourseId.ToString(),
                        objEnquiry.StudentName,
                        objEnquiry.ContactNo.ToString(),
                        objEnquiry.Comments,
                        objEnquiry.Enquiry1.StudentName
                    }
                }).ToArray()
            };

            return(new JsonResult(jsonData));
        }
 /// <summary>
 /// Shows how to get the total number of records
 /// </summary>
 private void GetRecordCount()
 {
     // get the total number of records in the Enquiry table
     int totalRecordCount = Enquiry.GetRecordCount();
 }