コード例 #1
0
ファイル: Animation.cs プロジェクト: ddksaku/loreal
        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);
                }
            }
            
        }
コード例 #2
0
ファイル: AddCapacities.xaml.cs プロジェクト: ddksaku/loreal
        // generating capacities
        private void btnGenerate_Click(object sender, RoutedEventArgs e)
        {
            int capacityValue = 0;
            int.TryParse(txtCapacityValue.Text, out capacityValue);

            IEnumerable<Customer> selectedCustomers = customers.Where(c => c.IsSelected);

            #region Validation warning
            if (capacityValue == 0)
            {
                MessageBox.Show("Please set positive capacity value");
                return;
            }

            if (cboAnimationType.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select animation type");
                return;
            }

            if (cboItemType.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select item type");
                return;
            }

            if (cboPriority.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select priority");
                return;
            }

            if (selectedCustomers.Count() == 0)
            {
                MessageBox.Show("Please select at least one customer");
                return;
            }
            #endregion

            // warning before ovewriting
            DbDataContext simpleContext = new DbDataContext(false);
            LongTaskExecutor createCapacity = new LongTaskExecutor("");
  

            IEnumerable<Customer> customersWithCapacitiesAlreadyInDB = simpleContext.CustomerCapacities.Where(ca => ca.IDAnimationType == ((AnimationType)cboAnimationType.SelectedItem).ID
                && ca.IDItemType == ((ItemType)cboItemType.SelectedItem).ID               
                && ca.IDPriority == ((Priority)cboPriority.SelectedItem).ID
                && selectedCustomers.Contains((Customer)ca.Customer)).Select(ca => ca.Customer).Distinct().ToList();

            if (customersWithCapacitiesAlreadyInDB.Count() > 0)
            {
                StringBuilder sb = new StringBuilder();
                foreach (Customer a in customersWithCapacitiesAlreadyInDB)
                {
                    sb.AppendLine(String.Format("{0} {1}", a.AccountNumber, a.Name));
                }

                String warningMessage = String.Format("{0} \r\n{1}", SystemMessagesManager.Instance.GetMessage("OverwriteCustomerCapacity"), sb.ToString());

                if (MessageBox.Show(warningMessage, "Warning", MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    return;
                }                    
                else
                {                    
                    createCapacity.DoWork += createCapacity_DoWork;
                    createCapacity.Run(selectedCustomers);
                }  
            }
           

            createCapacity.DoWork += createCapacity_DoWork;
            createCapacity.Run(selectedCustomers);

           
        }
コード例 #3
0
ファイル: AddCapacities.xaml.cs プロジェクト: ddksaku/loreal
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            IEnumerable<Customer> selectedCustomers = customers.Where(c => c.IsSelected);

            #region Validation warning

            if (cboAnimationType.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select animation type");
                return;
            }

            if (cboItemType.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select item type");
                return;
            }

            if (cboPriority.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select priority");
                return;
            }

            if (selectedCustomers.Count() == 0)
            {
                MessageBox.Show("Please select at least one customer");
                return;
            }
            #endregion

            LongTaskExecutor deleteCapacity = new LongTaskExecutor("");
            deleteCapacity.DoWork += deleteCapacity_DoWork;
            deleteCapacity.Run(selectedCustomers);

        }
コード例 #4
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
        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)));
                }
            }

        }
コード例 #5
0
ファイル: MainForm.xaml.cs プロジェクト: ddksaku/loreal
 void ucAnimationList_EditAnimation(object sender, Animation animation)
 {
     LongTaskExecutor animationOpener = new LongTaskExecutor("Opening the animation - " + animation.Name);
     animationOpener.DoWork += new DoWorkEventHandler(animationOpener_DoWork);
     animationOpener.Run(animation);
 }
コード例 #6
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
 private void Include()
 {
     LongTaskExecutor includeExecutor = new LongTaskExecutor("Including selected customer groups");
     includeExecutor.TaskFinished += new EventHandler(includeExecutor_TaskFinished);
     includeExecutor.DoWork += new DoWorkEventHandler(includeExecutor_DoWork);
     includeExecutor.Run();
 }
コード例 #7
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
 private void IncludeAll()
 {
     LongTaskExecutor includeAllExecutor = new LongTaskExecutor("Including all customer groups into animation");
     includeAllExecutor.TaskFinished += new EventHandler(includeAllExecutor_TaskFinished);
     includeAllExecutor.DoWork += new DoWorkEventHandler(includeAllExecutor_DoWork);
     includeAllExecutor.Run();
 }
コード例 #8
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
 private void recreateAllocationsForProduct(AnimationProduct animationProduct)
 {
     LongTaskExecutor recreateAllocationsExecutor = new LongTaskExecutor("Recreating allocations");
     recreateAllocationsExecutor.DoWork += new DoWorkEventHandler(recreateAllocationsForProductExecutor_DoWork);
     recreateAllocationsExecutor.Run(animationProduct);
 }
コード例 #9
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
 public void RecalculateAnimationProduct(RecalculationType calcType, AnimationProduct entity = null)
 {
     if (calcType == RecalculationType.CalculateTotal)
     {
         LongTaskExecutor recalculationExecutor = new LongTaskExecutor("Recalculating capacities ...");
         recalculationExecutor.DoWork += new DoWorkEventHandler(recalculationExecutor_DoWork);
         recalculationExecutor.Run(entity);
     }
     else if (calcType == RecalculationType.CalculateActiveAnimations)
     {
         LongTaskExecutor calcActiveAnimationExecutor = new LongTaskExecutor("Recalculating active animations ...");
         calcActiveAnimationExecutor.DoWork += new DoWorkEventHandler(calcActiveAnimationExecutor_DoWork);
         calcActiveAnimationExecutor.Run();
     }
     else if (calcType == RecalculationType.CalculateTotalCapacity && entity != null)
     {
         LongTaskExecutor calcTotalCapacityExecutor = new LongTaskExecutor("Recalculating total capacity for " + entity.ProductIdentifier);
         calcTotalCapacityExecutor.DoWork += new DoWorkEventHandler(calcTotalCapacityExecutor_DoWork);
         calcTotalCapacityExecutor.Run();
     }
     else if (calcType == RecalculationType.CalculateProductRecieved && entity != null)
     {
         LongTaskExecutor calcTotalCapacityExecutor = new LongTaskExecutor("Recalculating product recieved  ");
         calcTotalCapacityExecutor.DoWork += new DoWorkEventHandler(calcProductRecievedExecutor_DoWork);
         calcTotalCapacityExecutor.Run();
     }
     else if (calcType == RecalculationType.CalculateTotalAnimationQuantity)
     {
         Animation.AnimationProducts.ToList().ForEach(ap => ap.TotalAnimationQuantity = -1);
     }
 }
コード例 #10
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
 public void Save()
 {
     LongTaskExecutor saveAnimationExecutor = new LongTaskExecutor("Saving animation");
     saveAnimationExecutor.DoWork += new DoWorkEventHandler(saveAnimationExecutor_DoWork);
     saveAnimationExecutor.Run();
 }
コード例 #11
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
 public void RecreateAllocations()
 {
     LongTaskExecutor recreateAllocationsExecutor = new LongTaskExecutor("Recreating allocations");
     recreateAllocationsExecutor.DoWork +=new DoWorkEventHandler(recreateAllocationsExecutor_DoWork);
     recreateAllocationsExecutor.Run();
 }
コード例 #12
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
        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);
            }

        }
コード例 #13
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
 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);
     }
 }
コード例 #14
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
 private void RemoveAll()
 {
     removeAllExecutor = new LongTaskExecutor("Removing all customer groups from animation");
     removeAllExecutor.TaskFinished += new EventHandler(removeAllExecutor_TaskFinished);
     removeAllExecutor.DoWork += new DoWorkEventHandler(removeAllExecutor_DoWork);
     removeAllExecutor.Run();
 }
