private void ItemDataRefreshForWorker(object sender, DoWorkEventArgs e)
        {
            var loader = new GenericDataController();

            DataSkus        = loader.SmartSkuCollLoad();
            DataSkusMixDown = DataSkus.MakeMixdown();
        }
示例#2
0
 public SupplierData(string code, SkuCollection FullCollection)
 {
     SupplierCode  = code;
     ListOfSkus    = FullCollection.SearchBySuppName(code);
     Lines         = ListOfSkus.Count;
     LowPercentage = LowStock / Lines;
 }
示例#3
0
 public SkuCollection FetchAll()
 {
     SkuCollection coll = new SkuCollection();
     Query qry = new Query(Sku.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
示例#4
0
        /// <summary>
        /// Loads the sku collection.
        /// </summary>
        /// <param name="productId">The product id.</param>
        /// <returns></returns>
        private SkuCollection LoadSkuCollection(int productId)
        {
            SkuCollection skuCollection = new SkuCollection().Where(Sku.Columns.ProductId, Comparison.Equals, productId).Load();

            dgSkuInventory.DataSource            = skuCollection;
            dgSkuInventory.Columns[0].HeaderText = LocalizationUtility.GetText("hdrSku");
            dgSkuInventory.Columns[1].HeaderText = LocalizationUtility.GetText("hdrInventory");
            dgSkuInventory.DataBind();
            return(skuCollection);
        }
        private void LoadGraphButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                this.globalSelectedSku = null;
                if (SkuBox.Text.Length == 7 || SkuBox.Text.Length == 13)
                {
                    var SkuText = SkuBox.Text.Substring(0, 7) + "0001";
                    this.globalSelectedSku = skus.SearchSKUSReturningSingleSku(SkuText);
                }
                else
                {
                    var SearchColl   = new SkuCollection(true);
                    var SuppCodeTest = SkuBox.Text;
                    SearchColl = mixdownCollection.SearchSKUS(SuppCodeTest, true);
                    if (SearchColl.Count == 1)
                    {
                        this.globalSelectedSku = SearchColl[0];
                    }
                    else
                    {
                        var Dialog = new SearchOptionsDialog(SearchColl);
                        Dialog.ShowDialog();
                    }
                }
                if (this.globalSelectedSku == null)
                {
                    throw new Exception("Unrecognised String");
                }
                ItemTitle.Text = this.globalSelectedSku.Title.Invoice;
                if (UseAreaCheck.IsChecked == true)
                {
                    this.useAreaForChart = true;
                }
                else
                {
                    this.useAreaForChart = false;
                }

                if (IgnoreStockMinimumCheck.IsChecked == true)
                {
                    this.ignoreStockMinimums = true;
                }
                else
                {
                    this.ignoreStockMinimums = false;
                }
                Misc.OperationDialog("Loading Chart", LoadChartWorker);
                PlotPlot.Model = this.plotGlobal;
            }
            catch (Exception)
            {
            }
        }
示例#6
0
        public Packsizes(SkuCollection children, DataItem sku)
        {
            InitializeComponent();
            PacksizesList = sku.Packsizes;
            PacksizesDataGrid.DataContext = new DataItemDetails();

            foreach (var child in children)
            {
                var item = DataItemDetails.NewDataItemDetails(child);
                // PacksizesList.Add(item);
            }
            this.PacksizesDataGrid.ItemsSource = PacksizesList;
        }
示例#7
0
 public SearchOptionsDialog(SkuCollection SearchColl)
 {
     InitializeComponent();
     SearchCollection = SearchColl;
     foreach (WhlSKU sku in SearchCollection)
     {
         if (sku.SKU.Contains("xxxx"))
         {
             continue;
         }
         SkuBox.Items.Add(sku.Title.Label);
     }
 }
        public ItemChart(MainWindow mainWindowRef, WhlSKU selectedSku = null)
        {
            skus = mainWindowRef.DataSkus;
            mixdownCollection = mainWindowRef.DataSkusMixDown;
            if (selectedSku != null)
            {
                this.globalSelectedSku = selectedSku;
            }

            SetMainWindowRef(mainWindowRef);
            InitializeComponent();
            LoadChartData(selectedSku);
        }
