public SupplierData(string code, SkuCollection FullCollection)
 {
     SupplierCode  = code;
     ListOfSkus    = FullCollection.SearchBySuppName(code);
     Lines         = ListOfSkus.Count;
     LowPercentage = LowStock / Lines;
 }
        internal void PrepareDataGrid(object sender, DoWorkEventArgs e)
        {
            SupplierDataList.Clear();
            var Worker          = sender as BackgroundWorker;
            var CurrentColl     = _supplierSkuCollection.SearchBySuppName(_currentSupplier.Code).ExcludeStatus("Dead");
            var SupplierDataBag = new ConcurrentBag <DataItem>();
            var parallelopts    = new ParallelOptions {
                MaxDegreeOfParallelism = 4
            };

            Parallel.ForEach(CurrentColl, parallelopts, (sku) =>
            {
                if (int.Parse(sku.SalesData.EightWeekAverage.ToString()) == 0 && LoadNoSales != true)
                {
                    ListOfUnloadedSkus.Add(sku);
                    return;
                }
                if (sku.GetPrimarySupplier().Name != _currentSupplier.Code && LoadPrimaryOnly)
                {
                    return;
                }

                var newItem = DataItem.DataItemNew(sku);

                SupplierDataBag.Add(newItem);
                Worker.ReportProgress((SupplierDataBag.Count / CurrentColl.Count) * 100);
            });
            SupplierDataList.AddRange(SupplierDataBag);
        }
Beispiel #3
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());
                }
            }
        }