Esempio n. 1
0
        protected override void ExecuteMethod()
        {
            var result = MessageService.ShowYesNoMessageDialog("–азбиение", "ƒействительно хотите разбить выбранную строку?", defaultNo: true);

            if (result != MessageDialogResult.Yes)
            {
                return;
            }

            var technicalRequrementsWrapper = (TechnicalRequrements2Wrapper)ViewModel.SelectedItem;
            var salesUnit = technicalRequrementsWrapper.SalesUnits.First();

            var salesUnitsToDivide = technicalRequrementsWrapper.SalesUnits.ToList();

            salesUnitsToDivide.Remove(salesUnit);

            //создаем новые строки
            foreach (var unit in salesUnitsToDivide)
            {
                technicalRequrementsWrapper.SalesUnits.Remove(unit);

                //создаем новую строку
                var newTechnicalRequrements = new TechnicalRequrements
                {
                    SalesUnits = new List <SalesUnit> {
                        unit.Model
                    },
                    Comment = technicalRequrementsWrapper.Comment
                };
                var newTechnicalRequrementsWrapper = new TechnicalRequrements2Wrapper(newTechnicalRequrements);

                //добавл¤ем в новую строку файлы
                foreach (var fileWrapper in technicalRequrementsWrapper.Files)
                {
                    newTechnicalRequrementsWrapper.Files.Add(fileWrapper);
                }

                ViewModel.TechnicalRequrementsTaskWrapper.Requrements.Add(newTechnicalRequrementsWrapper);
            }
        }
Esempio n. 2
0
        public TceReportUnit(TechnicalRequrementsTask technicalRequrementsTask, TechnicalRequrements technicalRequrements, IEnumerable <Tender> tenders)
        {
            SalesUnits = technicalRequrements.SalesUnits.ToList();
            var salesUnit = SalesUnits.First();

            _tenders = tenders.ToList();

            OrderInTakeDate = salesUnit.OrderInTakeDate;

            if (technicalRequrementsTask.PriceCalculations.Any())
            {
                TceNumber = GetTceNumber(technicalRequrementsTask);
            }

            TaskOpenDate = technicalRequrementsTask.Start?.Date ?? DateTime.Today.AddYears(10);

            TaskStartDate  = technicalRequrementsTask.Start;
            TaskFinishDate = technicalRequrementsTask.Finish;

            Order = salesUnit.Order?.ToString();

            OrderPositions = SalesUnits.Select(unit => unit.OrderPosition).GetOrderPositions();

            var owners = new List <Company> {
                salesUnit.Facility.OwnerCompany
            };

            owners.AddRange(salesUnit.Facility.OwnerCompany.ParentCompanies().ToList());
            FacilityOwners = owners.ToStringEnum();

            var contragent = salesUnit.Specification?.Contract.Contragent ?? GetTenderWinner() ?? salesUnit.Facility.OwnerCompany;

            Contragent = contragent.ToString();

            Facility = salesUnit.Facility.ToString();

            Product = $"{salesUnit.Product.ProductType} {salesUnit.Product.Designation}";

            Amount = SalesUnits.Count;

            this.OrderInTakeStatus = GetOrderInTakeStatus();

            if (TaskStartDate.HasValue)
            {
                var dates = Offers
                            .Where(offer => offer.Project.Id == salesUnit.Project.Id)
                            .Select(offer => offer.Date)
                            .Where(x => x >= this.TaskStartDate.Value)
                            .ToList();

                if (dates.Any())
                {
                    FirstOfferDate = dates.Min();
                }

                if (FirstOfferDate.HasValue)
                {
                    Term = (FirstOfferDate.Value - TaskStartDate.Value).Days;
                }
            }


            if (salesUnit.IsLoosen)
            {
                CostOfWinner = salesUnit.Cost;
                Cost         = Math.Round(CostOfWinner.Value * (1.0 + _random.Next(5, 20) / 100.0), MidpointRounding.ToEven);

                if (salesUnit.ProductionTerm < GlobalAppProperties.Actual.StandartTermFromStartToEndProduction)
                {
                    LossReason = "Сроки производства";
                }
            }
            else
            {
                Cost = salesUnit.Cost;
            }

            Manager = salesUnit.Project.Manager?.Employee?.Person.ToString();

            BackManager = technicalRequrementsTask.BackManager?.Employee?.Person.ToString();

            RealizationDate = salesUnit.RealizationDateCalculated;


            if (salesUnit.IsLoosen)
            {
                CommonStatus = string.IsNullOrEmpty(Order) ? "Конкурс проигран" : "Заказ аннулирован";
            }
            else if (OrderInTakeDate < DateTime.Today)
            {
                CommonStatus = $"Факт ОИТ {OrderInTakeDate.Year}";
            }
            else if (OrderInTakeDate.Year > DateTime.Today.Year)
            {
                CommonStatus = $"Закупка или тендер перенесены на {OrderInTakeDate.Year} год";
            }

            Producer       = salesUnit.Producer?.ToString() ?? string.Empty;
            ProducerWinner = Producer;
        }