예제 #1
0
        protected override int CreateSystemRow(FillDataMode Mode, int RowIndex, params object[] Item)
        {
            int    i = 0;
            object objSysRowAction = Item[i++];
            object objCode         = Item[i++];
            //Variation
            object objListPrice      = Item[i++];
            object objTaxCategoryId  = Item[i++];
            object objTrackInventory = Item[i++];
            object objMerchantId     = Item[i++];
            object objWarehouseId    = Item[i++];
            object objWeight         = Item[i++];
            object objPackageId      = Item[i++];
            object objMinQuantity    = Item[i++];
            object objMaxQuantity    = Item[i++];
            //Inventory
            object objInStockQuantity           = Item[i++];
            object objReservedQuantity          = Item[i++];
            object objReorderMinQuantity        = Item[i++];
            object objPreorderQuantity          = Item[i++];
            object objBackorderQuantity         = Item[i++];
            object objAllowBackorder            = Item[i++];
            object objAllowPreorder             = Item[i++];
            object objInventoryStatus           = Item[i++];
            object objPreorderAvailabilityDate  = Item[i++];
            object objBackorderAvailabilityDate = Item[i++];

            CatalogEntryDto.VariationRow variationRow = null;
            CatalogEntryDto.InventoryRow inventoryRow = null;

            try
            {
                RowAction sysRowAction = RowAction.Default;

                if (objSysRowAction != null)
                {
                    sysRowAction = GetRowActionEnum((string)objSysRowAction);
                }

                string Code;
                if (objCode != null)
                {
                    Code = (string)objCode;
                }
                else
                {
                    throw new AbsentValue("Code");
                }

                bool            bVariationIsNew = false;
                bool            bInventoryIsNew = false;
                CatalogEntryDto catalogEntryDto = CatalogEntryManager.GetCatalogEntryDto(Code, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));
                if (catalogEntryDto.CatalogEntry.Count > 0)
                {
                    CatalogEntryDto.CatalogEntryRow entry = catalogEntryDto.CatalogEntry[0];
                    if (entry.ClassTypeId.Equals(EntryType.Variation, StringComparison.OrdinalIgnoreCase) ||
                        entry.ClassTypeId.Equals(EntryType.Package, StringComparison.OrdinalIgnoreCase))
                    {
                        if (catalogEntryDto.Variation.Count > 0)
                        {
                            if (sysRowAction == RowAction.Insert)
                            {
                                throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' already exists.", Code));
                            }

                            variationRow = catalogEntryDto.Variation[0];

                            if (sysRowAction == RowAction.Delete)
                            {
                                variationRow.Delete();
                            }
                        }
                        else
                        {
                            if (sysRowAction == RowAction.Update)
                            {
                                throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' does not exists.", Code));
                            }

                            if (sysRowAction == RowAction.Delete)
                            {
                                throw new MDPImportException(String.Format("The Variation with with Entry Code '{0}' does not exists.", Code));
                            }

                            variationRow = catalogEntryDto.Variation.NewVariationRow();
                            variationRow.CatalogEntryId = entry.CatalogEntryId;
                            variationRow.ListPrice      = 0;
                            variationRow.TaxCategoryId  = 0;
                            variationRow.TrackInventory = false;
                            variationRow.WarehouseId    = 0;
                            variationRow.Weight         = 1;
                            variationRow.PackageId      = 0;
                            variationRow.MinQuantity    = 1;
                            variationRow.MaxQuantity    = 100;
                            bVariationIsNew             = true;
                        }

                        if (catalogEntryDto.Inventory.Count > 0)
                        {
                            if (sysRowAction == RowAction.Insert)
                            {
                                throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' already exists.", Code));
                            }

                            inventoryRow = catalogEntryDto.Inventory[0];

                            if (sysRowAction == RowAction.Delete)
                            {
                                inventoryRow.Delete();
                            }
                        }
                        else
                        {
                            if (sysRowAction == RowAction.Update)
                            {
                                throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' does not exists.", Code));
                            }

                            if (sysRowAction == RowAction.Delete)
                            {
                                throw new MDPImportException(String.Format("The Inventory with with Entry Code '{0}' does not exists.", Code));
                            }

                            inventoryRow = catalogEntryDto.Inventory.NewInventoryRow();
                            inventoryRow.ApplicationId             = CatalogConfiguration.Instance.ApplicationId;
                            inventoryRow.SkuId                     = entry.Code;
                            inventoryRow.InStockQuantity           = 10;
                            inventoryRow.ReservedQuantity          = 2;
                            inventoryRow.ReorderMinQuantity        = 1;
                            inventoryRow.PreorderQuantity          = 10;
                            inventoryRow.BackorderQuantity         = 10;
                            inventoryRow.AllowBackorder            = false;
                            inventoryRow.AllowPreorder             = false;
                            inventoryRow.InventoryStatus           = 0;
                            inventoryRow.PreorderAvailabilityDate  = DateTime.UtcNow;
                            inventoryRow.BackorderAvailabilityDate = DateTime.UtcNow;
                            bInventoryIsNew = true;
                        }
                    }
                    else
                    {
                        throw new MDPImportException(String.Format("The Entry with code '{0}' has wrong type ('{1}') for Variation/Inventory import.", Code, entry.ClassTypeId));
                    }
                }
                else
                {
                    throw new MDPImportException(String.Format("The Entry with code '{0}' does not exists.", Code));
                }

                if (sysRowAction == RowAction.Delete)
                {
                    CatalogContext.Current.SaveCatalogEntry(catalogEntryDto);
                    return(0);
                }

                //Variation
                if (objListPrice != null)
                {
                    decimal ListPrice = (decimal)objListPrice;
                    variationRow.ListPrice = ListPrice;
                }

                if (objTaxCategoryId != null)
                {
                    variationRow.TaxCategoryId = GetTaxCategoryId((string)objTaxCategoryId);
                }

                if (objTrackInventory != null)
                {
                    variationRow.TrackInventory = (bool)objTrackInventory;
                }

                if (objMerchantId != null)
                {
                    Guid merchantId = GetMerchantId((string)objMerchantId);
                    if (merchantId != Guid.Empty)
                    {
                        variationRow.MerchantId = merchantId;
                    }
                }

                if (objWarehouseId != null)
                {
                    variationRow.WarehouseId = GetWarehouseId((string)objWarehouseId);
                }

                if (objWeight != null)
                {
                    variationRow.Weight = (double)objWeight;
                }

                if (objPackageId != null)
                {
                    variationRow.PackageId = GetPackageId((string)objPackageId);
                }

                if (objMinQuantity != null)
                {
                    variationRow.MinQuantity = (decimal)objMinQuantity;
                }

                if (objMaxQuantity != null)
                {
                    variationRow.MaxQuantity = (decimal)objMaxQuantity;
                }

                if (bVariationIsNew)
                {
                    catalogEntryDto.Variation.AddVariationRow(variationRow);
                }

                //Inventory
                if (objInStockQuantity != null)
                {
                    inventoryRow.InStockQuantity = (decimal)objInStockQuantity;
                }

                if (objReservedQuantity != null)
                {
                    inventoryRow.ReservedQuantity = (decimal)objReservedQuantity;
                }

                if (objReorderMinQuantity != null)
                {
                    inventoryRow.ReorderMinQuantity = (decimal)objReorderMinQuantity;
                }

                if (objPreorderQuantity != null)
                {
                    inventoryRow.PreorderQuantity = (decimal)objPreorderQuantity;
                }

                if (objBackorderQuantity != null)
                {
                    inventoryRow.BackorderQuantity = (decimal)objBackorderQuantity;
                }

                if (objAllowBackorder != null)
                {
                    inventoryRow.AllowBackorder = (bool)objAllowBackorder;
                }

                if (objAllowPreorder != null)
                {
                    inventoryRow.AllowPreorder = (bool)objAllowPreorder;
                }

                if (objInventoryStatus != null)
                {
                    inventoryRow.InventoryStatus = (int)objInventoryStatus;
                }

                if (objPreorderAvailabilityDate != null)
                {
                    inventoryRow.PreorderAvailabilityDate = ((DateTime)objPreorderAvailabilityDate).ToUniversalTime();
                }

                if (objBackorderAvailabilityDate != null)
                {
                    inventoryRow.BackorderAvailabilityDate = ((DateTime)objBackorderAvailabilityDate).ToUniversalTime();
                }

                if (bInventoryIsNew)
                {
                    catalogEntryDto.Inventory.AddInventoryRow(inventoryRow);
                }



                using (TransactionScope tx = new TransactionScope())
                {
                    // Save modifications
                    if (catalogEntryDto.HasChanges())
                    {
                        CatalogContext.Current.SaveCatalogEntry(catalogEntryDto);
                    }

                    tx.Complete();
                }
            }
            catch (Exception ex)
            {
                throw new MDPImportException(ex.Message, null, RowIndex, null, null, Item);
            }

            return(variationRow.CatalogEntryId);
        }
