Exemplo n.º 1
0
 public static Product Convert(this SearchProduct entity)
 {
     return(new Product
     {
         Name = entity.Name,
         Value = entity.Value,
         Id = entity.Id,
     });
 }
Exemplo n.º 2
0
        public void SearchProductTest()
        {
            SearchProduct search = new SearchProduct(driver);

            search.SearchProductPage();
            string actualResult = search.validatePage();

            Assert.AreEqual("Sort By", actualResult);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!EX_Admin.Power("prodesc_datainout", "导入导出"))
            {
                PageReturnMsg = PageNoPowerMsg();
            }

            sp = new SearchProduct(CurrentAdmin, CurrentLanguage.Code);
        }
Exemplo n.º 4
0
            public void SwatchPack()
            {
                //Start the reports
                test = extent.StartTest("Swatch Pack Scenario");

                //Create a Class and Method
                SearchProduct obj1 = new SearchProduct();

                obj1.SearchAProduct();
            }
Exemplo n.º 5
0
        public async Task <PagedList <Product> > ListAsync(Pagination pagination, SearchProduct search)
        {
            var queryable = _context.Products.AsQueryable();

            if (!String.IsNullOrEmpty(search.Name))
            {
                queryable = queryable.Where(c => c.Name.ToLower().Trim().Contains(search.Name.ToLower().Trim()));
            }

            return(await PagedList <Product> .ToPagedListAsync(queryable, pagination.PageNumber, pagination.PageSize));
        }
