Ejemplo n.º 1
0
        public void RecalculateAnimationProduct(AnimationProduct animationProduct = null, LongTaskExecutor executor = null)
        {
            if (animationProduct != null)
            {
                animationProduct.CalculateTotals();
                animationProduct.CalculateTotalCapacity();

                if (executor != null)
                {
                    executor.SendProgressMessage("   Calculating capacities for " + animationProduct.ProductIdentifier);
                }

                return;
            }

            foreach (AnimationProduct ap in AnimationProducts)
            {
                ap.CalculateTotals();
                
                ap.CalculateTotalCapacity();

                if (executor != null)
                {
                    executor.SendProgressMessage("   Calculating capacities for " + ap.ProductIdentifier);
                }
            }
            
        }
Ejemplo n.º 2
0
        private void remove(List<AnimationCustomerGroup> animationCustomerGroups, LongTaskExecutor executor)
        {
            try
            {
                string errorMsg = string.Empty;
                for (int i = animationCustomerGroups.Count - 1; i >= 0; i--)
                {
                    AnimationCustomerGroup animationCustomerGroupToDelete = animationCustomerGroups[i];
                    string customerGroupName = animationCustomerGroupToDelete.CustomerGroup.Name;

                    animation.ObservableAnimationCustomerGroups.Remove(animationCustomerGroupToDelete);
                    if (animationCustomerGroupToDelete.ID != Guid.Empty)
                    {
                        Db.AnimationCustomerGroups.DeleteOnSubmit(animationCustomerGroupToDelete);
                    }

                    if (executor != null)
                    {
                        executor.SendProgressMessage(customerGroupName + " is removed from the animation");
                    }

                    Db.SubmitChanges();
                }

                //executor.SendProgressMessage("Deleting allocations");
                //Db.SubmitChanges();
            }
            catch (Exception exc)
            {
                Logger.Log(exc.ToString(), LogLevel.Error);
                MessageBox.Show(exc.Message);
            }

        }
Ejemplo n.º 3
0
        private void include(List<CustomerGroup> groups, LongTaskExecutor executor)
        {
            try
            {

                for (int i = 0; i < groups.Count; i++)
                {
                    AnimationCustomerGroup cga = new AnimationCustomerGroup();
                    cga.IDCustomerGroup = groups[i].ID;
                    cga.IDAnimation = Animation.ID;

                    cga.OnCounterDate = Animation.OnCounterDate.HasValue? Animation.OnCounterDate.Value:DateTime.Now;
                    cga.PLVComponentDate = Animation.PLVComponentDate.HasValue? Animation.PLVComponentDate.Value:DateTime.Now;
                    cga.PLVDeliveryDate = Animation.PLVDeliveryDate.HasValue? Animation.PLVDeliveryDate.Value:DateTime.Now;
                    cga.StockDate = Animation.StockDate.HasValue? Animation.StockDate.Value:DateTime.Now;
                    cga.IncludeInAllocation = true;

                    // set the default retailer type
                    if (DefaultRetailerType != null)
                        cga.IDRetailerType = DefaultRetailerType.ID;

                    // set the default date for SAP Promotion Despatch Code
                    if (Animation != null)
                        cga.SAPDespatchCode = Animation.SAPDespatchCode;

                    // try to insert into DB if it is valid.
                    string errorMessage;
                    if (cga.IsValid(out errorMessage))
                    {
                        CustomerGroupInsertUpdate(cga);
                    }
                    else
                    {
                        continue;
                    }

                    Animation.ObservableAnimationCustomerGroups.Add(cga);

                    if (executor != null)
                    {
                        executor.SendProgressMessage(groups[i].Name + " is included into the animation.");
                    }
                }

                executor.SendProgressMessage("Recreating allocations");
                LongTaskExecutor.DoEvents();

                Db.up_recreateAllocationsAnimation(Animation.ID, false);
               
            }
            catch (SqlException sqlExc)
            {
                if (sqlExc.Number == 50000 && sqlExc.Class == 16 && sqlExc.State == 31)
                {
                    DbDataContext.MakeNewInstance();
                    this.Animation = GetByID(this.Animation.ID);
                }
                else
                {
                    MessageBox.Show(SystemMessagesManager.Instance.GetMessage("TableViewExceptionSql", Utility.GetExceptionsMessages(sqlExc)));
                }
            }

        }
Ejemplo n.º 4
0
 private void removeAll(Guid idAnimation, LongTaskExecutor executor)
 {
     try
     {
         executor.SendProgressMessage("Deleting allocations");
         Db.ExecuteCommand("DELETE FROM AnimationCustomerGroup WHERE IDAnimation = {0}", idAnimation);
         animation.ObservableAnimationCustomerGroups.Clear();
     }
     catch (Exception exc)
     {
         Logger.Log(exc.ToString(), LogLevel.Error);
         MessageBox.Show(exc.Message);
     }
 }