示例#9
0
        public static void CartRetrieved(string cartId)
        {
            var id = 0;

            if (int.TryParse(cartId, out id))
            {
                var shoppingCart = ShoppingCartProvider.GetShoppingCart(StaticDistributorID, StaticLocale, id);
                if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                {
                    var SKUsToRemove = new List <string>(new[]
                    {
                        HLConfigManager.Configurations.APFConfiguration.DistributorSku,
                        HLConfigManager.Configurations.APFConfiguration.SupervisorSku,
                        HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku,
                        HLConfigManager.Configurations.DOConfiguration.TodayMagazineSecondarySku,
                        HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku
                    });
                    SKUsToRemove.AddRange(HLConfigManager.Configurations.DOConfiguration.HFFSkuList);

                    foreach (var cartitem in shoppingCart.CartItems)
                    {
                        SKU_V01 sku;
                        if (SkuCollection != null && SkuCollection.TryGetValue(cartitem.SKU, out sku))
                        {
                            if (!sku.IsPurchasable)
                            {
                                SKUsToRemove.Add(sku.SKU);
                            }
                        }
                    }


                    SKUsToRemove.RemoveAll(x => x.ToString().Equals(string.Empty));
                    shoppingCart.DeleteItemsFromCart(SKUsToRemove.ToList());
                    if (shoppingCart.IsSavedCart)
                    {
                        HLRulesManager.Manager.ProcessSavedCartManagementRules(shoppingCart, ShoppingCartRuleReason.CartRetrieved);
                    }
                }
                if (shoppingCart.IsSavedCart || shoppingCart.IsFromCopy)
                {
                    HLRulesManager.Manager.ProcessSavedCartManagementRules(shoppingCart, ShoppingCartRuleReason.CartRetrieved);
                }
            }
        }
