Пример #1
0
        public JsonResult GetSalesOrderDetailerRecords(JQGridSettings JQGrid)
        {
            int TotapPages   = 0;
            int TotalRecords = 0;

            int SalesOrderID = int.Parse(Request.QueryString["SalesOrderID"]);

            IEnumerable <SalesOrderDetail> SOHIE = null;
            IQueryable <SalesOrderDetail>  SOHIQ = null;

            using (SalesEntities DB = new SalesEntities())
            {
                DB.Configuration.LazyLoadingEnabled   = false;
                DB.Configuration.ProxyCreationEnabled = false;

                SOHIQ = DB.SalesOrderDetails.AsQueryable().Where(d => d.SalesOrderID == SalesOrderID).Select(d => d);

                #region :::Soring-Searching:::
                if (JQGrid._search)
                {
                    JQGridFilters _filters = JsonConvert.DeserializeObject <JQGridFilters>(JQGrid.filters);
                    SOHIQ = SOHIQ.JQGridToolBarSearch(_filters);
                }
                else
                {
                    SOHIQ = SOHIQ.JQGridSorting(JQGrid.sidx, JQGrid.sord);
                }
                #endregion

                #region :::Pagination
                SOHIE = SOHIQ.AsEnumerable();
                try
                {
                    TotapPages   = Convert.ToInt32(Math.Ceiling((double)SOHIE.Count() / (double)JQGrid.rows));
                    TotalRecords = SOHIE.Count();
                    SOHIE        = SOHIE.Skip((JQGrid.page - 1) * JQGrid.rows).Take(JQGrid.rows).ToList();
                }
                catch (Exception e)
                {
                    throw;
                }
                #endregion
            }

            var jsonReader = new
            {
                root    = SOHIE,
                page    = JQGrid.page,
                total   = TotapPages,
                records = TotalRecords
            };


            return(Json(jsonReader, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public JsonResult GetEmployeeCollection(JQGridSettings JQGrid)
        {
            int TotapPages   = 0;
            int TotalRecords = 0;
            IEnumerable <Employee> IEEmployee = null;
            IQueryable <Employee>  IQEmployee = null;

            using (Employee DB = new Employee())
            {
                #region :::Soring-Searching:::
                if (JQGrid._search)
                {
                    //for Filter Toolbar
                    JQGridFilters _filters = JsonConvert.DeserializeObject <JQGridFilters>(JQGrid.filters);
                    IQEmployee = DB.GetEmployeeColection().AsQueryable().JQGridToolBarSearch(_filters);

                    //for Advanced Search
                    //JQGridAdvanceFilter _filters1 = JsonConvert.DeserializeObject<JQGridAdvanceFilter>(JQGrid.filters);
                    //IQEmployee = DB.GetEmployeeColection().AsQueryable().JQGridAdvancedSearch(_filters1);
                }
                else
                {
                    IQEmployee = DB.GetEmployeeColection().AsQueryable().JQGridSorting(JQGrid.sidx, JQGrid.sord);
                }
                #endregion

                #region :::Pagination
                IEEmployee = IQEmployee.AsEnumerable();
                try
                {
                    TotapPages   = Convert.ToInt32(Math.Ceiling((double)IEEmployee.Count() / (double)JQGrid.rows));
                    TotalRecords = IEEmployee.Count();
                    IEEmployee   = IEEmployee.Skip((JQGrid.page - 1) * JQGrid.rows).Take(JQGrid.rows).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
                #endregion
            }

            var jsonReader = new
            {
                root    = IEEmployee,
                page    = JQGrid.page,
                total   = TotapPages,
                records = TotalRecords
            };


            return(Json(jsonReader, JsonRequestBehavior.AllowGet));
        }