Esempio n. 1
0
        public ActionResult ItemSearch(string Page, ItemsSearch model)
        {
            ItemsDTO dto = new ItemsDTO();

            ModelState.Clear();
            if (!string.IsNullOrEmpty(model.SearchButton) || Page.IsNotNullOrEmpty())
            {
                if (Page != null)
                {
                    dto.page   = int.Parse(Page);
                    model.Page = dto.page;
                }
                ItemBL          bl     = new ItemBL();
                List <ItemsDTO> result = new List <ItemsDTO>();
                if (model.ItemName.IsNotNullOrEmpty())
                {
                    dto.name = model.ItemName;
                }
                if (model.ItemCode.IsNotNullOrEmpty())
                {
                    dto.code = model.ItemCode;
                }
                if (model.Category.HasValue)
                {
                    dto.category_id = model.Category;
                }

                bl.SearchData(dto, out result);
                model.PageCount     = bl.CountPage(dto);
                model.SearchResults = new StaticPagedList <ItemsDTO>(result, model.Page, 20, model.PageCount);
            }
            CategoryBL         category = new CategoryBL();
            List <CategoryDTO> categorydt;

            category.SearchList(out categorydt);
            CategoryDTO cate = new CategoryDTO();

            categorydt.Add(cate);
            ViewBag.CategoryList = categorydt;

            return(View(model));
        }