示例#10
0
 /// <summary>
 /// Handles the Load event of the Page control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         productId = Utility.GetIntParameter("productId");
         view      = Utility.GetParameter("view");
         if (view.Equals("s"))
         {
             SetSkuProperties();
             product = new Product(productId);
             associatedAttributeCollection = new ProductController().FetchAssociatedAttributesByProductId(productId);
             if (!Page.IsPostBack)
             {
                 chkAllowNegativeInventories.Checked = product.AllowNegativeInventories;
                 SkuCollection skuCollection = LoadSkuCollection(productId);
                 if (skuCollection.Count > 0)
                 {
                     pnlSkuList.Visible = false;
                 }
                 else
                 {
                     pnlSkuInventory.Visible = false;
                     string tempSku = product.BaseSku;
                     if (associatedAttributeCollection.Count > 0)
                     {
                         CreateSkus(associatedAttributeCollection[0], 0, tempSku);
                         lblTotalSkuCount.Text = skus.Count.ToString();
                     }
                     else
                     {
                         skus.Add(tempSku);
                         lblTotalSkuCount.Text = skus.Count.ToString();
                     }
                     skus.TrimExcess();
                     dlSkus.DataSource = skus;
                     dlSkus.DataBind();
                 }
             }
         }
     }
     catch (Exception ex) {
         Logger.Error(typeof(sku).Name + ".Page_Load", ex);
         base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
示例#11
0
 /// <summary>
 /// Loads the product.
 /// </summary>
 private void LoadProduct()
 {
     _product = Store.Caching.ProductCache.GetProductByProductID(productId);
     productAttributes.Product = _product;
     lblProductName.Text       = _product.Name;
     lblOurPriceAmount.Text    = StoreUtility.GetFormattedAmount(_product.DisplayPrice, true);
     if (Master.SiteSettings.AddTaxToPrice && TaxService.GetDefaultTaxProvider().IsProductLevelTaxProvider)
     {
         lblTaxApplied.Visible = true;
     }
     ajaxRating.CurrentRating = _product.Rating;
     ajaxRating.Visible       = SiteSettings.DisplayRatings;
     lblShortDescription.Text = HttpUtility.HtmlDecode(_product.ShortDescription);
     if (_product.RetailPrice != 0 && Master.SiteSettings.DisplayRetailPrice)
     {
         lblRetailPriceAmount.Text = StoreUtility.GetFormattedAmount(_product.RetailPrice, true);
         pnlRetailPrice.Visible    = true;
         pnlYouSave.Visible        = true;
         lblYouSaveAmount.Text     = string.Format("{0}&nbsp;({1})", StoreUtility.GetFormattedAmount(_product.YouSaveAmount, true), _product.YouSavePercentage.ToString("p"));
     }
     if (!IsPostBack)
     {
         SkuCollection productSkus = _product.SkuRecords(); //TODO: Cache this?
         if (productSkus.Count > 0)
         {
             if (productSkus.Count == 1)//there is only 1 Sku, so load the inventory
             {
                 productAttributes.GetInventory(productSkus[0].SkuX);
             }
             else
             {
                 ddlQuantity.Enabled  = false;
                 btnAddToCart.Enabled = false;
             }
         }
     }
     if (_product.AllowNegativeInventories)
     {
         ddlQuantity.Visible = false;
         txtQuantity.Visible = true;
         rfvQuantity.Visible = true;
     }
 }
        public SupplierData(MainWindow Main, Supplier SupplierCode)
        {
            InitializeComponent();
            SetMainWindowRef(Main);
            Title                     = SupplierCode.Name;
            _currentSupplier          = SupplierCode;
            SupplierSkuCollectionFull = Main.DataSkus;
            _supplierSkuCollection    = Main.DataSkusMixDown;
            LoadSupplierData();
            UpdateBooleans();
            SupplierNameBlock.Text = SupplierCode.Name;
            Stopwatch asd = new Stopwatch();

            asd.Start();
            Misc.OperationDialog("Preparing " + SupplierCode.Name, PrepareDataGrid);
            asd.Stop();
            Console.WriteLine(asd.ElapsedMilliseconds.ToString());
            RenderDataGrid();
        }
示例#13
0
        public ReorderSupplier(Supplier CurrentSupplier, SkuCollection FullSkuCollection)
        {
            LastOrderGuid = Guid.Empty;
            var Query = SQLServer.MSSelectDataDictionary("SELECT TOP 1 * from whldata.reorder_supplierdata WHERE SupplierCode='" + CurrentSupplier.Code + "';");

            foreach (Dictionary <string, object> result in Query)
            {
                Code     = result["SupplierCode"].ToString();
                FullName = result["SupplierFullName"].ToString();
                Children = FullSkuCollection.SearchBySuppName(Code);
                try
                {
                    MinimumOrder = Convert.ToDouble(result["MinimumOrder"]);
                }
                catch (NullReferenceException)
                {
                    MinimumOrder = 0;
                }
                int CheckForDiscount = Convert.ToInt32(result["CartonDiscount"]);
                if (CheckForDiscount == 1)
                {
                    CartonDiscount = true;
                }
                else
                {
                    CartonDiscount = false;
                }
                ReorderAtPercentage = Convert.ToDouble(result["ReorderPercentage"]);
                if (result["LastOrder"] != DBNull.Value)
                {
                    LastOrder = DateTime.Parse(result["LastOrder"].ToString());
                }
                if (result["LastOrderGuid"] != DBNull.Value)
                {
                    LastOrderGuid = new Guid(result["LastOrderGuid"].ToString());
                }
            }
        }
示例#14
0
 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try {
         SkuCollection skuCollection = new SkuCollection();
         Sku           sku;
         if (associatedAttributeCollection != null && associatedAttributeCollection.Count > 0)
         {
             CreateSkus(associatedAttributeCollection[0], 0, product.BaseSku);
         }
         else
         {
             skus.Add(product.BaseSku);
         }
         for (int i = 0; i < skus.Count; i++)
         {
             sku           = new Sku();
             sku.ProductId = productId;
             sku.SkuX      = skus[i];
             skuCollection.Add(sku);
         }
         skuCollection.SaveAll(WebUtility.GetUserName());
         product.IsEnabled = true;
         product.Save(WebUtility.GetUserName());
         Store.Caching.ProductCache.RemoveProductFromCache(productId);
         SkuCollection savedSkuCollection = LoadSkuCollection(productId);
         if (savedSkuCollection.Count > 0)
         {
             pnlSkuList.Visible      = false;
             pnlSkuInventory.Visible = true;
         }
         base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblAttributesSaved"));
     }
     catch (Exception ex) {
         Logger.Error(typeof(sku).Name + ".btnSave_Click", ex);
         base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
     }
 }