예제 #2
0
    /// <summary>
    /// Updates static field
    /// </summary>
    /// <param name="item">The data item.</param>
    /// <returns></returns>
    private void UpdateStaticField(CatalogEntryDto.CatalogEntryRow item)
    {
        CatalogEntryDto dto = new CatalogEntryDto();

        CatalogEntryDto.VariationRow[] variationRows = null;

        decimal decimalValue = 0;
        int     intValue     = 0;
        double  doubleValue  = 0;

        switch (FieldName)
        {
        case "Name":
            item.Name = tbItem.Text;
            dto.CatalogEntry.ImportRow(item);
            break;

        case "StartDate":
            item.StartDate = cdpItem.Value;
            dto.CatalogEntry.ImportRow(item);
            break;

        case "EndDate":
            item.EndDate = cdpItem.Value;
            dto.CatalogEntry.ImportRow(item);
            break;

        case "TemplateName":
            item.TemplateName = ddlItem.SelectedValue;
            dto.CatalogEntry.ImportRow(item);
            break;

        case "Code":
            if (item.InventoryRow != null)
            {
                CatalogEntryDto.InventoryRow inventoryRow = item.InventoryRow;
                inventoryRow.SkuId = tbItem.Text;
                dto.Inventory.ImportRow(inventoryRow);
            }
            item.Code = tbItem.Text;
            dto.CatalogEntry.ImportRow(item);
            break;

        case "SortOrder":
            intValue = -1;
            if (Int32.TryParse(tbItem.Text, out intValue))
            {
                CatalogRelationDto relationDto = CatalogContext.Current.GetCatalogRelationDto(item.CatalogId, CatalogNodeId, item.CatalogEntryId, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.NodeEntry));
                // Update relations
                foreach (CatalogRelationDto.NodeEntryRelationRow row in relationDto.NodeEntryRelation)
                {
                    row.SortOrder = intValue;
                }
                if (relationDto.HasChanges())
                {
                    CatalogContext.Current.SaveCatalogRelationDto(relationDto);
                }
            }
            break;

        case "IsActive":
            item.IsActive = becItem.IsSelected;
            dto.CatalogEntry.ImportRow(item);
            break;

        case "ListPrice":
            decimalValue = 0;
            if (Decimal.TryParse(tbItem.Text, out decimalValue))
            {
                variationRows = item.GetVariationRows();
                if (variationRows.Length > 0)
                {
                    variationRows[0].ListPrice = decimalValue;
                    dto.CatalogEntry.ImportRow(item);
                    dto.Variation.ImportRow(variationRows[0]);
                }
            }
            break;

        case "TrackInventory":
            variationRows = item.GetVariationRows();
            if (variationRows.Length > 0)
            {
                variationRows[0].TrackInventory = becItem.IsSelected;
                dto.CatalogEntry.ImportRow(item);
                dto.Variation.ImportRow(variationRows[0]);
            }
            break;

        case "MerchantId":
            if (!String.IsNullOrEmpty(ddlItem.SelectedValue))
            {
                variationRows = item.GetVariationRows();
                if (variationRows.Length > 0)
                {
                    variationRows[0].MerchantId = new Guid(ddlItem.SelectedValue);
                    dto.CatalogEntry.ImportRow(item);
                    dto.Variation.ImportRow(variationRows[0]);
                }
            }
            break;

        case "Weight":
            doubleValue = 0;
            if (Double.TryParse(tbItem.Text, out doubleValue))
            {
                variationRows = item.GetVariationRows();
                if (variationRows.Length > 0)
                {
                    variationRows[0].Weight = doubleValue;
                    dto.CatalogEntry.ImportRow(item);
                    dto.Variation.ImportRow(variationRows[0]);
                }
            }
            break;

        case "TaxCategoryId":
        case "WarehouseId":
        case "PackageId":
            if (!String.IsNullOrEmpty(ddlItem.SelectedValue))
            {
                intValue = 0;
                if (Int32.TryParse(ddlItem.SelectedValue, out intValue))
                {
                    variationRows = item.GetVariationRows();
                    if (variationRows.Length > 0)
                    {
                        variationRows[0][FieldName] = intValue;
                        dto.CatalogEntry.ImportRow(item);
                        dto.Variation.ImportRow(variationRows[0]);
                    }
                }
            }
            break;

        case "MinQuantity":
        case "MaxQuantity":
            decimalValue = 1;
            if (Decimal.TryParse(tbItem.Text, out decimalValue))
            {
                variationRows = item.GetVariationRows();
                if (variationRows.Length > 0)
                {
                    variationRows[0][FieldName] = decimalValue;
                    dto.CatalogEntry.ImportRow(item);
                    dto.Variation.ImportRow(variationRows[0]);
                }
            }
            break;

        case "InStockQuantity":
        case "ReservedQuantity":
        case "ReorderMinQuantity":
        case "PreorderQuantity":
        case "BackorderQuantity":
            decimalValue = 0;
            if (Decimal.TryParse(tbItem.Text, out decimalValue))
            {
                if (item.InventoryRow != null)
                {
                    item.InventoryRow[FieldName] = decimalValue;
                    dto.CatalogEntry.ImportRow(item);
                    dto.Inventory.ImportRow(item.InventoryRow);
                }
            }
            break;

        case "AllowBackorder":
        case "AllowPreorder":
            if (item.InventoryRow != null)
            {
                item.InventoryRow[FieldName] = becItem.IsSelected;
                dto.CatalogEntry.ImportRow(item);
                dto.Inventory.ImportRow(item.InventoryRow);
            }
            break;

        case "InventoryStatus":
            if (!String.IsNullOrEmpty(ddlItem.SelectedValue))
            {
                intValue = 0;
                if (Int32.TryParse(ddlItem.SelectedValue, out intValue))
                {
                    if (item.InventoryRow != null)
                    {
                        item.InventoryRow[FieldName] = intValue;
                        dto.CatalogEntry.ImportRow(item);
                        dto.Inventory.ImportRow(item.InventoryRow);
                    }
                }
            }
            break;

        case "PreorderAvailabilityDate":
        case "BackorderAvailabilityDate":
            if (item.InventoryRow != null)
            {
                item.InventoryRow[FieldName] = cdpItem.Value;
                dto.CatalogEntry.ImportRow(item);
                dto.Inventory.ImportRow(item.InventoryRow);
            }
            break;
        }

        if (dto.HasChanges())
        {
            CatalogContext.Current.SaveCatalogEntry(dto);
        }
    }
