Exemplo n.º 1
0
 /// <summary>
 /// Конфигурирует списки ростов и размеров
 /// </summary>
 private void ConfigureSizes()
 {
     if (nomenclature.Type.HeightType != null)
     {
         WearGrowths = sizeService.GetSize(uoW, nomenclature.Type.HeightType, false, true).ToList();
         IsUseGrowth = true;
     }
     WearSizes = nomenclature?.Type?.SizeType != null?
                 sizeService.GetSize(uoW, nomenclature.Type.SizeType, false, true).ToList() : new List <Size>();
 }
Exemplo n.º 2
0
        public void AddProductSizes()
        {
            var myProducts = ProductService.GetProducts();

            var listProductsResponse = client.ListProducts();

            foreach (var myProduct in myProducts)
            {
                var listProduct = listProductsResponse.Products.Where(x => x.BrandId == myProduct.Type.BrandID &&
                                                                      x.ProductId == myProduct.Type.PrintAuraID).FirstOrDefault();

                if (listProduct != null)
                {
                    var listSizes = listProduct.Colors.Where(x => x.Key == myProduct.Color.PrintAuraID).FirstOrDefault();

                    foreach (int listSize in listSizes.Value)
                    {
                        Size size = SizeService.GetSize(listSize);

                        if (size != null && !myProduct.Sizes.Any(x => x.SizeID == size.SizeID))
                        {
                            SizeService.CreateProductSize(myProduct.ProductID, size.SizeID);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
 public SizeTypeViewModel(
     IEntityUoWBuilder uowBuilder,
     IUnitOfWorkFactory unitOfWorkFactory,
     INavigationManager navigation,
     SizeService sizeService,
     IValidator validator = null) : base(uowBuilder, unitOfWorkFactory, navigation, validator)
 {
     this.sizeService = sizeService;
     Validations.Clear();
     Validations.Add(new ValidationRequest(Entity,
                                           new ValidationContext(Entity, new Dictionary <object, object> {
         { nameof(IUnitOfWork), UoW }
     })));
     if (UoW.IsNew)
     {
         IsNew = true;
         Sizes = new GenericObservableList <Size>();
     }
     else
     {
         Sizes = new GenericObservableList <Size>(sizeService.GetSize(UoW, Entity).ToList());
         if (Entity.Id <= SizeService.MaxStandartSizeTypeId)
         {
             IsStandartType = true;
         }
     }
 }
        private ChangeState CompareSize(Size fieldValue, Size newValue, ChangeType rowChange, IUnitOfWork uow)
        {
            var changeType = fieldValue == newValue ? ChangeType.NotChanged : rowChange;

            if (changeType == ChangeType.NotChanged)
            {
                return(new ChangeState(changeType));
            }
            var sizes = sizeService.GetSize(uow, null, true, false);

            if (sizes.All(x => x != newValue))
            {
                changeType = ChangeType.ParseError;
            }

            return(new ChangeState(changeType, newValue.Name));
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_MasterPageAdminCatalog_Catalog));

            Category cat = null;

            if (!string.IsNullOrEmpty(Request["categoryid"]))
            {
                if (Request["categoryid"].ToLower().Equals("WithoutCategory".ToLower()))
                {
                    ShowMethod = EShowMethod.OnlyWithoutCategories;
                }
                else if (Request["categoryid"].ToLower().Equals("InCategories".ToLower()))
                {
                    ShowMethod = EShowMethod.OnlyInCategories;
                }
                else if (Request["categoryid"].ToLower().Equals("AllProducts".ToLower()))
                {
                    ShowMethod = EShowMethod.AllProducts;
                }
                else
                {
                    ShowMethod = EShowMethod.Normal;
                    int.TryParse(Request["categoryid"], out CategoryId);
                    cat = CategoryService.GetCategory(CategoryId);
                    adminCategoryView.CategoryID = CategoryId;
                }
            }
            else
            {
                CategoryId = 0;
                ShowMethod = EShowMethod.Normal;
            }

            if (cat == null)
            {
                CategoryId = 0;
                if (ShowMethod == EShowMethod.Normal)
                {
                    ShowMethod = EShowMethod.AllProducts;
                    ShowMethod = EShowMethod.Normal;
                }
            }
            else
            {
                CategoryId           = cat.CategoryId;
                lblCategoryName.Text = cat.Name;
                hlDeleteCategory.Attributes["data-confirm"] =
                    string.Format(Resource.Admin_MasterPageAdminCatalog_Confirmation, cat.Name);
            }

            hlEditCategory.NavigateUrl = "javascript:open_window(\'m_Category.aspx?CategoryID=" + CategoryId + "&mode=edit\', 750, 640)";

            if (!IsPostBack)
            {
                var node2 = new TreeNode {
                    Text = Resource.Admin_m_Category_Root, Value = "0", Selected = true
                };
                tree2.Nodes.Add(node2);

                LoadChildCategories2(tree2.Nodes[0]);

                _paging = new SqlPaging()
                {
                    ItemsPerPage = 10,
                };

                switch (ShowMethod)
                {
                case EShowMethod.AllProducts:
                    lblCategoryName.Text = Resource.Admin_Catalog_AllProducts;
                    _paging.TableName    =
                        "[Catalog].[Product] left JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and [Offer].[Main] = 1 LEFT JOIN [Catalog].[Photo] ON [Product].[ProductID] = [Photo].[ObjId]  and Type='Product' AND [Photo].[Main] = 1 LEFT JOIN [Catalog].[ProductCategories] ON [Catalog].[ProductCategories].[ProductID] = [Product].[ProductID]";
                    break;

                case EShowMethod.OnlyInCategories:
                    lblCategoryName.Text = Resource.Admin_Catalog_AllProductsInCategories;
                    _paging.TableName    =
                        "[Catalog].[Product] left JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and [Offer].[Main] = 1 LEFT JOIN [Catalog].[Photo] ON [Product].[ProductID] = [Photo].[ObjId] and Type='Product' AND [Photo].[Main] = 1 inner JOIN [Catalog].[ProductCategories] ON [Catalog].[ProductCategories].[ProductID] = [Product].[ProductID]";
                    break;

                case EShowMethod.OnlyWithoutCategories:
                    lblCategoryName.Text = Resource.Admin_Catalog_AllProductsWithoutCategories;
                    _paging.TableName    =
                        "[Catalog].[Product] inner join (select ProductId from Catalog.Product where ProductId not in(Select ProductId from Catalog.ProductCategories)) as tmp on tmp.ProductId=[Product].[ProductID] Left JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and [Offer].[Main] = 1 LEFT JOIN [Catalog].[Photo] ON [Product].[ProductID] = [Photo].[ObjId]  and Type='Product' AND [Photo].[Main] = 1";
                    break;

                case EShowMethod.Normal:
                    _paging.TableName =
                        "[Catalog].[Product] left JOIN [Catalog].[Offer] ON [Product].[ProductID] = [Offer].[ProductID] and [Offer].[Main] = 1 LEFT JOIN [Catalog].[Photo] ON [Product].[ProductID] = [Photo].[ObjId] and Type='Product' AND [Photo].[Main] = 1 INNER JOIN Catalog.ProductCategories on ProductCategories.ProductId = [Product].[ProductID]";
                    break;
                }

                _paging.AddFieldsRange(new List <Field>()
                {
                    new Field {
                        Name = "Product.ProductID as ID", IsDistinct = true
                    },

                    new Field {
                        Name = "[Settings].[ArtNoToString](Product.ProductID) as ArtNo", Sorting = ShowMethod != EShowMethod.Normal ? SortDirection.Ascending : (SortDirection?)null
                    },
                    new Field {
                        Name = "Product.ArtNo as ProductArtNo"
                    },
                    new Field {
                        Name = "PhotoName"
                    },
                    new Field {
                        Name = "(Select Count(ProductID) From Catalog.ProductCategories Where ProductID=Product.ProductID) as ProductCategoriesCount"
                    },
                    new Field {
                        Name = "BriefDescription"
                    },
                    new Field {
                        Name = "Name"
                    },
                    new Field {
                        Name = "Price"
                    },
                    new Field {
                        Name = "(Select sum (Amount) from catalog.Offer where Offer.ProductID=Product.productID) as Amount"
                    },
                    new Field {
                        Name = "(Select count (offerid) from catalog.Offer where Offer.ProductID=Product.productID) as OffersCount"
                    },
                    new Field {
                        Name = "Enabled"
                    },
                    new Field
                    {
                        Name    = ShowMethod == EShowMethod.Normal ? "ProductCategories.SortOrder" : "-1 as SortOrder",
                        Sorting = SortDirection.Ascending
                    },
                    new Field {
                        Name = "Offer.ColorID", NotInQuery = true
                    },
                    new Field {
                        Name = "Offer.SizeID", NotInQuery = true
                    }
                });

                if (ShowMethod == EShowMethod.Normal)
                {
                    _paging.AddField(new Field
                    {
                        Name       = "ProductCategories.CategoryID",
                        NotInQuery = true,
                        Filter     = new EqualFieldFilter
                        {
                            Value     = CategoryId.ToString(),
                            ParamName = "@CategoryID"
                        }
                    });

                    grid.ChangeHeaderImageUrl("arrowSortOrder", "images/arrowup.gif");
                }
                else
                {
                    grid.ChangeHeaderImageUrl("arrowArtNo", "images/arrowup.gif");
                }

                pageNumberer.CurrentPageIndex = 1;
                pnlProducts.Visible           = CategoryId != 0 || ShowMethod != EShowMethod.Normal;
                productsHeader.Visible        = ShowMethod == EShowMethod.Normal;
                adminCategoryView.Visible     = ShowMethod == EShowMethod.Normal;
                grid.Columns[9].Visible       = ShowMethod == EShowMethod.Normal;

                _paging.CurrentPageIndex = 1;
                ViewState["Paging"]      = _paging;


                if (Request["search"].IsNotEmpty())
                {
                    var product = ProductService.GetProduct(Request["search"], true);
                    if (product != null)
                    {
                        Response.Redirect("Product.aspx?productID=" + product.ID);
                        return;
                    }

                    if (ProductService.GetProductsCount("where name like '%' + @search + '%'",
                                                        new SqlParameter("@search", Request["search"])) >
                        ProductService.GetProductsCount("where artno like '%' + @search + '%'",
                                                        new SqlParameter("@search", Request["search"])))
                    {
                        txtName.Text = Request["search"];
                    }
                    else
                    {
                        txtArtNo.Text = Request["search"];
                    }
                    btnFilter_Click(null, null);
                }

                if (Request["colorId"].IsNotEmpty())
                {
                    var color = ColorService.GetColor(Request["colorId"].TryParseInt());
                    if (color != null)
                    {
                        lblCategoryName.Text += string.Format(" {0}: {1}", Resource.Admin_Catalog_Color, color.ColorName);
                        _paging.Fields["Offer.ColorID"].Filter = new EqualFieldFilter {
                            ParamName = "@colorId", Value = Request["colorId"]
                        };
                    }
                }

                if (Request["sizeid"].IsNotEmpty())
                {
                    var size = SizeService.GetSize(Request["sizeid"].TryParseInt());
                    if (size != null)
                    {
                        lblCategoryName.Text += string.Format(" {0}: {1}", Resource.Admin_Catalog_Size, size.SizeName);
                        _paging.Fields["Offer.SizeID"].Filter = new EqualFieldFilter {
                            ParamName = "@sizeId", Value = Request["sizeId"]
                        };
                    }
                }
            }
            else
            {
                _paging = (SqlPaging)(ViewState["Paging"]);
                _paging.ItemsPerPage = SQLDataHelper.GetInt(ddRowsPerPage.SelectedValue);

                if (_paging == null)
                {
                    throw (new Exception("Paging lost"));
                }

                string strIds = Request.Form["SelectedIds"];

                if (!string.IsNullOrEmpty(strIds))
                {
                    strIds = strIds.Trim();
                    var arrids = strIds.Split(' ');

                    var ids = new string[arrids.Length];
                    _selectionFilter = new InSetFieldFilter {
                        IncludeValues = true
                    };

                    for (int idx = 0; idx <= ids.Length - 1; idx++)
                    {
                        string t       = arrids[idx];
                        var    idParts = t.Split('_');
                        switch (idParts[0])
                        {
                        case "Product":
                            if (idParts[1] != "-1")
                            {
                                ids[idx] = idParts[1];
                            }
                            else
                            {
                                _selectionFilter.IncludeValues = false;
                                _inverseSelection = true;
                            }
                            break;

                        default:
                            _inverseSelection = true;
                            break;
                        }
                    }
                    _selectionFilter.Values = ids.Distinct().Where(item => item != null).ToArray();
                }
            }
        }