示例#15
0
        public static MyHLShoppingCart UnfilteredCartRetrieved(int cartId)
        {
            var shoppingCart = ShoppingCartProvider.GetShoppingCart(StaticDistributorID, StaticLocale, cartId);

            if (shoppingCart != null && shoppingCart.CartItems != null)
            {
                if (HLConfigManager.Configurations.DOConfiguration.IsChina)
                {
                    var SKUsToRemove = new List <string>(new[]
                    {
                        HLConfigManager.Configurations.APFConfiguration.DistributorSku,
                        HLConfigManager.Configurations.APFConfiguration.SupervisorSku,
                        HLConfigManager.Configurations.DOConfiguration.TodayMagazineSku,
                        HLConfigManager.Configurations.DOConfiguration.TodayMagazineSecondarySku,
                        HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku
                    });


                    foreach (var cartitem in shoppingCart.CartItems)
                    {
                        SKU_V01 sku;
                        if (SkuCollection != null && SkuCollection.TryGetValue(cartitem.SKU, out sku))
                        {
                            if (!sku.IsPurchasable)
                            {
                                SKUsToRemove.Add(sku.SKU);
                            }
                        }
                    }
                    SKUsToRemove.RemoveAll(x => x.ToString().Equals(string.Empty));
                    shoppingCart.DeleteItemsFromCart(SKUsToRemove.ToList());
                }
                return(shoppingCart);
            }
            return(new MyHLShoppingCart());
        }
