Esempio n. 1
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            if (value == null)
            {
                writer.WriteValue("null");
            }

            if (value is DBNull)
            {
                writer.WriteValue("null");
            }

            CatalogEntryDto.VariationRow row = value as CatalogEntryDto.VariationRow;
            if (row == null)
            {
                writer.WriteValue("null");
            }
            else
            {
                writer.WriteStartObject();

                writer.WritePropertyName("ListPrice");
                if (row.IsListPriceNull() == false)
                {
                    writer.WriteValue(row.ListPrice);
                }
                else
                {
                    writer.WriteValue("null");
                }
                writer.WriteEndObject();
            }
        }
Esempio n. 2
0
        private void PopulateVariationInfo(CatalogEntryDto.CatalogEntryRow entryRow, LineItem lineItem)
        {
            CatalogEntryDto.VariationRow variationRow = entryRow.GetVariationRows().FirstOrDefault();

            if (variationRow != null)
            {
                lineItem.MaxQuantity = variationRow.MaxQuantity;
                lineItem.MinQuantity = variationRow.MinQuantity;
                CustomerContact customerContact = CustomerContext.Current.GetContactById(lineItem.Parent.Parent.CustomerId);

                Money?newListPrice = GetItemPrice(entryRow, lineItem, customerContact);
                if (newListPrice.HasValue)
                {
                    Money oldListPrice = new Money(Math.Round(lineItem.ListPrice, 2), lineItem.Parent.Parent.BillingCurrency);

                    if (oldListPrice != newListPrice.Value)
                    {
                        AddWarningSafe(Warnings,
                                       "LineItemPriceChange-" + lineItem.Parent.LineItems.IndexOf(lineItem).ToString(),
                                       string.Format("Price for \"{0}\" has been changed from {1} to {2}.", lineItem.DisplayName, oldListPrice.ToString(), newListPrice.ToString()));

                        // Set new price on line item.
                        lineItem.ListPrice = newListPrice.Value.Amount;
                        if (lineItem.Parent.Parent.ProviderId.ToLower().Equals("frontend"))
                        {
                            lineItem.PlacedPrice = newListPrice.Value.Amount;
                        }
                    }
                }
            }
        }
        private void PopulateVariationInfo(CatalogEntryDto.CatalogEntryRow entryRow, LineItem lineItem, List <LineItem> lineItemsToRemove)
        {
            CatalogEntryDto.VariationRow variationRow = entryRow.GetVariationRows().FirstOrDefault();

            if (variationRow != null)
            {
                lineItem.MaxQuantity = variationRow.MaxQuantity;
                lineItem.MinQuantity = variationRow.MinQuantity;
                CustomerContact customerContact = CustomerContext.Current.GetContactById(lineItem.Parent.Parent.CustomerId);

                Money?newListPrice = GetItemPrice(entryRow, lineItem, customerContact);
                if (newListPrice.HasValue)
                {
                    var   billingCurrency = new Currency(lineItem.Parent.Parent.BillingCurrency);
                    Money oldListPrice    = new Money(billingCurrency.Round(lineItem.ListPrice), billingCurrency);

                    if (oldListPrice != newListPrice.Value)
                    {
                        AddWarningSafe(Warnings,
                                       "LineItemPriceChange-" + lineItem.Parent.LineItems.IndexOf(lineItem).ToString(),
                                       string.Format("Price for \"{0}\" has been changed from {1} to {2}.", lineItem.DisplayName, oldListPrice.ToString(), newListPrice.ToString()));

                        // Set new price on line item.
                        lineItem.ListPrice = newListPrice.Value.Amount;
                        if (OrderGroup.ProviderId.ToLower().Equals("frontend") && OrderGroup is Orders.Cart)
                        {
                            lineItem.PlacedPrice = newListPrice.Value.Amount;
                        }
                    }
                }
                else
                {
                    AddWarningSafe(Warnings, "LineItemRemoved-" + lineItem.LineItemId.ToString(),
                                   String.Format("Item \"{0}\" has been removed from the cart. The line item doesn't have price associated.",
                                                 lineItem.DisplayName));
                    lineItemsToRemove.Add(lineItem);
                }
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
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();
                    }
                }
            }
        }
Esempio n. 6
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);
            }
        }
Esempio n. 7
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");
            }
        }