コード例 #1
0
        public ViewResult List(string sortOrder, string currentFilter, string searchString, int?page, string PgeSize)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    ViewBag.CurrentSort = sortOrder;
                    ViewBag.TerritoryDescriptionSortParm = String.IsNullOrEmpty(sortOrder) ? "TerritoryDescription_desc" : "";

                    BusinessLayer.Validation pge      = new BusinessLayer.Validation();
                    List <SelectListItem>    PgeSizes = pge.PageSize();

                    //Assigning generic list to ViewBag
                    ViewBag.PgeSizeList = PgeSizes;

                    if (searchString != null)
                    {
                        page = 1;
                    }
                    else
                    {
                        searchString = currentFilter;
                    }

                    ViewBag.CurrentFilter = searchString;

                    TerritoriesBusinessModelLayers          territoriesBusinessModelLayers = new TerritoriesBusinessModelLayers();
                    List <BusinessModelLayer.Vwterritories> vwterritoriess = territoriesBusinessModelLayers.GetAllVwterritoriess();

                    if (!String.IsNullOrEmpty(searchString))
                    {
                        vwterritoriess = vwterritoriess.Where(s => s.TerritoryDescription.ToString().ToLower().Contains(searchString.ToLower())).ToList();
                    }

                    switch (sortOrder)
                    {
                    case "TerritoryDescription_desc":
                        vwterritoriess = vwterritoriess.OrderByDescending(s => s.TerritoryDescription).ToList();
                        break;

                    //case "!!!":
                    //	vwterritoriess = vwterritoriess.OrderBy(s => s.!!!).ToList();
                    //	break;
                    //case "!!!_desc":
                    //	vwterritoriess = vwterritoriess.OrderByDescending(s => s.!!!).ToList();
                    //	break;
                    default:      // TerritoryDescription ascending
                        vwterritoriess = vwterritoriess.OrderBy(s => s.TerritoryDescription).ToList();
                        break;
                    }

                    int pageSize = 10;
                    if (PgeSize != null)
                    {
                        Int32.TryParse(PgeSize, out pageSize);
                    }
                    ViewBag.PgeSize = pageSize;
                    int pageNumber = (page ?? 1);
                    return(View(vwterritoriess.ToPagedList(pageNumber, pageSize)));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public ActionResult Edit(int RegionID, string sortOrder, string currentFilter, string searchString, int?page, string PgeSize)
        {
            try     // handle exogenous exceptions
            {
                try // log all exceptions
                {
                    ViewBag.CurrentSort = sortOrder;
                    ViewBag.RegionID    = RegionID;

                    BusinessLayer.Validation pge      = new BusinessLayer.Validation();
                    List <SelectListItem>    PgeSizes = pge.PageSize();

                    //Assigning generic list to ViewBag
                    ViewBag.PgeSizeList = PgeSizes;

                    if (searchString != null)
                    {
                        page = 1;
                    }
                    else
                    {
                        searchString = currentFilter;
                    }

                    ViewBag.CurrentFilter = searchString;

                    //REGION TABLE MASTER
                    BusinessModelLayer.Region.RegionMasterDetailModel pageModel = new BusinessModelLayer.Region.RegionMasterDetailModel();
                    RegionBusinessModelLayers      regionBusinessModelLayers    = new RegionBusinessModelLayers();
                    Region.RegionMasterDetailModel regionMasterDetailModel      = new Region.RegionMasterDetailModel();

                    pageModel.Region = regionBusinessModelLayers.GetAllRegions().FirstOrDefault(x => x.RegionID == RegionID);

                    int pageSize = 10;
                    if (PgeSize != null)
                    {
                        Int32.TryParse(PgeSize, out pageSize);
                    }
                    ViewBag.PgeSize = pageSize;

                    int pageNumber = (page ?? 1);


                    //TERRITORIES DETAIL BEGIN

                    ViewBag.RegionIDSortParm = String.IsNullOrEmpty(sortOrder) ? "RegionID_desc" : "";
                    TerritoriesBusinessModelLayers territoriesBusinessModelLayers = new TerritoriesBusinessModelLayers();

                    List <BusinessModelLayer.Vwterritories> territoriess = territoriesBusinessModelLayers.GetAllVwterritoriess().FindAll(x => x.RegionID == RegionID).ToList();

                    if (!String.IsNullOrEmpty(searchString))
                    {
                        territoriess = territoriess.Where(s => s.RegionID == RegionID && s.TerritoryDescription.ToString().ToLower().Contains(searchString.ToLower())).ToList();
                    }

                    switch (sortOrder)
                    {
                    case "RegionID_desc":
                        territoriess = territoriess.OrderByDescending(s => s.RegionID).ToList();
                        break;

                    default:      // RegionID ascending
                        territoriess = territoriess.OrderBy(s => s.RegionID).ToList();
                        break;
                    }
                    pageModel.TerritoriesVwDetl = territoriess.ToPagedList(pageNumber, pageSize);

                    //TERRITORIES DETAIL END
                    return(View(pageModel));
                }
                catch (Exception ex)
                {
                    BusinessLayer.ExceptionLogging exlog = new BusinessLayer.ExceptionLogging();
                    exlog.SendExcepToDB(ex);
                    throw;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }