示例#1
0
        protected AnimationCustomerGroup CreateAnimationCustomerGroup(Animation animation, CustomerGroup group, Division division)
        {
            AnimationCustomerGroup animationGroup = new AnimationCustomerGroup();
            animationGroup.ID = Guid.NewGuid();
            animationGroup.Animation = animation;
            animationGroup.CustomerGroup = group;
            animationGroup.IncludeInAllocation = true;
            animationGroup.OnCounterDate = DateTime.Now;
            animationGroup.PLVComponentDate = DateTime.Now;
            animationGroup.PLVDeliveryDate = DateTime.Now;
            animationGroup.StockDate = DateTime.Now;
            animationGroup.RetailerType = CreateRetailerType(division);

            return animationGroup;
        }
示例#2
0
        public void CustomerGroupInsertUpdate(AnimationCustomerGroup entity)
        {
            if (entity.ID == Guid.Empty)
            {
                Db.AnimationCustomerGroups.InsertOnSubmit(entity);
                entity.OverridenFlags = (int)AnimationCustomerGroupOverrides.None;
            }

            if (entity.OverridenFlags == null)
            {
                entity.OverridenFlags = (int)AnimationCustomerGroupOverrides.None;
            }

            SetAnimationCustomerGroupOverrides(entity);

            entity.Animation = Animation;

            try
            {
                Db.SubmitChanges();
            }
            catch(SqlException sqlExc)
            {
                if (sqlExc.Number == 50000 && sqlExc.Class == 16 && sqlExc.State == 31)
                {
                    if (sqlExc.Errors.Count > 0)
                    {
                        MessageBox.Show(sqlExc.Errors[0].Message);
                    }
                    else
                    {
                        MessageBox.Show(sqlExc.Message);
                    }
                }
                else
                    MessageBox.Show(SystemMessagesManager.Instance.GetMessage("TableViewExceptionSql", Utility.GetExceptionsMessages(sqlExc)));

                Db.AnimationCustomerGroups.DeleteOnSubmit(entity);
                Db.SubmitChanges();

                throw;
            }
        }
示例#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)));
                }
            }

        }
示例#4
0
        private void SetAnimationCustomerGroupOverrides(AnimationCustomerGroup acg)
        {
            AnimationCustomerGroup original = Db.AnimationCustomerGroups.GetOriginalEntityState(acg);

            if (original.SAPDespatchCode != acg.SAPDespatchCode)
            {
                acg.OverridenFlags |= (int)AnimationCustomerGroupOverrides.SapDespatchCode;
            }

            if (original.OnCounterDate != acg.OnCounterDate)
            {
                acg.OverridenFlags |= (int)AnimationCustomerGroupOverrides.OnCounterDate;
            }

            if (original.PLVComponentDate != acg.PLVComponentDate)
            {
                acg.OverridenFlags |= (int)AnimationCustomerGroupOverrides.PLVComponentDate;
            }

            if (original.PLVDeliveryDate != acg.PLVDeliveryDate)
            {
                acg.OverridenFlags |= (int)AnimationCustomerGroupOverrides.PLVDeliveryDate;
            }

            if (original.StockDate != acg.StockDate)
            {
                acg.OverridenFlags |= (int)AnimationCustomerGroupOverrides.StockDate;
            }
        }