コード例 #1
0
ファイル: PurchaseCore.cs プロジェクト: mgladilov/Cas
        /// <summary>
        /// Регистрирует выполнение рабочего пакета
        /// </summary>
        /// <param name="rfq"></param>
        /// <param name="date"></param>
        /// <param name="remarks"></param>
        public void Close(RequestForQuotation rfq, DateTime date, string remarks)
        {
            rfq.Status      = WorkPackageStatus.Closed;
            rfq.ClosingDate = date;
            rfq.Remarks     = remarks;

            _newKeeper.Save(rfq);
        }
コード例 #2
0
ファイル: PurchaseCore.cs プロジェクト: mgladilov/Cas
        /*
         *
         */

        #region private List<Product> GetProducts(RequestForQuotation rfq)
        /// <summary>
        /// Возвращает все комплектующие, находящиеся в определенном ордере запроса
        /// </summary>
        /// <returns></returns>
        private List <Product> GetProducts(RequestForQuotation rfq)
        {
            #region Поиск Продуктов

            //Строка запроса, производящая выборку идентификаторов Продуктов среди записей котировочных ордеров
            //пренадлежащих переданному котировочному ордеру и указывающих на котировки КИТов
            var accessoryParentId =
                BaseQueries.GetSelectQueryColumnOnly <RequestForQuotationRecord>
                    (BasePackageRecord.PackageItemIdProperty,
                    new ICommonFilter[]
            {
                new CommonFilter <int>(BasePackageRecord.ParentPackageIdProperty, rfq.ItemId),
                new CommonFilter <int>(BasePackageRecord.PackageItemTypeProperty, SmartCoreType.Product.ItemId)
            });
            //Фильтр по ключевому полю таблицы обозначающий
            //что значения ключевого поля таблицы должны быть
            //среди идентификаторов КИТов
            ICommonFilter idFilter = new CommonFilter <string>(BaseEntityObject.ItemIdProperty,
                                                               FilterType.In,
                                                               new[] { accessoryParentId });
            //создаются запросы на выборку задач по компонентам с заданного ВС
            //дополнительно фильтрую ключевое поле. значение ключевого поля
            //задач по компонентам ВС должно быть среди идентификатор родительских задач КИТов
            var kits = _loader.GetObjectListAll <Product>(idFilter, true, true, true);

            #endregion

            #region загрузка деталей

            //Строка запроса, производящая выборку идентификаторов Продуктов среди записей котировочных ордеров
            //пренадлежащих переданному котировочному ордеру и указывающих на котировки КИТов
            accessoryParentId =
                BaseQueries.GetSelectQueryColumnOnly <RequestForQuotationRecord>
                    (BasePackageRecord.PackageItemIdProperty,
                    new ICommonFilter[]
            {
                new CommonFilter <int>(BasePackageRecord.ParentPackageIdProperty, rfq.ItemId),
                new CommonFilter <int>(BasePackageRecord.PackageItemTypeProperty, SmartCoreType.Product.ItemId)
            });
            //Фильтр по ключевому полю таблицы обозначающий
            //что значения ключевого поля таблицы должны быть
            //среди идентификаторов КИТов
            idFilter = new CommonFilter <string>(BaseEntityObject.ItemIdProperty,
                                                 FilterType.In,
                                                 new[] { accessoryParentId });
            //создаются запросы на выборку задач по компонентам с заданного ВС
            //дополнительно фильтрую ключевое поле. значение ключевого поля
            //задач по компонентам ВС должно быть среди идентификатор родительских задач КИТов
            var componentModels = _loader.GetObjectListAll <ComponentModel>(idFilter, true, true);
            #endregion

            var accessories = new List <Product>();

            accessories.AddRange(kits.ToArray());
            accessories.AddRange(componentModels.ToArray());

            return(accessories);
        }
コード例 #3
0
ファイル: PurchaseCore.cs プロジェクト: mgladilov/Cas
        /// <summary>
        /// Публикует рабочий пакет - выдает рабочий пакет на перрон
        /// </summary>
        /// <param name="rfq"></param>
        /// <param name="date"></param>
        public void Publish(RequestForQuotation rfq, DateTime date)
        {
            if (rfq.Status != WorkPackageStatus.Closed)
            {
                rfq.Status         = WorkPackageStatus.Published;
                rfq.PublishingDate = date;
            }
            else
            {
                //CasEnvironment.Loader.LoadWorkPackageItems(wp);

                rfq.Status  = WorkPackageStatus.Published;
                rfq.Remarks = "";
            }

            _newKeeper.Save(rfq);
        }
コード例 #4
0
ファイル: PurchaseCore.cs プロジェクト: mgladilov/Cas
        /// <summary>
        /// Загружает все элементы рабочего пакета
        /// </summary>
        /// <param name="rfq"></param>
        public void LoadRequestForQuotationItems(RequestForQuotation rfq)
        {
            if (rfq == null)
            {
                return;
            }

            rfq.Products = GetProducts(rfq);
            rfq.PackageRecords.Clear();
            rfq.PackageRecords.AddRange(_newLoader.GetObjectListAll <RequestForQuotationRecordDTO, RequestForQuotationRecord>(new Filter("ParentPackageId", rfq.ItemId)));

            _packageCore.SetParents(rfq);

            foreach (var record in rfq.PackageRecords)
            {
                record.Product = rfq.Products.FirstOrDefault(a => a.ItemId == record.PackageItemId);
            }
        }
