Beispiel #1
0
        public List <ProductType> SearchingProductType(ProductTypeSearchCriteria productTypeSearchCriteria)
        {
            IQueryable <ProductType> query   = null;
            BaoHienDBDataContext     context = BaoHienRepository.GetBaoHienDBDataContext();

            if (context != null)
            {
                query = from pt in context.ProductTypes
                        where (pt.Status == null)
                        select pt;
            }
            if (productTypeSearchCriteria.ProductTypeCode != null)
            {
                query = query.Where(p => p.TypeCode.ToLower().Contains(productTypeSearchCriteria.ProductTypeCode));
            }
            if (productTypeSearchCriteria.ProductTypeName != null)
            {
                query = query.Where(p => p.TypeName.ToLower().Contains(productTypeSearchCriteria.ProductTypeName));
            }

            if (query != null)
            {
                return(query.ToList());
            }
            return(null);
        }
        private void searchProductType()
        {
            ProductTypeSearchCriteria producTypeSearchCriteria = new ProductTypeSearchCriteria
            {
                ProductTypeCode = string.IsNullOrEmpty(txtCode.Text) ? "" : txtCode.Text.ToLower(),
                ProductTypeName = string.IsNullOrEmpty(txtName.Text) ? "" : txtName.Text.ToLower()
            };

            ProductTypeService producTypeService = new ProductTypeService();
            List <ProductType> productTypes      = producTypeService.SearchingProductType(producTypeSearchCriteria);

            if (productTypes != null)
            {
                dgvProductTypeList.DataSource = productTypes;
                lblTotalResult.Text           = productTypes.Count.ToString();
            }
        }