示例#16
0
 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try {
     SkuCollection skuCollection = new SkuCollection();
     Sku sku;
     if (associatedAttributeCollection != null && associatedAttributeCollection.Count > 0)
     CreateSkus(associatedAttributeCollection[0], 0, product.BaseSku);
     else
     skus.Add(product.BaseSku);
     for(int i = 0;i < skus.Count;i++) {
       sku = new Sku();
       sku.ProductId = productId;
       sku.SkuX = skus[i];
       skuCollection.Add(sku);
     }
     skuCollection.SaveAll(WebUtility.GetUserName());
     product.IsEnabled = true;
     product.Save(WebUtility.GetUserName());
     Store.Caching.ProductCache.RemoveProductFromCache(productId);
     SkuCollection savedSkuCollection = LoadSkuCollection(productId);
     if(savedSkuCollection.Count > 0) {
       pnlSkuList.Visible = false;
       pnlSkuInventory.Visible = true;
     }
     base.MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblAttributesSaved"));
       }
       catch (Exception ex) {
     Logger.Error(typeof(sku).Name + ".btnSave_Click", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
示例#17
0
 public SkuCollection FetchByQuery(Query qry)
 {
     SkuCollection coll = new SkuCollection();
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
示例#18
0
 public SkuCollection FetchByID(object SkuId)
 {
     SkuCollection coll = new SkuCollection().Where("SkuId", SkuId).Load();
     return coll;
 }
示例#19
0
        public override void Run()
        {
            State = WorkerState.Working;
            parsedSkuExclusions = ParseSkuInclusionAndExclusions(SkuExclusions);
            parsedSkuInclusions = ParseSkuInclusionAndExclusions(SkuInclusions);
            //parsedSkuValueInclusions = ParseSkuValueInclusions(SkuValueInclusions);

            taxonomyAttributesCache = new Dictionary <Guid, List <KeyValuePair <Attribute, SchemaData> > >();
            baseAttributeNames      = new Dictionary <string, string>();
            delimiter = FieldDelimiter.GetValue().ToString();

            //Create new context
            currentDb = new SkuDataDbDataContext();
            var dlo = new DataLoadOptions();

            projectField1Name = AryaTools.Instance.InstanceData.CurrentProject.EntityField1Name ?? string.Empty;
            dlo.LoadWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas);
            dlo.LoadWith <EntityInfo>(entityInfo => entityInfo.EntityDatas);
            dlo.LoadWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas);

            dlo.AssociateWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.TaxonomyDatas.Where(p => p.Active));
            dlo.AssociateWith <EntityInfo>(entityInfo => entityInfo.EntityDatas.Where(p => p.Active));
            dlo.AssociateWith <SchemaInfo>(schemaInfo => schemaInfo.SchemaDatas.Where(p => p.Active));
            dlo.AssociateWith <TaxonomyInfo>(taxonomyInfo => taxonomyInfo.SkuInfos.Where(p => p.Active));

            currentDb.LoadOptions    = dlo;
            currentDb.CommandTimeout = 2000;

            currentDb.Connection.Open();
            currentDb.Connection.ChangeDatabase(AryaTools.Instance.InstanceData.Dc.Connection.Database);

            InitGlobals(GlobalAttributes.ToList());

            StatusMessage = "Init";

            var fi           = new FileInfo(ExportFileName);
            var baseFileName = fi.FullName.Replace(fi.Extension, string.Empty);

            attributeDataFile = new StreamWriter(baseFileName + "_AttributeData.txt", false, Encoding.UTF8);

            attributeDataFile.Write("ItemId{0}Taxonomy{0}Node Type", delimiter);
            foreach (var attribute in globalAttributeHeaders)
            {
                string attributeHeader = null;
                var    parts           = attribute.Split(':');
                var    noOfHeaders     = 0;
                if (parts.Count() > 1)
                {
                    Int32.TryParse(parts[1].Trim(), out noOfHeaders);
                }
                if (parts.Count() == 2 && noOfHeaders > 0)
                {
                    for (var i = 0; i < noOfHeaders; i++)
                    {
                        if (attributeHeader == null)
                        {
                            attributeHeader += parts[0].Trim() + (i + 1);
                        }
                        else
                        {
                            attributeHeader += "\t" + parts[0].Trim() + (i + 1);
                        }
                    }
                }
                else
                {
                    attributeHeader = attribute;
                }
                attributeDataFile.Write("{0}{1}", delimiter, attributeHeader);
            }

            attributeDataFile.WriteLine("{0}Rank 1{0}Att 1{0}Val 1{0}Uom 1{0}[...]", delimiter);

            CurrentProgress = 0;

            if (SkuCollection != null && SkuCollection.Any())
            {
                var taxonomies =
                    (SkuCollection.Split(2000)
                     .SelectMany(skus => currentDb.Skus.Where(s => skus.Contains(s.ItemID)))
                     .GroupBy(s => s.Taxonomy)).ToList();

                MaximumProgress = taxonomies.Count;

                foreach (var st in taxonomies)
                {
                    WriteSkusToFile(st.Key, st.ToList());
                    CurrentProgress++;
                }
            }
            else
            {
                var allExportTaxonomyIds =
                    Taxonomies.Cast <ExtendedTaxonomyInfo>().Select(p => p.Taxonomy.ID).Distinct().ToList();
                var exportTaxonomies         = currentDb.TaxonomyInfos.Where(p => allExportTaxonomyIds.Contains(p.ID)).ToList();
                var allExportChildTaxonomies = exportTaxonomies.SelectMany(p => p.AllChildren2).Distinct().ToList();

                MaximumProgress = allExportChildTaxonomies.Count;

                foreach (var exportChildTaxonomy in allExportChildTaxonomies)
                {
                    WriteTaxonomyToFile(exportChildTaxonomy);
                    CurrentProgress++;
                }
            }

            attributeDataFile.Close();

            StatusMessage = "Done!";
            State         = WorkerState.Ready;
        }
 /// <summary>
 /// Normalizes the cart quantities.
 /// </summary>
 /// <param name="order">The order.</param>
 /// <returns></returns>
 public static bool NormalizeCartQuantities(Order order)
 {
     bool changesMade = false;
       if (order.OrderId > 0) {
     List<OrderItem> itemsToRemove = new List<OrderItem>();
     foreach (OrderItem item in order.OrderItemCollection) {
       Product product = Product.FetchByID(item.ProductId);
       if (!product.AllowNegativeInventories) {
     SkuCollection skuCollection = new SkuCollection().Where(Sku.Columns.SkuX, SubSonic.Comparison.Equals, item.Sku).Load();
     if (skuCollection != null) {
       if (skuCollection.Count == 0 || skuCollection[0].Inventory == 0 || product.ProductStatusDescriptorId == (int)ProductStatus.Inactive) {
         itemsToRemove.Add(item);
         changesMade = true;
       }
       else if (item.Quantity > skuCollection[0].Inventory) {
         item.Quantity = skuCollection[0].Inventory;
         new OrderController().AdjustQuantity(order.OrderId, item.OrderItemId, item.Quantity, order.UserName);
         changesMade = true;
       }
     }
       }
     }
     foreach (OrderItem item in itemsToRemove) {
       new OrderController().RemoveItem(order.OrderId, item.OrderItemId, order.UserName);
       order.OrderItemCollection.Remove(item);
     }
     if (order.OrderItemCollection.Count == 0) {
       Order.Delete(order.OrderId);
     }
       }
       return changesMade;
 }
示例#21
0
 /// <summary>
 /// Loads the sku collection.
 /// </summary>
 /// <param name="productId">The product id.</param>
 /// <returns></returns>
 private SkuCollection LoadSkuCollection(int productId)
 {
     SkuCollection skuCollection = new SkuCollection().Where(Sku.Columns.ProductId, Comparison.Equals, productId).Load();
       dgSkuInventory.DataSource = skuCollection;
       dgSkuInventory.Columns[0].HeaderText = LocalizationUtility.GetText("hdrSku");
       dgSkuInventory.Columns[1].HeaderText = LocalizationUtility.GetText("hdrInventory");
       dgSkuInventory.DataBind();
       return skuCollection;
 }