예제 #3
0
        /// <summary>
        /// Saves the changes.
        /// </summary>
        /// <param name="context">The context.</param>
        public void SaveChanges(IDictionary context)
        {
            CatalogEntryDto dto = (CatalogEntryDto)context[_CatalogEntryDtoString];

            ProcessSalePricesTableEvents(_CatalogEntryDto);

            CatalogEntryDto.VariationRow variationRow = null;
            CatalogEntryDto.InventoryRow inventoryRow = null;

            CatalogDto catalogDto = null;

            // get catalog current entry belongs to
            if (CatalogEntryId > 0)
            {
                catalogDto = CatalogContext.Current.GetCatalogDto(dto.CatalogEntry[0].CatalogId);
            }
            else
            {
                catalogDto = CatalogContext.Current.GetCatalogDto(ParentCatalogId);
            }

            if (dto.Variation == null || dto.Variation.Count == 0)
            {
                variationRow = dto.Variation.NewVariationRow();
            }
            else
            {
                variationRow = dto.Variation[0];
            }

            if (dto.Inventory == null || dto.Inventory.Count == 0)
            {
                inventoryRow = dto.Inventory.NewInventoryRow();
                inventoryRow.ApplicationId = CatalogConfiguration.Instance.ApplicationId;
            }
            else
            {
                inventoryRow = dto.Inventory[0];
            }

            // Update Variation
            variationRow.ListPrice      = Decimal.Parse(ListPrice.Text);
            variationRow.MinQuantity    = Decimal.Parse(MinQty.Text);
            variationRow.MaxQuantity    = Decimal.Parse(MaxQty.Text);
            variationRow.CatalogEntryId = dto.CatalogEntry[0].CatalogEntryId;
            variationRow.TaxCategoryId  = Int32.Parse(TaxList.SelectedValue);

            if (!String.IsNullOrEmpty(MerchantList.SelectedValue))
            {
                variationRow.MerchantId = new Guid(MerchantList.SelectedValue);
            }

            variationRow.Weight = Double.Parse(Weight.Text);

            if (!String.IsNullOrEmpty(PackageList.SelectedValue))
            {
                variationRow.PackageId = Int32.Parse(PackageList.SelectedValue);
            }

            if (!String.IsNullOrEmpty(WarehouseList.SelectedValue))
            {
                variationRow.WarehouseId = Int32.Parse(WarehouseList.SelectedValue);
            }

            variationRow.TrackInventory = TrackInventory.IsSelected;

            // Update Inventory
            inventoryRow.InventoryStatus           = Int32.Parse(InventoryStatusList.SelectedValue);
            inventoryRow.InStockQuantity           = Decimal.Parse(InStockQty.Text);
            inventoryRow.ReservedQuantity          = Decimal.Parse(ReservedQty.Text);
            inventoryRow.ReorderMinQuantity        = Decimal.Parse(ReorderMinQty.Text);
            inventoryRow.AllowPreorder             = AllowPreorder.IsSelected;
            inventoryRow.PreorderQuantity          = Decimal.Parse(PreorderQty.Text);
            inventoryRow.PreorderAvailabilityDate  = PreorderAvail.Value != DateTime.MinValue ? PreorderAvail.Value.ToUniversalTime() : DateTime.UtcNow;
            inventoryRow.AllowBackorder            = AllowBackorder.IsSelected;
            inventoryRow.BackorderQuantity         = Decimal.Parse(BackorderQty.Text);
            inventoryRow.BackorderAvailabilityDate = BackorderAvail.Value != DateTime.MinValue ? BackorderAvail.Value.ToUniversalTime() : DateTime.UtcNow;
            inventoryRow.SkuId = dto.CatalogEntry[0].Code;

            // Update SalePrice
            dto.SalePrice.Merge(_CatalogEntryDto.SalePrice, false);
            foreach (CatalogEntryDto.SalePriceRow row in dto.SalePrice.Rows)
            {
                if (row.RowState == DataRowState.Deleted)
                {
                    continue;
                }
                if (row.RowState == DataRowState.Added || String.Compare(dto.CatalogEntry[0].Code, row.ItemCode, true) != 0)
                {
                    row.ItemCode = dto.CatalogEntry[0].Code;
                    if (String.IsNullOrEmpty(row.Currency))
                    {
                        row.Currency = catalogDto.Catalog[0].DefaultCurrency;
                    }
                }
            }

            // Make sure to attach new rows
            if (variationRow.RowState == DataRowState.Detached)
            {
                dto.Variation.Rows.Add(variationRow);
            }

            if (inventoryRow.RowState == DataRowState.Detached)
            {
                dto.Inventory.Rows.Add(inventoryRow);
            }
        }