コード例 #15
0
ファイル: AnimationManager.cs プロジェクト: ddksaku/loreal
//        private void PreProcessBeforeRemove(AnimationCustomerGroup acg)
//        {
//            // delete customer allocations
//            string caDeleteString = @"Delete from CustomerAllocation
//                                      Where IDAnimationProductDetail in (Select ID from AnimationProductDetail Where IDAnimationProduct in (Select ID from AnimationProduct Where IDAnimation={0}) )
//                                      AND (Select IDCustomerGroup from Customer as C Where C.ID = IDCustomer) = {1}";
//            int rows = Db.ExecuteCommand(caDeleteString, acg.IDAnimation, acg.IDCustomerGroup);

//            // delete customer group allocations
//            string cgaDeleteString = @"Delete from CustomerGroupAllocation
//                                      Where IDAnimationProductDetail in (Select ID from AnimationProductDetail Where IDAnimationProduct in (Select ID from AnimationProduct Where IDAnimation={0}) )
//                                      AND IDCustomerGroup = {1}";
//            rows = Db.ExecuteCommand(cgaDeleteString, acg.IDAnimation, acg.IDCustomerGroup);
                
//        }

        private void Remove()
        {
            LongTaskExecutor removeExecutor = new LongTaskExecutor("Removing a customer group");
            removeExecutor.TaskFinished += new EventHandler(removeExecutor_TaskFinished);
            removeExecutor.DoWork += new DoWorkEventHandler(removeExecutor_DoWork);
            removeExecutor.Run();
        }
コード例 #16
0
ファイル: RunAllocations.xaml.cs プロジェクト: ddksaku/loreal
        private void btnRunAllocation_Click(object sender, RoutedEventArgs e)
        {
            tabResults.Items.Clear();

            if (cboeAnimations.SelectedItem != null)
            {
                Animation ani = cboeAnimations.SelectedItem as Animation;

                if (ani != null)
                {
                    // check if SAP order is created
                    if (ani.DateSAPOrderCreated != null)
                    {
                        if (MessageBox.Show(SystemMessagesManager.Instance.GetMessage("RunAllocationOrderCreated"), "Warning", MessageBoxButton.YesNo) == MessageBoxResult.No)
                            return;
                    }

                    LongTaskExecutor runAllocationExecutor = new LongTaskExecutor("Running allocation for "+ani.Name);
                    runAllocationExecutor.DoWork += new System.ComponentModel.DoWorkEventHandler(runAllocationExecutor_DoWork);
                    runAllocationExecutor.Run(ani);
                }
            }
            else
            {
                string systemMessage = SystemMessagesManager.Instance.GetMessage("RunAllocationOrderCreated");
                string warning = String.Empty;

                foreach (Animation animation in cboeAnimations.ItemsSource)
                {
                    if (animation.DateSAPOrderCreated != null)
                    {
                        warning += string.Format(systemMessage, animation.Name) + Environment.NewLine;
                    }
                }

                if (!String.IsNullOrEmpty(warning) && MessageBox.Show(warning, "Warning", MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    return;
                }
                
                //Run for all animation in selected sales drive
                foreach (Animation animation in cboeAnimations.ItemsSource)
                {
                    if (animation != null)
                    {
                        // check if SAP order is created
                        if (animation.DateSAPOrderCreated != null)
                        {
                            if (System.Windows.MessageBox.Show(SystemMessagesManager.Instance.GetMessage("RunAllocationOrderCreated", animation.Name), "Warning", MessageBoxButton.YesNo) == MessageBoxResult.No)
                            {
                                return;
                            }
                        }

                        LongTaskExecutor runAllocationExecutor = new LongTaskExecutor("Running allocation for "+animation.Name);
                        runAllocationExecutor.DoWork += new System.ComponentModel.DoWorkEventHandler(runAllocationExecutor_DoWork);
                        runAllocationExecutor.Run(animation);
                    }
                }
            }

            if (tabResults.Items.Count > 0)
            {
                tabResults.SelectedIndex = 0;
            }
        }