Exemplo n.º 6
0
        public IEnumerable <Product> Get(SearchProduct searchReq)
        {
            IEnumerable <Product> product = null;

            using (var connection = new SqlConnection(connectionString))
            {
                //product = connection.Query<Product>("SELECT * FROM products;");
                string qryStr = $"EXEC getProducts @ProductID,@ProductName,@CatID,@PriceFrom,@PriceTo;";
                product = connection.Query <Product>(qryStr, searchReq);
            }
            return(product);
        }
        public IHttpActionResult GetCountProduct(SearchProduct searchProduct)
        {
            var count = _productCatalogService.GetCountProduct(searchProduct);

            return(Ok(new
            {
                data = new
                {
                    count
                }
            }));
        }
 private void ControlKeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyCode == Keys.Enter)
         {
             if (sender == SearchProduct && SearchProduct.EditValue != null)
             {
                 spLength.Focus();
             }
             else if (sender == spPrice)
             {
                 spLength.Focus();
             }
             else if (sender == spLength)
             {
                 spWidth.Focus();
             }
             else if (sender == spWidth)
             {
                 spQuantity.Focus();
             }
             else if (sender == spQuantity)
             {
                 spDiscount.Value = (spPrice.Value * spLength.Value * spWidth.Value * spQuantity.Value) - (int)(spPrice.Value * spLength.Value * spWidth.Value * spQuantity.Value);
                 spDiscount.Focus();
             }
             else if (sender == spDiscount)
             {
                 ProductView.AddNewRow();
                 SearchProduct.EditValue = null;
                 SearchProduct.Focus();
             }
         }
         else if (e.KeyCode == Keys.Delete)
         {
             if (sender == ProductView)
             {
                 if (ProductView.RowCount > 0)
                 {
                     SpInvoiceDiscount.Value = SpInvoiceDiscount.Value - decimal.Parse(ProductView.GetRowCellValue(ProductView.FocusedRowHandle, ProductView.Columns[9]).ToString());
                     spInvoiceTotal.Value    = spInvoiceTotal.Value - decimal.Parse(ProductView.GetRowCellValue(ProductView.FocusedRowHandle, ProductView.Columns[10]).ToString());
                     ProductView.DeleteRow(ProductView.FocusedRowHandle);
                     SearchProduct.Focus();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public IHttpActionResult Search(SearchProduct searchProduct)
        {
            var products = _productCatalogService.Search(searchProduct);

            return(Ok(new
            {
                data = new
                {
                    products
                }
            }));
        }
Exemplo n.º 10
0
        public List <ProductModel> GetList(SearchProduct search)
        {
            List <ProductModel> lstObject = new List <ProductModel>();

            try
            {
                lstObject = Execute(() => GetListNoCache(search), "ProductBo:GetList", Const.MediumCacheTime, true, search);
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.LogType.Error, ex.ToString());
            }
            return(lstObject);
        }
Exemplo n.º 11
0
        List <ProductDetails> IProduct.GetAllProductList(SearchProduct search)
        {
            List <ProductDetails> list = new List <ProductDetails>();

            try
            {
                list = iProduct.GetAllProductList(search);
                return(list);
            }
            catch (Exception)
            {
                return(list);
            }
        }
Exemplo n.º 12
0
        public int GetListCount(SearchProduct search)
        {
            int totalCount = 0;

            try
            {
                totalCount = Execute(() => _productDal.GetListCount(search), "ProductBo:GetListCount", Const.MediumCacheTime, true, search);
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.LogType.Error, ex.ToString());
            }
            return(totalCount);
        }
Exemplo n.º 13
0
        public int GetCountProduct(SearchProduct searchProduct)
        {
            return(_connectionFactory.GetConnection.Query <int>(@"
					SELECT COUNT(*)
					  FROM Dealer			AS DEA
					 INNER JOIN Company		AS COM ON COM.[DealerId] = DEA.Id		AND COM.[Status] = 'Active' AND COM.[Enable] = 1
					 INNER JOIN Category	AS CAT ON CAT.[CompanyId] = COM.Id		AND CAT.[Status] = 'Active'
					 INNER JOIN Product		AS PRO ON PRO.[CategoryId] = CAT.Id		AND PRO.[Status] = 'Active' AND PRO.[Enable] = 1
					 WHERE DEA.[Status] = 'Active'
					   AND DEA.[Enable] = 1
					   AND (@dealerId = -1 OR DEA.Id = @dealerId)
					   AND (@companyId = -1 OR COM.Id = @companyId)
					   AND (@categoryId = -1 OR CAT.Id = @categoryId)"                    ,
                                                                searchProduct).FirstOrDefault());
        }
Exemplo n.º 14
0
        public ProductsModelLight(SearchProduct search)
            : base(search)
        {
            this.ProductFamilyId = search.ProductFamilyId;

            this.ProductSubFamilyId = search.ProductSubFamilyId;

            this.ProductTypeId = search.ProductTypeId;

            this.ProductModelTypeId = search.ProductModelTypeId;

            this.ProductPowerVoltageTypeId = search.ProductPowerVoltageTypeId;

            this.CoolingCapacityRatedMax = search.CoolingCapacityRatedMax;
            this.CoolingCapacityRatedMin = search.CoolingCapacityRatedMin;

            this.HeatingCapacityRatedMax = search.HeatingCapacityRatedMax;
            this.HeatingCapacityRatedMin = search.HeatingCapacityRatedMin;

            this.SEERNonDuctedMax = search.SEERNonDuctedMax;
            this.SEERNonDuctedMin = search.SEERNonDuctedMin;

            this.IEERNonDuctedMax = search.IEERNonDuctedMax;
            this.IEERNonDuctedMin = search.IEERNonDuctedMin;

            this.EERNonDuctedMax = search.EERNonDuctedMax;
            this.EERNonDuctedMin = search.EERNonDuctedMin;

            this.HSPFNonDuctedMax = search.HSPFNonDuctedMax;
            this.HSPFNonDuctedMin = search.HSPFNonDuctedMin;

            this.COP47NonDuctedMax = search.COP47NonDuctedMax;
            this.COP47NonDuctedMin = search.COP47NonDuctedMin;


            this.ProductHeatExchangerTypeId = search.ProductHeatExchangerTypeId;

            this.UnitInstallationTypeId = search.UnitInstallationTypeId;

            this.ProductClassPIMId = search.ProductClassPIMId;

            this.ProductCategoryId = search.ProductCategoryId;

            this.CoolingCapacityRatedValue   = search.CoolingCapacityRatedValue;
            this.CoolingCapacityNominalValue = search.CoolingCapacityNominalValue;
            this.HeatingCapacityRatedValue   = search.HeatingCapacityRatedValue;
            this.AirFlowRateHighValue        = search.AirFlowRateHighValue;
        }
 private void btnAddNew_Click(object sender, EventArgs e)
 {
     try
     {
         SearchProduct.Focus();
         DataTable dt = new DataTable();
         dt.Columns.Add(new DataColumn {
             ColumnName = "v1", DataType = typeof(string)
         });                                                                             //PCode
         dt.Columns.Add(new DataColumn {
             ColumnName = "v2", DataType = typeof(string)
         });                                                                             //PName
         dt.Columns.Add(new DataColumn {
             ColumnName = "v3", DataType = typeof(string)
         });                                                                             //UCode
         dt.Columns.Add(new DataColumn {
             ColumnName = "v4", DataType = typeof(string)
         });                                                                             //UName
         dt.Columns.Add(new DataColumn {
             ColumnName = "v5", DataType = typeof(string)
         });                                                                             //Price
         dt.Columns.Add(new DataColumn {
             ColumnName = "v6", DataType = typeof(string)
         });                                                                             //Length
         dt.Columns.Add(new DataColumn {
             ColumnName = "v7", DataType = typeof(string)
         });                                                                             //Width
         dt.Columns.Add(new DataColumn {
             ColumnName = "v8", DataType = typeof(string)
         });                                                                             //Quantity
         dt.Columns.Add(new DataColumn {
             ColumnName = "v9", DataType = typeof(string)
         });                                                                             //Total Quantity
         dt.Columns.Add(new DataColumn {
             ColumnName = "v10", DataType = typeof(string)
         });                                                                              //Discount
         dt.Columns.Add(new DataColumn {
             ColumnName = "v11", DataType = typeof(string)
         });                                                                              //Line Total
         ProductGrid.DataSource  = dt;
         ProductGrid.DataMember  = dt.TableName;
         SpInvoiceDiscount.Value = spInvoiceTotal.Value = spInvoicePaied.Value = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 16
0
        public string ParserProductUrl(string urlAlias, ref SearchProduct searchInfo)
        {
            string trueAlias = string.Empty;

            urlAlias = string.Concat(urlAlias, "-");

            #region Category

            int cateId = 0;

            if (!string.IsNullOrEmpty(urlAlias) && urlAlias.StartsWith("san-pham"))
            {
                urlAlias  = urlAlias.Replace("san-pham-", string.Empty);
                trueAlias = "san-pham";
            }
            else if (!string.IsNullOrEmpty(urlAlias))
            {
                List <CategoryEntity> lstCateDesc = _categoryBo.GetListDesc();
                foreach (var item in lstCateDesc)
                {
                    if (urlAlias.StartsWith(item.DisplayUrl + "-"))
                    {
                        searchInfo.CateId = cateId = item.CatalogID;
                        urlAlias          = StringUtils.SubStringAlias(urlAlias, item.DisplayUrl);
                        trueAlias         = string.Concat(trueAlias, item.DisplayUrl);
                        break;
                    }
                }
            }
            if (cateId == 0)
            {
                trueAlias = "san-pham";
            }

            #endregion

            if (!string.IsNullOrEmpty(searchInfo.TextSearch))
            {
                trueAlias = string.Format("{0}/k={1}", trueAlias, searchInfo.TextSearch);
            }

            if (searchInfo.PageIndex > 1)
            {
                trueAlias = string.Format("{0}/p{1}", trueAlias, searchInfo.PageIndex);
            }

            return(string.Concat("/", trueAlias));
        }
Exemplo n.º 17
0
        public SearchProduct GetSearchProductDetail(string apiKey, string SearchKey = null, string sortColumn = null, string sortColumnDir = "asc", int pageNo = 0, int pageSize = 100, int stateId = 0, int Districtid = 0, int cropID = 0, int categoryID = 0, int SubCatId = 0, int CompanyId = 0, int totalRecords = 0)
        {
            SearchProduct _catProList = new SearchProduct();

            if (apiKey == ConfigurationManager.AppSettings["reasonkey"])
            {
                try
                {
                    _catProList = _agentbal.GetSearchProducts(true, categoryID, SubCatId, CompanyId, 0, stateId, Districtid, 0, "0", cropID, SearchKey, pageNo, pageSize, sortColumn, sortColumnDir);
                }
                catch (Exception ex)
                {
                    LogBal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0);
                }
            }
            return(_catProList);
        }
        public async Task <ActionResult> Search(SearchProduct collection)
        {
            try
            {
                // TODO: Add insert logic here
                ProductBL wDB = new ProductBL();

                List <Product> wListProduct = ProductEntityToProductModel.ConvertoListProdyctEntityTOListProductModel(await wDB.GetListProducts(ProductEntityToProductModel.ConvertoProdyctEntityTOSearchProductModel(collection)));
                TempData["ListProducts"] = wListProduct;

                return(RedirectToAction("Index", "Home", collection));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemplo n.º 19
0
        List <ProductDetails> IProductDA.GetAllProductList(SearchProduct product)
        {
            List <ProductDetails> list = new List <ProductDetails>();

            try
            {
                DataSet ds = new DataSet();

                if (connString.State == ConnectionState.Closed)
                {
                    connString.Open();
                }
                cmd             = new SqlCommand("uspGetProductList", connString);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@FuzzySearch", product.FuzzySearch);
                cmd.Parameters.AddWithValue("@ProductId", product.ProductId);
                cmd.Parameters.AddWithValue("@CategoryId", product.CategoryId);
                cmd.Parameters.AddWithValue("@BrandId", product.BrandId);
                cmd.Parameters.AddWithValue("@FromPrice", product.FromPrice);
                cmd.Parameters.AddWithValue("@ToPrice", product.ToPrice);
                cmd.Parameters.AddWithValue("@StartIndex", product.StartIndex);
                cmd.Parameters.AddWithValue("@NumberOfRows", product.NumberOfRows);
                SqlDataAdapter sda = new SqlDataAdapter(cmd);
                sda.Fill(ds);
                sda.Dispose();

                list = ExtensionMethods.ConvertToListOf <ProductDetails>(ds.Tables[0]);
                if (list != null && list.Count > 0 && ds.Tables.Count > 1 && ds.Tables[1].Rows.Count > 0)
                {
                    list[0].ProductImage = new List <M_ProductImage>();
                    list[0].ProductImage = ExtensionMethods.ConvertToListOf <M_ProductImage>(ds.Tables[1]);
                }

                return(list);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                connString.Close();
            }
        }
Exemplo n.º 20
0
        public void Should_return_products()
        {
            //Arrange
            var user = GetUserSessionModel("*****@*****.**");

            SearchProduct search = new SearchProduct();

            search.ProductFamilyId = (int?)ProductFamilyEnum.VRV;

            //Act
            response = productService.GetProductList(user, search);


            //Assert
            ProductsModel productsModel = (ProductsModel)response.Model;

            Assert.That(response.IsOK, Is.EqualTo(true));
            Assert.That(productsModel.Products.Count(), Is.GreaterThan(0));
        }
Exemplo n.º 21
0
        public int GetListCount(SearchProduct search)
        {
            string storeName = "FE_Product_GetList_Count";

            try
            {
                using (var context = Context())
                {
                    return(context.StoredProcedure("FE_Product_GetList_Count")
                           .Parameter("CateId", search.CateId, DataTypes.Int32)
                           .Parameter("Keyword", search.TextSearch, DataTypes.String)
                           .QuerySingle <int>());
                }
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0} => {1}", storeName, ex));
            }
        }
Exemplo n.º 22
0
        public async Task <List <Product> > InsertSearch(string productName)
        {
            HttpClient     client     = new HttpClient();
            List <Product> products   = new List <Product>();
            SearchProduct  rootObject = null;



            int i = 1;

            do
            {
                string URL = "https://world.openfoodfacts.org/cgi/search.pl?search_terms=" + productName + "&search_simple=1&json=1&page=" + i;
                HttpResponseMessage response = await client.GetAsync(URL);

                if (response.IsSuccessStatusCode)
                {
                    rootObject = await response.Content.ReadAsAsync <SearchProduct>();

                    foreach (Product product in rootObject.Products)
                    {
                        if (product.Product_Name.ToUpper().Contains(productName.ToUpper()))
                        {
                            Product p = new Product
                            {
                                Name_Product    = product.Product_Name,
                                Image_front_url = product.Image_front_url,
                                NovaGroup       = product.NovaGroup
                            };
                            products.Add(p);
                        }
                    }
                    if (rootObject.Page_size + rootObject.Skip >= rootObject.Count)
                    {
                        break;
                    }
                    i++;
                }
            } while (rootObject.Page_size + rootObject.Skip < rootObject.Count);

            return(products);
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Log.Info("Before: Process to Create Report on ShowProduct");
            if (datalist.Items.Count != 0)
            {
                List <Sale>   lst = (List <Sale>)datalist.ItemsSource;
                SearchProduct rpt = new SearchProduct(fdate.Content.ToString()
                                                      , ldate.Content.ToString(),
                                                      lst,
                                                      stockqty.Content.ToString(),
                                                      cname.Content.ToString());

                rpt.ShowDialog();
                Log.Info("After: Process to Create Report on ShowProduct");
            }
            else
            {
                MessageBox.Show("No Records Found");
            }
        }
Exemplo n.º 24
0
        public async Task <IActionResult> SearchProduct([FromBody] SearchProduct product)
        {
            try
            {
                var _productResponse = await _searchProduct.Execute(
                    product.ProductId,
                    product.ProductName,
                    product.ProductSeller,
                    product.ProductDescription,
                    product.MinPrice,
                    product.MaxPrice
                    );

                return(Ok(_productResponse));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Exemplo n.º 25
0
        public List <ProductModel> GetListNoCache(SearchProduct search)
        {
            List <ProductModel>  lstModel   = new List <ProductModel>();
            List <ProductEntity> lstProduct = _productDal.GetList(search);

            if (lstProduct != null && lstProduct.Count > 0)
            {
                //lstModel = lstProduct.Select(x => new ProductModel(x)).ToList();
                CategoryEntity category = new CategoryEntity();
                foreach (ProductEntity item in lstProduct)
                {
                    category = _categoryBo.GetByCateId(item.CatalogID);
                    if (category != null && category.CatalogID > 0)
                    {
                        ProductModel productModel = new ProductModel(item, category);
                        lstModel.Add(productModel);
                    }
                }
            }
            return(lstModel);
        }
Exemplo n.º 26
0
        public void UpdateGrid(SearchProduct product)
        {
            if (product != null)
            {
                product.ActualPrice = product.Price;

                decimal discount = 0;
                if (product.Discount.HasValue)
                {
                    discount = product.Discount.Value;
                }

                if (product.Price.HasValue && product.Price.Value > 0)
                {
                    var rootPrice = product.Price.Value;
                    product.ActualPrice = rootPrice - (rootPrice * discount) / 100;
                }

                if (listProduct == null)
                {
                    listProduct = new List <SearchProduct>();
                }

                if (!HasFooter)
                {
                    listProduct.Add(product);
                    listProduct.Add(new SearchProduct());
                    HasFooter = true;
                }
                else
                {
                    listProduct.Insert(listProduct.Count - 1, product);
                }

                dataGridView.DataSource = null;
                dataGridView.DataSource = listProduct;
                dataGridView.Refresh();
            }
        }
Exemplo n.º 27
0
        // GET: Products
        public async Task <IActionResult> Index()
        {
            HttpClient     client     = new HttpClient();
            List <Product> products   = new List <Product>();
            SearchProduct  rootObject = null;
            int            i          = 1;

            do
            {
                string URL = "https://world.openfoodfacts.org/cgi/search.pl?search_terms=coke&search_simple=1&json=1&page=" + i;
                HttpResponseMessage response = await client.GetAsync(URL);

                if (response.IsSuccessStatusCode)
                {
                    rootObject = await response.Content.ReadAsAsync <SearchProduct>();

                    foreach (Product product in rootObject.Products)
                    {
                        if (product.Product_Name.ToUpper().Contains("COKE"))
                        {
                            Product p = new Product
                            {
                                Product_Name    = product.Product_Name,
                                Image_front_url = product.Image_front_url,
                            };
                            products.Add(p);
                        }
                    }
                    if (rootObject.Page_size + rootObject.Skip >= rootObject.Count)
                    {
                        break;
                    }
                    i++;
                }
            } while (rootObject.Page_size + rootObject.Skip < rootObject.Count);

            return(View(products));
            //return View(await _context.Product.ToListAsync());
        }
        public PagedResponse <ProductDto> Execute(SearchProduct search)
        {
            var query = _context.Products.Include(x => x.Brand).Include(x => x.Gender).Include(x => x.ShoeType).AsQueryable();

            if (!string.IsNullOrEmpty(search.Name) || !string.IsNullOrWhiteSpace(search.Name))
            {
                query = query.Where(x => x.Name.ToLower().Contains(search.Name.ToLower()));
            }
            if (search.BrandId != null)
            {
                query = query.Where(x => x.BrandId == search.BrandId);
            }
            if (search.GenderId != null)
            {
                query = query.Where(x => x.GenderId == search.GenderId);
            }
            if (search.ShoeTypeId != null)
            {
                query = query.Where(x => x.ShoeTypeId == search.ShoeTypeId);
            }
            if (search.MinPrice != null)
            {
                query = query.Where(x => x.Price >= search.MinPrice);
            }
            if (search.MaxPrice != null)
            {
                query = query.Where(x => x.Price <= search.MaxPrice);
            }
            var skipCount = search.PerPage * (search.Page - 1);
            var response  = new PagedResponse <ProductDto>
            {
                CurrentPage  = search.Page,
                ItemsPerPage = search.PerPage,
                TotalCount   = query.Count(),
                Items        = _mapper.Map <List <ProductDto> >(query.Skip(skipCount).Take(search.PerPage).ToList())
            };

            return(response);
        }
Exemplo n.º 29
0
        public MetaModel BuildMetaProduct(SearchProduct searchInfo)
        {
            MetaModel metaTag = new MetaModel()
            {
                TitlePage       = "Sản phẩm",
                MetaTitle       = Const.MetaProductTitle,
                MetaDescription = Const.MetaProductDescription,
                MetaKeyword     = Const.MetaProductKeyword
            };

            if (!string.IsNullOrEmpty(searchInfo.TextSearch))
            {
                metaTag.TitlePage       = string.Format("Tìm kiếm: \"{0}\"", searchInfo.TextSearch);
                metaTag.MetaTitle       = string.Format("Tìm kiếm: \"{0}\"", searchInfo.TextSearch);
                metaTag.MetaDescription = string.Format("Tìm kiếm: \"{0}\"", searchInfo.TextSearch);
            }
            else if (searchInfo.CateId > 0)
            {
                CategoryEntity cateInfo = _categoryBo.GetByCateId(searchInfo.CateId);
                if (cateInfo != null && cateInfo.CatalogID > 0)
                {
                    metaTag.TitlePage       = cateInfo.Name;
                    metaTag.MetaTitle       = cateInfo.Name;
                    metaTag.MetaDescription = cateInfo.Name;
                }
            }

            if (searchInfo.PageIndex > 1)
            {
                metaTag.TitlePage = string.Concat(metaTag.TitlePage, " - trang " + searchInfo.PageIndex);
                if (!string.IsNullOrEmpty(Const.PrefixTitle))
                {
                    metaTag.TitlePage = string.Concat(metaTag.TitlePage, " - ", Const.PrefixTitle);
                }
            }

            return(metaTag);
        }
Exemplo n.º 30
0
        public IEnumerable <ProductCatalog> Search(SearchProduct searchProduct)
        {
            return(_connectionFactory.GetConnection.Query <ProductCatalog>(@"
					SELECT DEA.[Name]		AS 'DealerName', 
						   COM.[DealerId], 
						   COM.[Name]		AS 'CompanyName', 
						   CAT.[CompanyId], 
						   CAT.[Name]		AS 'CategoryName', 
						   PRO.*
					  FROM Dealer			AS DEA
					 INNER JOIN Company		AS COM ON COM.[DealerId] = DEA.Id		AND COM.[Status] = 'Active' AND COM.[Enable] = 1
					 INNER JOIN Category	AS CAT ON CAT.[CompanyId] = COM.Id		AND CAT.[Status] = 'Active'
					 INNER JOIN Product		AS PRO ON PRO.[CategoryId] = CAT.Id		AND PRO.[Status] = 'Active' AND PRO.[Enable] = 1
					 WHERE DEA.[Status] = 'Active'
					   AND DEA.[Enable] = 1
					   AND (@dealerId = -1 OR DEA.Id = @dealerId)
					   AND (@companyId = -1 OR COM.Id = @companyId)
					   AND (@categoryId = -1 OR CAT.Id = @categoryId)
					 ORDER BY PRO.Name DESC 
					OFFSET ((@pageNumber - 1) * @rowsPage) ROWS
					 FETCH NEXT @rowsPage ROWS ONLY;"                    ,
                                                                           searchProduct));
        }
Exemplo n.º 31
0
        private void LoadProducts(Order order)
        {
            if (order.Details.Count == 0) return;

            listProduct = new List<SearchProduct>();
            listProductLD = new List<SearchProductLD>();

            foreach (var detail in order.Details)
            {
                if(detail.ProductId.HasValue)
                {
                    var searchProduct = new SearchProduct();
                    searchProduct.Price = detail.ProductPrice;
                    searchProduct.QuantityValue = detail.Quantity.ToString();
                    searchProduct.Total = detail.Total;
                    searchProduct.ActualPrice = detail.ProductActualPrice;
                    searchProduct.Discount = detail.Discount;
                    searchProduct.TotalValue = detail.Total.ToString(Constants.CurrencyFormat);
                    searchProduct.Id = detail.ProductId.Value;
                    searchProduct.Name = detail.Product.Name;
                    searchProduct.Code = detail.Product.Code;

                    listProduct.Add(searchProduct);
                }
                else if(detail.ProductLdId.HasValue)
                {
                    var searchProduct = new SearchProductLD();
                    searchProduct.Price = detail.ProductPrice;
                    searchProduct.QuantityValue = detail.Quantity.ToString();
                    searchProduct.Total = detail.Total;
                    searchProduct.ActualPrice = detail.ProductActualPrice;
                    searchProduct.Discount = detail.Discount;
                    searchProduct.TotalValue = detail.Total.ToString(Constants.CurrencyFormat);
                    searchProduct.Id = detail.ProductLdId.Value;
                    searchProduct.Name = detail.ProductLD.Name;
                    searchProduct.Code = detail.ProductLD.Code;

                    listProductLD.Add(searchProduct);
                }

            }
            if (listProduct.Count > 0)
            {
                listProduct.Add(new SearchProduct());
                HasFooter = true;

                dataGridView.DataSource = null;
                dataGridView.DataSource = listProduct;
                dataGridView.Refresh();
            }

            if (listProductLD.Count > 0)
            {
                listProductLD.Add(new SearchProductLD());
                HasFooterLD = true;

                dataGridViewLD.DataSource = null;
                dataGridViewLD.DataSource = listProductLD;
                dataGridViewLD.Refresh();
            }
        }
Exemplo n.º 32
0
        public void UpdateGrid(SearchProduct product)
        {
            if (product != null)
            {
                product.ActualPrice = product.Price;

                decimal discount = 0;
                if (product.Discount.HasValue)
                    discount = product.Discount.Value;

                if (product.Price.HasValue && product.Price.Value > 0)
                {
                    var rootPrice = product.Price.Value;
                    product.ActualPrice = rootPrice - (rootPrice * discount) / 100;
                }

                if (listProduct == null)
                {
                    listProduct = new List<SearchProduct>();
                }

                if (!HasFooter)
                {
                    listProduct.Add(product);
                    listProduct.Add(new SearchProduct());
                    HasFooter = true;
                }
                else
                {
                    listProduct.Insert(listProduct.Count - 1, product);
                }

                dataGridView.DataSource = null;
                dataGridView.DataSource = listProduct;
                dataGridView.Refresh();
            }
        }
Exemplo n.º 33
0
        private void SelectProduct(object sender, EventArgs e)
        {
            if (dataGridView.SelectedRows.Count > 0)
            {
                try
                {
                    int index = dataGridView.SelectedRows[0].Index;
                    SelectedProduct = dataGridView.SelectedRows[0].DataBoundItem as SearchProduct;

                    ListSelectedProduct.Add(SelectedProduct);

                    var orderForm = this.ParentForm as OrderForm;
                    if (orderForm != null)
                    {
                        orderForm.UpdateGrid(SelectedProduct);
                    }

                    var list = dataGridView.DataSource as List<SearchProduct>;
                    list.RemoveAt(index);

                    dataGridView.DataSource = null;
                    dataGridView.DataSource = list;
                    dataGridView.Refresh();
                }
                catch(Exception ex)
                {
                    logger.EnterMethod("Select Product");
                    logger.LogException(ex);
                }
            }
        }