예제 #4
0
        /// <summary>
        /// Validates the items.
        /// </summary>
        private void ValidateItems()
        {
            CatalogRelationDto relationDto = null;
            CatalogDto         catalogDto  = null;
            int oldCatalogId = 0;

            foreach (OrderForm form in OrderGroup.OrderForms)
            {
                foreach (LineItem lineItem in form.LineItems)
                {
                    if (lineItem.CatalogEntryId != "0" && !String.IsNullOrEmpty(lineItem.CatalogEntryId) && !lineItem.CatalogEntryId.StartsWith("@")) // ignore custom entries
                    {
                        CatalogEntryDto entryDto = CatalogContext.Current.GetCatalogEntryDto(lineItem.CatalogEntryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryFull));

                        if (entryDto.CatalogEntry.Count > 0)
                        {
                            CatalogEntryDto.CatalogEntryRow entryRow = entryDto.CatalogEntry[0];
                            if (entryRow.IsActive && entryRow.StartDate < FrameworkContext.Current.CurrentDateTime && entryRow.EndDate > FrameworkContext.Current.CurrentDateTime)
                            {
                                if (oldCatalogId != entryRow.CatalogId)
                                {
                                    // load these Dtos only if we haven't loaded them before
                                    catalogDto   = CatalogContext.Current.GetCatalogDto(entryRow.CatalogId);
                                    relationDto  = CatalogContext.Current.GetCatalogRelationDto(entryRow.CatalogId, 0, 0, String.Empty, new CatalogRelationResponseGroup(CatalogRelationResponseGroup.ResponseGroup.CatalogEntry));
                                    oldCatalogId = entryRow.CatalogId;
                                }

                                // check if catalog is visible
                                if (catalogDto.Catalog.Count > 0 && catalogDto.Catalog[0].IsActive && catalogDto.Catalog[0].StartDate <FrameworkContext.Current.CurrentDateTime && catalogDto.Catalog[0].EndDate> FrameworkContext.Current.CurrentDateTime)
                                {
                                    // populate item
                                    lineItem.Catalog = catalogDto.Catalog[0].Name;

                                    // get parent entry
                                    if (relationDto.CatalogEntryRelation.Count > 0)
                                    {
                                        CatalogRelationDto.CatalogEntryRelationRow[] entryRelationRows = (CatalogRelationDto.CatalogEntryRelationRow[])relationDto.CatalogEntryRelation.Select(String.Format("ChildEntryId={0}", entryRow.CatalogEntryId));
                                        if (entryRelationRows.Length > 0)
                                        {
                                            CatalogEntryDto parentEntryDto = CatalogContext.Current.GetCatalogEntryDto(entryRelationRows[0].ParentEntryId, new CatalogEntryResponseGroup(CatalogEntryResponseGroup.ResponseGroup.CatalogEntryInfo));
                                            if (parentEntryDto.CatalogEntry.Count > 0)
                                            {
                                                lineItem.ParentCatalogEntryId = parentEntryDto.CatalogEntry[0].Code;
                                            }
                                        }
                                    }

                                    // Inventory info
                                    CatalogEntryDto.InventoryRow invRow = entryRow.InventoryRow;
                                    if (invRow != null)
                                    {
                                        lineItem.AllowBackordersAndPreorders = invRow.AllowBackorder | invRow.AllowPreorder;
                                        lineItem.BackorderQuantity           = invRow.BackorderQuantity;
                                        lineItem.InStockQuantity             = invRow.InStockQuantity;
                                        lineItem.InventoryStatus             = invRow.InventoryStatus;
                                        lineItem.PreorderQuantity            = invRow.PreorderQuantity;
                                    }

                                    CatalogEntryDto.VariationRow[] varRows = entryRow.GetVariationRows();

                                    if (varRows.Length > 0)
                                    {
                                        CatalogEntryDto.VariationRow varRow = varRows[0];

                                        lineItem.MaxQuantity = varRow.MaxQuantity;
                                        lineItem.MinQuantity = varRow.MinQuantity;

                                        Account account  = ProfileContext.Current.GetAccount(lineItem.Parent.Parent.CustomerId);
                                        decimal?newPrice = GetItemPrice(entryRow, lineItem, account);

                                        if (newPrice == null)
                                        {
                                            newPrice = varRow.ListPrice;
                                        }

                                        // Check the price changes if any
                                        if (lineItem.ListPrice != (decimal)newPrice)
                                        {
                                            Warnings.Add("LineItemPriceChange-" + form.LineItems.IndexOf(lineItem).ToString(), String.Format("Price for \"{0}\" has been changed from {1:c} to {2:c}.", lineItem.DisplayName, lineItem.ListPrice, newPrice));
                                            lineItem.ListPrice = (decimal)newPrice;
                                            //lineItem.PlacedPrice = lineItem.ListPrice;
                                        }
                                    }

                                    continue;
                                }
                                else
                                {
                                    // Go to remove
                                }
                            }
                        }

                        // Remove item if it reached this stage
                        Warnings.Add("LineItemRemoved-" + lineItem.Id.ToString(), String.Format("Item \"{0}\" has been removed from the cart because it is no longer available.", lineItem.DisplayName));

                        // Delete item
                        lineItem.Delete();
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Binds the form.
        /// </summary>
        private void BindForm()
        {
            BindLists();
            if (CatalogEntryId > 0)
            {
                CatalogDto catalogDto = CatalogContext.Current.GetCatalogDto(_CatalogEntryDto.CatalogEntry[0].CatalogId);
                if (_CatalogEntryDto.CatalogEntry.Count > 0)
                {
                    if (_CatalogEntryDto.Variation.Count != 0)
                    {
                        CatalogEntryDto.VariationRow variationRow = _CatalogEntryDto.Variation[0];

                        ListPrice.Text            = variationRow.ListPrice.ToString("#0.00");              //"N2");
                        DisplayPriceCurrency.Text = catalogDto.Catalog[0].DefaultCurrency;
                        MinQty.Text = variationRow.MinQuantity.ToString();
                        MaxQty.Text = variationRow.MaxQuantity.ToString();
                        Weight.Text = variationRow.Weight.ToString();

                        if (!variationRow.IsMerchantIdNull())
                        {
                            ManagementHelper.SelectListItem(MerchantList, variationRow.MerchantId);
                        }

                        ManagementHelper.SelectListItem(PackageList, variationRow.PackageId);
                        ManagementHelper.SelectListItem(WarehouseList, variationRow.WarehouseId);
                        ManagementHelper.SelectListItem(TaxList, variationRow.TaxCategoryId);

                        TrackInventory.IsSelected = variationRow.TrackInventory;
                    }

                    if (_CatalogEntryDto.Inventory.Count != 0)
                    {
                        CatalogEntryDto.InventoryRow inventoryRow = _CatalogEntryDto.Inventory[0];

                        ManagementHelper.SelectListItem(InventoryStatusList, inventoryRow.InventoryStatus);
                        InStockQty.Text           = inventoryRow.InStockQuantity.ToString();
                        ReservedQty.Text          = inventoryRow.ReservedQuantity.ToString();
                        ReorderMinQty.Text        = inventoryRow.ReorderMinQuantity.ToString();
                        AllowPreorder.IsSelected  = inventoryRow.AllowPreorder;
                        PreorderQty.Text          = inventoryRow.PreorderQuantity.ToString();
                        PreorderAvail.Value       = ManagementHelper.GetUserDateTime(inventoryRow.PreorderAvailabilityDate);
                        AllowBackorder.IsSelected = inventoryRow.AllowBackorder;
                        BackorderQty.Text         = inventoryRow.BackorderQuantity.ToString();
                        BackorderAvail.Value      = ManagementHelper.GetUserDateTime(inventoryRow.BackorderAvailabilityDate);
                    }

                    // Bind SalePrices
                    GridHelper.BindGrid(SalePricesGrid, "Catalog", "EntrySalePrice");
                    BindSalePricesGrid();
                }
            }
            else // set defaults
            {
                InStockQty.Text           = "10";
                ReservedQty.Text          = "2";
                ReorderMinQty.Text        = "1";
                AllowPreorder.IsSelected  = false;
                PreorderQty.Text          = "10";
                PreorderAvail.Value       = ManagementHelper.GetUserDateTime(DateTime.Now.ToUniversalTime());
                AllowBackorder.IsSelected = false;
                BackorderQty.Text         = "10";
                BackorderAvail.Value      = ManagementHelper.GetUserDateTime(DateTime.Now.ToUniversalTime());
                MinQty.Text = "1";
                MaxQty.Text = "100";
                Weight.Text = Decimal.Parse("1.0", System.Globalization.CultureInfo.InvariantCulture).ToString();

                GridHelper.BindGrid(SalePricesGrid, "Catalog", "EntrySalePrice");
            }
        }