Пример #1
0
 public GeneralPricelist GetGeneralPricelist(int iNumber)
 {
     return(GeneralPricelist.Read(this._context, iNumber));
 }
Пример #2
0
        public bool UpdateSpecificPrices(DateTime?startDate, int pricelistrPricesLimit = 50, int customerPricesLimit = 0)
        {
            // Pricelist specific prices

            int pricelistPricesCount = 0;

            Log("\nLoading Pricelist specific prices.");
            StatusUpdate("Updating pricelist specific prices.");

            for (int pricelistNumber = 0; pricelistNumber <= pricelistrPricesLimit; pricelistNumber++)
            {
                try
                {
                    GeneralPricelist generalPricelist = GeneralPricelist.Read(visma._context, pricelistNumber);

                    var filteredPricelist = generalPricelist.Where(x => ((!startDate.HasValue) || (x.EditStamp >= startDate.Value)));

                    if (filteredPricelist.Count() > 0)
                    {
                        Log(string.Format("Pricelist {0} has {1} specific prices.", pricelistNumber, generalPricelist.Count));

                        foreach (PricelistItem pricelistItem in filteredPricelist)
                        {
                            UpdatePricelistItem(pricelistItem, pricelistNumber, null);
                        }
                    }
                    else
                    {
                        //Log(string.Format("No specific prices for Customer {0}.", customerSpecificNumber));
                    }
                }
                catch (Csla.DataPortalException ex)
                {
                    Log(string.Format("Pricelist {0} - no pricelist", pricelistNumber));
                }
            }



            // Customer specific prices

            int customerPricesCount = 0;

            Log("\nLoading Customer specific prices");
            StatusUpdate("Updating customer specific prices.");

            DataSet.CustomerDataTable customerRows = customerTA.GetDataByShopID(shop.ID);
            foreach (var customerRow in customerRows)
            {
                int customerSpecificNumber = customerRow.VismaCustomerNumber;

                CustomerPricelist customerSpecificPricelist = CustomerPricelist.Read(visma._context, customerSpecificNumber);

                var filteredPricelist = customerSpecificPricelist.Where(x => ((!startDate.HasValue) || (x.EditStamp >= startDate.Value)));


                if (filteredPricelist.Count() > 0)
                {
                    Log(string.Format("Customer {0} has {1} specific prices.", customerSpecificNumber, filteredPricelist.Count()));

                    foreach (PricelistItem pricelistItem in filteredPricelist)
                    {
                        UpdatePricelistItem(pricelistItem, null, customerSpecificNumber);
                    }
                }
                else
                {
                    //Log(string.Format("No specific prices for Customer {0}.", customerSpecificNumber));
                }

                customerPricesCount += 1;

                if ((customerPricesLimit > 0) && (customerPricesCount >= customerPricesLimit))
                {
                    break;
                }
            }


            return(true);
        }