예제 #1
0
        protected override void OnInit(EventArgs e)
        {
            int productId = Request.QueryStringNativeInt("productId");
            int groupId   = Request.QueryStringNativeInt("groupId");
            int kitItemId = Request.QueryStringNativeInt("itemId");

            KitProductData kitProduct = KitProductData.Find(productId, Customer.Current);

            KitData = kitProduct;

            if (kitProduct != null)
            {
                KitGroupData kitGroup = kitProduct.GetGroup(groupId);
                if (kitGroup != null)
                {
                    KitItemData item = kitGroup.GetItem(kitItemId);
                    if (item != null)
                    {
                        KitItem = item;
                        kitProduct.TempFileStub = Request.QueryStringCanBeDangerousContent("stub");
                    }
                }
            }

            base.OnInit(e);
        }
예제 #2
0
        private void DeleteKitItem(DataListCommandEventArgs e)
        {
            var          hdfGroupId = e.Item.FindControl <HiddenField>("hdfGroupId");
            int          groupId    = hdfGroupId.Value.ToNativeInt();
            KitGroupData kitGroup   = this.Kit.GetGroup(groupId);

            int         id          = e.CommandArgument.ToString().ToNativeInt();
            KitItemData toBeDeleted = kitGroup.GetItem(id);

            if (toBeDeleted != null)
            {
                kitGroup.DeleteItem(toBeDeleted);
            }
        }
        private void UpdateKitItems(bool updateAll)
        {
            foreach (RepeaterItem rptItemKit in dlMappedKits.Items)
            {
                if (rptItemKit.ItemType == ListItemType.Item ||
                    rptItemKit.ItemType == ListItemType.AlternatingItem)
                {
                    HiddenField hdfKitProductId = rptItemKit.FindControl <HiddenField>("hdfKitProductId");
                    int         kitId           = hdfKitProductId.Value.ToNativeInt();

                    KitProductData kit = MappedKitProducts.Find(k => k.Id == kitId);
                    if (kit != null)
                    {
                        Repeater rptKitGroups = rptItemKit.FindControl <Repeater>("rptKitGroups");
                        foreach (RepeaterItem rptItemGroup in rptKitGroups.Items)
                        {
                            if (rptItemGroup.ItemType == ListItemType.Item ||
                                rptItemGroup.ItemType == ListItemType.AlternatingItem)
                            {
                                HiddenField hdfGroupId = rptItemGroup.FindControl <HiddenField>("hdfGroupId");
                                int         groupId    = hdfGroupId.Value.ToNativeInt();

                                KitGroupData group = kit.GetGroup(groupId);
                                if (group != null)
                                {
                                    Repeater rptKitItems = rptItemGroup.FindControl <Repeater>("rptKitItems");
                                    foreach (RepeaterItem rptKitItem in rptKitItems.Items)
                                    {
                                        if (rptKitItem.ItemType == ListItemType.Item ||
                                            rptKitItem.ItemType == ListItemType.AlternatingItem)
                                        {
                                            HiddenField hdfKitItemtId = rptKitItem.FindControl <HiddenField>("hdfKitItemtId");
                                            int         kitItemId     = hdfKitItemtId.Value.ToNativeInt();

                                            CheckBox chkUpdate = rptKitItem.FindControl <CheckBox>("chkUpdate");
                                            if (chkUpdate.Checked)
                                            {
                                                KitItemData kitItem = group.GetItem(kitItemId);
                                                if (kitItem != null)
                                                {
                                                    kitItem.Name        = XmlCommon.GetLocaleEntry(Variant.Name, LocaleSetting, false);
                                                    kitItem.Description = XmlCommon.GetLocaleEntry(Variant.Description, LocaleSetting, false);

                                                    if (updateAll)
                                                    {
                                                        kitItem.PriceDelta  = Variant.SalePrice > decimal.Zero ? Variant.SalePrice : Variant.Price;
                                                        kitItem.WeightDelta = Variant.Weight;
                                                    }
                                                    kitItem.Save(LocaleSetting);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            BindData();
        }