コード例 #5
0
ファイル: PurchaseCore.cs プロジェクト: mgladilov/Cas
        /// <summary>
        /// Удаляет запись из рабочего пакета
        /// </summary>
        /// <param name="accessory"></param>
        /// <param name="rfq"></param>
        public void DeleteFromRequestForQuotation(Product accessory, RequestForQuotation rfq)
        {
            var rfqRecord =
                rfq.PackageRecords.FirstOrDefault(wpr => wpr.PackageItemId == accessory.ItemId &&
                                                  wpr.PackageItemType == accessory.SmartCoreObjectType);

            if (rfqRecord == null)
            {
                rfqRecord = _newLoader.GetObject <RequestForQuotationRecordDTO, RequestForQuotationRecord>(new List <Filter>()
                {
                    new Filter("PackageItemId", accessory.ItemId),
                    new Filter("PackageItemTypeId", accessory.SmartCoreObjectType.ItemId),
                    new Filter("ParentPackageId", rfq.ItemId)
                });
            }

            if (rfqRecord != null)
            {
                _newKeeper.Delete(rfqRecord);
            }
        }
コード例 #6
0
ファイル: PurchaseCore.cs プロジェクト: mgladilov/Cas
        /// <summary>
        /// Сохранение Запросного ордера
        /// </summary>
        public RequestForQuotation AddQuotationOrder(IEnumerable <RequestForQuotationRecord> quotationList,
                                                     Supplier toSupplier,
                                                     BaseEntityObject parent,
                                                     out string message,
                                                     IORQORRelation[] iorqorRelations = null)
        {
            if (parent == null)
            {
                message = "Not set parent." +
                          "\nFailed to create empty quotation order";
                return(null);
            }

            if (!(parent is Aircraft) && !(parent is Operator) && !(parent is Store))
            {
                message = "Parent must be Aircraft or Store or Operator." +
                          "\nFailed to create empty quotation order";
                return(null);
            }

            if (quotationList == null)
            {
                message = "Selected tasks not have a accessories." +
                          "\nFailed to create empty quotation order";
                return(null);
            }

            var rqst = new RequestForQuotation
            {
                Description    = "",
                Status         = WorkPackageStatus.Opened,
                Author         = _casEnvironment.Operators[0].Name,
                OpeningDate    = DateTime.Today,
                PublishingDate = new DateTime(1852, 01, 01),
                ClosingDate    = new DateTime(1852, 01, 01),
                Remarks        = "",
                ParentType     = parent.SmartCoreObjectType,
                ParentId       = parent.ItemId,
                Title          = parent + "-QO-" + DateTime.Now,
                ToSupplier     = toSupplier
            };

            _newKeeper.Save(rqst);

            #region Формирование записей рабочего пакета
            foreach (var item in quotationList)
            {
                rqst.PackageRecords.Add(item);
            }
            #endregion

            #region Сохранение рабочего пакета и его записей

            foreach (var item in rqst.PackageRecords)
            {
                item.ParentPackageId = rqst.ItemId;

                _newKeeper.Save(item);

                var relation = iorqorRelations != null
                                        ? iorqorRelations.FirstOrDefault(i => i.RequestForQuotationRecord == item)
                                        : null;

                if (relation != null)
                {
                    _newKeeper.Save(relation);
                }
            }

            message = "Items added successfully";

            #endregion

            return(rqst);
        }
コード例 #7
0
ファイル: PurchaseCore.cs プロジェクト: mgladilov/Cas
        /// <summary>
        /// Сохранение Запросного ордера
        /// </summary>
        public RequestForQuotation AddQuotationOrder(IEnumerable <KeyValuePair <Product, double> > quotationList, BaseEntityObject parent, out string message)
        {
            if (parent == null)
            {
                message = "Not set parent." +
                          "\nFailed to create empty quotation order";
                return(null);
            }

            if (!(parent is Aircraft) && !(parent is Operator) && !(parent is Store))
            {
                message = "Parent must be Aircraft or Store or Operator." +
                          "\nFailed to create empty quotation order";
                return(null);
            }

            if (quotationList == null)
            {
                message = "Selected tasks not have a accessories." +
                          "\nFailed to create empty quotation order";
                return(null);
            }

            var rqst = new RequestForQuotation
            {
                Description    = "",
                Status         = WorkPackageStatus.Opened,
                Author         = _casEnvironment.Operators[0].Name,
                OpeningDate    = DateTime.Today,
                PublishingDate = new DateTime(1852, 01, 01),
                ClosingDate    = new DateTime(1852, 01, 01),
                Remarks        = "",
                ParentType     = parent.SmartCoreObjectType,
                ParentId       = parent.ItemId,
                Title          = parent + "-QO-" + DateTime.Now
            };

            _newKeeper.Save(rqst);

            #region Формирование записей рабочего пакета
            foreach (var item in quotationList)
            {
                Product product  = item.Key;
                double  quantity = item.Value;

                var record =
                    rqst.PackageRecords.FirstOrDefault(r => r.PackageItemType == product.SmartCoreObjectType &&
                                                       r.PackageItemId == product.ItemId);
                if (record != null)
                {
                    record.Quantity += item.Value;
                }
                else
                {
                    record = new RequestForQuotationRecord(rqst.ItemId, product, quantity);
                    rqst.PackageRecords.Add(record);
                }
            }
            #endregion

            #region Сохранение рабочего пакета и его записей

            foreach (var item in rqst.PackageRecords)
            {
                item.ParentPackageId = rqst.ItemId;
                _newKeeper.Save(item);
            }

            message = "Items added successfully";

            #endregion

            return(rqst);
        }