예제 #1
0
        public ActionResult GetAll(DataTableAjaxPostModel dataModel)
        {
            var khuyenMai = KMService.GetAll(dataModel);

            return(Json(khuyenMai));
        }
예제 #2
0
        //This get provides a list of Paged Accounts
        public async Task <JsonResult> OnPostPaging([FromForm] DataTableAjaxPostModel Model)
        {
            int filteredResultsCount = 0;
            int totalResultsCount    = 0;

            DataTableAjaxPostModel.GetOrderByParameters(Model.order, Model.columns, "ActCostAccountID",
                                                        out bool SortDir, out string SortBy);


            //First create the View of the new model you wish to display to the user
            var AccountQuery = _context.ActCostAccount
                               .Include(b => b.Branch)
                               .Include(c => c.ActCostCategory)
                               .Include(sc => sc.ActCostSubCategory)
                               .Include(cd => cd.ActCostDriver)
                               .Include(sp => sp.ActCostAllocationSplit)
                               .Select(acc => new
            {
                acc.ActCostAccountID,
                AccountName     = acc.Description,
                AccountNo       = acc.AccountNo,
                Branch          = acc.Branch.BranchName,
                Category        = acc.ActCostCategory.Description,
                SubCategory     = acc.ActCostSubCategory.Description,
                CostDriver      = acc.ActCostDriver.Description,
                AllocationSplit = acc.ActCostAllocationSplit.Description
            }
                                       );

            totalResultsCount    = AccountQuery.Count();
            filteredResultsCount = totalResultsCount;

            if (!string.IsNullOrEmpty(Model.search.value))
            {
                AccountQuery = AccountQuery
                               .Where(
                    d => d.AccountName.ToLower().Contains(Model.search.value.ToLower()) ||
                    d.AccountNo.ToString().ToLower().Contains(Model.search.value.ToLower()) ||
                    d.Branch.ToString().ToLower().Contains(Model.search.value.ToLower()) ||
                    d.Category.ToString().ToLower().Contains(Model.search.value.ToLower()) ||
                    d.SubCategory.ToString().ToLower().Contains(Model.search.value.ToLower()) ||
                    d.CostDriver.ToString().ToLower().Contains(Model.search.value.ToLower()) ||
                    d.AllocationSplit.ToString().ToLower().Contains(Model.search.value.ToLower())
                    );

                filteredResultsCount = AccountQuery.Count();
            }
            var Result = await AccountQuery
                         .Skip(Model.start)
                         .Take(Model.length)
                         .OrderBy(SortBy, SortDir)
                         .ToListAsync();

            var value = new
            {
                // this is what datatables wants sending back
                draw            = Model.draw,
                recordsTotal    = totalResultsCount,
                recordsFiltered = filteredResultsCount,
                data            = Result
            };

            return(new JsonResult(value));
        }
예제 #3
0
        public object CustomServerSideSearchAction(DataTableAjaxPostModel model)
        {
            try
            {
                IQueryable <User> UsersQuery = _dbContext.Users.AsQueryable();
                var searchValue = model.search.value;
                if (!string.IsNullOrEmpty(searchValue))
                {
                    UsersQuery = UsersQuery.Where(t => t.Name.Contains(searchValue));
                }
                #region Sắp xếp
                IOrderedQueryable <User> UsersOrder = null;
                var order = model.order.Count;
                if (order > 0)
                {
                    for (int i = 0; i < order; i++)
                    {
                        var indexCol = model.order[i].column;
                        var dir      = model.order[i].dir;
                        var colName  = model.columns[indexCol].data;
                        colName = Common.UppercaseFirst(colName); //Viết hoa lại chữ cái đầu
                        if (!string.IsNullOrEmpty(colName))
                        {
                            if (i == 0)
                            {
                                if (dir == "asc")
                                {
                                    UsersOrder = UsersQuery.OrderBy(x => x.GetType().GetProperty(colName).GetValue(x, null));
                                }
                                else
                                {
                                    UsersOrder = UsersQuery.OrderByDescending(x => x.GetType().GetProperty(colName).GetValue(x, null));
                                }
                            }
                            else
                            {
                                if (dir == "asc")
                                {
                                    UsersOrder = UsersOrder.ThenBy(x => x.GetType().GetProperty(colName).GetValue(x, null));
                                }
                                else
                                {
                                    UsersOrder = UsersOrder.ThenByDescending(x => x.GetType().GetProperty(colName).GetValue(x, null));
                                }
                            }
                        }
                        else
                        {
                            UsersQuery = UsersQuery.OrderByDescending(x => x.ID);
                        }
                    }
                    if (UsersOrder != null)
                    {
                        UsersQuery = UsersOrder;
                    }
                }
                else
                {
                    UsersQuery = UsersQuery.OrderByDescending(x => x.ID);
                }
                #endregion

                var lstUser = UsersQuery
                              .Skip(model.start)  //Bỏ qua số dữ liệu
                              .Take(model.length) //Số dữ liệu lấy ra
                              .ToList();
                // Tổng số dữ liệu lấy ra khi đã truy vấn (tìm kiếm) và chưa phân trang
                int filteredResultsCount = UsersQuery.Count();
                // Tổng số dữ liệu trong database
                int totalResultsCount = _dbContext.Users.Count();
                return(new ObjectReturn
                {
                    draw = model.draw,
                    recordsTotal = totalResultsCount,
                    recordsFiltered = filteredResultsCount,
                    data = lstUser
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #4
0
        public async Task <JsonResult> OnPostPaging([FromForm] DataTableAjaxPostModel Model)
        {
            int filteredResultsCount = 0;
            int totalResultsCount    = 0;

            DataTableAjaxPostModel.GetOrderByParameters(Model.order, Model.columns, "LoadDate",
                                                        out bool SortDir, out string SortBy);


            //First create the View of the new model you wish to display to the user
            var LoadQuery = _context.Loads
                            .Include(s => s.LoadStatus)
                            .Include(d => d.Destination.StartLocation)
                            .Include(d => d.Destination.EndLocation)
                            .Select(l => new
            {
                l.LoadID,
                l.LoadDate,
                l.LoadName,
                LoadStatus   = l.LoadStatus.Description,
                SubContrator = l.Driver.SubContractor.Name,
                l.Vehicle.RegistrationNumber,
                Destination = l.Destination.EndLocation.LocationName + " : " +
                              l.Destination.StartLocation.LocationName,
                DriverName     = l.Driver.FirstName + l.Driver.Surname,
                LoadCreateDate = l.CreatedUtc,
                LoadCreatedBy  = l.User.UserName,
                l.LoadStatusID
            }
                                    );

            if (Model.LoadStatus.ToUpper().Contains("INCOMPLETE"))
            {
                LoadQuery = LoadQuery.Where(l => l.LoadStatusID == 1);
            }

            totalResultsCount    = LoadQuery.Count();
            filteredResultsCount = totalResultsCount;

            if (!string.IsNullOrEmpty(Model.search.value))
            {
                LoadQuery = LoadQuery
                            .Where(
                    c => c.SubContrator.ToLower().Contains(Model.search.value.ToLower()) ||
                    c.DriverName.ToLower().Contains(Model.search.value.ToLower()) ||
                    c.Destination.ToLower().Contains(Model.search.value.ToLower()) ||
                    c.RegistrationNumber.ToLower().Contains(Model.search.value.ToLower()) ||
                    c.LoadStatus.ToLower().Contains(Model.search.value.ToLower())
                    );

                filteredResultsCount = LoadQuery.Count();
            }
            // LoadQuery.OrderByDescending(l => l.LoadDate);
            var Result = await LoadQuery
                         .Skip(Model.start)
                         .Take(Model.length)
                         .OrderBy(SortBy, SortDir)
                         //                       .OrderByDescending(l => l.LoadDate)
                         .ToListAsync();

            var value = new
            {
                // this is what datatables wants sending back
                draw            = Model.draw,
                recordsTotal    = totalResultsCount,
                recordsFiltered = filteredResultsCount,
                data            = Result
            };

            return(new JsonResult(value));
        }
    public static object GetMedicalFacilities(DataTableAjaxPostModel model)
    {
        var cols = new List <string>()
        {
            "LOWER(TRIM(mf.hospital_name))", "LOWER(TRIM(mf.address))", "LOWER(TRIM(mf.email_id))", "LOWER(TRIM(mf.contact_no))", "LOWER(TRIM(cm.city_name))"
        };
        // Initialization.
        DataTableData <MedicalFacilityModel> result = new DataTableData <MedicalFacilityModel>();

        try
        {
            // Initialization.
            string draw     = model.draw.ToString();
            int    startRec = model.start;
            int    pageSize = model.length;

            var c_order = "";
            foreach (var o in model.order)
            {
                var columnName = cols[o.column];
                c_order += string.IsNullOrWhiteSpace(c_order) ? columnName + " " + o.dir : ", " + columnName + " " + o.dir;
            }
            if (!string.IsNullOrWhiteSpace(c_order))
            {
                c_order = " order by " + c_order;
            }

            var c_search = "";
            foreach (var s in model.columns)
            {
                if (!string.IsNullOrWhiteSpace(s.search.value) && s.searchable)
                {
                    var i          = model.columns.IndexOf(s);
                    var columnName = cols[i];
                    c_search += i == 1 ? " and " + columnName + " like '%" + s.search.value.Trim().ToLower() + "%'" : " and " + columnName + " like '%" + s.search.value + "%'";
                }
            }

            var medicalFacilities = new MedicalFacilityManager().GetAllMedicalFacilitiesPaginated(startRec, pageSize, c_order, c_search);

            var medicalFacilityList = medicalFacilities.Data;
            foreach (var medicalFacility in medicalFacilityList)
            {
                medicalFacility.Link = "<a href='javascript:void(0);' style='margin-right:10px' class='edit-mf' data-id='" + medicalFacility.Id + "'>Edit</a><a href='javascript:void(0);' class='add-mf-images' data-id='" + medicalFacility.Id + "'>Add Images</a><a href='javascript:void(0);' style='margin-left:10px' class='delete-mf' data-id='" + medicalFacility.Id + "'>Delete</a>";
            }

            int recFilter = medicalFacilities.Data.Count;

            result.draw            = Convert.ToInt32(draw);
            result.recordsTotal    = medicalFacilities.TotalCount;
            result.recordsFiltered = medicalFacilities.TotalCount;
            result.data            = medicalFacilityList;
        }
        catch (Exception ex)
        {
            // Info
            Console.Write(ex);
        }
        // Return info.
        return(result);
    }
예제 #6
0
        public IActionResult GetList(DataTableAjaxPostModel param)
        {
            int recordsTotal = 0;
            var result       = _voucherSetupRepository.GetList(this.loginUserId, isAdmin);

            if (result.Any())
            {
                recordsTotal = result.Count;

                if (param.status == Helper.Active)
                {
                    result = result.Where(x => x.Status).ToList();
                }
                else if (param.status == Helper.Inactive)
                {
                    result = result.Where(x => !x.Status).ToList();
                }

                if (!string.IsNullOrEmpty(param.search.value))
                {
                    var search = param.search.value;
                    result = result.Where(x => x.Name.ToLower().Contains(search.ToLower()) ||
                                          x.Value.ToString().Contains(search.ToLower()) ||
                                          x.Usage.ToLower().Contains(search.ToLower()) ||
                                          x.StartDate.ToLower().Contains(search.ToLower()) ||
                                          x.EndDate.ToLower().Contains(search.ToLower())
                                          ).ToList();
                }
            }

            string order    = Convert.ToString(param.order[0].column);
            string orderDir = param.order[0].dir;

            switch (order)
            {
            case "0":
                result = orderDir.Equals("DESC", StringComparison.CurrentCultureIgnoreCase) ? result.OrderByDescending(p => p.Name).ToList() : result.OrderBy(p => p.Name).ToList();
                break;

            case "1":
                result = orderDir.Equals("DESC", StringComparison.CurrentCultureIgnoreCase) ? result.OrderByDescending(p => p.Value).ToList() : result.OrderBy(p => p.Value).ToList();
                break;

            case "2":
                result = orderDir.Equals("DESC", StringComparison.CurrentCultureIgnoreCase) ? result.OrderByDescending(p => p.Usage).ToList() : result.OrderBy(p => p.Usage).ToList();
                break;

            case "3":
                result = orderDir.Equals("DESC", StringComparison.CurrentCultureIgnoreCase) ? result.OrderByDescending(p => p.StartDate).ToList() : result.OrderBy(p => p.StartDate).ToList();
                break;

            case "4":
                result = orderDir.Equals("DESC", StringComparison.CurrentCultureIgnoreCase) ? result.OrderByDescending(p => p.EndDate).ToList() : result.OrderBy(p => p.EndDate).ToList();
                break;

            default:
                result = result.OrderByDescending(p => p.Id).ToList();
                break;
            }

            var data = result;

            if (param.length > 0)
            {
                data = result.Skip(param.start).Take(param.length).ToList();
            }

            return(Json(new
            {
                draw = param.draw,
                recordsFiltered = result.Count,
                recordsTotal = recordsTotal,
                data = data
            }));
        }
예제 #7
0
        public ActionResult GetAll(DataTableAjaxPostModel dataModel)
        {
            var KHs = KHService.GetAll(dataModel);

            return(Json(KHs));
        }
예제 #8
0
        public GridModel <CommissionViewModel> ObtenerLista(DataTableAjaxPostModel filters)
        {
            var searchBy = (filters.search != null) ? filters.search.value : null;


            string sortBy  = "";
            string sortDir = "";

            if (filters.order != null)
            {
                // in this example we just default sort on the 1st column
                sortBy  = filters.columns[filters.order[0].column].data;
                sortDir = filters.order[0].dir.ToLower();
            }


            GridModel <CommissionViewModel> resultado    = new GridModel <CommissionViewModel>();
            IQueryable <commissions>        queryFilters = Set;



            int count_records          = queryFilters.Count();
            int count_records_filtered = count_records;


            if (String.IsNullOrWhiteSpace(searchBy) == false)
            {
                // as we only have 2 cols allow the user type in name 'firstname lastname' then use the list to search the first and last name of dbase
                var searchTerms = searchBy.Split(' ').ToList().ConvertAll(x => x.ToLower());

                queryFilters = queryFilters.Where(s => searchTerms.Any(srch => s.name.ToLower().Contains(srch)));


                count_records_filtered = queryFilters.Count();
            }


            var query = queryFilters.Select(a => new CommissionViewModel
            {
                commission_id = a.commission_id,
                name          = a.name
            });

            if (String.IsNullOrEmpty(sortBy))
            {
                sortBy = "commission_id";
            }
            if (String.IsNullOrEmpty(sortDir))
            {
                sortDir = "asc";
            }
            string sortExpression = sortBy.Trim() + " " + sortDir.Trim();

            if (sortExpression.Trim() != "")
            {
                query = OrderByDinamic.OrderBy <CommissionViewModel>(query, sortExpression.Trim());
            }
            resultado.rows = query.Skip(filters.start).Take(filters.length).ToList();



            resultado.total = count_records;

            resultado.recordsFiltered = count_records_filtered;
            return(resultado);
        }
예제 #9
0
        public JsonResult Index(DataTableAjaxPostModel model)
        {
            var users       = db.Accounts;
            var search      = users.Where(a => true);
            int CurrentUser = int.Parse(Session["UserID"].ToString());

            if (CurrentUser != 14)
            {
                search = search.Where(a => a.ID != "14");
            }
            if (model.search.value != null)
            {
                string searchValue = model.search.value;
                search = search.Where(a => a.Username.Contains(searchValue) || a.Name.Contains(searchValue));
            }
            if (model.columns[1].search.value != null)
            {
                string searchValue = model.columns[1].search.value;
                search = search.Where(a => a.Username.Contains(searchValue));
            }
            if (model.columns[2].search.value != null)
            {
                string searchValue = model.columns[2].search.value;
                search = search.Where(a => a.Name.Contains(searchValue));
            }

            var sorting = search.OrderBy(a => a.ID);

            if (model.order[0].column == 2)
            {
                if (model.order[0].dir.Equals("asc"))
                {
                    sorting = search.OrderBy(a => a.Username);
                }
                else
                {
                    sorting = search.OrderByDescending(a => a.Username);
                }
            }
            else if (model.order[0].column == 3)
            {
                if (model.order[0].dir.Equals("asc"))
                {
                    sorting = search.OrderBy(a => a.Name);
                }
                else
                {
                    sorting = search.OrderByDescending(a => a.Name);
                }
            }
            var paging = sorting.Skip(model.start).Take(model.length).ToList();
            var result = new List <CustomUser>(paging.Count);

            foreach (var s in paging)
            {
                result.Add(new CustomUser
                {
                    ID       = s.ID,
                    Name     = s.Name,
                    Username = s.Username
                });
            }
            ;
            return(Json(new
            {
                draw = model.draw,
                recordsTotal = users.Count(),
                recordsFiltered = search.Count(),
                data = result
            }));
        }
예제 #10
0
        public object GetAll(DataTableAjaxPostModel dataModel)
        {
            var sortBy = dataModel.columns[dataModel.order[0].column].data; //Lấy cột để sắp xếp
            var dirBy  = dataModel.order[0].dir.ToLower();                  //Lấy thứ tự tăng/giảm
            var search = dataModel.search.value;

            var model = context.PHIEUDATHANG_NCCs.AsQueryable(); //lấy sản phẩm (chưa thực thi)

            //serch
            if (!string.IsNullOrWhiteSpace(search))
            {
                model = model.Where(t => t.NHACUNGCAP.TENNCC.Contains(search));
            }
            var totalRecord = model.Count();

            //Sorting
            switch (sortBy)
            {
            case "MaDatHang":
                model = dirBy == "desc" ? model.OrderByDescending(t => t.MAPHIEUDAT)
                            : model.OrderBy(t => t.MAPHIEUDAT);
                break;

            case "TongTien":
                model = dirBy == "desc" ? model.OrderByDescending(t => t.TONGTIEN)
                            : model.OrderBy(t => t.TONGTIEN);
                break;

            case "TenNCC":
                model = dirBy == "desc" ? model.OrderByDescending(t => t.NHACUNGCAP.TENNCC)
                            : model.OrderBy(t => t.NHACUNGCAP.TENNCC);
                break;

            case "NguoiDat":
                model = dirBy == "desc" ? model.OrderByDescending(t => t.NGUOIDAT)
                            : model.OrderBy(t => t.NHACUNGCAP.TENNCC);
                break;

            case "TrangThai":
                model = dirBy == "desc" ? model.OrderByDescending(t => t.TRANGTHAI)
                            : model.OrderBy(t => t.TRANGTHAI);
                break;

            case "NgayDat":
                model = dirBy == "desc" ? model.OrderByDescending(t => t.NGAYDAT)
                            : model.OrderBy(t => t.NGAYDAT);
                break;

            default:
                model = model.OrderBy(t => t.MAPHIEUDAT);
                break;
            }
            ;

            //paging

            if (dataModel.length == 0)
            {
                dataModel.length = 10;
            }
            model = model.Skip(dataModel.start).Take(dataModel.length);
            var data = model.
                       Select(t => new PhieuDatHang_NCCViewModel()
            {
                MaPhieuDat = t.MAPHIEUDAT,
                TenNCC     = t.NHACUNGCAP.TENNCC,
                TongTien   = t.TONGTIEN,
                NguoiDat   = t.NGUOIDAT,
                NgayDat    = t.NGAYDAT,
                TrangThai  = t.TRANGTHAI == 0 ? TinhTrangDatHang.DaHuy :
                             (t.TRANGTHAI == 1) ? TinhTrangDatHang.DangXyLy : (t.TRANGTHAI == 2) ?
                             TinhTrangDatHang.DaNhan : TinhTrangDatHang.DangDat
            }).ToList();

            return(new
            {
                draw = Convert.ToInt32(dataModel.draw),
                recordsTotal = totalRecord,
                recordsFiltered = totalRecord,
                data = data
            });
        }
예제 #11
0
 public GridModel <InstitutionViewModel> ObtenerLista(DataTableAjaxPostModel filters)
 {
     return(oRepositorio.ObtenerLista(filters));
 }
예제 #12
0
        /// <summary>
        /// get search purchase invoice result list.
        /// </summary>
        /// <param name="dataTableAjaxPostModel"></param>
        /// <param name="searchFilterModel"></param>
        /// <returns>
        /// return list.
        /// </returns>
        public async Task <DataTableResultModel <PurchaseInvoiceModel> > GetPurchaseInvoiceList(DataTableAjaxPostModel dataTableAjaxPostModel, SearchFilterPurchaseInvoiceModel searchFilterModel)
        {
            string searchBy = dataTableAjaxPostModel.search?.value;
            int    take     = dataTableAjaxPostModel.length;
            int    skip     = dataTableAjaxPostModel.start;

            string sortBy  = string.Empty;
            string sortDir = string.Empty;

            if (dataTableAjaxPostModel.order != null)
            {
                sortBy  = dataTableAjaxPostModel.columns[dataTableAjaxPostModel.order[0].column].data;
                sortDir = dataTableAjaxPostModel.order[0].dir.ToLower();
            }

            // search the dbase taking into consideration table sorting and paging
            DataTableResultModel <PurchaseInvoiceModel> resultModel = await GetDataFromDbase(searchFilterModel, searchBy, take, skip, sortBy, sortDir);

            return(resultModel); // returns.
        }
예제 #13
0
 public GridModel <InvestigatorViewModel> ObtenerInvestigadores(DataTableAjaxPostModel filters, List <int> interest_areas)
 {
     return(oRepositorioInvestigator.ObtenerInvestigadores(filters, interest_areas));
 }
예제 #14
0
 public GridModel <ConsultationViewModel> ObtenerListaEnviados(DataTableAjaxPostModel filters)
 {
     return(oRepositorio.ObtenerListaEnviados(filters));
 }
예제 #15
0
 public GridModel <ConsultationViewModel> ObtenerLista(DataTableAjaxPostModel filters, int user_id)
 {
     return(oRepositorio.ObtenerLista(filters, user_id));
 }